Skip to content

Commit 16df28d

Browse files
committed
add shadcn example
1 parent 8a49712 commit 16df28d

32 files changed

Lines changed: 3787 additions & 170 deletions

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"access": "public",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
10-
"ignore": ["docs"]
10+
"ignore": ["docs", "shadcn"]
1111
}

docs/docs/api.mdx

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,30 @@ sidebar_position: 2
55

66
## ImageUploadProps
77

8-
| Name | Description | Type | Default |
9-
| ------------------ | --------------------------------------- | ---------------------------------------------------- | ----------------------------------------- |
10-
| children | custom upload zone | React.ReactNode | |
11-
| width | image width | `number` | 100 |
12-
| height | image height | `number` | `width` |
13-
| value | default images | `string` \| `ValueItem` \| `(string \| ValueItem)[]` | [] |
14-
| onChange | callback for when the images changes | (value: `ImageItem[]`) => void | |
15-
| onUpload | callback for when the drop event occurs | (file: `File`) => `string` \| `Promise<string>` | (file: File) => URL.createObjectURL(file) |
16-
| max | max image number | `number` | Infinity |
17-
| readonly | for preview | `boolean` | |
18-
| className | root className | `string` | |
19-
| itemClassName | image className | `string` | |
20-
| dropzoneClassName | dropzone className | `string` | |
21-
| dropzoneOptions | | DropzoneOptions | |
22-
| photoProviderProps | | Omit\<PhotoProviderProps, "children"\> | |
8+
| Name | Description | Type | Default |
9+
| ------------------ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
10+
| children | custom upload zone | React.ReactNode | |
11+
| width | image width | `number` | 100 |
12+
| height | image height | `number` | `width` |
13+
| value | default images | `string` \| `ImageItem` \| `(string \| ImageItem)[]` | [] |
14+
| onChange | callback for when the images changes | (value: `ImageItem[]`) => void | |
15+
| onUpload | callback for when the drop event occurs | (file: `File`) => `string` \| `Promise<string>` | (file: File) => URL.createObjectURL(file) |
16+
| max | max image number | `number` | Infinity |
17+
| readonly | for preview | `boolean` | |
18+
| className | root className | `string` | |
19+
| itemClassName | image className | `string` | |
20+
| dropzoneClassName | dropzone className | `string` | |
21+
| dropzoneOptions | | [DropzoneOptions](https://react-dropzone.js.org/#section-components) | |
22+
| photoProviderProps | | Omit\<[PhotoProviderProps](https://react-photo-view.vercel.app/en-US/docs/api#photoprovider), "children"\> | |
2323

2424
### Types
2525

2626
```ts
27-
type ValueItem = {
28-
url: string;
29-
name?: string;
30-
};
31-
3227
type ImageItem = {
33-
id: string;
28+
id?: string;
3429
url?: string;
3530
name?: string;
3631
file?: File;
3732
loading?: boolean;
3833
};
3934
```
40-
41-
## DropzoneOptions
42-
43-
[react-dropzone](https://react-dropzone.js.org/#section-components)
44-
45-
## PhotoProviderProps
46-
47-
[react-photo-view](https://react-photo-view.vercel.app/en-US/docs/api#photoprovider)

docs/docs/getting-started.mdx

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ npm install @fourcels/react-image-upload
1313

1414
```jsx
1515
import { ImageUpload } from "@fourcels/react-image-upload";
16+
import "@fourcels/react-image-upload/dist/index.css";
1617

1718
function MyApp() {
1819
return <ImageUpload />;
@@ -68,30 +69,3 @@ function MyApp() {
6869
readonly
6970
/>
7071
```
71-
72-
### Reset
73-
74-
```jsx live
75-
function MyApp() {
76-
const imageUploadRef = React.useRef(null);
77-
78-
return (
79-
<div>
80-
<ImageUpload
81-
ref={imageUploadRef}
82-
value={[
83-
"../img/undraw_docusaurus_mountain.svg",
84-
"../img/undraw_docusaurus_react.svg",
85-
"../img/undraw_docusaurus_tree.svg",
86-
]}
87-
/>
88-
<button
89-
className="button button--secondary margin-top--md"
90-
onClick={() => imageUploadRef.current?.reset()}
91-
>
92-
Reset
93-
</button>
94-
</div>
95-
);
96-
}
97-
```

examples/shadcn/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "next/typescript"]
3+
}

examples/shadcn/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts

examples/shadcn/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

examples/shadcn/app/favicon.ico

25.3 KB
Binary file not shown.
66.3 KB
Binary file not shown.
64.7 KB
Binary file not shown.

examples/shadcn/app/globals.css

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
body {
6+
font-family: Arial, Helvetica, sans-serif;
7+
}
8+
9+
@layer utilities {
10+
.text-balance {
11+
text-wrap: balance;
12+
}
13+
}
14+
15+
@layer base {
16+
:root {
17+
--background: 0 0% 100%;
18+
--foreground: 240 10% 3.9%;
19+
--card: 0 0% 100%;
20+
--card-foreground: 240 10% 3.9%;
21+
--popover: 0 0% 100%;
22+
--popover-foreground: 240 10% 3.9%;
23+
--primary: 240 5.9% 10%;
24+
--primary-foreground: 0 0% 98%;
25+
--secondary: 240 4.8% 95.9%;
26+
--secondary-foreground: 240 5.9% 10%;
27+
--muted: 240 4.8% 95.9%;
28+
--muted-foreground: 240 3.8% 46.1%;
29+
--accent: 240 4.8% 95.9%;
30+
--accent-foreground: 240 5.9% 10%;
31+
--destructive: 0 84.2% 60.2%;
32+
--destructive-foreground: 0 0% 98%;
33+
--border: 240 5.9% 90%;
34+
--input: 240 5.9% 90%;
35+
--ring: 240 10% 3.9%;
36+
--chart-1: 12 76% 61%;
37+
--chart-2: 173 58% 39%;
38+
--chart-3: 197 37% 24%;
39+
--chart-4: 43 74% 66%;
40+
--chart-5: 27 87% 67%;
41+
--radius: 0.5rem;
42+
}
43+
.dark {
44+
--background: 240 10% 3.9%;
45+
--foreground: 0 0% 98%;
46+
--card: 240 10% 3.9%;
47+
--card-foreground: 0 0% 98%;
48+
--popover: 240 10% 3.9%;
49+
--popover-foreground: 0 0% 98%;
50+
--primary: 0 0% 98%;
51+
--primary-foreground: 240 5.9% 10%;
52+
--secondary: 240 3.7% 15.9%;
53+
--secondary-foreground: 0 0% 98%;
54+
--muted: 240 3.7% 15.9%;
55+
--muted-foreground: 240 5% 64.9%;
56+
--accent: 240 3.7% 15.9%;
57+
--accent-foreground: 0 0% 98%;
58+
--destructive: 0 62.8% 30.6%;
59+
--destructive-foreground: 0 0% 98%;
60+
--border: 240 3.7% 15.9%;
61+
--input: 240 3.7% 15.9%;
62+
--ring: 240 4.9% 83.9%;
63+
--chart-1: 220 70% 50%;
64+
--chart-2: 160 60% 45%;
65+
--chart-3: 30 80% 55%;
66+
--chart-4: 280 65% 60%;
67+
--chart-5: 340 75% 55%;
68+
}
69+
}
70+
71+
@layer base {
72+
* {
73+
@apply border-border;
74+
}
75+
body {
76+
@apply bg-background text-foreground;
77+
}
78+
}

0 commit comments

Comments
 (0)