diff --git a/src/app/components/FileUploadUtils.ts b/src/app/components/FileUploadUtils.ts index 6e67e79..303b3c5 100644 --- a/src/app/components/FileUploadUtils.ts +++ b/src/app/components/FileUploadUtils.ts @@ -8,6 +8,7 @@ import { FILE_SIZE_CONFIG, UPLOAD_TIMEOUT_CONFIG, SWARM_DEFERRED_UPLOAD, + BEE_GATEWAY_URL, } from './constants'; import { processTarFile, TarProcessingResult } from './FolderUploadUtils'; import { getStampUsage, formatDateEU } from './utils'; @@ -131,6 +132,13 @@ export const isArchiveFile = (filename?: string): boolean => { return archiveExtensions.some(ext => filename.toLowerCase().endsWith(ext)); }; +export const getFileReferenceUrl = (reference: string, filename?: string): string => { + if (filename && !isArchiveFile(filename)) { + return `${BEE_GATEWAY_URL}${reference}/${filename}`; + } + return `${BEE_GATEWAY_URL}${reference}/`; +}; + /** * Interface for XHR upload response */ diff --git a/src/app/components/SwapComponent.tsx b/src/app/components/SwapComponent.tsx index 31a7e6f..626e45b 100644 --- a/src/app/components/SwapComponent.tsx +++ b/src/app/components/SwapComponent.tsx @@ -67,6 +67,7 @@ import { handleFileUpload as uploadFile, handleMultiFileUpload, isArchiveFile, + getFileReferenceUrl, MultiFileResult, getUserFriendlyErrorMessage, } from './FileUploadUtils'; @@ -1915,15 +1916,52 @@ const SwapComponent: React.FC = () => { {result.success && result.reference && ( -
{ - navigator.clipboard.writeText(result.reference); - }} - title="Click to copy reference" - > - {result.reference} -
+ <> +
+ { + navigator.clipboard.writeText(result.reference); + const el = e.currentTarget; + el.setAttribute('data-copied', 'true'); + setTimeout(() => { + el.setAttribute('data-copied', 'false'); + }, 2000); + }} + title="Click to copy reference" + data-copied="false" + > + {result.reference} + +
+
+ + + Open link + +
+ )} {!result.success && result.error && (
{result.error}
diff --git a/src/app/components/css/SwapComponent.module.css b/src/app/components/css/SwapComponent.module.css index 7085447..7d56029 100644 --- a/src/app/components/css/SwapComponent.module.css +++ b/src/app/components/css/SwapComponent.module.css @@ -577,7 +577,7 @@ font-family: monospace; font-size: 14px; cursor: pointer; - transition: background-color 0.2s; + transition: background-color 0.2s, color 0.2s; position: relative; } @@ -615,6 +615,11 @@ z-index: 10; } +.referenceCode[data-copied="true"] { + color: #3fb950; + background-color: rgba(63, 185, 80, 0.15); +} + .referenceLink { display: inline-block; margin-top: 10px; @@ -1423,6 +1428,24 @@ margin: 20px 0; max-height: 300px; overflow-y: auto; + padding-bottom: 4px; + scrollbar-width: thin; + scrollbar-color: #30363d #161b22; +} + +.multiFileResults::-webkit-scrollbar { + width: 8px; +} + +.multiFileResults::-webkit-scrollbar-track { + background: #161b22; + border-radius: 4px; +} + +.multiFileResults::-webkit-scrollbar-thumb { + background-color: #30363d; + border-radius: 4px; + border: 2px solid #161b22; } .fileResult { @@ -1469,21 +1492,45 @@ background-color: #ff5a52; } -.fileResultReference { - font-family: monospace; +.fileResultReferenceCode { font-size: 12px; - color: #8b949e; - word-break: break-all; - cursor: pointer; padding: 4px; - background-color: #0d1117; - border-radius: 4px; - margin-top: 5px; - transition: background-color 0.2s; + margin: 5px 0 0; } -.fileResultReference:hover { - background-color: #1f2937; +.fileResultReferenceCode[data-copied="true"]::after { + top: auto; + bottom: -26px; + font-size: 11px; + padding: 3px 6px; +} + +.fileResultLinkButtons { + display: flex; + gap: 6px; + margin-top: 6px; +} + +.fileResultLink { + flex: 1; + text-align: center; + padding: 4px 8px; + font-size: 11px; + border-radius: 6px; + color: #ff7a00; + text-decoration: none; + border: 1px solid #ff7a00; + transition: all 0.2s; + background: transparent; + cursor: pointer; + font-family: inherit; + line-height: 1.2; +} + +.fileResultLink:hover { + background-color: #ff7a00; + color: #ffffff; + text-decoration: none; } .fileResultError {