adaptive design added

This commit is contained in:
Daniel Shleifman
2021-05-31 19:26:56 +03:00
parent 78d02c00b6
commit c2793438ad
3 changed files with 79 additions and 16 deletions

View File

@@ -25,8 +25,9 @@ export default function TorrentCache({ cache, cacheMap, isMini }) {
useEffect(() => { useEffect(() => {
// initializing stageSettings // initializing stageSettings
isMini ? updateStageSettings(24, 4) : updateStageSettings(12, 2) if (isMini) return dimensions.width < 500 ? updateStageSettings(20, 3) : updateStageSettings(24, 4)
}, [isMini]) updateStageSettings(12, 2)
}, [isMini, dimensions.width])
const { boxHeight, strokeWidth, marginBetweenBlocks, stageOffset } = stageSettings const { boxHeight, strokeWidth, marginBetweenBlocks, stageOffset } = stageSettings
const preloadPiecesAmount = Math.round(cache.Capacity / cache.PiecesLength - 1) const preloadPiecesAmount = Math.round(cache.Capacity / cache.PiecesLength - 1)
@@ -40,7 +41,7 @@ export default function TorrentCache({ cache, cacheMap, isMini }) {
let activeId = null let activeId = null
return ( return (
<Measure bounds onResize={contentRect => setDimensions(contentRect.bounds)}> <Measure bounds onResize={({ bounds }) => setDimensions(bounds)}>
{({ measureRef }) => ( {({ measureRef }) => (
<div ref={measureRef}> <div ref={measureRef}>
<DialogContent style={{ padding: 0 }}> <DialogContent style={{ padding: 0 }}>

View File

@@ -251,7 +251,7 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
</Button> </Button>
</CacheSection> </CacheSection>
<TorrentFilesSection> {/* <TorrentFilesSection>
<SectionTitle mb={20}>Torrent Content</SectionTitle> <SectionTitle mb={20}>Torrent Content</SectionTitle>
{!playableFileList?.length ? ( {!playableFileList?.length ? (
@@ -309,7 +309,7 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
</Table> </Table>
</> </>
)} )}
</TorrentFilesSection> </TorrentFilesSection> */}
</DialogContentGrid> </DialogContentGrid>
)} )}
</div> </div>

View File

@@ -8,6 +8,15 @@ export const DialogContentGrid = styled.div`
grid-template-areas: grid-template-areas:
'main cache' 'main cache'
'file-list file-list'; 'file-list file-list';
@media (max-width: 1450px) {
grid-template-columns: 1fr;
grid-template-rows: repeat(3, min-content);
grid-template-areas:
'main'
'cache'
'file-list';
}
` `
export const Poster = styled.div` export const Poster = styled.div`
${({ poster }) => css` ${({ poster }) => css`
@@ -33,6 +42,22 @@ export const Poster = styled.div`
transform: scale(2.5) translateY(-3px); transform: scale(2.5) translateY(-3px);
} }
`} `}
@media (max-width: 1280px) {
align-self: start;
}
@media (max-width: 840px) {
height: 200px;
${!poster &&
css`
width: 150px;
svg {
transform: translateY(-3px);
}
`}
}
`} `}
` `
export const MainSection = styled.section` export const MainSection = styled.section`
@@ -42,6 +67,10 @@ export const MainSection = styled.section`
grid-template-columns: min-content 1fr; grid-template-columns: min-content 1fr;
gap: 30px; gap: 30px;
background: linear-gradient(145deg, #e4f6ed, #b5dec9); background: linear-gradient(145deg, #e4f6ed, #b5dec9);
@media (max-width: 840px) {
grid-template-columns: 1fr;
}
` `
export const MainSectionButtonGroup = styled.div` export const MainSectionButtonGroup = styled.div`
@@ -52,6 +81,14 @@ export const MainSectionButtonGroup = styled.div`
:not(:last-child) { :not(:last-child) {
margin-bottom: 30px; margin-bottom: 30px;
} }
@media (max-width: 1045px) {
grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 880px) {
grid-template-columns: 1fr;
}
` `
export const CacheSection = styled.section` export const CacheSection = styled.section`
@@ -73,6 +110,11 @@ export const SectionSubName = styled.div`
${({ mb }) => css` ${({ mb }) => css`
${mb && `margin-bottom: ${mb}px`}; ${mb && `margin-bottom: ${mb}px`};
color: #7c7b7c; color: #7c7b7c;
@media (max-width: 800px) {
${mb && `margin-bottom: ${mb / 2}px`};
font-size: 11px;
}
`} `}
` `
@@ -83,6 +125,11 @@ export const SectionTitle = styled.div`
font-weight: 200; font-weight: 200;
line-height: 1; line-height: 1;
word-break: break-word; word-break: break-word;
@media (max-width: 800px) {
font-size: 25px;
${mb && `margin-bottom: ${mb / 2}px`};
}
`} `}
` `
@@ -99,15 +146,25 @@ export const WidgetWrapper = styled.div`
grid-template-columns: repeat(auto-fit, minmax(max-content, 220px)); grid-template-columns: repeat(auto-fit, minmax(max-content, 220px));
gap: 20px; gap: 20px;
${({ detailedView }) =>
detailedView &&
css`
@media (max-width: 800px) { @media (max-width: 800px) {
gap: 15px; gap: 15px;
grid-template-columns: repeat(2, 1fr);
} }
@media (max-width: 410px) { @media (max-width: 410px) {
gap: 10px; gap: 10px;
}
${({ detailedView }) =>
detailedView
? css`
@media (max-width: 800px) {
grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 410px) {
grid-template-columns: 1fr;
}
`
: css`
@media (max-width: 840px) {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
`} `}
@@ -206,6 +263,11 @@ export const SmallLabel = styled.div`
font-size: 20px; font-size: 20px;
font-weight: 300; font-weight: 300;
line-height: 1; line-height: 1;
@media (max-width: 800px) {
font-size: 18px;
${mb && `margin-bottom: ${mb / 1.5}px`};
}
`} `}
` `