-
Notifications
You must be signed in to change notification settings - Fork 408
refactor: UploadButton #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e4eab7e
add with-novel example
juliusmarminge 0ad4378
cs
juliusmarminge 57b6418
rm try-catch
juliusmarminge 489a2f7
swap
juliusmarminge ef7075d
return
juliusmarminge 0c23565
refactor efect code
juliusmarminge e556991
refactor UploadButton
juliusmarminge 4e30034
fix docs
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "uploadthing": minor | ||
| "@uploadthing/react": minor | ||
| --- | ||
|
|
||
| feat: add `generateReactHelpers.getRouteConfig`, `isValidFileSize` and `isValidFileType` helpers | ||
|
|
||
| 💡 See https://github.com/pingdotgg/uploadthing/blob/main/examples/with-novel/uploadthing/novel-plugin.ts#L50-L61 for a live example utilizing these helpers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { createRouteHandler, createUploadthing } from "uploadthing/next-legacy"; | ||
|
|
||
| const f = createUploadthing(); | ||
| const router = { | ||
| mockRoute: f(["image"]) | ||
| .middleware(() => { | ||
| throw new Error("This is just a mock route, you cant use it"); | ||
| return {}; | ||
| }) | ||
| .onUploadComplete(() => {}), | ||
| }; | ||
|
|
||
| export default createRouteHandler({ | ||
| router, | ||
| config: { uploadthingSecret: "sk_foo" }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Go to https://uploadthing.com/dashboard to get your API secret | ||
| UPLOADTHING_SECRET='sk_live_xxx' | ||
| UPLOADTHING_APP_ID='xxx' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Integrating UploadThing with Novel | ||
|
|
||
| <a href="https://stackblitz.com/github/pingdotgg/uploadthing/tree/main/examples/with-novel"> | ||
| <img height="64" src="https://github.com/pingdotgg/uploadthing/assets/51714798/45907a4e-aa64-401a-afb3-b6c6df6eb71f" /> | ||
| </a> | ||
|
|
||
| This is a stripped down version of the Novel Web app. See the original full | ||
| source code at: https://github.com/steven-tey/novel/tree/main/apps/web | ||
|
|
||
| For the UploadThing specific code in this example, see | ||
| [uploadthing/novel-plugin.ts](./uploadthing/novel-plugin.ts). | ||
|
|
||
| ## QuickStart | ||
|
|
||
| 1. Grab an API key from the UploadThing dashboard: | ||
| https://uploadthing.com/dashboard | ||
| 2. `cp .env.example .env` and paste in your API key in the newly created `.env` | ||
| file | ||
| 3. `pnpm i && pnpm dev` | ||
| 4. Use the editor and upload files! | ||
|
|
||
| ## Further reference | ||
|
|
||
| Check out the docs at: | ||
|
|
||
| - https://docs.uploadthing.com/getting-started/appdir | ||
| - https://novel.sh/docs |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { Crimson_Text, Inconsolata, Inter } from "next/font/google"; | ||
| import localFont from "next/font/local"; | ||
|
|
||
| export const cal = localFont({ | ||
| src: "./CalSans-SemiBold.otf", | ||
| variable: "--font-title", | ||
| }); | ||
|
|
||
| export const crimsonBold = Crimson_Text({ | ||
| weight: "700", | ||
| variable: "--font-title", | ||
| subsets: ["latin"], | ||
| }); | ||
|
|
||
| export const inter = Inter({ | ||
| variable: "--font-default", | ||
| subsets: ["latin"], | ||
| }); | ||
|
|
||
| export const inconsolataBold = Inconsolata({ | ||
| weight: "700", | ||
| variable: "--font-title", | ||
| subsets: ["latin"], | ||
| }); | ||
|
|
||
| export const crimson = Crimson_Text({ | ||
| weight: "400", | ||
| variable: "--font-default", | ||
| subsets: ["latin"], | ||
| }); | ||
|
|
||
| export const inconsolata = Inconsolata({ | ||
| variable: "--font-default", | ||
| subsets: ["latin"], | ||
| }); | ||
|
|
||
| export const titleFontMapper = { | ||
| Default: cal.variable, | ||
| Serif: crimsonBold.variable, | ||
| Mono: inconsolataBold.variable, | ||
| }; | ||
|
|
||
| export const defaultFontMapper = { | ||
| Default: inter.variable, | ||
| Serif: crimson.variable, | ||
| Mono: inconsolata.variable, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
|
|
||
| @layer base { | ||
| :root { | ||
| --background: 0 0% 100%; | ||
| --foreground: 222.2 84% 4.9%; | ||
|
|
||
| --card: 0 0% 100%; | ||
| --card-foreground: 222.2 84% 4.9%; | ||
|
|
||
| --popover: 0 0% 100%; | ||
| --popover-foreground: 222.2 84% 4.9%; | ||
|
|
||
| --primary: 222.2 47.4% 11.2%; | ||
| --primary-foreground: 210 40% 98%; | ||
|
|
||
| --secondary: 210 40% 96.1%; | ||
| --secondary-foreground: 222.2 47.4% 11.2%; | ||
|
|
||
| --muted: 210 40% 96.1%; | ||
| --muted-foreground: 215.4 16.3% 46.9%; | ||
|
|
||
| --accent: 210 40% 96.1%; | ||
| --accent-foreground: 222.2 47.4% 11.2%; | ||
|
|
||
| --destructive: 0 84.2% 60.2%; | ||
| --destructive-foreground: 210 40% 98%; | ||
|
|
||
| --border: 214.3 31.8% 91.4%; | ||
| --input: 214.3 31.8% 91.4%; | ||
| --ring: 222.2 84% 4.9%; | ||
|
|
||
| --radius: 0.5rem; | ||
|
|
||
| --novel-highlight-default: #ffffff; | ||
| --novel-highlight-purple: #f6f3f8; | ||
| --novel-highlight-red: #fdebeb; | ||
| --novel-highlight-yellow: #fbf4a2; | ||
| --novel-highlight-blue: #c1ecf9; | ||
| --novel-highlight-green: #acf79f; | ||
| --novel-highlight-orange: #faebdd; | ||
| --novel-highlight-pink: #faf1f5; | ||
| --novel-highlight-gray: #f1f1ef; | ||
| } | ||
|
|
||
| .dark { | ||
| --background: 222.2 84% 4.9%; | ||
| --foreground: 210 40% 98%; | ||
|
|
||
| --card: 222.2 84% 4.9%; | ||
| --card-foreground: 210 40% 98%; | ||
|
|
||
| --popover: 222.2 84% 4.9%; | ||
| --popover-foreground: 210 40% 98%; | ||
|
|
||
| --primary: 210 40% 98%; | ||
| --primary-foreground: 222.2 47.4% 11.2%; | ||
|
|
||
| --secondary: 217.2 32.6% 17.5%; | ||
| --secondary-foreground: 210 40% 98%; | ||
|
|
||
| --muted: 217.2 32.6% 17.5%; | ||
| --muted-foreground: 215 20.2% 65.1%; | ||
|
|
||
| --accent: 217.2 32.6% 17.5%; | ||
| --accent-foreground: 210 40% 98%; | ||
|
|
||
| --destructive: 0 62.8% 30.6%; | ||
| --destructive-foreground: 210 40% 98%; | ||
|
|
||
| --border: 217.2 32.6% 17.5%; | ||
| --input: 217.2 32.6% 17.5%; | ||
| --ring: 212.7 26.8% 83.9%; | ||
|
|
||
| --novel-highlight-default: #000000; | ||
| --novel-highlight-purple: #3f2c4b; | ||
| --novel-highlight-red: #5c1a1a; | ||
| --novel-highlight-yellow: #5c4b1a; | ||
| --novel-highlight-blue: #1a3d5c; | ||
| --novel-highlight-green: #1a5c20; | ||
| --novel-highlight-orange: #5c3a1a; | ||
| --novel-highlight-pink: #5c1a3a; | ||
| --novel-highlight-gray: #3a3a3a; | ||
| } | ||
| } | ||
|
|
||
| @layer base { | ||
| * { | ||
| @apply border-border; | ||
| } | ||
| body { | ||
| @apply bg-background text-foreground; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having these actually load instead of fetch failing helped reduce some impossible states we had weird paths for just to display in here