From 65e1e0caa2cfb8f79d1ab1132227b8550a5ced63 Mon Sep 17 00:00:00 2001 From: Jixun Wu Date: Sun, 21 May 2023 15:38:07 +0100 Subject: [PATCH] chore: move file row's grid layout to its own file --- src/features/file-listing/FileRow.tsx | 32 +++---------------- .../file-listing/FileRowResponsiveGrid.tsx | 27 ++++++++++++++++ 2 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 src/features/file-listing/FileRowResponsiveGrid.tsx diff --git a/src/features/file-listing/FileRow.tsx b/src/features/file-listing/FileRow.tsx index 9b2be79..7e4fe72 100644 --- a/src/features/file-listing/FileRow.tsx +++ b/src/features/file-listing/FileRow.tsx @@ -1,3 +1,4 @@ +import { useRef } from 'react'; import { Box, Button, @@ -5,7 +6,6 @@ import { CardBody, Center, Collapse, - Grid, GridItem, Image, Link, @@ -15,8 +15,8 @@ import { Wrap, WrapItem, } from '@chakra-ui/react'; +import { FileRowResponsiveGrid } from './FileRowResponsiveGrid'; import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice'; -import { useCallback, useRef } from 'react'; import { useAppDispatch } from '~/hooks'; import noCoverFallbackImageURL from '~/assets/no-cover.svg'; @@ -59,29 +59,7 @@ export function FileRow({ id, file }: FileRowProps) { - +
)} - + {file.decrypted && - + diff --git a/src/features/file-listing/FileRowResponsiveGrid.tsx b/src/features/file-listing/FileRowResponsiveGrid.tsx new file mode 100644 index 0000000..24e2783 --- /dev/null +++ b/src/features/file-listing/FileRowResponsiveGrid.tsx @@ -0,0 +1,27 @@ +import { Grid, chakra } from '@chakra-ui/react'; + +export const FileRowResponsiveGrid = chakra(Grid, { + baseStyle: { + gridTemplateAreas: { + base: ` + "cover" + "title" + "meta" + "action" + `, + md: ` + "cover title action" + "cover meta action" + `, + }, + gridTemplateRows: { + base: 'repeat(auto-fill)', + md: 'min-content 1fr', + }, + gridTemplateColumns: { + base: '1fr', + md: '160px 1fr', + }, + gap: 3, + }, +});