Skip to content

Commit

Permalink
theme color changes accordign to the app
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunsoftprodigy committed Oct 10, 2024
1 parent 933b96f commit ad3b49a
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 31 deletions.
10 changes: 6 additions & 4 deletions mirror-2/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"deno.enablePaths": ["supabase/functions"],
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"deno.enablePaths": [
"supabase/functions"
],
"deno.lint": true,
"deno.unstable": [
"bare-node-builtins",
Expand All @@ -16,8 +21,5 @@
"http",
"net"
],
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"typescript.tsdk": "node_modules/typescript/lib"
}
61 changes: 60 additions & 1 deletion mirror-2/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@tailwind components;
@tailwind utilities;

@layer base {
/* @layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
Expand Down Expand Up @@ -57,7 +57,66 @@
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
} */

@layer base {
.blue-theme {
--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: 217.2 91.2% 59.8%;
--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%;
--radius: 0.5rem;
--ring: 224.3 76.3% 48%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}

.red-theme {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;
--card: 0 0% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 0 0% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 72.2% 50.6%;
--primary-foreground: 0 85.7% 97.3%;
--secondary: 0 0% 14.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 14.9%;
--muted-foreground: 0 0% 63.9%;
--accent: 0 0% 14.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--radius: 0rem;
--ring: 0 72.2% 50.6%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

.ant-tree-switcher_close {
margin-top: 0.5rem !important;
}
Expand Down
23 changes: 11 additions & 12 deletions mirror-2/app/layout.client.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
"use client"
"use client";
import { store } from "@/state/store";
import { Provider } from 'react-redux'
import { Provider } from "react-redux";
import { ThemeProvider } from "next-themes";
import { useSetupAuthEvents } from "@/hooks/auth";

export default function ClientLayout({ children }) {
return (
<Provider store={store}>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
attribute={"class"}
themes={["blue-theme", "red-theme"]}
defaultTheme={"blue-theme"}
enableSystem={false}
disableTransitionOnChange
enableColorScheme
>
<AuthLayout children={children} />
</ThemeProvider>
</Provider>
)
);
}

// separate component here because auth setup needs to be within the store
export function AuthLayout({ children }) {
useSetupAuthEvents()
useSetupAuthEvents();
return (
<main className="items-center">
<div className="">
{children}
</div>
<div className="">{children}</div>
</main>

)
);
}
5 changes: 3 additions & 2 deletions mirror-2/components/theme-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import { useEffect, useState } from "react";
const ThemeSwitcher = () => {
const [shown, setShown] = useState(false);
const { theme, setTheme } = useTheme();
const appName = process.env.NEXT_PUBLIC_APP_NAME;

// useEffect only runs on the client, so now we can safely show the UI
useEffect(() => {
setTheme("dark");
}, []);
setTheme(appName === "The Mirror" ? "blue-theme" : "red-theme");
}, [appName]);

if (!shown) {
return null;
Expand Down
8 changes: 4 additions & 4 deletions mirror-2/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const buttonVariants = cva(
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90 delay-0",
default: "bg-primary hover:bg-primary/90 delay-0",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline:
Expand All @@ -30,12 +30,12 @@ const buttonVariants = cva(
variant: "default",
size: "default",
},
},
}
);

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}

Expand All @@ -49,7 +49,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
{...props}
/>
);
},
}
);
Button.displayName = "Button";

Expand Down
16 changes: 8 additions & 8 deletions mirror-2/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
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<HTMLInputElement> { }
extends React.InputHTMLAttributes<HTMLInputElement> {}

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-slate-950 placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:file:text-slate-50 dark:placeholder:text-slate-400 dark:focus-visible:ring-slate-300",
"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-slate-950 placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:file:text-slate-50 dark:placeholder:text-slate-400 dark:focus-visible:ring-slate-300 text-black",
className
)}
ref={ref}
{...props}
/>
)
);
}
)
Input.displayName = "Input"
);
Input.displayName = "Input";

export { Input }
export { Input };

0 comments on commit ad3b49a

Please sign in to comment.