-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
485 additions
and
219 deletions.
There are no files selected for viewing
This file contains 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,68 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { Form } from "@palettify/ui"; | ||
|
||
const lightTheme = { | ||
background: "0 0% 100%", | ||
foreground: "222.2 47.4% 11.2%", | ||
muted: "210 40% 96.1%", | ||
mutedForeground: "215.4 16.3% 46.9%", | ||
popover: "0 0% 100%", | ||
popoverForeground: "222.2 47.4% 11.2%", | ||
border: "214.3 31.8% 91.4%", | ||
input: "214.3 31.8% 91.4%", | ||
card: "0 0% 100%", | ||
cardForeground: "222.2 47.4% 11.2%", | ||
primary: "222.2 47.4% 11.2%", | ||
primaryForeground: "210 40% 98%", | ||
secondary: "210 40% 96.1%", | ||
secondaryForeground: "222.2 47.4% 11.2%", | ||
accent: "210 40% 96.1%", | ||
accentForeground: "222.2 47.4% 11.2%", | ||
destructive: "0 100% 50%", | ||
destructiveForeground: "210 40% 98%", | ||
ring: "215 20.2% 65.1%", | ||
radius: "0.5rem", | ||
}; | ||
|
||
const darkTheme = { | ||
background: "224 71% 4%", | ||
foreground: "213 31% 91%", | ||
muted: "223 47% 11%", | ||
mutedForeground: "215.4 16.3% 56.9%", | ||
accent: "216 34% 17%", | ||
accentForeground: "210 40% 98%", | ||
popover: "224 71% 4%", | ||
popoverForeground: "215 20.2% 65.1%", | ||
border: "216 34% 17%", | ||
input: "216 34% 17%", | ||
card: "224 71% 4%", | ||
cardForeground: "213 31% 91%", | ||
primary: "210 40% 98%", | ||
primaryForeground: "222.2 47.4% 1.2%", | ||
secondary: "222.2 47.4% 11.2%", | ||
secondaryForeground: "210 40% 98%", | ||
destructive: "0 63% 31%", | ||
destructiveForeground: "210 40% 98%", | ||
ring: "216 34% 17%", | ||
radius: "0.5rem", | ||
}; | ||
|
||
interface FormProviderProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const FormProvider = (props: FormProviderProps) => { | ||
const { children } = props; | ||
|
||
const form = useForm({ | ||
values: { | ||
library: "shadcn", | ||
lightTheme, | ||
darkTheme, | ||
}, | ||
}); | ||
return <Form {...form}>{children}</Form>; | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import { ReactNode } from "react"; | ||
import { FormProvider } from "./form-provider"; | ||
import { Preview } from "./preview"; | ||
|
||
interface DashboardLayoutProps { | ||
children: ReactNode; | ||
} | ||
|
||
export default async function DashboardLayout(props: DashboardLayoutProps) { | ||
export default function DashboardLayout(props: DashboardLayoutProps) { | ||
const { children } = props; | ||
|
||
return ( | ||
<div className="min-h-screen"> | ||
<div> | ||
<FormProvider> | ||
<div className="min-h-screen"> | ||
<div className="lg:w-[500px]"> | ||
<div className="container px-8"> | ||
<div className="bg-card rounded-xl border p-4 shadow-xl">{children}</div> | ||
</div> | ||
</div> | ||
<Preview /> | ||
</div> | ||
</div> | ||
</FormProvider> | ||
); | ||
} |
This file contains 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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { useSearchParams } from "next/navigation"; | ||
import { UpdateSiteAppearance } from "@/modules/theme-previewer/components/theme-form"; | ||
|
||
export default function PalettesPage() { | ||
function PalettesPage() { | ||
useSearchParams(); | ||
return <UpdateSiteAppearance />; | ||
} | ||
|
||
export default PalettesPage; |
This file contains 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 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 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
138 changes: 69 additions & 69 deletions
138
...b/src/modules/theme-previewer/components/preview/shadcn-preview/dynamic-theme-wrapper.tsx
This file contains 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 |
---|---|---|
@@ -1,74 +1,74 @@ | ||
// "use client"; | ||
"use client"; | ||
|
||
// import React from "react"; | ||
import React from "react"; | ||
import { useTheme } from "next-themes"; | ||
import { useFormContext } from "react-hook-form"; | ||
|
||
// interface ThemeWrapperProps extends React.ComponentProps<"div"> { | ||
// // defaultThemes: Theme[]; | ||
// // themes?: Theme[]; | ||
// } | ||
interface ThemeWrapperProps extends React.ComponentProps<"div"> { | ||
children: React.ReactNode; | ||
} | ||
|
||
// export function DynamicThemeWrapper({ | ||
// defaultThemes, | ||
// themes = [], | ||
// children, | ||
// }: ThemeWrapperProps) { | ||
// const darkTheme = (themes.find((t) => t.mode === "dark") ?? | ||
// defaultThemes.find((t) => t.mode === "dark")) as Theme; | ||
// const lightTheme = (themes.find((t) => t.mode === "light") ?? | ||
// defaultThemes.find((t) => t.mode === "light")) as Theme; | ||
export function DynamicThemeWrapper(props: ThemeWrapperProps) { | ||
const { children } = props; | ||
|
||
// return ( | ||
// <div> | ||
// <style jsx global>{` | ||
// :root { | ||
// --background: ${lightTheme.background}; | ||
// --foreground: ${lightTheme.foreground}; | ||
// --card: ${lightTheme.card}; | ||
// --card-foreground: ${lightTheme.cardForeground}; | ||
// --popover: ${lightTheme.popover}; | ||
// --popover-foreground: ${lightTheme.popoverForeground}; | ||
// --primary: ${lightTheme.primary}; | ||
// --primary-foreground: ${lightTheme.primaryForeground}; | ||
// --secondary: ${lightTheme.secondary}; | ||
// --secondary-foreground: ${lightTheme.secondaryForeground}; | ||
// --muted: ${lightTheme.muted}; | ||
// --muted-foreground: ${lightTheme.mutedForeground}; | ||
// --accent: ${lightTheme.accent}; | ||
// --accent-foreground: ${lightTheme.accentForeground}; | ||
// --destructive: ${lightTheme.destructive}; | ||
// --destructive-foreground: ${lightTheme.destructiveForeground}; | ||
// --success: ${lightTheme.success}; | ||
// --success-foreground: ${lightTheme.successForeground}; | ||
// --border: ${lightTheme.border}; | ||
// --input: ${lightTheme.input}; | ||
// --ring: ${lightTheme.ring}; | ||
// } | ||
const form = useFormContext(); | ||
|
||
// .dark { | ||
// --background: ${darkTheme.background}; | ||
// --foreground: ${darkTheme.foreground}; | ||
// --card: ${darkTheme.card}; | ||
// --card-foreground: ${darkTheme.cardForeground}; | ||
// --popover: ${darkTheme.popover}; | ||
// --popover-foreground: ${darkTheme.popoverForeground}; | ||
// --primary: ${darkTheme.primary}; | ||
// --primary-foreground: ${darkTheme.primaryForeground}; | ||
// --secondary: ${darkTheme.secondary}; | ||
// --secondary-foreground: ${darkTheme.secondaryForeground}; | ||
// --muted: ${darkTheme.muted}; | ||
// --muted-foreground: ${darkTheme.mutedForeground}; | ||
// --accent: ${darkTheme.accent}; | ||
// --accent-foreground: ${darkTheme.accentForeground}; | ||
// --destructive: ${darkTheme.destructive}; | ||
// --destructive-foreground: ${darkTheme.destructiveForeground}; | ||
// --success: ${darkTheme.success}; | ||
// --success-foreground: ${darkTheme.successForeground}; | ||
// --border: ${darkTheme.border}; | ||
// --input: ${darkTheme.input}; | ||
// --ring: ${darkTheme.ring}; | ||
// } | ||
// `}</style> | ||
// {children} | ||
// </div> | ||
// ); | ||
// } | ||
const mode = useTheme().resolvedTheme; | ||
const darkTheme = form.watch("darkTheme"); | ||
const lightTheme = form.watch("lightTheme"); | ||
const resolvedTheme = mode === "dark" ? darkTheme : lightTheme; | ||
|
||
return ( | ||
<div className="preview-mode"> | ||
<style jsx global>{` | ||
.preview-mode { | ||
--background: ${resolvedTheme.background}; | ||
--foreground: ${resolvedTheme.foreground}; | ||
--card: ${resolvedTheme.card}; | ||
--card-foreground: ${resolvedTheme.cardForeground}; | ||
--popover: ${resolvedTheme.popover}; | ||
--popover-foreground: ${resolvedTheme.popoverForeground}; | ||
--primary: ${resolvedTheme.primary}; | ||
--primary-foreground: ${resolvedTheme.primaryForeground}; | ||
--secondary: ${resolvedTheme.secondary}; | ||
--secondary-foreground: ${resolvedTheme.secondaryForeground}; | ||
--muted: ${resolvedTheme.muted}; | ||
--muted-foreground: ${resolvedTheme.mutedForeground}; | ||
--accent: ${resolvedTheme.accent}; | ||
--accent-foreground: ${resolvedTheme.accentForeground}; | ||
--destructive: ${resolvedTheme.destructive}; | ||
--destructive-foreground: ${resolvedTheme.destructiveForeground}; | ||
--success: ${resolvedTheme.success}; | ||
--success-foreground: ${resolvedTheme.successForeground}; | ||
--border: ${resolvedTheme.border}; | ||
--input: ${resolvedTheme.input}; | ||
--ring: ${resolvedTheme.ring}; | ||
} | ||
.preview-mode.dark { | ||
--background: ${resolvedTheme.background}; | ||
--foreground: ${resolvedTheme.foreground}; | ||
--card: ${resolvedTheme.card}; | ||
--card-foreground: ${resolvedTheme.cardForeground}; | ||
--popover: ${resolvedTheme.popover}; | ||
--popover-foreground: ${resolvedTheme.popoverForeground}; | ||
--primary: ${resolvedTheme.primary}; | ||
--primary-foreground: ${resolvedTheme.primaryForeground}; | ||
--secondary: ${resolvedTheme.secondary}; | ||
--secondary-foreground: ${resolvedTheme.secondaryForeground}; | ||
--muted: ${resolvedTheme.muted}; | ||
--muted-foreground: ${resolvedTheme.mutedForeground}; | ||
--accent: ${resolvedTheme.accent}; | ||
--accent-foreground: ${resolvedTheme.accentForeground}; | ||
--destructive: ${resolvedTheme.destructive}; | ||
--destructive-foreground: ${resolvedTheme.destructiveForeground}; | ||
--success: ${resolvedTheme.success}; | ||
--success-foreground: ${resolvedTheme.successForeground}; | ||
--border: ${resolvedTheme.border}; | ||
--input: ${resolvedTheme.input}; | ||
--ring: ${resolvedTheme.ring}; | ||
} | ||
`}</style> | ||
<div className="text-foreground bg-background">{children}</div> | ||
</div> | ||
); | ||
} |
9 changes: 5 additions & 4 deletions
9
apps/web/src/modules/theme-previewer/components/preview/shadcn-preview/shadcn-preview.tsx
This file contains 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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import React from "react"; | ||
import React, { Suspense } from "react"; | ||
import { DashboardPage } from "./dashboard"; | ||
import { DynamicThemeWrapper } from "./dynamic-theme-wrapper"; | ||
import { StyledJsxRegistry } from "./registry"; | ||
|
||
// import { DynamicThemeWrapper } from "./dynamic-theme-wrapper"; | ||
|
||
export const ShadcnPreview = () => { | ||
return ( | ||
<StyledJsxRegistry> | ||
<DashboardPage /> | ||
<DynamicThemeWrapper> | ||
<DashboardPage /> | ||
</DynamicThemeWrapper> | ||
</StyledJsxRegistry> | ||
); | ||
}; |
Oops, something went wrong.