From 31d4311dd3d5e2087a7c0d7a07c56a1240dfe13c Mon Sep 17 00:00:00 2001 From: Daniel Shleifman Date: Tue, 15 Jun 2021 17:24:36 +0300 Subject: [PATCH] notification fixed --- .../TorrentCache/LargeSnake.jsx | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/LargeSnake.jsx b/web/src/components/DialogTorrentDetailsContent/TorrentCache/LargeSnake.jsx index 08e80e9..05cb2bc 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/LargeSnake.jsx +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/LargeSnake.jsx @@ -2,6 +2,7 @@ import styled, { css } from 'styled-components' import Measure from 'react-measure' import { useState } from 'react' import { v4 as uuidv4 } from 'uuid' +import { useTranslation } from 'react-i18next' import { defaultBackgroundColor, @@ -17,6 +18,14 @@ const borderWidth = 1 const defaultPieceSize = 14 const pieceSizeForMiniMap = 23 const gapBetweenPieces = 3 +const miniCacheMaxHeight = 340 + +const ScrollNotification = styled.div` + margin-top: 10px; + text-transform: uppercase; + color: rgba(0, 0, 0, 0.5); + align-self: center; +` const SnakeWrapper = styled.div` ${({ pieceSize, piecesInOneRow }) => css` @@ -26,6 +35,12 @@ const SnakeWrapper = styled.div` grid-auto-rows: max-content; justify-content: center; + ${piecesInOneRow && + css` + max-height: ${miniCacheMaxHeight}px; + overflow: auto; + `} + .piece { width: ${pieceSize}px; height: ${pieceSize}px; @@ -59,28 +74,32 @@ const PercentagePiece = styled.div` ` export default function LargeSnake({ cacheMap, isMini, preloadPiecesAmount }) { + const { t } = useTranslation() const [dimensions, setDimensions] = useState({ width: 0, height: 0 }) - const pieceSize = isMini ? pieceSizeForMiniMap : defaultPieceSize let piecesInOneRow let shotCacheMap if (isMini) { const pieceSizeWithGap = pieceSize + gapBetweenPieces - piecesInOneRow = Math.floor(dimensions.width / pieceSizeWithGap) + piecesInOneRow = Math.floor((dimensions.width * 0.95) / pieceSizeWithGap) shotCacheMap = isMini && getShortCacheMap({ cacheMap, preloadPiecesAmount, piecesInOneRow }) } return isMini ? ( setDimensions(bounds)}> {({ measureRef }) => ( - - {shotCacheMap.map(({ className, id, percentage }) => ( - - {percentage > 0 && percentage <= 100 && } - - ))} - +
+ + {shotCacheMap.map(({ className, id, percentage }) => ( + + {percentage > 0 && percentage <= 100 && } + + ))} + + + {dimensions.height >= miniCacheMaxHeight && {t('ScrollDown')}} +
)}
) : (