diff --git a/apps/desktop/src/components/theme-provider.tsx b/apps/desktop/src/components/theme-provider.tsx index a49649de..4d676bd2 100644 --- a/apps/desktop/src/components/theme-provider.tsx +++ b/apps/desktop/src/components/theme-provider.tsx @@ -1,73 +1,67 @@ -import { createContext, useContext, useEffect, useState } from "react" - -type Theme = "dark" | "light" | "system" - +import { createContext, useContext, useEffect, useState } from "react"; + +type Theme = "dark" | "light" | "system"; + type ThemeProviderProps = { - children: React.ReactNode - defaultTheme?: Theme - storageKey?: string -} - + children: React.ReactNode; + defaultTheme?: Theme; + storageKey?: string; +}; + type ThemeProviderState = { - theme: Theme - setTheme: (theme: Theme) => void -} - + theme: Theme; + setTheme: (theme: Theme) => void; +}; + const initialState: ThemeProviderState = { theme: "system", setTheme: () => null, -} - -const ThemeProviderContext = createContext(initialState) - +}; + +const ThemeProviderContext = createContext(initialState); + export function ThemeProvider({ children, defaultTheme = "system", storageKey = "vite-ui-theme", ...props }: ThemeProviderProps) { - const [theme, setTheme] = useState( - () => (localStorage.getItem(storageKey) as Theme) || defaultTheme - ) - + const [theme, setTheme] = useState(() => (localStorage.getItem(storageKey) as Theme) || defaultTheme); + useEffect(() => { - const root = window.document.documentElement - - root.classList.remove("light", "dark") - + 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 + const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; + + root.classList.add(systemTheme); + return; } - - root.classList.add(theme) - }, [theme]) - + + root.classList.add(theme); + }, [theme]); + const value = { theme, setTheme: (theme: Theme) => { - localStorage.setItem(storageKey, theme) - setTheme(theme) + localStorage.setItem(storageKey, theme); + setTheme(theme); }, - } - + }; + return ( {children} - ) + ); } - + export const useTheme = () => { - const context = useContext(ThemeProviderContext) - - if (context === undefined) - throw new Error("useTheme must be used within a ThemeProvider") - - return context -} + const context = useContext(ThemeProviderContext); + + if (context === undefined) throw new Error("useTheme must be used within a ThemeProvider"); + + return context; +}; diff --git a/apps/desktop/src/components/ui/button.tsx b/apps/desktop/src/components/ui/button.tsx index 0ba42773..40b908c1 100644 --- a/apps/desktop/src/components/ui/button.tsx +++ b/apps/desktop/src/components/ui/button.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { Slot } from "@radix-ui/react-slot"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +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", @@ -10,12 +10,9 @@ const buttonVariants = cva( 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", + 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", }, @@ -31,26 +28,20 @@ const buttonVariants = cva( size: "default", }, } -) +); export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { - asChild?: boolean + asChild?: boolean; } const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button" - return ( - - ) + const Comp = asChild ? Slot : "button"; + return ; } -) -Button.displayName = "Button" +); +Button.displayName = "Button"; -export { Button, buttonVariants } +export { Button, buttonVariants }; diff --git a/apps/desktop/src/components/ui/input.tsx b/apps/desktop/src/components/ui/input.tsx index 677d05fd..25a49cd4 100644 --- a/apps/desktop/src/components/ui/input.tsx +++ b/apps/desktop/src/components/ui/input.tsx @@ -1,25 +1,22 @@ -import * as React from "react" +import * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -export interface InputProps - extends React.InputHTMLAttributes {} +export interface InputProps extends React.InputHTMLAttributes {} -const Input = React.forwardRef( - ({ className, type, ...props }, ref) => { - return ( - - ) - } -) -Input.displayName = "Input" +const Input = React.forwardRef(({ className, type, ...props }, ref) => { + return ( + + ); +}); +Input.displayName = "Input"; -export { Input } +export { Input }; diff --git a/apps/desktop/src/components/ui/label.tsx b/apps/desktop/src/components/ui/label.tsx index 683faa79..80e30eec 100644 --- a/apps/desktop/src/components/ui/label.tsx +++ b/apps/desktop/src/components/ui/label.tsx @@ -1,24 +1,17 @@ -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import * as LabelPrimitive from "@radix-ui/react-label"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const labelVariants = cva( - "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" -) +const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"); const Label = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef & - VariantProps + React.ComponentPropsWithoutRef & VariantProps >(({ className, ...props }, ref) => ( - -)) -Label.displayName = LabelPrimitive.Root.displayName + +)); +Label.displayName = LabelPrimitive.Root.displayName; -export { Label } +export { Label }; diff --git a/apps/desktop/src/components/ui/link.tsx b/apps/desktop/src/components/ui/link.tsx index 19aa1a4d..240204f5 100644 --- a/apps/desktop/src/components/ui/link.tsx +++ b/apps/desktop/src/components/ui/link.tsx @@ -1,15 +1,7 @@ -export const Link = ({ to, children, ...props }: { - to: string; - children: React.ReactNode; -}) => { +export const Link = ({ to, children, ...props }: { to: string; children: React.ReactNode }) => { return ( - + {children} ); -} +}; diff --git a/apps/desktop/src/lib/utils.ts b/apps/desktop/src/lib/utils.ts index ec79801f..365058ce 100644 --- a/apps/desktop/src/lib/utils.ts +++ b/apps/desktop/src/lib/utils.ts @@ -1,6 +1,6 @@ -import { type ClassValue, clsx } from "clsx" -import { twMerge } from "tailwind-merge" - +import { type ClassValue, clsx } from "clsx"; +import { twMerge } from "tailwind-merge"; + export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)) + return twMerge(clsx(inputs)); } diff --git a/apps/desktop/tsconfig.json b/apps/desktop/tsconfig.json index ddfd0318..604aa473 100644 --- a/apps/desktop/tsconfig.json +++ b/apps/desktop/tsconfig.json @@ -3,14 +3,10 @@ "compilerOptions": { "baseUrl": ".", "paths": { - "@/*": [ - "./src/*" - ] + "@/*": ["./src/*"] } }, - "include": [ - "src" - ], + "include": ["src"], "references": [ { "path": "./tsconfig.node.json"