@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 +170 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -96
- package/dist/index.mjs.map +1 -1
- package/dist/themes/index.d.mts +16 -17
- package/dist/themes/index.d.ts +16 -17
- package/dist/themes/index.js +170 -96
- package/dist/themes/index.js.map +1 -1
- package/dist/themes/index.mjs +166 -96
- package/dist/themes/index.mjs.map +1 -1
- package/docs/troubleshooting.md +147 -99
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -44,68 +44,20 @@ var init_utils = __esm({
|
|
44
44
|
"src/lib/utils.ts"() {
|
45
45
|
}
|
46
46
|
});
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
// Will need additional classes
|
62
|
-
default:
|
63
|
-
return "default";
|
64
|
-
}
|
65
|
-
};
|
66
|
-
mapVariantToShadcnVariant = (variant) => {
|
67
|
-
switch (variant) {
|
68
|
-
case "primary":
|
69
|
-
return "default";
|
70
|
-
case "secondary":
|
71
|
-
return "outline";
|
72
|
-
case "tertiary":
|
73
|
-
return "ghost";
|
74
|
-
default:
|
75
|
-
return "default";
|
76
|
-
}
|
77
|
-
};
|
78
|
-
getColorVariantClasses = (color, variant) => {
|
79
|
-
const colorVariantMap = {
|
80
|
-
primary: {
|
81
|
-
brand: "bg-brand-600 hover:bg-brand-700 text-white focus-visible:ring-brand-500",
|
82
|
-
error: "bg-error-600 hover:bg-error-700 text-white focus-visible:ring-error-500",
|
83
|
-
warning: "bg-warning-600 hover:bg-warning-700 text-white focus-visible:ring-warning-500",
|
84
|
-
success: "bg-success-600 hover:bg-success-700 text-white focus-visible:ring-success-500"
|
85
|
-
},
|
86
|
-
secondary: {
|
87
|
-
brand: "border-brand-300 text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
|
88
|
-
error: "border-error-300 text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
|
89
|
-
warning: "border-warning-300 text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
|
90
|
-
success: "border-success-300 text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
|
91
|
-
},
|
92
|
-
tertiary: {
|
93
|
-
brand: "text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
|
94
|
-
error: "text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
|
95
|
-
warning: "text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
|
96
|
-
success: "text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
|
97
|
-
}
|
98
|
-
};
|
99
|
-
return colorVariantMap[variant]?.[color] || "";
|
100
|
-
};
|
101
|
-
isDarkTheme = (theme, systemTheme) => {
|
102
|
-
if (theme === "system") {
|
103
|
-
return systemTheme === "dark";
|
104
|
-
}
|
105
|
-
return theme === "dark";
|
106
|
-
};
|
107
|
-
}
|
108
|
-
});
|
47
|
+
function useThemeServer() {
|
48
|
+
return {
|
49
|
+
theme: "system",
|
50
|
+
setTheme: (theme) => {
|
51
|
+
},
|
52
|
+
resolvedTheme: "light",
|
53
|
+
isDark: false
|
54
|
+
};
|
55
|
+
}
|
56
|
+
function ThemeContextProvider({
|
57
|
+
children
|
58
|
+
}) {
|
59
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
60
|
+
}
|
109
61
|
function useTheme() {
|
110
62
|
const [themeData, setThemeData] = React2.useState({
|
111
63
|
theme: "system",
|
@@ -116,47 +68,48 @@ function useTheme() {
|
|
116
68
|
});
|
117
69
|
const [mounted, setMounted] = React2.useState(false);
|
118
70
|
React2.useEffect(() => {
|
119
|
-
|
120
|
-
|
121
|
-
const
|
71
|
+
if (typeof window === "undefined") return;
|
72
|
+
import('next-themes').then((nextThemes) => {
|
73
|
+
const themeManager = {
|
74
|
+
getTheme: () => {
|
75
|
+
if (typeof window !== "undefined") {
|
76
|
+
const savedTheme = localStorage.getItem("theme");
|
77
|
+
if (savedTheme) return savedTheme;
|
78
|
+
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
79
|
+
return "dark";
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return "light";
|
83
|
+
},
|
84
|
+
setTheme: (theme) => {
|
85
|
+
if (typeof window !== "undefined") {
|
86
|
+
localStorage.setItem("theme", theme);
|
87
|
+
document.documentElement.classList.toggle("dark", theme === "dark");
|
88
|
+
setThemeData((prev) => ({
|
89
|
+
...prev,
|
90
|
+
theme,
|
91
|
+
resolvedTheme: theme,
|
92
|
+
isDark: theme === "dark"
|
93
|
+
}));
|
94
|
+
}
|
95
|
+
}
|
96
|
+
};
|
97
|
+
const currentTheme = themeManager.getTheme();
|
98
|
+
const isDark = currentTheme === "dark";
|
122
99
|
setThemeData({
|
123
|
-
theme:
|
124
|
-
setTheme,
|
125
|
-
resolvedTheme:
|
100
|
+
theme: currentTheme,
|
101
|
+
setTheme: themeManager.setTheme,
|
102
|
+
resolvedTheme: currentTheme,
|
126
103
|
isDark
|
127
104
|
});
|
128
105
|
setMounted(true);
|
129
106
|
});
|
130
107
|
}, []);
|
131
|
-
if (!mounted) {
|
132
|
-
return {
|
133
|
-
theme: "system",
|
134
|
-
setTheme: (theme) => {
|
135
|
-
},
|
136
|
-
resolvedTheme: "light",
|
137
|
-
isDark: false
|
138
|
-
};
|
139
|
-
}
|
140
108
|
return themeData;
|
141
109
|
}
|
142
|
-
function useThemeServer() {
|
143
|
-
return {
|
144
|
-
theme: "system",
|
145
|
-
setTheme: (theme) => {
|
146
|
-
},
|
147
|
-
resolvedTheme: "light",
|
148
|
-
isDark: false
|
149
|
-
};
|
150
|
-
}
|
151
|
-
function ThemeContextProvider({
|
152
|
-
children
|
153
|
-
}) {
|
154
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
155
|
-
}
|
156
110
|
var init_theme_context = __esm({
|
157
111
|
"src/themes/theme-context.tsx"() {
|
158
112
|
"use client";
|
159
|
-
init_theme_utils();
|
160
113
|
}
|
161
114
|
});
|
162
115
|
function ThemeToggle({
|
@@ -165,12 +118,43 @@ function ThemeToggle({
|
|
165
118
|
size = "md",
|
166
119
|
...props
|
167
120
|
}) {
|
121
|
+
if (typeof window === "undefined") {
|
122
|
+
return /* @__PURE__ */ jsx(
|
123
|
+
"button",
|
124
|
+
{
|
125
|
+
type: "button",
|
126
|
+
className: cn(
|
127
|
+
"inline-flex items-center justify-center rounded-md border border-input bg-background",
|
128
|
+
size === "sm" ? "h-8 w-8" : size === "lg" ? "h-12 w-12" : "h-10 w-10",
|
129
|
+
className
|
130
|
+
),
|
131
|
+
"aria-label": "Toggle theme",
|
132
|
+
...props,
|
133
|
+
children: /* @__PURE__ */ jsx(IconSun, { size: size === "sm" ? 16 : size === "lg" ? 24 : 20, stroke: 1.5 })
|
134
|
+
}
|
135
|
+
);
|
136
|
+
}
|
168
137
|
const { theme, setTheme, resolvedTheme } = useTheme();
|
169
138
|
const [mounted, setMounted] = React2.useState(false);
|
170
139
|
React2.useEffect(() => {
|
171
140
|
setMounted(true);
|
172
141
|
}, []);
|
173
|
-
if (!mounted)
|
142
|
+
if (!mounted) {
|
143
|
+
return /* @__PURE__ */ jsx(
|
144
|
+
"button",
|
145
|
+
{
|
146
|
+
type: "button",
|
147
|
+
className: cn(
|
148
|
+
"inline-flex items-center justify-center rounded-md border border-input bg-background",
|
149
|
+
size === "sm" ? "h-8 w-8" : size === "lg" ? "h-12 w-12" : "h-10 w-10",
|
150
|
+
className
|
151
|
+
),
|
152
|
+
"aria-label": "Toggle theme",
|
153
|
+
...props,
|
154
|
+
children: /* @__PURE__ */ jsx(IconSun, { size: size === "sm" ? 16 : size === "lg" ? 24 : 20, stroke: 1.5 })
|
155
|
+
}
|
156
|
+
);
|
157
|
+
}
|
174
158
|
const toggleTheme = () => {
|
175
159
|
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
176
160
|
};
|
@@ -1942,13 +1926,99 @@ function ClientThemeToggle(props) {
|
|
1942
1926
|
});
|
1943
1927
|
}, []);
|
1944
1928
|
if (!mounted || !ThemeToggleComponent) {
|
1945
|
-
return
|
1929
|
+
return /* @__PURE__ */ jsx(
|
1930
|
+
"button",
|
1931
|
+
{
|
1932
|
+
type: "button",
|
1933
|
+
className: "inline-flex items-center justify-center rounded-md border border-input bg-background h-10 w-10",
|
1934
|
+
"aria-label": "Toggle theme",
|
1935
|
+
...props,
|
1936
|
+
children: /* @__PURE__ */ jsxs(
|
1937
|
+
"svg",
|
1938
|
+
{
|
1939
|
+
width: "20",
|
1940
|
+
height: "20",
|
1941
|
+
viewBox: "0 0 24 24",
|
1942
|
+
fill: "none",
|
1943
|
+
stroke: "currentColor",
|
1944
|
+
strokeWidth: "2",
|
1945
|
+
strokeLinecap: "round",
|
1946
|
+
strokeLinejoin: "round",
|
1947
|
+
children: [
|
1948
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "4" }),
|
1949
|
+
/* @__PURE__ */ jsx("path", { d: "M12 2v2" }),
|
1950
|
+
/* @__PURE__ */ jsx("path", { d: "M12 20v2" }),
|
1951
|
+
/* @__PURE__ */ jsx("path", { d: "m4.93 4.93 1.41 1.41" }),
|
1952
|
+
/* @__PURE__ */ jsx("path", { d: "m17.66 17.66 1.41 1.41" }),
|
1953
|
+
/* @__PURE__ */ jsx("path", { d: "M2 12h2" }),
|
1954
|
+
/* @__PURE__ */ jsx("path", { d: "M20 12h2" }),
|
1955
|
+
/* @__PURE__ */ jsx("path", { d: "m6.34 17.66-1.41 1.41" }),
|
1956
|
+
/* @__PURE__ */ jsx("path", { d: "m19.07 4.93-1.41 1.41" })
|
1957
|
+
]
|
1958
|
+
}
|
1959
|
+
)
|
1960
|
+
}
|
1961
|
+
);
|
1946
1962
|
}
|
1947
1963
|
return /* @__PURE__ */ jsx(ThemeToggleComponent, { ...props });
|
1948
1964
|
}
|
1949
1965
|
|
1950
|
-
// src/
|
1951
|
-
|
1966
|
+
// src/lib/theme-utils.ts
|
1967
|
+
var mapColorToShadcnVariant = (color) => {
|
1968
|
+
switch (color) {
|
1969
|
+
case "brand":
|
1970
|
+
return "default";
|
1971
|
+
case "error":
|
1972
|
+
return "destructive";
|
1973
|
+
case "warning":
|
1974
|
+
case "success":
|
1975
|
+
return "secondary";
|
1976
|
+
// Will need additional classes
|
1977
|
+
default:
|
1978
|
+
return "default";
|
1979
|
+
}
|
1980
|
+
};
|
1981
|
+
var mapVariantToShadcnVariant = (variant) => {
|
1982
|
+
switch (variant) {
|
1983
|
+
case "primary":
|
1984
|
+
return "default";
|
1985
|
+
case "secondary":
|
1986
|
+
return "outline";
|
1987
|
+
case "tertiary":
|
1988
|
+
return "ghost";
|
1989
|
+
default:
|
1990
|
+
return "default";
|
1991
|
+
}
|
1992
|
+
};
|
1993
|
+
var getColorVariantClasses = (color, variant) => {
|
1994
|
+
const colorVariantMap = {
|
1995
|
+
primary: {
|
1996
|
+
brand: "bg-brand-600 hover:bg-brand-700 text-white focus-visible:ring-brand-500",
|
1997
|
+
error: "bg-error-600 hover:bg-error-700 text-white focus-visible:ring-error-500",
|
1998
|
+
warning: "bg-warning-600 hover:bg-warning-700 text-white focus-visible:ring-warning-500",
|
1999
|
+
success: "bg-success-600 hover:bg-success-700 text-white focus-visible:ring-success-500"
|
2000
|
+
},
|
2001
|
+
secondary: {
|
2002
|
+
brand: "border-brand-300 text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
|
2003
|
+
error: "border-error-300 text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
|
2004
|
+
warning: "border-warning-300 text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
|
2005
|
+
success: "border-success-300 text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
|
2006
|
+
},
|
2007
|
+
tertiary: {
|
2008
|
+
brand: "text-brand-700 hover:bg-brand-50 focus-visible:ring-brand-500",
|
2009
|
+
error: "text-error-700 hover:bg-error-50 focus-visible:ring-error-500",
|
2010
|
+
warning: "text-warning-700 hover:bg-warning-50 focus-visible:ring-warning-500",
|
2011
|
+
success: "text-success-700 hover:bg-success-50 focus-visible:ring-success-500"
|
2012
|
+
}
|
2013
|
+
};
|
2014
|
+
return colorVariantMap[variant]?.[color] || "";
|
2015
|
+
};
|
2016
|
+
var isDarkTheme = (theme, systemTheme) => {
|
2017
|
+
if (theme === "system") {
|
2018
|
+
return systemTheme === "dark";
|
2019
|
+
}
|
2020
|
+
return theme === "dark";
|
2021
|
+
};
|
1952
2022
|
|
1953
2023
|
export { Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ClientThemeProvider, ClientThemeToggle, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, EmailButton, EmailCaption, EmailContainer, EmailFooter, EmailHeader, EmailHeading, EmailLayout, EmailMuted, EmailText, Heading, HoverCard, HoverCardContent, HoverCardTrigger, Input, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Slider, Text, ThemeContextProvider, ThemeProvider, ThemeProviderNoSSR, ThemeToggle, Toggle, ToggleGroup, ToggleGroupItem, buttonVariants, cn, colors, filterDOMProps, generateId, getColorVariantClasses, isDarkTheme, isNotNullOrUndefined, mapColorToShadcnVariant, mapVariantToShadcnVariant, radius, shadows, spacing, tokens, typography, useTheme, useThemeServer };
|
1954
2024
|
//# sourceMappingURL=index.mjs.map
|