uni-theme-select 1.0.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.
@@ -0,0 +1,12 @@
1
+ declare function setTheme(name: string): void;
2
+ declare function getAvailableThemes(): string[];
3
+ declare function loadSavedTheme(): void;
4
+
5
+ type Theme = {
6
+ name: string;
7
+ properties: Record<string, string>;
8
+ };
9
+
10
+ declare const themes: Theme[];
11
+
12
+ export { type Theme, getAvailableThemes, loadSavedTheme, setTheme, themes };
@@ -0,0 +1,12 @@
1
+ declare function setTheme(name: string): void;
2
+ declare function getAvailableThemes(): string[];
3
+ declare function loadSavedTheme(): void;
4
+
5
+ type Theme = {
6
+ name: string;
7
+ properties: Record<string, string>;
8
+ };
9
+
10
+ declare const themes: Theme[];
11
+
12
+ export { type Theme, getAvailableThemes, loadSavedTheme, setTheme, themes };
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ getAvailableThemes: () => getAvailableThemes,
23
+ loadSavedTheme: () => loadSavedTheme,
24
+ setTheme: () => setTheme,
25
+ themes: () => themes
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/themes.ts
30
+ var themes = [
31
+ {
32
+ name: "light",
33
+ properties: {
34
+ "bg-color": "#ffffff",
35
+ "text-color": "#000000",
36
+ "primary-color": "#2563eb"
37
+ }
38
+ },
39
+ {
40
+ name: "dark",
41
+ properties: {
42
+ "bg-color": "#000000",
43
+ "text-color": "#ffffff",
44
+ "primary-color": "#60a5fa"
45
+ }
46
+ },
47
+ {
48
+ name: "beige",
49
+ properties: {
50
+ "bg-color": "#f5f5dc",
51
+ "text-color": "#333333",
52
+ "primary-color": "#c19a6b"
53
+ }
54
+ }
55
+ ];
56
+
57
+ // src/themeManager.ts
58
+ function setTheme(name) {
59
+ const theme = themes.find((t) => t.name === name);
60
+ if (!theme) {
61
+ console.warn(`Theme "${name}" not found`);
62
+ return;
63
+ }
64
+ const root = document.documentElement;
65
+ Object.entries(theme.properties).forEach(([key, value]) => {
66
+ root.style.setProperty(`--${key}`, value);
67
+ });
68
+ localStorage.setItem("uts-theme", name);
69
+ }
70
+ function getAvailableThemes() {
71
+ return themes.map((t) => t.name);
72
+ }
73
+ function loadSavedTheme() {
74
+ const saved = localStorage.getItem("uts-theme");
75
+ if (saved) {
76
+ setTheme(saved);
77
+ }
78
+ }
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ getAvailableThemes,
82
+ loadSavedTheme,
83
+ setTheme,
84
+ themes
85
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,56 @@
1
+ // src/themes.ts
2
+ var themes = [
3
+ {
4
+ name: "light",
5
+ properties: {
6
+ "bg-color": "#ffffff",
7
+ "text-color": "#000000",
8
+ "primary-color": "#2563eb"
9
+ }
10
+ },
11
+ {
12
+ name: "dark",
13
+ properties: {
14
+ "bg-color": "#000000",
15
+ "text-color": "#ffffff",
16
+ "primary-color": "#60a5fa"
17
+ }
18
+ },
19
+ {
20
+ name: "beige",
21
+ properties: {
22
+ "bg-color": "#f5f5dc",
23
+ "text-color": "#333333",
24
+ "primary-color": "#c19a6b"
25
+ }
26
+ }
27
+ ];
28
+
29
+ // src/themeManager.ts
30
+ function setTheme(name) {
31
+ const theme = themes.find((t) => t.name === name);
32
+ if (!theme) {
33
+ console.warn(`Theme "${name}" not found`);
34
+ return;
35
+ }
36
+ const root = document.documentElement;
37
+ Object.entries(theme.properties).forEach(([key, value]) => {
38
+ root.style.setProperty(`--${key}`, value);
39
+ });
40
+ localStorage.setItem("uts-theme", name);
41
+ }
42
+ function getAvailableThemes() {
43
+ return themes.map((t) => t.name);
44
+ }
45
+ function loadSavedTheme() {
46
+ const saved = localStorage.getItem("uts-theme");
47
+ if (saved) {
48
+ setTheme(saved);
49
+ }
50
+ }
51
+ export {
52
+ getAvailableThemes,
53
+ loadSavedTheme,
54
+ setTheme,
55
+ themes
56
+ };
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "uni-theme-select",
3
+ "version": "1.0.0",
4
+ "description": "Framework-agnostic theme switcher",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "files": ["dist"],
9
+ "scripts": {
10
+ "build": "tsup src/index.ts --format cjs,esm --dts",
11
+ "dev": "tsup src/index.ts --format cjs,esm --watch --dts"
12
+ },
13
+ "keywords": ["theme", "dark-mode", "css-variables"],
14
+ "author": "sri_manohari",
15
+ "license": "ISC",
16
+ "devDependencies": {
17
+ "tsup": "^8.5.1",
18
+ "typescript": "^5.9.3"
19
+ }
20
+ }