diff --git a/.github/workflows/storybook-deployment.yml b/.github/workflows/storybook-deployment.yml index 4d0265bc..22df860c 100644 --- a/.github/workflows/storybook-deployment.yml +++ b/.github/workflows/storybook-deployment.yml @@ -1,39 +1,39 @@ # Workflow name name: Build and Publish Storybook to GitHub Pages - + on: - # Event for the workflow to run on - push: - branches: - - master - + # Event for the workflow to run on + push: + branches: + - master + permissions: - contents: read - pages: write - id-token: write - + contents: read + pages: write + id-token: write + # List of jobs jobs: - deploy: - environment: - name: github-pages - url: ${{ steps.build-publish.outputs.page_url }} - runs-on: ubuntu-latest - # Job steps - steps: - # Manual Checkout - - uses: actions/checkout@v4 - - # Set up Node - - uses: actions/setup-node@v4 - with: - node-version: '20.x' - - #👇 Add Storybook build and deploy to GitHub Pages as a step in the workflow - - id: build-publish - uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3 - with: - install_command: npm install # default: npm ci - build_command: npm run build && npm run build-storybook # default: npm run build-storybook - path: storybook-static # default: dist/storybook - checkout: false # default: true \ No newline at end of file + deploy: + environment: + name: github-pages + url: ${{ steps.build-publish.outputs.page_url }} + runs-on: ubuntu-latest + # Job steps + steps: + # Manual Checkout + - uses: actions/checkout@v4 + + # Set up Node + - uses: actions/setup-node@v4 + with: + node-version: '20.x' + + #👇 Add Storybook build and deploy to GitHub Pages as a step in the workflow + - id: build-publish + uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3 + with: + install_command: npm install # default: npm ci + build_command: npm run build && npm run build-storybook # default: npm run build-storybook + path: storybook-static # default: dist/storybook + checkout: false # default: true diff --git a/src/components/dropzone/dropzone.stories.tsx b/src/components/dropzone/dropzone.stories.tsx index e9127d1d..28d5906a 100644 --- a/src/components/dropzone/dropzone.stories.tsx +++ b/src/components/dropzone/dropzone.stories.tsx @@ -15,6 +15,11 @@ const meta: Meta = { control: { type: 'select' }, }, }, + decorators: ( Story ) => ( +
+ +
+ ), }; export default meta; diff --git a/src/components/dropzone/dropzone.tsx b/src/components/dropzone/dropzone.tsx index 8fc286f4..93ce053e 100644 --- a/src/components/dropzone/dropzone.tsx +++ b/src/components/dropzone/dropzone.tsx @@ -1,7 +1,7 @@ -import { useState, createContext, useContext, useRef } from 'react'; +import { useState, createContext, useContext, useRef, useMemo } from 'react'; import { CloudUpload, File, ImageOff, Trash } from 'lucide-react'; import { cn, formatFileSize } from '@/utilities/functions'; -import Loader from '../loader'; +import Loader from '@/components/loader'; import { nanoid } from 'nanoid'; export interface DropzoneProps { @@ -42,6 +42,14 @@ export const FilePreview = () => { const { file, removeFile, isLoading, error, errorText } = useFileUploadContext()!; + const renderFileIcon = useMemo( () => { + return ( + + + + ); + }, [ file ] ); + if ( ! file ) { return null; } @@ -53,8 +61,8 @@ export const FilePreview = () => { error && 'border-alert-border-danger bg-alert-background-danger' ) } > -
- { isLoading && } +
+ { isLoading && renderFileIcon } { ! isLoading && ( file.type.startsWith( 'image/' ) ? (
{ ) }
) : ( - - - + renderFileIcon ) ) } -
- +
+ { isLoading ? 'Loading...' : file.name } { ! isLoading && ( @@ -94,17 +100,19 @@ export const FilePreview = () => { ) }
+ { isLoading ? ( + + + + ) : ( + + ) }
- { isLoading ? ( - - ) : ( - - ) }
); }; @@ -210,7 +218,7 @@ export const Dropzone = ( {