1 import plugin from "tailwindcss/plugin"
2 import { FONT_FAMILY_MONO, FONT_FAMILY_SANS } from "./constants"
3 import { theme } from "./theme/extension/theme"
4 import { colors } from "./theme/tokens/colors"
5 import { components } from "./theme/tokens/components"
6 import { effects } from "./theme/tokens/effects"
7 import { typography } from "./theme/tokens/typography"
8
9 export default plugin(
10 function medusaUi({ addBase, addComponents, config }) {
11 const [darkMode, className = ".dark"] = ([] as string[]).concat(
12 config("darkMode", "media")
13 )
14
15 addBase({
16 "*": {
17 borderColor: "var(--border-base)",
18 },
19 })
20
21 addComponents(typography)
22
23 addBase({
24 ":root": { ...colors.light, ...effects.light },
25 ...components.light,
26 })
27
28 if (darkMode === "class") {
29 addBase({
30 [className]: { ...colors.dark, ...effects.dark },
31 })
32 } else {
33 addBase({
34 "@media (prefers-color-scheme: dark)": {
35 ":root": { ...colors.dark, ...effects.dark },
36 ...components.dark,
37 },
38 })
39 }
40 },
41 {
42 theme: {
43 extend: {
44 ...theme.extend,
45 fontFamily: {
46 sans: FONT_FAMILY_SANS,
47 mono: FONT_FAMILY_MONO,
48 },
49 transitionProperty: {
50 fg: "color, background-color, border-color, box-shadow, opacity",
51 },
52 keyframes: {
53 "accordion-down": {
54 from: { height: "0px" },
55 to: { height: "var(--radix-accordion-content-height)" },
56 },
57 "accordion-up": {
58 from: { height: "var(--radix-accordion-content-height)" },
59 to: { height: "0px" },
60 },
61 },
62 animation: {
63 "accordion-down": "accordion-down 0.2s ease-out",
64 "accordion-up": "accordion-up 0.2s ease-out",
65 },
66 },
67 },
68 }
69 )