diff --git a/apps/studio/components/interfaces/Storage/BucketFilePickerDialog/BucketFilePickerRow.tsx b/apps/studio/components/interfaces/Storage/BucketFilePickerDialog/BucketFilePickerRow.tsx index 5ec97e3b1bd..a43544d17cf 100644 --- a/apps/studio/components/interfaces/Storage/BucketFilePickerDialog/BucketFilePickerRow.tsx +++ b/apps/studio/components/interfaces/Storage/BucketFilePickerDialog/BucketFilePickerRow.tsx @@ -1,54 +1,12 @@ -import { FilesBucket as FilesBucketIcon } from 'icons' -import { AlertCircle, File, Film, FolderOpen, Image, LoaderCircle, Music } from 'lucide-react' +import { AlertCircle, LoaderCircle } from 'lucide-react' import type { CSSProperties, MouseEvent } from 'react' import { Checkbox, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import { STORAGE_ROW_STATUS, STORAGE_ROW_TYPES, STORAGE_VIEWS } from '../Storage.constants' import { type StorageItem } from '../Storage.types' +import { StorageRowIcon } from '../StorageRowIcon' import { formatBytes } from '@/lib/helpers' -const RowIcon = ({ - view, - status, - fileType, - isOpened = false, - mimeType, -}: { - view: STORAGE_VIEWS - status: STORAGE_ROW_STATUS - fileType: string - isOpened?: boolean - mimeType: string | undefined -}) => { - if (view === STORAGE_VIEWS.LIST && status === STORAGE_ROW_STATUS.LOADING) { - return ( - - ) - } - - if (fileType === STORAGE_ROW_TYPES.FOLDER) { - return isOpened ? ( - - ) : ( - - ) - } - - if (mimeType?.includes('image')) { - return - } - - if (mimeType?.includes('audio')) { - return - } - - if (mimeType?.includes('video')) { - return - } - - return -} - interface BucketFilePickerRowProps { item: StorageItem view: STORAGE_VIEWS @@ -114,7 +72,7 @@ export const BucketFilePickerRow = ({ hidden: isSelected, })} > - { - if (view === STORAGE_VIEWS.LIST && status === STORAGE_ROW_STATUS.LOADING) { - return - } - - if (fileType === STORAGE_ROW_TYPES.FOLDER) { - return isOpened ? ( - - ) : ( - - ) - } - - if (mimeType?.includes('image')) { - return - } - - if (mimeType?.includes('audio')) { - return - } - - if (mimeType?.includes('video')) { - return - } - - return -} - interface FileExplorerRowProps { index: number item: StorageItem @@ -329,7 +284,7 @@ export const FileExplorerRow = ({ )} style={{ top: '2px' }} > -
- { + test.each(CASES)('renders $name at the canonical stroke width', (props) => { + const { container } = customRender( + + ) + + const icon = container.querySelector('svg') + + expect(icon).toHaveClass(props.expectedIcon) + expect(icon).toHaveAttribute('stroke-width', '1.5') + }) +}) diff --git a/apps/studio/components/interfaces/Storage/StorageRowIcon.tsx b/apps/studio/components/interfaces/Storage/StorageRowIcon.tsx new file mode 100644 index 00000000000..814a3b259c2 --- /dev/null +++ b/apps/studio/components/interfaces/Storage/StorageRowIcon.tsx @@ -0,0 +1,60 @@ +import { FilesBucket as FilesBucketIcon } from 'icons' +import { File, Film, FolderOpen, Image as ImageIcon, LoaderCircle, Music } from 'lucide-react' + +import { STORAGE_ROW_STATUS, STORAGE_ROW_TYPES, STORAGE_VIEWS } from './Storage.constants' + +const ICON_STROKE_WIDTH = 1.5 + +interface StorageRowIconProps { + view: STORAGE_VIEWS + status: STORAGE_ROW_STATUS + fileType: string + isOpened?: boolean + mimeType: string | undefined +} + +export const StorageRowIcon = ({ + view, + status, + fileType, + isOpened = false, + mimeType, +}: StorageRowIconProps) => { + if (view === STORAGE_VIEWS.LIST && status === STORAGE_ROW_STATUS.LOADING) { + return ( + + ) + } + + if (fileType === STORAGE_ROW_TYPES.FOLDER) { + return isOpened ? ( + + ) : ( + + ) + } + + if (mimeType?.includes('image')) { + return ( + + ) + } + + if (mimeType?.includes('audio')) { + return + } + + if (mimeType?.includes('video')) { + return + } + + return +}