-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
20 changed files
with
1,839 additions
and
346 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,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/app.css", | ||
"baseColor": "zinc", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
import "./app.css" | ||
import { ThemeProvider } from "@/components/theme-provider" | ||
import { ModeToggle } from "./components/mode-toggle" | ||
|
||
export function App() { | ||
return <h1>Pinorama</h1> | ||
function App() { | ||
return ( | ||
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme"> | ||
<ModeToggle /> | ||
</ThemeProvider> | ||
) | ||
} | ||
|
||
export default App |
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
import { useTheme } from "@/components/theme-provider" | ||
import { Button } from "@/components/ui/button" | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger | ||
} from "@/components/ui/dropdown-menu" | ||
import { Moon, Sun } from "lucide-react" | ||
|
||
export function ModeToggle() { | ||
const { setTheme } = useTheme() | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="outline" size="icon"> | ||
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" /> | ||
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" /> | ||
<span className="sr-only">Toggle theme</span> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuItem onClick={() => setTheme("light")}> | ||
Light | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => setTheme("dark")}> | ||
Dark | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => setTheme("system")}> | ||
System | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
) | ||
} |
73 changes: 73 additions & 0 deletions
73
packages/pinorama-studio/src/components/theme-provider.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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { createContext, useContext, useEffect, useState } from "react" | ||
|
||
type Theme = "dark" | "light" | "system" | ||
|
||
type ThemeProviderProps = { | ||
children: React.ReactNode | ||
defaultTheme?: Theme | ||
storageKey?: string | ||
} | ||
|
||
type ThemeProviderState = { | ||
theme: Theme | ||
setTheme: (theme: Theme) => void | ||
} | ||
|
||
const initialState: ThemeProviderState = { | ||
theme: "system", | ||
setTheme: () => null | ||
} | ||
|
||
const ThemeProviderContext = createContext<ThemeProviderState>(initialState) | ||
|
||
export function ThemeProvider({ | ||
children, | ||
defaultTheme = "system", | ||
storageKey = "vite-ui-theme", | ||
...props | ||
}: ThemeProviderProps) { | ||
const [theme, setTheme] = useState<Theme>( | ||
() => (localStorage.getItem(storageKey) as Theme) || defaultTheme | ||
) | ||
|
||
useEffect(() => { | ||
const root = window.document.documentElement | ||
|
||
root.classList.remove("light", "dark") | ||
|
||
if (theme === "system") { | ||
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)") | ||
.matches | ||
? "dark" | ||
: "light" | ||
|
||
root.classList.add(systemTheme) | ||
return | ||
} | ||
|
||
root.classList.add(theme) | ||
}, [theme]) | ||
|
||
const value = { | ||
theme, | ||
setTheme: (theme: Theme) => { | ||
localStorage.setItem(storageKey, theme) | ||
setTheme(theme) | ||
} | ||
} | ||
|
||
return ( | ||
<ThemeProviderContext.Provider {...props} value={value}> | ||
{children} | ||
</ThemeProviderContext.Provider> | ||
) | ||
} | ||
|
||
export const useTheme = () => { | ||
const context = useContext(ThemeProviderContext) | ||
|
||
if (context === undefined) | ||
throw new Error("useTheme must be used within a ThemeProvider") | ||
|
||
return context | ||
} |
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,56 @@ | ||
import { Slot } from "@radix-ui/react-slot" | ||
import { type VariantProps, cva } from "class-variance-authority" | ||
import * as React from "react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const buttonVariants = cva( | ||
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", | ||
{ | ||
variants: { | ||
variant: { | ||
default: "bg-primary text-primary-foreground hover:bg-primary/90", | ||
destructive: | ||
"bg-destructive text-destructive-foreground hover:bg-destructive/90", | ||
outline: | ||
"border border-input bg-background hover:bg-accent hover:text-accent-foreground", | ||
secondary: | ||
"bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||
ghost: "hover:bg-accent hover:text-accent-foreground", | ||
link: "text-primary underline-offset-4 hover:underline" | ||
}, | ||
size: { | ||
default: "h-10 px-4 py-2", | ||
sm: "h-9 rounded-md px-3", | ||
lg: "h-11 rounded-md px-8", | ||
icon: "h-10 w-10" | ||
} | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
size: "default" | ||
} | ||
} | ||
) | ||
|
||
export interface ButtonProps | ||
extends React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
VariantProps<typeof buttonVariants> { | ||
asChild?: boolean | ||
} | ||
|
||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, variant, size, asChild = false, ...props }, ref) => { | ||
const Comp = asChild ? Slot : "button" | ||
return ( | ||
<Comp | ||
className={cn(buttonVariants({ variant, size, className }))} | ||
ref={ref} | ||
{...props} | ||
/> | ||
) | ||
} | ||
) | ||
Button.displayName = "Button" | ||
|
||
export { Button, buttonVariants } |
Oops, something went wrong.