diff options
| author | A Farzat <a@farzat.xyz> | 2025-10-08 13:36:27 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2025-10-08 13:36:27 +0300 |
| commit | d93a91867baff153e0d57655996726914f042888 (patch) | |
| tree | c1a58ab23d52ca6e53e4ef3233ee17bf9e2e9ac8 /front-end | |
| parent | 6d02de42105e1fa390984c665fd73b8e6f6116f5 (diff) | |
| download | csca5028-d93a91867baff153e0d57655996726914f042888.tar.gz csca5028-d93a91867baff153e0d57655996726914f042888.zip | |
Add duration overlays to the videos
Diffstat (limited to 'front-end')
| -rw-r--r-- | front-end/src/App.css | 13 | ||||
| -rw-r--r-- | front-end/src/App.jsx | 19 |
2 files changed, 32 insertions, 0 deletions
diff --git a/front-end/src/App.css b/front-end/src/App.css index 1548a0d..0220950 100644 --- a/front-end/src/App.css +++ b/front-end/src/App.css @@ -182,6 +182,19 @@ body { transform: scale(1.05); } +.duration-overlay { + position: absolute; + bottom: 8px; + right: 8px; + background: rgba(0, 0, 0, 0.8); + color: white; + padding: 2px 6px; + border-radius: 4px; + font-size: 0.8rem; + font-weight: bold; + backdrop-filter: blur(4px); +} + .play-button { position: absolute; top: 50%; diff --git a/front-end/src/App.jsx b/front-end/src/App.jsx index a540e47..92d0adf 100644 --- a/front-end/src/App.jsx +++ b/front-end/src/App.jsx @@ -122,6 +122,22 @@ function App() { } }; + const formatDuration = (seconds) => { + if (seconds < 0) { + return '?:??'; + } + + const hours = Math.floor(seconds / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + const remainingSeconds = seconds % 60; + + if (hours > 0) { + return `${hours}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`; + } else { + return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`; + } + }; + return ( <div className="App"> <header className="App-header"> @@ -219,6 +235,9 @@ function App() { e.target.src = 'https://via.placeholder.com/300x180/333/fff?text=No+Thumbnail'; }} /> + <div className="duration-overlay"> + {formatDuration(video.duration)} + </div> <div className="play-button">▶</div> </div> |
