@tydavidson/design-system 1.1.14 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -75,68 +75,20 @@ var init_utils = __esm({
75
75
  "src/lib/utils.ts"() {
76
76
  }
77
77
  });
78
-
79
- // src/lib/theme-utils.ts
80
- exports.mapColorToShadcnVariant = void 0; exports.mapVariantToShadcnVariant = void 0; exports.getColorVariantClasses = void 0; exports.isDarkTheme = void 0;
81
- var init_theme_utils = __esm({
82
- "src/lib/theme-utils.ts"() {
83
- exports.mapColorToShadcnVariant = (color) => {
84
- switch (color) {
85
- case "brand":
86
- return "default";
87
- case "error":
88
- return "destructive";
89
- case "warning":
90
- case "success":
91
- return "secondary";
92
- // Will need additional classes
93
- default:
94
- return "default";
95
- }
96
- };
97
- exports.mapVariantToShadcnVariant = (variant) => {
98
- switch (variant) {
99
- case "primary":
100
- return "default";
101
- case "secondary":
102
- return "outline";
103
- case "tertiary":
104
- return "ghost";
105
- default:
106
- return "default";
107
- }
108
- };
109
- exports.getColorVariantClasses = (color, variant) => {
110
- const colorVariantMap = {
111
- primary: {
112
- brand: "bg-brand-600 hover:bg-brand-700 text-white focus-visible:ring-brand-500",
113
- error: "bg-error-600 hover:bg-error-700 text-white focus-visible:ring-error-500",
114
- warning: "bg-warning-600 hover:bg-warning-700 text-white focus-visible:ring-warning-500",
115
- success: "bg-success-600 hover:bg-success-700 text-white focus-visible:ring-success-500"
116
- },
117
- secondary: {
118
- brand: "border-brand-300 text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
119
- error: "border-error-300 text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
120
- warning: "border-warning-300 text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
121
- success: "border-success-300 text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
122
- },
123
- tertiary: {
124
- brand: "text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
125
- error: "text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
126
- warning: "text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
127
- success: "text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
128
- }
129
- };
130
- return colorVariantMap[variant]?.[color] || "";
131
- };
132
- exports.isDarkTheme = (theme, systemTheme) => {
133
- if (theme === "system") {
134
- return systemTheme === "dark";
135
- }
136
- return theme === "dark";
137
- };
138
- }
139
- });
78
+ function useThemeServer() {
79
+ return {
80
+ theme: "system",
81
+ setTheme: (theme) => {
82
+ },
83
+ resolvedTheme: "light",
84
+ isDark: false
85
+ };
86
+ }
87
+ function ThemeContextProvider({
88
+ children
89
+ }) {
90
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
91
+ }
140
92
  function useTheme() {
141
93
  const [themeData, setThemeData] = React2__namespace.useState({
142
94
  theme: "system",
@@ -147,47 +99,48 @@ function useTheme() {
147
99
  });
148
100
  const [mounted, setMounted] = React2__namespace.useState(false);
149
101
  React2__namespace.useEffect(() => {
150
- import('next-themes').then(({ useTheme: useNextTheme }) => {
151
- const { theme, setTheme, resolvedTheme, systemTheme } = useNextTheme();
152
- const isDark = exports.isDarkTheme(theme, systemTheme);
102
+ if (typeof window === "undefined") return;
103
+ import('next-themes').then((nextThemes) => {
104
+ const themeManager = {
105
+ getTheme: () => {
106
+ if (typeof window !== "undefined") {
107
+ const savedTheme = localStorage.getItem("theme");
108
+ if (savedTheme) return savedTheme;
109
+ if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
110
+ return "dark";
111
+ }
112
+ }
113
+ return "light";
114
+ },
115
+ setTheme: (theme) => {
116
+ if (typeof window !== "undefined") {
117
+ localStorage.setItem("theme", theme);
118
+ document.documentElement.classList.toggle("dark", theme === "dark");
119
+ setThemeData((prev) => ({
120
+ ...prev,
121
+ theme,
122
+ resolvedTheme: theme,
123
+ isDark: theme === "dark"
124
+ }));
125
+ }
126
+ }
127
+ };
128
+ const currentTheme = themeManager.getTheme();
129
+ const isDark = currentTheme === "dark";
153
130
  setThemeData({
154
- theme: theme || "system",
155
- setTheme,
156
- resolvedTheme: resolvedTheme || "light",
131
+ theme: currentTheme,
132
+ setTheme: themeManager.setTheme,
133
+ resolvedTheme: currentTheme,
157
134
  isDark
158
135
  });
159
136
  setMounted(true);
160
137
  });
161
138
  }, []);
162
- if (!mounted) {
163
- return {
164
- theme: "system",
165
- setTheme: (theme) => {
166
- },
167
- resolvedTheme: "light",
168
- isDark: false
169
- };
170
- }
171
139
  return themeData;
172
140
  }
173
- function useThemeServer() {
174
- return {
175
- theme: "system",
176
- setTheme: (theme) => {
177
- },
178
- resolvedTheme: "light",
179
- isDark: false
180
- };
181
- }
182
- function ThemeContextProvider({
183
- children
184
- }) {
185
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
186
- }
187
141
  var init_theme_context = __esm({
188
142
  "src/themes/theme-context.tsx"() {
189
143
  "use client";
190
- init_theme_utils();
191
144
  }
192
145
  });
193
146
  function ThemeToggle({
@@ -196,12 +149,43 @@ function ThemeToggle({
196
149
  size = "md",
197
150
  ...props
198
151
  }) {
152
+ if (typeof window === "undefined") {
153
+ return /* @__PURE__ */ jsxRuntime.jsx(
154
+ "button",
155
+ {
156
+ type: "button",
157
+ className: cn(
158
+ "inline-flex items-center justify-center rounded-md border border-input bg-background",
159
+ size === "sm" ? "h-8 w-8" : size === "lg" ? "h-12 w-12" : "h-10 w-10",
160
+ className
161
+ ),
162
+ "aria-label": "Toggle theme",
163
+ ...props,
164
+ children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconSun, { size: size === "sm" ? 16 : size === "lg" ? 24 : 20, stroke: 1.5 })
165
+ }
166
+ );
167
+ }
199
168
  const { theme, setTheme, resolvedTheme } = useTheme();
200
169
  const [mounted, setMounted] = React2__namespace.useState(false);
201
170
  React2__namespace.useEffect(() => {
202
171
  setMounted(true);
203
172
  }, []);
204
- if (!mounted) return null;
173
+ if (!mounted) {
174
+ return /* @__PURE__ */ jsxRuntime.jsx(
175
+ "button",
176
+ {
177
+ type: "button",
178
+ className: cn(
179
+ "inline-flex items-center justify-center rounded-md border border-input bg-background",
180
+ size === "sm" ? "h-8 w-8" : size === "lg" ? "h-12 w-12" : "h-10 w-10",
181
+ className
182
+ ),
183
+ "aria-label": "Toggle theme",
184
+ ...props,
185
+ children: /* @__PURE__ */ jsxRuntime.jsx(iconsReact.IconSun, { size: size === "sm" ? 16 : size === "lg" ? 24 : 20, stroke: 1.5 })
186
+ }
187
+ );
188
+ }
205
189
  const toggleTheme = () => {
206
190
  setTheme(resolvedTheme === "dark" ? "light" : "dark");
207
191
  };
@@ -1973,13 +1957,99 @@ function ClientThemeToggle(props) {
1973
1957
  });
1974
1958
  }, []);
1975
1959
  if (!mounted || !ThemeToggleComponent) {
1976
- return null;
1960
+ return /* @__PURE__ */ jsxRuntime.jsx(
1961
+ "button",
1962
+ {
1963
+ type: "button",
1964
+ className: "inline-flex items-center justify-center rounded-md border border-input bg-background h-10 w-10",
1965
+ "aria-label": "Toggle theme",
1966
+ ...props,
1967
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1968
+ "svg",
1969
+ {
1970
+ width: "20",
1971
+ height: "20",
1972
+ viewBox: "0 0 24 24",
1973
+ fill: "none",
1974
+ stroke: "currentColor",
1975
+ strokeWidth: "2",
1976
+ strokeLinecap: "round",
1977
+ strokeLinejoin: "round",
1978
+ children: [
1979
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "4" }),
1980
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 2v2" }),
1981
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 20v2" }),
1982
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m4.93 4.93 1.41 1.41" }),
1983
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m17.66 17.66 1.41 1.41" }),
1984
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 12h2" }),
1985
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 12h2" }),
1986
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6.34 17.66-1.41 1.41" }),
1987
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m19.07 4.93-1.41 1.41" })
1988
+ ]
1989
+ }
1990
+ )
1991
+ }
1992
+ );
1977
1993
  }
1978
1994
  return /* @__PURE__ */ jsxRuntime.jsx(ThemeToggleComponent, { ...props });
1979
1995
  }
1980
1996
 
1981
- // src/themes/index.ts
1982
- init_theme_utils();
1997
+ // src/lib/theme-utils.ts
1998
+ var mapColorToShadcnVariant = (color) => {
1999
+ switch (color) {
2000
+ case "brand":
2001
+ return "default";
2002
+ case "error":
2003
+ return "destructive";
2004
+ case "warning":
2005
+ case "success":
2006
+ return "secondary";
2007
+ // Will need additional classes
2008
+ default:
2009
+ return "default";
2010
+ }
2011
+ };
2012
+ var mapVariantToShadcnVariant = (variant) => {
2013
+ switch (variant) {
2014
+ case "primary":
2015
+ return "default";
2016
+ case "secondary":
2017
+ return "outline";
2018
+ case "tertiary":
2019
+ return "ghost";
2020
+ default:
2021
+ return "default";
2022
+ }
2023
+ };
2024
+ var getColorVariantClasses = (color, variant) => {
2025
+ const colorVariantMap = {
2026
+ primary: {
2027
+ brand: "bg-brand-600 hover:bg-brand-700 text-white focus-visible:ring-brand-500",
2028
+ error: "bg-error-600 hover:bg-error-700 text-white focus-visible:ring-error-500",
2029
+ warning: "bg-warning-600 hover:bg-warning-700 text-white focus-visible:ring-warning-500",
2030
+ success: "bg-success-600 hover:bg-success-700 text-white focus-visible:ring-success-500"
2031
+ },
2032
+ secondary: {
2033
+ brand: "border-brand-300 text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
2034
+ error: "border-error-300 text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
2035
+ warning: "border-warning-300 text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
2036
+ success: "border-success-300 text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
2037
+ },
2038
+ tertiary: {
2039
+ brand: "text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
2040
+ error: "text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
2041
+ warning: "text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
2042
+ success: "text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
2043
+ }
2044
+ };
2045
+ return colorVariantMap[variant]?.[color] || "";
2046
+ };
2047
+ var isDarkTheme = (theme, systemTheme) => {
2048
+ if (theme === "system") {
2049
+ return systemTheme === "dark";
2050
+ }
2051
+ return theme === "dark";
2052
+ };
1983
2053
 
1984
2054
  exports.Button = Button;
1985
2055
  exports.Card = Card;
@@ -2070,7 +2140,11 @@ exports.cn = cn;
2070
2140
  exports.colors = colors;
2071
2141
  exports.filterDOMProps = filterDOMProps;
2072
2142
  exports.generateId = generateId;
2143
+ exports.getColorVariantClasses = getColorVariantClasses;
2144
+ exports.isDarkTheme = isDarkTheme;
2073
2145
  exports.isNotNullOrUndefined = isNotNullOrUndefined;
2146
+ exports.mapColorToShadcnVariant = mapColorToShadcnVariant;
2147
+ exports.mapVariantToShadcnVariant = mapVariantToShadcnVariant;
2074
2148
  exports.radius = radius;
2075
2149
  exports.shadows = shadows;
2076
2150
  exports.spacing = spacing;