Skip to content

Commit 3b28397

Browse files
committed
Example: one-card dropzone with icon actions and a single refused-files line
1 parent b51024a commit 3b28397

5 files changed

Lines changed: 265 additions & 74 deletions

File tree

‎examples/nextjs/app/avatar/page.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export default function AvatarPage() {
1010
return (
1111
<section className="flex flex-col gap-4">
1212
<h2 className="font-medium">Avatar</h2>
13-
<div className="flex items-start gap-5">
13+
<div className="flex items-start gap-6">
1414
<div className="size-24 shrink-0 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800">
1515
{avatar && <img src={avatar.url} alt="Your avatar" className="size-full object-cover" />}
1616
</div>
1717
<div className="flex-1">
18-
<Dropzone zone={zone} label="Drop an image, or click to choose" compact />
18+
<Dropzone zone={zone} label="Drop an image" compact />
1919
</div>
2020
</div>
2121
</section>

‎examples/nextjs/app/form/page.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22
import { useActionState, useEffect, useRef, useState } from 'react';
3-
import { Dropzone, formatBytes } from '@/components/dropzone';
3+
import { Dropzone, formatBytes, refusal } from '@/components/dropzone';
44
import { useDropzone } from '@/lib/dropzone';
55
import { savePost } from './actions';
66

@@ -12,7 +12,8 @@ export default function FormPage() {
1212
const form = useRef<HTMLFormElement>(null);
1313

1414
const held = zone.uploads.filter((u) => u.status === 'idle').length;
15-
const failed = zone.uploads.some((u) => u.status === 'error');
15+
// Refused files clear themselves; only failed uploads hold the form.
16+
const failed = zone.uploads.some((u) => u.status === 'error' && !refusal(u));
1617

1718
// Submit once the uploads the button started have all landed.
1819
useEffect(() => {

‎examples/nextjs/app/globals.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
:root {
44
color-scheme: light dark;
55
}
6+
7+
@theme {
8+
--font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
9+
}

‎examples/nextjs/app/layout.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import type { Metadata } from 'next';
2+
import { Inter } from 'next/font/google';
23
import { Nav } from '@/components/nav';
34
import './globals.css';
45

6+
const inter = Inter({ subsets: ['latin'], variable: '--font-inter' });
7+
58
export const metadata: Metadata = {
69
title: '@upstash/react-dropzone example',
710
description: 'Drag and drop uploads to Upstash Blob',
811
};
912

1013
export default function RootLayout({ children }: { children: React.ReactNode }) {
1114
return (
12-
<html lang="en">
13-
<body className="min-h-dvh bg-zinc-50 font-sans text-zinc-900 antialiased dark:bg-zinc-950 dark:text-zinc-100">
15+
<html lang="en" className={inter.variable}>
16+
<body className="min-h-dvh bg-zinc-100 font-sans text-zinc-900 antialiased dark:bg-zinc-950 dark:text-zinc-100">
1417
<div className="mx-auto flex max-w-2xl flex-col gap-8 px-5 py-10">
1518
<header className="flex flex-wrap items-center justify-between gap-4">
1619
<div>

0 commit comments

Comments
 (0)