@korioinc/next-core 2.0.18 → 2.0.20
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/theme-switcher/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/theme-switcher/index.tsx"],"names":[],"mappings":"AAkBA,QAAA,MAAM,aAAa,+CA4FlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -2,19 +2,30 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useTheme } from 'next-themes';
|
|
5
|
+
const THEME_ORDER = ['system', 'light', 'dark'];
|
|
6
|
+
const normalizeTheme = (value) => {
|
|
7
|
+
if (value === 'light' || value === 'dark' || value === 'system') {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
return 'system';
|
|
11
|
+
};
|
|
5
12
|
const ThemeSwitcher = () => {
|
|
6
|
-
const { theme, setTheme } = useTheme();
|
|
13
|
+
const { theme, resolvedTheme, setTheme } = useTheme();
|
|
7
14
|
const [mounted, setMounted] = React.useState(false);
|
|
8
15
|
React.useEffect(() => {
|
|
9
16
|
setMounted(true);
|
|
10
17
|
}, []);
|
|
11
|
-
|
|
18
|
+
const currentTheme = normalizeTheme(theme);
|
|
19
|
+
const resolvedThemeLabel = resolvedTheme === 'dark' ? 'Dark' : 'Light';
|
|
20
|
+
const currentThemeLabel = currentTheme === 'system' ? `System (${resolvedThemeLabel})` : currentTheme === 'dark' ? 'Dark' : 'Light';
|
|
12
21
|
const toggleTheme = () => {
|
|
13
|
-
|
|
22
|
+
const currentIndex = THEME_ORDER.indexOf(currentTheme);
|
|
23
|
+
const nextTheme = THEME_ORDER[(currentIndex + 1) % THEME_ORDER.length];
|
|
24
|
+
setTheme(nextTheme);
|
|
14
25
|
};
|
|
15
26
|
if (!mounted) {
|
|
16
27
|
return (_jsx("button", { className: 'border-glass-strong bg-glass relative inline-flex h-9 w-9 items-center justify-center rounded-md border opacity-0', "aria-hidden": 'true', children: _jsx("div", { className: 'h-5 w-5' }) }));
|
|
17
28
|
}
|
|
18
|
-
return (_jsxs("button", { onClick: toggleTheme, className: 'border-glass-strong bg-glass hover:bg-glass-tinted relative inline-flex h-9 w-9 items-center justify-center rounded-md border transition-colors', "aria-label": `Switch theme (current: ${
|
|
29
|
+
return (_jsxs("button", { onClick: toggleTheme, className: 'border-glass-strong bg-glass hover:bg-glass-tinted relative inline-flex h-9 w-9 items-center justify-center rounded-md border transition-colors', "aria-label": `Switch theme (current: ${currentThemeLabel})`, title: `Theme: ${currentThemeLabel} (click to change)`, children: [_jsxs("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', className: `absolute h-5 w-5 transition-all ${currentTheme === 'light' ? 'scale-100 rotate-0 opacity-100' : 'scale-0 rotate-90 opacity-0'}`, children: [_jsx("circle", { cx: '12', cy: '12', r: '5' }), _jsx("line", { x1: '12', y1: '1', x2: '12', y2: '3' }), _jsx("line", { x1: '12', y1: '21', x2: '12', y2: '23' }), _jsx("line", { x1: '4.22', y1: '4.22', x2: '5.64', y2: '5.64' }), _jsx("line", { x1: '18.36', y1: '18.36', x2: '19.78', y2: '19.78' }), _jsx("line", { x1: '1', y1: '12', x2: '3', y2: '12' }), _jsx("line", { x1: '21', y1: '12', x2: '23', y2: '12' }), _jsx("line", { x1: '4.22', y1: '19.78', x2: '5.64', y2: '18.36' }), _jsx("line", { x1: '18.36', y1: '5.64', x2: '19.78', y2: '4.22' })] }), _jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', className: `absolute h-5 w-5 transition-all ${currentTheme === 'dark' ? 'scale-100 rotate-0 opacity-100' : 'scale-0 -rotate-90 opacity-0'}`, children: _jsx("path", { d: 'M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z' }) }), _jsxs("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', className: `absolute h-5 w-5 transition-all ${currentTheme === 'system' ? 'scale-100 rotate-0 opacity-100' : 'scale-0 rotate-90 opacity-0'}`, children: [_jsx("rect", { x: '3', y: '4', width: '18', height: '12', rx: '2' }), _jsx("line", { x1: '8', y1: '20', x2: '16', y2: '20' }), _jsx("line", { x1: '12', y1: '16', x2: '12', y2: '20' })] })] }));
|
|
19
30
|
};
|
|
20
31
|
export default ThemeSwitcher;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korioinc/next-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./ads": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"tsc-alias": "^1.8.16",
|
|
80
80
|
"tw-animate-css": "^1.4.0",
|
|
81
81
|
"typescript": "^5.9.3",
|
|
82
|
-
"@korioinc/next-configs": "2.0.
|
|
82
|
+
"@korioinc/next-configs": "2.0.20"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@floating-ui/react": "^0.27.17",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"schema-dts": "^1.1.5",
|
|
95
95
|
"tailwind-merge": "^3.4.0",
|
|
96
96
|
"valtio": "^2.3.0",
|
|
97
|
-
"@korioinc/next-conf": "2.0.
|
|
97
|
+
"@korioinc/next-conf": "2.0.20"
|
|
98
98
|
},
|
|
99
99
|
"publishConfig": {
|
|
100
100
|
"access": "public",
|