Skip to content

Commit

Permalink
fix(): Split out tailwind theme into preset.
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanCQ committed Dec 20, 2023
1 parent 5c1865e commit bbe60c6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "../tailwind.config";
export * from "./atoms/accordion";
export * from "./atoms/alert";
export * from "./atoms/alert-dialog";
Expand Down Expand Up @@ -41,4 +40,5 @@ export * from "./atoms/tooltip";
export * from "./atoms/use-toast";
export * from "./molecules/slide-in";
export * from "./molecules/theme-selector";
export * from "./tailwind.config";
export * from "./utils";
80 changes: 80 additions & 0 deletions src/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import typography from "@tailwindcss/typography";
import { Config } from "tailwindcss";
import animate from "tailwindcss-animate";
export const tailwindTheme = {
darkMode: ["class", ".theme-mode-dark"],
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
fontFamily: {
sans: ["Inter"],
},
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
},
"slide-up": {
from: { opacity: "0", transform: "translateY(50%)" },
to: { opacity: "1", transform: "translateY(0)" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
"slide-up": "slide-up 0.6s ease-in",
},
},
},
plugins: [animate, typography],
} satisfies Partial<Config>;
2 changes: 1 addition & 1 deletion stories/atoms/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ const meta: Meta<typeof Button> = {
export default meta;

export const Default: StoryObj<typeof Button> = {
args: {},
args: { children: "Button Text" },
};
79 changes: 2 additions & 77 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,6 @@
import typography from "@tailwindcss/typography";
import { Config } from "tailwindcss";
import animate from "tailwindcss-animate";
import { tailwindTheme } from "./src";
export default {
darkMode: ["class", ".theme-mode-dark"],
content: ["./src/**/*.{ts,tsx}", "./stories/**/*.{ts,tsx}"],
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
fontFamily: {
sans: ["Inter"],
},
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
},
"slide-up": {
from: { opacity: "0", transform: "translateY(50%)" },
to: { opacity: "1", transform: "translateY(0)" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
"slide-up": "slide-up 0.6s ease-in",
},
},
},
plugins: [animate, typography],
presets: [tailwindTheme],
} satisfies Config;

0 comments on commit bbe60c6

Please sign in to comment.