@4alldigital/foundation-ui--core 3.14.0 → 3.15.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4alldigital/foundation-ui--core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "Foundation UI Core Component Library (source distribution)",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/he": "^1.2.3"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "7c02101d1542e447b86540d31d4846384b407774"
|
|
42
42
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useThemeContext } from "../../context/Theme";
|
|
5
|
+
|
|
6
|
+
export interface DarkModeToggleProps {
|
|
7
|
+
variant?: "icon" | "label" | "full";
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const SunIcon = () => (
|
|
12
|
+
<>
|
|
13
|
+
<circle cx="12" cy="12" r="5" />
|
|
14
|
+
<path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" />
|
|
15
|
+
</>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const MoonIcon = () => <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z" />;
|
|
19
|
+
|
|
20
|
+
const DarkModeToggle: React.FC<DarkModeToggleProps> = ({ variant = "full", className }) => {
|
|
21
|
+
const { isDarkTheme, toggleTheme } = useThemeContext();
|
|
22
|
+
|
|
23
|
+
const label = isDarkTheme ? "Light Mode" : "Dark Mode";
|
|
24
|
+
|
|
25
|
+
if (variant === "icon") {
|
|
26
|
+
return (
|
|
27
|
+
<button
|
|
28
|
+
onClick={toggleTheme}
|
|
29
|
+
aria-label={isDarkTheme ? "Switch to light mode" : "Switch to dark mode"}
|
|
30
|
+
className={className || "p-2 rounded-lg transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.06]"}
|
|
31
|
+
>
|
|
32
|
+
<svg className="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
|
|
33
|
+
{isDarkTheme ? <SunIcon /> : <MoonIcon />}
|
|
34
|
+
</svg>
|
|
35
|
+
</button>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (variant === "label") {
|
|
40
|
+
return (
|
|
41
|
+
<button
|
|
42
|
+
onClick={toggleTheme}
|
|
43
|
+
aria-label={isDarkTheme ? "Switch to light mode" : "Switch to dark mode"}
|
|
44
|
+
className={className || "text-[0.85rem] font-medium transition-colors hover:opacity-80"}
|
|
45
|
+
>
|
|
46
|
+
{label}
|
|
47
|
+
</button>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<button
|
|
53
|
+
onClick={toggleTheme}
|
|
54
|
+
aria-label={isDarkTheme ? "Switch to light mode" : "Switch to dark mode"}
|
|
55
|
+
className={
|
|
56
|
+
className ||
|
|
57
|
+
"flex w-full items-center justify-between rounded-xl px-3 py-2.5 text-[0.85rem] font-medium transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.06]"
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
<span>{label}</span>
|
|
61
|
+
<svg className="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
|
|
62
|
+
{isDarkTheme ? <SunIcon /> : <MoonIcon />}
|
|
63
|
+
</svg>
|
|
64
|
+
</button>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default DarkModeToggle;
|
|
@@ -94,13 +94,6 @@ const Header = ({
|
|
|
94
94
|
</div>
|
|
95
95
|
{/* <!-- tablet/desktop --> */}
|
|
96
96
|
<div className="hidden md:flex items-center justify-center gap-2">
|
|
97
|
-
{theme?.toggleTheme && (
|
|
98
|
-
<Button
|
|
99
|
-
onClick={theme.toggleTheme}
|
|
100
|
-
icon={theme.isDarkTheme ? 'mdi:weather-sunny' : 'mdi:weather-night'}
|
|
101
|
-
ariaLabel={theme.isDarkTheme ? 'Switch to light mode' : 'Switch to dark mode'}
|
|
102
|
-
/>
|
|
103
|
-
)}
|
|
104
97
|
{!context?.app?.isAuthenticated && context?.app?.loginCallback && (
|
|
105
98
|
<div className="w-32 flex justify-end">
|
|
106
99
|
<Button rounded onClick={context?.app?.loginCallback}>{T.UI.LOGIN}</Button>
|
|
@@ -196,22 +189,6 @@ const Header = ({
|
|
|
196
189
|
|
|
197
190
|
{/* Footer */}
|
|
198
191
|
<div className="px-5 py-5 border-t border-black/[0.06] dark:border-white/[0.08]">
|
|
199
|
-
{/* Dark mode toggle */}
|
|
200
|
-
{theme?.toggleTheme && (
|
|
201
|
-
<button
|
|
202
|
-
onClick={theme.toggleTheme}
|
|
203
|
-
className="flex w-full items-center justify-between rounded-xl px-3 py-2.5 mb-3 text-[0.85rem] font-medium text-body-text/70 dark:text-body-text-dark/70 transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.06]"
|
|
204
|
-
>
|
|
205
|
-
<span>{theme.isDarkTheme ? 'Light Mode' : 'Dark Mode'}</span>
|
|
206
|
-
<svg className="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
|
|
207
|
-
{theme.isDarkTheme ? (
|
|
208
|
-
<><circle cx="12" cy="12" r="5" /><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" /></>
|
|
209
|
-
) : (
|
|
210
|
-
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z" />
|
|
211
|
-
)}
|
|
212
|
-
</svg>
|
|
213
|
-
</button>
|
|
214
|
-
)}
|
|
215
192
|
{/* Auth action */}
|
|
216
193
|
{context?.app?.isAuthenticated ? (
|
|
217
194
|
<button
|
package/src/components/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { default as Chip } from './Chip';
|
|
|
10
10
|
export { default as Calendar } from './Calendar';
|
|
11
11
|
export { default as Collapsible } from './Collapsible';
|
|
12
12
|
export { default as Copy } from './Copy';
|
|
13
|
+
export { default as DarkModeToggle } from './DarkModeToggle';
|
|
13
14
|
export { default as FileUpload } from './FileUpload';
|
|
14
15
|
export { default as Heading } from './Heading';
|
|
15
16
|
export { default as Hr } from './Hr';
|