@fakhrirafiki/theme-engine 0.4.17 → 0.4.19
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 +35 -23
- package/dist/index.mjs +35 -23
- package/dist/styles/components.css +38 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4715,40 +4715,50 @@ var MoonIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
|
4715
4715
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" })
|
|
4716
4716
|
}
|
|
4717
4717
|
);
|
|
4718
|
+
var SystemIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
4719
|
+
"svg",
|
|
4720
|
+
{
|
|
4721
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4722
|
+
width: "16",
|
|
4723
|
+
height: "16",
|
|
4724
|
+
viewBox: "0 0 24 24",
|
|
4725
|
+
fill: "none",
|
|
4726
|
+
stroke: "currentColor",
|
|
4727
|
+
strokeWidth: "2",
|
|
4728
|
+
strokeLinecap: "round",
|
|
4729
|
+
strokeLinejoin: "round",
|
|
4730
|
+
className: "theme-toggle-icon",
|
|
4731
|
+
children: [
|
|
4732
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { width: "20", height: "14", x: "2", y: "3", rx: "2" }),
|
|
4733
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "8", x2: "16", y1: "21", y2: "21" }),
|
|
4734
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", x2: "12", y1: "17", y2: "21" })
|
|
4735
|
+
]
|
|
4736
|
+
}
|
|
4737
|
+
);
|
|
4718
4738
|
var ThemeToggle = (0, import_react3.forwardRef)(
|
|
4719
4739
|
({ className, size = "md", variant = "default", children, ...props }, ref) => {
|
|
4720
4740
|
const { mode, resolvedMode, toggleMode } = useTheme();
|
|
4721
|
-
const nextResolvedMode = resolvedMode === "light" ? "dark" : "light";
|
|
4722
4741
|
const handleClick = (event) => {
|
|
4723
4742
|
const { clientX: x, clientY: y } = event;
|
|
4724
4743
|
toggleMode({ x, y });
|
|
4725
4744
|
};
|
|
4726
|
-
const sizeClasses = {
|
|
4727
|
-
sm: "h-8 w-8 p-1.5",
|
|
4728
|
-
md: "h-9 w-9 p-2",
|
|
4729
|
-
lg: "h-10 w-10 p-2.5"
|
|
4730
|
-
};
|
|
4731
|
-
const variantClasses = {
|
|
4732
|
-
default: "bg-background border border-input hover:bg-accent hover:text-accent-foreground",
|
|
4733
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
4734
|
-
ghost: "hover:bg-accent hover:text-accent-foreground"
|
|
4735
|
-
};
|
|
4736
4745
|
const baseClasses = (0, import_clsx.clsx)(
|
|
4737
4746
|
// Base button styles
|
|
4738
4747
|
"theme-toggle",
|
|
4739
|
-
"inline-flex items-center justify-center",
|
|
4740
|
-
"rounded-md text-sm font-medium",
|
|
4741
|
-
"ring-offset-background transition-colors",
|
|
4742
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
4743
|
-
"disabled:pointer-events-none disabled:opacity-50",
|
|
4744
|
-
// Size and variant
|
|
4745
|
-
sizeClasses[size],
|
|
4746
|
-
variantClasses[variant],
|
|
4747
4748
|
className
|
|
4748
4749
|
);
|
|
4749
4750
|
const renderIcon = () => {
|
|
4750
4751
|
if (children) return children;
|
|
4751
|
-
|
|
4752
|
+
switch (mode) {
|
|
4753
|
+
case "light":
|
|
4754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SunIcon, {});
|
|
4755
|
+
case "dark":
|
|
4756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MoonIcon, {});
|
|
4757
|
+
case "system":
|
|
4758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SystemIcon, {});
|
|
4759
|
+
default:
|
|
4760
|
+
return resolvedMode === "dark" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MoonIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SunIcon, {});
|
|
4761
|
+
}
|
|
4752
4762
|
};
|
|
4753
4763
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4754
4764
|
"button",
|
|
@@ -4756,10 +4766,12 @@ var ThemeToggle = (0, import_react3.forwardRef)(
|
|
|
4756
4766
|
ref,
|
|
4757
4767
|
className: baseClasses,
|
|
4758
4768
|
onClick: handleClick,
|
|
4759
|
-
"data-
|
|
4769
|
+
"data-size": size,
|
|
4770
|
+
"data-variant": variant,
|
|
4771
|
+
"data-mode": resolvedMode,
|
|
4760
4772
|
"data-theme": resolvedMode,
|
|
4761
|
-
"aria-label": `Switch to ${
|
|
4762
|
-
title: `Switch to ${
|
|
4773
|
+
"aria-label": `Switch to ${resolvedMode === "light" ? "dark" : "light"} mode`,
|
|
4774
|
+
title: `Switch to ${resolvedMode === "light" ? "dark" : "light"} mode`,
|
|
4763
4775
|
...props,
|
|
4764
4776
|
children: renderIcon()
|
|
4765
4777
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -4671,40 +4671,50 @@ var MoonIcon = () => /* @__PURE__ */ jsx3(
|
|
|
4671
4671
|
children: /* @__PURE__ */ jsx3("path", { d: "m12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" })
|
|
4672
4672
|
}
|
|
4673
4673
|
);
|
|
4674
|
+
var SystemIcon = () => /* @__PURE__ */ jsxs2(
|
|
4675
|
+
"svg",
|
|
4676
|
+
{
|
|
4677
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4678
|
+
width: "16",
|
|
4679
|
+
height: "16",
|
|
4680
|
+
viewBox: "0 0 24 24",
|
|
4681
|
+
fill: "none",
|
|
4682
|
+
stroke: "currentColor",
|
|
4683
|
+
strokeWidth: "2",
|
|
4684
|
+
strokeLinecap: "round",
|
|
4685
|
+
strokeLinejoin: "round",
|
|
4686
|
+
className: "theme-toggle-icon",
|
|
4687
|
+
children: [
|
|
4688
|
+
/* @__PURE__ */ jsx3("rect", { width: "20", height: "14", x: "2", y: "3", rx: "2" }),
|
|
4689
|
+
/* @__PURE__ */ jsx3("line", { x1: "8", x2: "16", y1: "21", y2: "21" }),
|
|
4690
|
+
/* @__PURE__ */ jsx3("line", { x1: "12", x2: "12", y1: "17", y2: "21" })
|
|
4691
|
+
]
|
|
4692
|
+
}
|
|
4693
|
+
);
|
|
4674
4694
|
var ThemeToggle = forwardRef(
|
|
4675
4695
|
({ className, size = "md", variant = "default", children, ...props }, ref) => {
|
|
4676
4696
|
const { mode, resolvedMode, toggleMode } = useTheme();
|
|
4677
|
-
const nextResolvedMode = resolvedMode === "light" ? "dark" : "light";
|
|
4678
4697
|
const handleClick = (event) => {
|
|
4679
4698
|
const { clientX: x, clientY: y } = event;
|
|
4680
4699
|
toggleMode({ x, y });
|
|
4681
4700
|
};
|
|
4682
|
-
const sizeClasses = {
|
|
4683
|
-
sm: "h-8 w-8 p-1.5",
|
|
4684
|
-
md: "h-9 w-9 p-2",
|
|
4685
|
-
lg: "h-10 w-10 p-2.5"
|
|
4686
|
-
};
|
|
4687
|
-
const variantClasses = {
|
|
4688
|
-
default: "bg-background border border-input hover:bg-accent hover:text-accent-foreground",
|
|
4689
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
4690
|
-
ghost: "hover:bg-accent hover:text-accent-foreground"
|
|
4691
|
-
};
|
|
4692
4701
|
const baseClasses = clsx(
|
|
4693
4702
|
// Base button styles
|
|
4694
4703
|
"theme-toggle",
|
|
4695
|
-
"inline-flex items-center justify-center",
|
|
4696
|
-
"rounded-md text-sm font-medium",
|
|
4697
|
-
"ring-offset-background transition-colors",
|
|
4698
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
4699
|
-
"disabled:pointer-events-none disabled:opacity-50",
|
|
4700
|
-
// Size and variant
|
|
4701
|
-
sizeClasses[size],
|
|
4702
|
-
variantClasses[variant],
|
|
4703
4704
|
className
|
|
4704
4705
|
);
|
|
4705
4706
|
const renderIcon = () => {
|
|
4706
4707
|
if (children) return children;
|
|
4707
|
-
|
|
4708
|
+
switch (mode) {
|
|
4709
|
+
case "light":
|
|
4710
|
+
return /* @__PURE__ */ jsx3(SunIcon, {});
|
|
4711
|
+
case "dark":
|
|
4712
|
+
return /* @__PURE__ */ jsx3(MoonIcon, {});
|
|
4713
|
+
case "system":
|
|
4714
|
+
return /* @__PURE__ */ jsx3(SystemIcon, {});
|
|
4715
|
+
default:
|
|
4716
|
+
return resolvedMode === "dark" ? /* @__PURE__ */ jsx3(MoonIcon, {}) : /* @__PURE__ */ jsx3(SunIcon, {});
|
|
4717
|
+
}
|
|
4708
4718
|
};
|
|
4709
4719
|
return /* @__PURE__ */ jsx3(
|
|
4710
4720
|
"button",
|
|
@@ -4712,10 +4722,12 @@ var ThemeToggle = forwardRef(
|
|
|
4712
4722
|
ref,
|
|
4713
4723
|
className: baseClasses,
|
|
4714
4724
|
onClick: handleClick,
|
|
4715
|
-
"data-
|
|
4725
|
+
"data-size": size,
|
|
4726
|
+
"data-variant": variant,
|
|
4727
|
+
"data-mode": resolvedMode,
|
|
4716
4728
|
"data-theme": resolvedMode,
|
|
4717
|
-
"aria-label": `Switch to ${
|
|
4718
|
-
title: `Switch to ${
|
|
4729
|
+
"aria-label": `Switch to ${resolvedMode === "light" ? "dark" : "light"} mode`,
|
|
4730
|
+
title: `Switch to ${resolvedMode === "light" ? "dark" : "light"} mode`,
|
|
4719
4731
|
...props,
|
|
4720
4732
|
children: renderIcon()
|
|
4721
4733
|
}
|
|
@@ -8,6 +8,44 @@
|
|
|
8
8
|
border: 1px solid hsl(var(--border));
|
|
9
9
|
background-color: hsl(var(--background));
|
|
10
10
|
color: hsl(var(--foreground));
|
|
11
|
+
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
border-radius: calc(var(--radius) + 0.125rem);
|
|
17
|
+
font-size: 0.875rem;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
line-height: 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.theme-toggle:disabled {
|
|
23
|
+
opacity: 0.5;
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.theme-toggle[data-size="sm"] {
|
|
29
|
+
width: 2rem;
|
|
30
|
+
height: 2rem;
|
|
31
|
+
padding: 0.375rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.theme-toggle[data-size="md"] {
|
|
35
|
+
width: 2.25rem;
|
|
36
|
+
height: 2.25rem;
|
|
37
|
+
padding: 0.5rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.theme-toggle[data-size="lg"] {
|
|
41
|
+
width: 2.5rem;
|
|
42
|
+
height: 2.5rem;
|
|
43
|
+
padding: 0.625rem;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.theme-toggle[data-variant="ghost"] {
|
|
47
|
+
border-color: transparent;
|
|
48
|
+
background-color: transparent;
|
|
11
49
|
}
|
|
12
50
|
|
|
13
51
|
.theme-toggle:hover {
|
|
@@ -31,14 +69,6 @@
|
|
|
31
69
|
color: hsl(var(--foreground));
|
|
32
70
|
}
|
|
33
71
|
|
|
34
|
-
.theme-toggle[data-theme="light"] .theme-toggle-icon {
|
|
35
|
-
rotate: 180deg;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.theme-toggle[data-theme="dark"] .theme-toggle-icon {
|
|
39
|
-
rotate: 0deg;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
72
|
/* ThemePresetButtons: lightweight CSS-based animations and hover affordances */
|
|
43
73
|
|
|
44
74
|
/* ThemePresetButtons: base button styling (no Tailwind required) */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fakhrirafiki/theme-engine",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.19",
|
|
4
4
|
"description": "Elegant theming system with smooth transitions, custom presets, semantic accent colors, and complete shadcn/ui support for modern React applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|