Skip to content

Commit c3cc791

Browse files
fix: tailwind file sourcing & dropzone.
1 parent 237d113 commit c3cc791

3 files changed

Lines changed: 52 additions & 39 deletions

File tree

examples/ui-playground/src/app/playground/shadcn/drop-zone-section.tsx

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -167,36 +167,44 @@ function CustomDropzone() {
167167
setPreviews([])
168168
}
169169

170+
const [disabled, setDisabled] = useState(false)
171+
170172
return (
171-
<DropzoneProvider
172-
src={files}
173-
previews={previews}
174-
onError={handleError}
175-
onDrop={handleDrop}
176-
className="min-h-32"
177-
maxFiles={5}
178-
>
179-
<DropZoneEmptyContent>
180-
<DropZoneArea>
181-
{/* These content will be displayed if no previewable item */}
182-
<div className="flex flex-col items-center justify-center gap-y-6">
183-
<DropZoneEmptyUploadButton />
184-
<DropZoneEmptyUploadDescription />
185-
<DropZoneEmptyUploadCaption />
186-
</div>
187-
</DropZoneArea>
188-
</DropZoneEmptyContent>
189-
<DropZoneNonemptyContent>
190-
{/* These content will be displayed if there're available previewable item */}
191-
<CustomDropzoneContent removePreview={removePreview}>
192-
<div className="flex flex-col gap-y-4">
193-
{previews.map((preview, index) => (
194-
<FilePreviewItem key={preview.url} index={index} removePreview={removePreview} />
195-
))}
196-
</div>
197-
</CustomDropzoneContent>
198-
</DropZoneNonemptyContent>
199-
</DropzoneProvider>
173+
<div>
174+
<Button className="mb-12" onClick={() => setDisabled(!disabled)}>
175+
Toggle disabled
176+
</Button>
177+
<DropzoneProvider
178+
src={files}
179+
previews={previews}
180+
onError={handleError}
181+
onDrop={handleDrop}
182+
className="min-h-32"
183+
maxFiles={5}
184+
disabled={disabled}
185+
>
186+
<DropZoneEmptyContent>
187+
<DropZoneArea>
188+
{/* These content will be displayed if no previewable item */}
189+
<div className="flex flex-col items-center justify-center gap-y-6">
190+
<DropZoneEmptyUploadButton />
191+
<DropZoneEmptyUploadDescription />
192+
<DropZoneEmptyUploadCaption />
193+
</div>
194+
</DropZoneArea>
195+
</DropZoneEmptyContent>
196+
<DropZoneNonemptyContent>
197+
{/* These content will be displayed if there're available previewable item */}
198+
<CustomDropzoneContent removePreview={removePreview}>
199+
<div className="flex flex-col gap-y-4">
200+
{previews.map((preview, index) => (
201+
<FilePreviewItem key={preview.url} index={index} removePreview={removePreview} />
202+
))}
203+
</div>
204+
</CustomDropzoneContent>
205+
</DropZoneNonemptyContent>
206+
</DropzoneProvider>
207+
</div>
200208
)
201209
}
202210

examples/ui-playground/src/styles/tailwind.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@import './tiptap-style.css';
33

44
@source "../../node_modules/@genseki/react";
5+
@source "../../node_modules/@genseki/ui";
56

67
.tiptap.ProseMirror {
78
height: 100%;

packages/ui/src/components/primitives/drop-zone.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ interface DropzoneContextType extends DropzoneState {
4141
maxSize?: DropzoneOptions['maxSize']
4242
minSize?: DropzoneOptions['minSize']
4343
maxFiles?: DropzoneOptions['maxFiles']
44+
disabled?: DropzoneOptions['disabled']
4445
}
4546

4647
interface FinalDropzoneContextType extends DropzoneContextType {
@@ -137,6 +138,7 @@ export const DropzoneProvider = ({
137138
maxSize={maxSize}
138139
minSize={minSize}
139140
maxFiles={maxFiles}
141+
disabled={disabled}
140142
{...dropzoneCtx}
141143
>
142144
{children}
@@ -166,7 +168,9 @@ export const DropZoneEmptyContent = (props: { children?: React.ReactNode }) => {
166168
return props.children
167169
}
168170

169-
export const DropZoneArea = (props: React.ComponentPropsWithRef<'button'>) => {
171+
export const DropZoneArea = (
172+
props: Pick<React.ComponentPropsWithRef<'button'>, 'className' | 'id' | 'children'>
173+
) => {
170174
const dropzoneCtx = useDropZone()
171175

172176
return (
@@ -176,10 +180,11 @@ export const DropZoneArea = (props: React.ComponentPropsWithRef<'button'>) => {
176180
data-drag-reject={dropzoneCtx.isDragReject}
177181
data-focused={dropzoneCtx.isFocused}
178182
data-file-dialog-active={dropzoneCtx.isFileDialogActive}
183+
data-disabled={dropzoneCtx.disabled}
179184
className={cn(
180185
'group/dropzone relative h-auto w-full flex-col overflow-hidden rounded-md border border-dashed p-12',
181186
'data-[drag-active=true]:ring-ring ring-offset-2 data-[drag-active=true]:outline-none data-[drag-active=true]:ring-[2px]',
182-
'disabled:bg-surface-primary-disabled',
187+
'data-[disabled=true]:bg-surface-primary-disabled',
183188
props.className
184189
)}
185190
{...dropzoneCtx.getRootProps({
@@ -190,8 +195,8 @@ export const DropZoneArea = (props: React.ComponentPropsWithRef<'button'>) => {
190195
>
191196
<input
192197
{...dropzoneCtx.getInputProps()}
193-
disabled={props.disabled}
194-
aria-disabled={props.disabled}
198+
disabled={dropzoneCtx.disabled}
199+
aria-disabled={dropzoneCtx.disabled}
195200
id={props.id}
196201
/>
197202
{props.children}
@@ -254,13 +259,12 @@ export const DropZoneEmptyUploadButton = ({
254259
<Button
255260
variant="outline"
256261
asChild
262+
className={cn(
263+
'group-data-[disabled=true]/dropzone:bg-surface-primary-disabled group-data-[disabled=true]/dropzone:active:bg-surface-primary-disabled group-data-[disabled=true]/dropzone:cursor-default',
264+
className
265+
)}
257266
children={
258-
<span
259-
className={cn(
260-
'group-disabled/dropzone:bg-surface-primary-disabled group-disabled/dropzone:active:bg-surface-primary-disabled group-disabled/dropzone:cursor-default',
261-
className
262-
)}
263-
>
267+
<span>
264268
<PaperclipIcon />
265269
<span>Upload {maxFiles === 1 ? 'a file' : 'files'}</span>
266270
</span>

0 commit comments

Comments
 (0)