-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feat : Made a tailwind config customisable by api
- Updated global CSS and theme variables to set primary and secondary colorsfor light and dark modes. - Modified tailwind configuration in UI and app components, ensuring consistency of colors and styles. - Made the root layout to be able to load the variables from an api call ✨ Add custom theme variables for light and dark mode - Moved the css variable setting function into tailwind config package - Made a basic tailwind config and attached it to all relavant packages
- Loading branch information
1 parent
24fb777
commit 05e1625
Showing
15 changed files
with
203 additions
and
107 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
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 +1,19 @@ | ||
export * from "@repo/tailwind-config/tw-config"; | ||
import {type Config} from "tailwindcss"; | ||
import { presetTheme } from "@repo/tailwind-config/tw-config"; | ||
|
||
const config = { | ||
content: [ | ||
"./app/**/*.{js,ts,jsx,tsx,mdx}", | ||
"./pages/**/*.{js,ts,jsx,tsx,mdx}", | ||
"./components/**/*.{js,ts,jsx,tsx,mdx}", | ||
|
||
// Or if using `src` directory: | ||
"./src/**/*.{js,ts,jsx,tsx,mdx}", | ||
], | ||
theme: { | ||
extend: {}, | ||
}, | ||
presets: [presetTheme], | ||
} satisfies Config | ||
|
||
export default config |
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 |
---|---|---|
@@ -1 +1,19 @@ | ||
export * from "@repo/tailwind-config/tw-config"; | ||
import {type Config} from "tailwindcss"; | ||
import { presetTheme } from "@repo/tailwind-config/tw-config"; | ||
|
||
const config = { | ||
content: [ | ||
"./app/**/*.{js,ts,jsx,tsx,mdx}", | ||
"./pages/**/*.{js,ts,jsx,tsx,mdx}", | ||
"./components/**/*.{js,ts,jsx,tsx,mdx}", | ||
|
||
// Or if using `src` directory: | ||
"./src/**/*.{js,ts,jsx,tsx,mdx}", | ||
], | ||
theme: { | ||
extend: {}, | ||
}, | ||
presets: [presetTheme], | ||
} satisfies Config | ||
|
||
export default config |
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,35 @@ | ||
function setDocumentStyleProperty( | ||
property: string, | ||
lightValue: string, | ||
darkValue?: string, | ||
) { | ||
document.documentElement.style.setProperty(`--${property}`, lightValue); | ||
document.documentElement.style.setProperty( | ||
`--${property}-dark`, | ||
darkValue || lightValue, | ||
); | ||
} | ||
|
||
export function themeVariablesCSS() { | ||
setDocumentStyleProperty("background", "255, 255, 255", "23, 23, 23"); | ||
setDocumentStyleProperty("foreground", "23, 23, 23", "236, 237, 238"); | ||
setDocumentStyleProperty("border", "229, 231, 235", "63, 63, 70"); | ||
setDocumentStyleProperty("content", "255, 255, 255", "39, 39, 42"); | ||
setDocumentStyleProperty("input-border", "63, 63, 70", "156, 166, 163"); | ||
setDocumentStyleProperty("divider", "218, 222, 242", "78, 84, 83"); | ||
setDocumentStyleProperty("primary", "255, 137, 36"); | ||
setDocumentStyleProperty("primary-foreground", "255, 255, 255"); | ||
setDocumentStyleProperty("secondary", "212, 212, 216", "63, 63, 70"); | ||
setDocumentStyleProperty( | ||
"secondary-foreground", | ||
"17, 24, 28", | ||
"255, 255, 255", | ||
); | ||
setDocumentStyleProperty("success", "23, 201, 100"); | ||
setDocumentStyleProperty("success-foreground", "17, 24, 28"); | ||
setDocumentStyleProperty("warning", "245, 165, 36"); | ||
setDocumentStyleProperty("warning-foreground", "17, 24, 28"); | ||
setDocumentStyleProperty("danger", "243, 18, 96"); | ||
setDocumentStyleProperty("danger-foreground", "255, 255, 255"); | ||
setDocumentStyleProperty("focus", "var(--primary"); | ||
} |
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,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
|
||
@layer base { | ||
:root{ | ||
--primary: #006FEE; | ||
--primary-foreground: #FFFFFF; | ||
|
||
--success: #17c964; | ||
--success-foreground: #11181C; | ||
|
||
--warning: #f5a524; | ||
--warning-foreground: #11181C; | ||
|
||
--danger: #f31260; | ||
--danger-foreground: #FFFFFF; | ||
|
||
--focus: #006FEE; | ||
} | ||
|
||
.default.light { | ||
--background: #FFFFFF; | ||
--foreground: #11181C; | ||
|
||
--secondary: #d4d4d8; | ||
--secondary-foreground: #11181C; | ||
|
||
--content-1: #FFFFFF; | ||
--content-2: #f4f4f5; | ||
--content-3: #e4e4e7; | ||
--content-4: #d4d4d8; | ||
} | ||
|
||
.default.dark { | ||
--background: #000000; | ||
--foreground: #ECEDEE; | ||
|
||
--secondary: #3f3f46; | ||
--secondary-foreground: #FFFFFF; | ||
|
||
--content-1: #18181b; | ||
--content-2: #27272a; | ||
--content-3: #3f3f46; | ||
--content-4: #52525b; | ||
} | ||
} | ||
|
||
@layer base { | ||
html, | ||
body { | ||
scroll-behavior: smooth; | ||
--header-height: 74px; | ||
--footer-height: 60px; | ||
--sidebar-width: 260px; | ||
} | ||
/* Track */ | ||
::-webkit-scrollbar { | ||
width: 8px; | ||
} | ||
::-webkit-scrollbar-track { | ||
background: #f2f2f2; | ||
} | ||
/* Handle */ | ||
::-webkit-scrollbar-thumb { | ||
border-radius: 8px; | ||
background: #999; | ||
} | ||
/* Handle on hover */ | ||
::-webkit-scrollbar-thumb:hover { | ||
background: #777; | ||
} | ||
} | ||
@tailwind utilities; |
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
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,3 +1,13 @@ | ||
export function ApplicationLayout({ children }: { children: React.ReactNode }) { | ||
return <body className="h-screen w-full light">{children}</body>; | ||
"use client"; | ||
|
||
import { ReactNode, useEffect } from "react"; | ||
import { themeVariablesCSS } from "@repo/tailwind-config/css-variable-setter"; | ||
|
||
export function ApplicationLayout({ children }: { children: ReactNode }) { | ||
|
||
useEffect(() => { | ||
themeVariablesCSS() | ||
}, []); | ||
|
||
return <body className="h-screen w-full light bg-primary">{children}</body>; | ||
} |
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,8 +1,17 @@ | ||
export * from "@repo/tailwind-config/tw-config"; | ||
import {type Config} from "tailwindcss"; | ||
import { presetTheme } from "@repo/tailwind-config/tw-config"; | ||
|
||
/** | ||
* Author: sidarth-23 | ||
* Date: 2023-02-15 | ||
* | ||
* Any changes you want, make it in the tailwind config package so that it is consistent across all the apps | ||
*/ | ||
const config = { | ||
content: [ | ||
"./components/**/*.{js,ts,jsx,tsx,mdx}", | ||
|
||
// Or if using `src` directory: | ||
"./src/**/*.{js,ts,jsx,tsx,mdx}", | ||
], | ||
theme: { | ||
extend: {}, | ||
}, | ||
presets: [presetTheme], | ||
} satisfies Config | ||
|
||
export default config |
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
Oops, something went wrong.