@feraxjs/thselector 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.
- package/LICENSE +9 -0
- package/README.md +64 -0
- package/dist/dropdown.min.js +2 -0
- package/dist/dropdown.min.js.map +1 -0
- package/dist/index.cjs +140 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +146 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/index.mjs +135 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 feraxhp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# thselector
|
|
2
|
+
[](https://github.com/feraxjs/thselector/actions/workflows/pages/pages-build-deployment)
|
|
3
|
+
|
|
4
|
+
The simplest way to add theme management to your HTML. Easy to configure and set up.
|
|
5
|
+
|
|
6
|
+
I think that the purpose of the web is to be simple. I am tired of complicated things to achieve simple use cases, and for that reason I developed this simple theme selector. With no more than 1 line of code, you will be able to add simple (light, dark, system) control theme for your web, and 3 more to add custom themes and a component to manage user input.
|
|
7
|
+
|
|
8
|
+
Are you migrating? see: [migration](#migration).
|
|
9
|
+
|
|
10
|
+
## Documentation
|
|
11
|
+
_thselector_ uses the `prefers-color-scheme` and _css trics_ to be as simple as posible.
|
|
12
|
+
|
|
13
|
+
### Core
|
|
14
|
+
~~~html
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/gh/feraxjs/thselector@v0.1.0/src/core.js"></script> <!-- 1' -->
|
|
16
|
+
~~~
|
|
17
|
+
|
|
18
|
+
The _core_ is the most important part. wich manages the system-theme, and user prefered theme. The _core_ also provides some functionality through the `window.th` object and a custom _event_ named _`th-changed`_, wich dispatches every time the theme changes.
|
|
19
|
+
|
|
20
|
+
#### th-change envent
|
|
21
|
+
this event provides 2 variables through `event.detail`:
|
|
22
|
+
1. `theme`: the current theme ("dark", "light")
|
|
23
|
+
2. `isSistem`: If the theme is manage by the system or is fixed by the user.
|
|
24
|
+
|
|
25
|
+
### window.th objetc
|
|
26
|
+
- verbose: controls when to show logs or not [default to false]
|
|
27
|
+
- themes: list of the posible values for the theme
|
|
28
|
+
- setTheme: function to change the theme
|
|
29
|
+
- init: to instanciate the listeners
|
|
30
|
+
- remove: to remove the listeners
|
|
31
|
+
|
|
32
|
+
## Components
|
|
33
|
+
The library also provides some simple components to manage the theme selection by the user, and changes between: system, ligth and dark.
|
|
34
|
+
|
|
35
|
+
### dropdown
|
|
36
|
+
~~~html
|
|
37
|
+
<script src="https://cdn.jsdelivr.net/gh/feraxjs/thselector@v0.1.0/src/components/dropdown.js" defer></script>
|
|
38
|
+
~~~
|
|
39
|
+
|
|
40
|
+
## Wroking with CSS
|
|
41
|
+
In css you have to declare 2 color schemes, one for light and one for dark.
|
|
42
|
+
the library will declare in the root the current selected text by adding the
|
|
43
|
+
attribute _`theme`_.
|
|
44
|
+
|
|
45
|
+
Aditionally, the meta tag colorscheme also is declared to automaticly change the
|
|
46
|
+
default css of the document.
|
|
47
|
+
|
|
48
|
+
for a better example see: [feraxjs/themes](https://github.com/feraxjs/themes).
|
|
49
|
+
|
|
50
|
+
## Migration
|
|
51
|
+
the internal state is compleate the same as feraxhp/theselector, but con file names chage.
|
|
52
|
+
There fore, the migration will be as easy as changing the file name in the html
|
|
53
|
+
|
|
54
|
+
- `load-theme.js` >> `src/core.js`
|
|
55
|
+
- `select-theme.js` >> `src/components/dropdown.js`
|
|
56
|
+
|
|
57
|
+
### CSS
|
|
58
|
+
now instead of 1 css file with latte-{other}.css file to import the css. you have to
|
|
59
|
+
import 2 css. One for the ligth theme and One for the dark theme.
|
|
60
|
+
|
|
61
|
+
> [!note]
|
|
62
|
+
> The themes can be found in [feraxjs/themes](https://github.com/feraxjs/themes).
|
|
63
|
+
|
|
64
|
+
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";const e=document.getElementById("fth-select");if(e){const t={light:{id:"fth-olight",text:"Light",value:"light"},dark:{id:"fth-odark",text:"Dark",value:"dark"},system:{id:"fth-osystem",text:"System",value:"system"}};function n(t,n){let d=document.getElementById(n.id);return d||(d=document.createElement("option"),d.id=n.id,d.value=n.value,d.textContent=n.text,e.appendChild(d)),d}const d=Object.values(t).map(e=>n(e.value,e));function i(e){const t=d.find(t=>t.value===e);t&&(t.selected=!0)}i(localStorage.getItem("[fx-theme]")??"system"),e.addEventListener("change",e=>{const t=e.target.value;window.th.setTheme(t)}),document.addEventListener("th-changed",e=>{e.detail.isSistem?i(t.system):i(e.detail.theme)})}});
|
|
2
|
+
//# sourceMappingURL=dropdown.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.min.js","sources":["../src/components/dropdown.js"],"sourcesContent":["const selector = document.getElementById(\"fth-select\");\n\nif (selector) {\n const OPTIONS = {\n light: { id: 'fth-olight', text: 'Light', value: 'light' },\n dark: { id: 'fth-odark', text: 'Dark', value: 'dark' },\n system: { id: 'fth-osystem', text: 'System', value: 'system' }\n };\n\n function createOrUpdateOption(theme, config) {\n let option = document.getElementById(config.id);\n\n if (!option) {\n option = document.createElement(\"option\");\n option.id = config.id;\n option.value = config.value; // Usa el valor definido en OPTIONS\n option.textContent = config.text;\n selector.appendChild(option);\n }\n return option;\n }\n\n const options = Object.values(OPTIONS).map(config => createOrUpdateOption(config.value, config));\n\n\n function setSelectedOption(theme) {\n const optionToSelect = options.find(option => option.value === theme);\n if (optionToSelect) {\n optionToSelect.selected = true;\n }\n }\n\n const currentTheme = localStorage.getItem('[fx-theme]') ?? 'system';\n setSelectedOption(currentTheme);\n\n selector.addEventListener(\"change\", (event) => {\n const newTheme = event.target.value;\n window.th.setTheme(newTheme);\n });\n\n document.addEventListener('th-changed', (event) => {\n if (event.detail.isSistem) setSelectedOption(OPTIONS.system);\n else setSelectedOption(event.detail.theme);\n });\n}"],"names":["selector","document","getElementById","OPTIONS","light","id","text","value","dark","system","createOrUpdateOption","theme","config","option","createElement","textContent","appendChild","options","Object","values","map","setSelectedOption","optionToSelect","find","selected","localStorage","getItem","addEventListener","event","newTheme","target","window","th","setTheme","detail","isSistem"],"mappings":"0FAAA,MAAMA,EAAWC,SAASC,eAAe,cAEzC,GAAIF,EAAU,CACV,MAAMG,EAAU,CACZC,MAAO,CAAEC,GAAI,aAAcC,KAAM,QAASC,MAAO,SACjDC,KAAM,CAAEH,GAAI,YAAaC,KAAM,OAAQC,MAAO,QAC9CE,OAAQ,CAAEJ,GAAI,cAAeC,KAAM,SAAUC,MAAO,WAGxD,SAASG,EAAqBC,EAAOC,GACjC,IAAIC,EAASZ,SAASC,eAAeU,EAAOP,IAS5C,OAPKQ,IACDA,EAASZ,SAASa,cAAc,UAChCD,EAAOR,GAAKO,EAAOP,GACnBQ,EAAON,MAAQK,EAAOL,MACtBM,EAAOE,YAAcH,EAAON,KAC5BN,EAASgB,YAAYH,IAElBA,CACV,CAED,MAAMI,EAAUC,OAAOC,OAAOhB,GAASiB,IAAIR,GAAUF,EAAqBE,EAAOL,MAAOK,IAGxF,SAASS,EAAkBV,GACvB,MAAMW,EAAiBL,EAAQM,KAAKV,GAAUA,EAAON,QAAUI,GAC3DW,IACAA,EAAeE,UAAW,EAEjC,CAGDH,EADqBI,aAAaC,QAAQ,eAAiB,UAG3D1B,EAAS2B,iBAAiB,SAAWC,IACjC,MAAMC,EAAWD,EAAME,OAAOvB,MAC9BwB,OAAOC,GAAGC,SAASJ,KAGvB5B,SAAS0B,iBAAiB,aAAeC,IACjCA,EAAMM,OAAOC,SAAUd,EAAkBlB,EAAQM,QAChDY,EAAkBO,EAAMM,OAAOvB,QAE5C"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const THEME_STORAGE_KEY = '[fx-theme]';
|
|
6
|
+
const META_ID = 'fth-meta';
|
|
7
|
+
|
|
8
|
+
window.th = {
|
|
9
|
+
verbose: false,
|
|
10
|
+
themes: Object.freeze({
|
|
11
|
+
light: 'light',
|
|
12
|
+
dark: 'dark',
|
|
13
|
+
system: 'dark light'
|
|
14
|
+
}),
|
|
15
|
+
|
|
16
|
+
setMetaTag(content) {
|
|
17
|
+
let meta = document.getElementById(META_ID);
|
|
18
|
+
if (!meta) {
|
|
19
|
+
meta = document.createElement('meta');
|
|
20
|
+
meta.id = META_ID;
|
|
21
|
+
meta.name = 'color-scheme';
|
|
22
|
+
document.head.appendChild(meta);
|
|
23
|
+
}
|
|
24
|
+
meta.content = content;
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
getSystemTheme() {
|
|
28
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
29
|
+
? 'dark'
|
|
30
|
+
: 'light';
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
setTheme(theme) {
|
|
34
|
+
if (!(theme in this.themes)) {
|
|
35
|
+
console.warn(`Invalid theme: ${theme}. Falling back to system theme.`);
|
|
36
|
+
theme = 'system';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.setMetaTag(this.themes[theme] || this.themes.system);
|
|
40
|
+
|
|
41
|
+
const finalTheme = theme === 'system' ? this.getSystemTheme() : theme;
|
|
42
|
+
|
|
43
|
+
document.documentElement.setAttribute('theme', finalTheme);
|
|
44
|
+
|
|
45
|
+
try { localStorage.setItem(THEME_STORAGE_KEY, theme); }
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (this.verbose) console.debug("Error saving the theme:", e);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.dispatchThemeChangeEvent(finalTheme, theme === 'system');
|
|
51
|
+
|
|
52
|
+
return finalTheme;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
dispatchThemeChangeEvent(theme, isSistem) {
|
|
56
|
+
const event = new CustomEvent('th-changed', { detail: { theme, isSistem } });
|
|
57
|
+
document.dispatchEvent(event);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
init() {
|
|
61
|
+
try {
|
|
62
|
+
const savedTheme = localStorage.getItem(THEME_STORAGE_KEY) ?? 'system';
|
|
63
|
+
this.setTheme(savedTheme);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (this.verbose) console.debug('Error loading theme:', error);
|
|
66
|
+
this.setTheme('system');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!('matchMedia' in window)) {
|
|
70
|
+
if (this.verbose) console.debug("The 'matchMedia' parameter is not present");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const listener = () => {
|
|
74
|
+
const currentTheme = localStorage.getItem(THEME_STORAGE_KEY);
|
|
75
|
+
if (currentTheme === 'system') { this.setTheme('system'); }
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener);
|
|
79
|
+
|
|
80
|
+
return () => {
|
|
81
|
+
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
window.th.remove = window.th.init();
|
|
87
|
+
|
|
88
|
+
const th = window.th;
|
|
89
|
+
|
|
90
|
+
function init_dropdown() {
|
|
91
|
+
const selector = document.getElementById("fth-select");
|
|
92
|
+
|
|
93
|
+
if (selector) {
|
|
94
|
+
const OPTIONS = {
|
|
95
|
+
light: { id: 'fth-olight', text: 'Light', value: 'light' },
|
|
96
|
+
dark: { id: 'fth-odark', text: 'Dark', value: 'dark' },
|
|
97
|
+
system: { id: 'fth-osystem', text: 'System', value: 'system' }
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
function createOrUpdateOption(theme, config) {
|
|
101
|
+
let option = document.getElementById(config.id);
|
|
102
|
+
|
|
103
|
+
if (!option) {
|
|
104
|
+
option = document.createElement("option");
|
|
105
|
+
option.id = config.id;
|
|
106
|
+
option.value = config.value; // Usa el valor definido en OPTIONS
|
|
107
|
+
option.textContent = config.text;
|
|
108
|
+
selector.appendChild(option);
|
|
109
|
+
}
|
|
110
|
+
return option;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const options = Object.values(OPTIONS).map(config => createOrUpdateOption(config.value, config));
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
function setSelectedOption(theme) {
|
|
117
|
+
const optionToSelect = options.find(option => option.value === theme);
|
|
118
|
+
if (optionToSelect) {
|
|
119
|
+
optionToSelect.selected = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const currentTheme = localStorage.getItem('[fx-theme]') ?? 'system';
|
|
124
|
+
setSelectedOption(currentTheme);
|
|
125
|
+
|
|
126
|
+
selector.addEventListener("change", (event) => {
|
|
127
|
+
const newTheme = event.target.value;
|
|
128
|
+
window.th.setTheme(newTheme);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
document.addEventListener('th-changed', (event) => {
|
|
132
|
+
if (event.detail.isSistem) setSelectedOption(OPTIONS.system);
|
|
133
|
+
else setSelectedOption(event.detail.theme);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
exports.init_dropdown = init_dropdown;
|
|
139
|
+
exports.th = th;
|
|
140
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/core.js","../src/index.js"],"sourcesContent":["const THEME_STORAGE_KEY = '[fx-theme]';\nconst META_ID = 'fth-meta';\n\nwindow.th = {\n verbose: false,\n themes: Object.freeze({\n light: 'light',\n dark: 'dark',\n system: 'dark light'\n }),\n\n setMetaTag(content) {\n let meta = document.getElementById(META_ID);\n if (!meta) {\n meta = document.createElement('meta');\n meta.id = META_ID;\n meta.name = 'color-scheme';\n document.head.appendChild(meta);\n }\n meta.content = content;\n },\n\n getSystemTheme() {\n return window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n },\n\n setTheme(theme) {\n if (!(theme in this.themes)) {\n console.warn(`Invalid theme: ${theme}. Falling back to system theme.`);\n theme = 'system';\n }\n \n this.setMetaTag(this.themes[theme] || this.themes.system);\n \n const finalTheme = theme === 'system' ? this.getSystemTheme() : theme;\n \n document.documentElement.setAttribute('theme', finalTheme);\n \n try { localStorage.setItem(THEME_STORAGE_KEY, theme); }\n catch (e) { \n if (this.verbose) console.debug(\"Error saving the theme:\", e)\n }\n \n this.dispatchThemeChangeEvent(finalTheme, theme === 'system');\n \n return finalTheme;\n },\n \n dispatchThemeChangeEvent(theme, isSistem) {\n const event = new CustomEvent('th-changed', { detail: { theme, isSistem } });\n document.dispatchEvent(event);\n },\n \n init() {\n try {\n const savedTheme = localStorage.getItem(THEME_STORAGE_KEY) ?? 'system';\n this.setTheme(savedTheme);\n } catch (error) {\n if (this.verbose) console.debug('Error loading theme:', error);\n this.setTheme('system');\n }\n \n if (!('matchMedia' in window)) {\n if (this.verbose) console.debug(\"The 'matchMedia' parameter is not present\")\n }\n \n const listener = () => {\n const currentTheme = localStorage.getItem(THEME_STORAGE_KEY);\n if (currentTheme === 'system') { this.setTheme('system'); }\n }\n \n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener);\n \n return () => {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener);\n }\n }\n}\n\nwindow.th.remove = window.th.init();\n","import './core.js';\n\nexport const th = window.th;\n\nexport function init_dropdown() {\n// ./components/dropdown.js\n}\n"],"names":[],"mappings":";;;;AAAA,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,OAAO,GAAG,UAAU,CAAC;AAC3B;AACA,MAAM,CAAC,EAAE,GAAG;AACZ,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;AAC1B,QAAQ,KAAK,EAAE,OAAO;AACtB,QAAQ,IAAI,EAAE,MAAM;AACpB,QAAQ,MAAM,EAAE,YAAY;AAC5B,KAAK,CAAC;AACN;AACA,IAAI,UAAU,CAAC,OAAO,EAAE;AACxB,QAAQ,IAAI,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACpD,QAAQ,IAAI,CAAC,IAAI,EAAE;AACnB,YAAY,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAClD,YAAY,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC;AAC9B,YAAY,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;AACvC,YAAY,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC5C,SAAS;AACT,QAAQ,IAAI,CAAC,OAAO,GAAG,OAAO,C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,CAAA,CAAA,CAAA;AAAA;AAAA;AAAA,IAAA,SAAA,iBAAA,CAAA,KAAA,EAAA;AAAA,QAAA,MAAA,cAAA,GAAA,OAAA,CAAA,IAAA,CAAA,MAAA,IAAA,MAAA,CAAA,KAAA,KAAA,KAAA,CAAA,CAAA;AAAA,QAAA,IAAA,cAAA,EAAA;AAAA,YAAA,cAAA,CAAA,QAAA,GAAA,IAAA,CAAA;AAAA,SAAA;AAAA,KAAA;AAAA;AAAA,IAAA,MAAA,YAAA,GAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,IAAA,QAAA,CAAA;AAAA,IAAA,iBAAA,CAAA,YAAA,CAAA,CAAA;AAAA;AAAA,IAAA,QAAA,CAAA,gBAAA,CAAA,QAAA,EAAA,CAAA,KAAA,KAAA;AAAA,QAAA,MAAA,QAAA,GAAA,KAAA,CAAA,MAAA,CAAA,KAAA,CAAA;AAAA,QAAA,MAAA,CAAA,EAAA,CAAA,QAAA,CAAA,QAAA,CAAA,CAAA;AAAA,KAAA,CAAA,CAAA;AAAA;AAAA,IAAA,QAAA,CAAA,gBAAA,CAAA,YAAA,EAAA,CAAA,KAAA,KAAA;AAAA,QAAA,IAAA,KAAA,CAAA,MAAA,CAAA,QAAA,EAAA,iBAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA;AAAA,aAAA,iBAAA,CAAA,KAAA,CAAA,MAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KAAA,CAAA,CAAA;AAAA,CAAA;AACA;;;;;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.thselector = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const THEME_STORAGE_KEY = '[fx-theme]';
|
|
8
|
+
const META_ID = 'fth-meta';
|
|
9
|
+
|
|
10
|
+
window.th = {
|
|
11
|
+
verbose: false,
|
|
12
|
+
themes: Object.freeze({
|
|
13
|
+
light: 'light',
|
|
14
|
+
dark: 'dark',
|
|
15
|
+
system: 'dark light'
|
|
16
|
+
}),
|
|
17
|
+
|
|
18
|
+
setMetaTag(content) {
|
|
19
|
+
let meta = document.getElementById(META_ID);
|
|
20
|
+
if (!meta) {
|
|
21
|
+
meta = document.createElement('meta');
|
|
22
|
+
meta.id = META_ID;
|
|
23
|
+
meta.name = 'color-scheme';
|
|
24
|
+
document.head.appendChild(meta);
|
|
25
|
+
}
|
|
26
|
+
meta.content = content;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
getSystemTheme() {
|
|
30
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
31
|
+
? 'dark'
|
|
32
|
+
: 'light';
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
setTheme(theme) {
|
|
36
|
+
if (!(theme in this.themes)) {
|
|
37
|
+
console.warn(`Invalid theme: ${theme}. Falling back to system theme.`);
|
|
38
|
+
theme = 'system';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.setMetaTag(this.themes[theme] || this.themes.system);
|
|
42
|
+
|
|
43
|
+
const finalTheme = theme === 'system' ? this.getSystemTheme() : theme;
|
|
44
|
+
|
|
45
|
+
document.documentElement.setAttribute('theme', finalTheme);
|
|
46
|
+
|
|
47
|
+
try { localStorage.setItem(THEME_STORAGE_KEY, theme); }
|
|
48
|
+
catch (e) {
|
|
49
|
+
if (this.verbose) console.debug("Error saving the theme:", e);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.dispatchThemeChangeEvent(finalTheme, theme === 'system');
|
|
53
|
+
|
|
54
|
+
return finalTheme;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
dispatchThemeChangeEvent(theme, isSistem) {
|
|
58
|
+
const event = new CustomEvent('th-changed', { detail: { theme, isSistem } });
|
|
59
|
+
document.dispatchEvent(event);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
init() {
|
|
63
|
+
try {
|
|
64
|
+
const savedTheme = localStorage.getItem(THEME_STORAGE_KEY) ?? 'system';
|
|
65
|
+
this.setTheme(savedTheme);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (this.verbose) console.debug('Error loading theme:', error);
|
|
68
|
+
this.setTheme('system');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!('matchMedia' in window)) {
|
|
72
|
+
if (this.verbose) console.debug("The 'matchMedia' parameter is not present");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const listener = () => {
|
|
76
|
+
const currentTheme = localStorage.getItem(THEME_STORAGE_KEY);
|
|
77
|
+
if (currentTheme === 'system') { this.setTheme('system'); }
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener);
|
|
81
|
+
|
|
82
|
+
return () => {
|
|
83
|
+
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
window.th.remove = window.th.init();
|
|
89
|
+
|
|
90
|
+
const th = window.th;
|
|
91
|
+
|
|
92
|
+
function init_dropdown() {
|
|
93
|
+
const selector = document.getElementById("fth-select");
|
|
94
|
+
|
|
95
|
+
if (selector) {
|
|
96
|
+
const OPTIONS = {
|
|
97
|
+
light: { id: 'fth-olight', text: 'Light', value: 'light' },
|
|
98
|
+
dark: { id: 'fth-odark', text: 'Dark', value: 'dark' },
|
|
99
|
+
system: { id: 'fth-osystem', text: 'System', value: 'system' }
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function createOrUpdateOption(theme, config) {
|
|
103
|
+
let option = document.getElementById(config.id);
|
|
104
|
+
|
|
105
|
+
if (!option) {
|
|
106
|
+
option = document.createElement("option");
|
|
107
|
+
option.id = config.id;
|
|
108
|
+
option.value = config.value; // Usa el valor definido en OPTIONS
|
|
109
|
+
option.textContent = config.text;
|
|
110
|
+
selector.appendChild(option);
|
|
111
|
+
}
|
|
112
|
+
return option;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const options = Object.values(OPTIONS).map(config => createOrUpdateOption(config.value, config));
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
function setSelectedOption(theme) {
|
|
119
|
+
const optionToSelect = options.find(option => option.value === theme);
|
|
120
|
+
if (optionToSelect) {
|
|
121
|
+
optionToSelect.selected = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const currentTheme = localStorage.getItem('[fx-theme]') ?? 'system';
|
|
126
|
+
setSelectedOption(currentTheme);
|
|
127
|
+
|
|
128
|
+
selector.addEventListener("change", (event) => {
|
|
129
|
+
const newTheme = event.target.value;
|
|
130
|
+
window.th.setTheme(newTheme);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
document.addEventListener('th-changed', (event) => {
|
|
134
|
+
if (event.detail.isSistem) setSelectedOption(OPTIONS.system);
|
|
135
|
+
else setSelectedOption(event.detail.theme);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
exports.init_dropdown = init_dropdown;
|
|
141
|
+
exports.th = th;
|
|
142
|
+
|
|
143
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
144
|
+
|
|
145
|
+
}));
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/core.js","../src/index.js"],"sourcesContent":["const THEME_STORAGE_KEY = '[fx-theme]';\nconst META_ID = 'fth-meta';\n\nwindow.th = {\n verbose: false,\n themes: Object.freeze({\n light: 'light',\n dark: 'dark',\n system: 'dark light'\n }),\n\n setMetaTag(content) {\n let meta = document.getElementById(META_ID);\n if (!meta) {\n meta = document.createElement('meta');\n meta.id = META_ID;\n meta.name = 'color-scheme';\n document.head.appendChild(meta);\n }\n meta.content = content;\n },\n\n getSystemTheme() {\n return window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n },\n\n setTheme(theme) {\n if (!(theme in this.themes)) {\n console.warn(`Invalid theme: ${theme}. Falling back to system theme.`);\n theme = 'system';\n }\n \n this.setMetaTag(this.themes[theme] || this.themes.system);\n \n const finalTheme = theme === 'system' ? this.getSystemTheme() : theme;\n \n document.documentElement.setAttribute('theme', finalTheme);\n \n try { localStorage.setItem(THEME_STORAGE_KEY, theme); }\n catch (e) { \n if (this.verbose) console.debug(\"Error saving the theme:\", e)\n }\n \n this.dispatchThemeChangeEvent(finalTheme, theme === 'system');\n \n return finalTheme;\n },\n \n dispatchThemeChangeEvent(theme, isSistem) {\n const event = new CustomEvent('th-changed', { detail: { theme, isSistem } });\n document.dispatchEvent(event);\n },\n \n init() {\n try {\n const savedTheme = localStorage.getItem(THEME_STORAGE_KEY) ?? 'system';\n this.setTheme(savedTheme);\n } catch (error) {\n if (this.verbose) console.debug('Error loading theme:', error);\n this.setTheme('system');\n }\n \n if (!('matchMedia' in window)) {\n if (this.verbose) console.debug(\"The 'matchMedia' parameter is not present\")\n }\n \n const listener = () => {\n const currentTheme = localStorage.getItem(THEME_STORAGE_KEY);\n if (currentTheme === 'system') { this.setTheme('system'); }\n }\n \n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener);\n \n return () => {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener);\n }\n }\n}\n\nwindow.th.remove = window.th.init();\n","import './core.js';\n\nexport const th = window.th;\n\nexport function init_dropdown() {\n// ./components/dropdown.js\n}\n"],"names":[],"mappings":";;;;;;IAAA,MAAM,iBAAiB,GAAG,YAAY,CAAC;IACvC,MAAM,OAAO,GAAG,UAAU,CAAC;AAC3B;IACA,MAAM,CAAC,EAAE,GAAG;IACZ,IAAI,OAAO,EAAE,KAAK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A,KAAA,CAAA,CAAA;AAAA;IAAA,IAAA,QAAA,CAAA,gBAAA,CAAA,YAAA,EAAA,CAAA,KAAA,KAAA;IAAA,QAAA,IAAA,KAAA,CAAA,MAAA,CAAA,QAAA,EAAA,iBAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA;IAAA,aAAA,iBAAA,CAAA,KAAA,CAAA,MAAA,CAAA,KAAA,CAAA,CAAA;IAAA,KAAA,CAAA,CAAA;IAAA,CAAA;IACA;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).thselector={})}(this,function(e){"use strict";const t="[fx-theme]",s="fth-meta";window.th={verbose:!1,themes:Object.freeze({light:"light",dark:"dark",system:"dark light"}),setMetaTag(e){let t=document.getElementById(s);t||(t=document.createElement("meta"),t.id=s,t.name="color-scheme",document.head.appendChild(t)),t.content=e},getSystemTheme:()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",setTheme(e){e in this.themes||(console.warn(`Invalid theme: ${e}. Falling back to system theme.`),e="system"),this.setMetaTag(this.themes[e]||this.themes.system);const s="system"===e?this.getSystemTheme():e;document.documentElement.setAttribute("theme",s);try{localStorage.setItem(t,e)}catch(e){this.verbose&&console.debug("Error saving the theme:",e)}return this.dispatchThemeChangeEvent(s,"system"===e),s},dispatchThemeChangeEvent(e,t){const s=new CustomEvent("th-changed",{detail:{theme:e,isSistem:t}});document.dispatchEvent(s)},init(){try{const e=localStorage.getItem(t)??"system";this.setTheme(e)}catch(e){this.verbose&&console.debug("Error loading theme:",e),this.setTheme("system")}"matchMedia"in window||this.verbose&&console.debug("The 'matchMedia' parameter is not present");const e=()=>{"system"===localStorage.getItem(t)&&this.setTheme("system")};return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",e)}}},window.th.remove=window.th.init();const n=window.th;e.th=n,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
|
+
//# sourceMappingURL=index.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.min.js","sources":["../src/core.js","../src/index.js"],"sourcesContent":["const THEME_STORAGE_KEY = '[fx-theme]';\nconst META_ID = 'fth-meta';\n\nwindow.th = {\n verbose: false,\n themes: Object.freeze({\n light: 'light',\n dark: 'dark',\n system: 'dark light'\n }),\n\n setMetaTag(content) {\n let meta = document.getElementById(META_ID);\n if (!meta) {\n meta = document.createElement('meta');\n meta.id = META_ID;\n meta.name = 'color-scheme';\n document.head.appendChild(meta);\n }\n meta.content = content;\n },\n\n getSystemTheme() {\n return window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n },\n\n setTheme(theme) {\n if (!(theme in this.themes)) {\n console.warn(`Invalid theme: ${theme}. Falling back to system theme.`);\n theme = 'system';\n }\n \n this.setMetaTag(this.themes[theme] || this.themes.system);\n \n const finalTheme = theme === 'system' ? this.getSystemTheme() : theme;\n \n document.documentElement.setAttribute('theme', finalTheme);\n \n try { localStorage.setItem(THEME_STORAGE_KEY, theme); }\n catch (e) { \n if (this.verbose) console.debug(\"Error saving the theme:\", e)\n }\n \n this.dispatchThemeChangeEvent(finalTheme, theme === 'system');\n \n return finalTheme;\n },\n \n dispatchThemeChangeEvent(theme, isSistem) {\n const event = new CustomEvent('th-changed', { detail: { theme, isSistem } });\n document.dispatchEvent(event);\n },\n \n init() {\n try {\n const savedTheme = localStorage.getItem(THEME_STORAGE_KEY) ?? 'system';\n this.setTheme(savedTheme);\n } catch (error) {\n if (this.verbose) console.debug('Error loading theme:', error);\n this.setTheme('system');\n }\n \n if (!('matchMedia' in window)) {\n if (this.verbose) console.debug(\"The 'matchMedia' parameter is not present\")\n }\n \n const listener = () => {\n const currentTheme = localStorage.getItem(THEME_STORAGE_KEY);\n if (currentTheme === 'system') { this.setTheme('system'); }\n }\n \n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener);\n \n return () => {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener);\n }\n }\n}\n\nwindow.th.remove = window.th.init();\n","import './core.js';\n\nexport const th = window.th;\n\nexport function init_dropdown() {\n// ./components/dropdown.js\n}\n"],"names":["THEME_STORAGE_KEY","META_ID","window","th","verbose","themes","Object","freeze","light","dark","system","setMetaTag","content","meta","document","getElementById","createElement","id","name","head","appendChild","getSystemTheme","matchMedia","matches","setTheme","theme","this","console","warn","finalTheme","documentElement","setAttribute","localStorage","setItem","e","debug","dispatchThemeChangeEvent","isSistem","event","CustomEvent","detail","dispatchEvent","init","savedTheme","getItem","error","listener","addEventListener","removeEventListener","remove"],"mappings":"iPAAA,MAAMA,EAAoB,aACpBC,EAAU,WAEhBC,OAAOC,GAAK,CACRC,SAAS,EACTC,OAAQC,OAAOC,OAAO,CAClBC,MAAO,QACPC,KAAM,OACNC,OAAQ,eAGZ,UAAAC,CAAWC,GACP,IAAIC,EAAOC,SAASC,eAAed,GAC9BY,IACDA,EAAOC,SAASE,cAAc,QAC9BH,EAAKI,GAAKhB,EACVY,EAAKK,KAAO,eACZJ,SAASK,KAAKC,YAAYP,IAE9BA,EAAKD,QAAUA,CAClB,EAEDS,eAAc,IACHnB,OAAOoB,WAAW,gCAAgCC,QACnD,OACA,QAGV,QAAAC,CAASC,GACCA,KAASC,KAAKrB,SAChBsB,QAAQC,KAAK,kBAAkBH,oCAC/BA,EAAQ,UAGZC,KAAKf,WAAWe,KAAKrB,OAAOoB,IAAUC,KAAKrB,OAAOK,QAElD,MAAMmB,EAAuB,WAAVJ,EAAqBC,KAAKL,iBAAmBI,EAEhEX,SAASgB,gBAAgBC,aAAa,QAASF,GAE/C,IAAMG,aAAaC,QAAQjC,EAAmByB,EAAS,CACvD,MAAOS,GACDR,KAAKtB,SAASuB,QAAQQ,MAAM,0BAA2BD,EAC5D,CAID,OAFAR,KAAKU,yBAAyBP,EAAsB,WAAVJ,GAEnCI,CACV,EAED,wBAAAO,CAAyBX,EAAOY,GAC5B,MAAMC,EAAQ,IAAIC,YAAY,aAAc,CAAEC,OAAQ,CAAEf,QAAOY,cAC/DvB,SAAS2B,cAAcH,EAC1B,EAED,IAAAI,GACE,IACI,MAAMC,EAAaX,aAAaY,QAAQ5C,IAAsB,SAC9D0B,KAAKF,SAASmB,EACjB,CAAC,MAAOE,GACDnB,KAAKtB,SAASuB,QAAQQ,MAAM,uBAAwBU,GACxDnB,KAAKF,SAAS,SACjB,CAEK,eAAgBtB,QAChBwB,KAAKtB,SAASuB,QAAQQ,MAAM,6CAGlC,MAAMW,EAAW,KAEM,WADAd,aAAaY,QAAQ5C,IACT0B,KAAKF,SAAS,WAKjD,OAFAtB,OAAOoB,WAAW,gCAAgCyB,iBAAiB,SAAUD,GAEtE,KACL5C,OAAOoB,WAAW,gCAAgC0B,oBAAoB,SAAUF,GAEnF,GAGL5C,OAAOC,GAAG8C,OAAS/C,OAAOC,GAAGuC,OC/EhB,MAAAvC,EAAKD,OAAOC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const THEME_STORAGE_KEY = '[fx-theme]';
|
|
2
|
+
const META_ID = 'fth-meta';
|
|
3
|
+
|
|
4
|
+
window.th = {
|
|
5
|
+
verbose: false,
|
|
6
|
+
themes: Object.freeze({
|
|
7
|
+
light: 'light',
|
|
8
|
+
dark: 'dark',
|
|
9
|
+
system: 'dark light'
|
|
10
|
+
}),
|
|
11
|
+
|
|
12
|
+
setMetaTag(content) {
|
|
13
|
+
let meta = document.getElementById(META_ID);
|
|
14
|
+
if (!meta) {
|
|
15
|
+
meta = document.createElement('meta');
|
|
16
|
+
meta.id = META_ID;
|
|
17
|
+
meta.name = 'color-scheme';
|
|
18
|
+
document.head.appendChild(meta);
|
|
19
|
+
}
|
|
20
|
+
meta.content = content;
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
getSystemTheme() {
|
|
24
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
25
|
+
? 'dark'
|
|
26
|
+
: 'light';
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
setTheme(theme) {
|
|
30
|
+
if (!(theme in this.themes)) {
|
|
31
|
+
console.warn(`Invalid theme: ${theme}. Falling back to system theme.`);
|
|
32
|
+
theme = 'system';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.setMetaTag(this.themes[theme] || this.themes.system);
|
|
36
|
+
|
|
37
|
+
const finalTheme = theme === 'system' ? this.getSystemTheme() : theme;
|
|
38
|
+
|
|
39
|
+
document.documentElement.setAttribute('theme', finalTheme);
|
|
40
|
+
|
|
41
|
+
try { localStorage.setItem(THEME_STORAGE_KEY, theme); }
|
|
42
|
+
catch (e) {
|
|
43
|
+
if (this.verbose) console.debug("Error saving the theme:", e);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.dispatchThemeChangeEvent(finalTheme, theme === 'system');
|
|
47
|
+
|
|
48
|
+
return finalTheme;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
dispatchThemeChangeEvent(theme, isSistem) {
|
|
52
|
+
const event = new CustomEvent('th-changed', { detail: { theme, isSistem } });
|
|
53
|
+
document.dispatchEvent(event);
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
init() {
|
|
57
|
+
try {
|
|
58
|
+
const savedTheme = localStorage.getItem(THEME_STORAGE_KEY) ?? 'system';
|
|
59
|
+
this.setTheme(savedTheme);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (this.verbose) console.debug('Error loading theme:', error);
|
|
62
|
+
this.setTheme('system');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!('matchMedia' in window)) {
|
|
66
|
+
if (this.verbose) console.debug("The 'matchMedia' parameter is not present");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const listener = () => {
|
|
70
|
+
const currentTheme = localStorage.getItem(THEME_STORAGE_KEY);
|
|
71
|
+
if (currentTheme === 'system') { this.setTheme('system'); }
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener);
|
|
75
|
+
|
|
76
|
+
return () => {
|
|
77
|
+
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
window.th.remove = window.th.init();
|
|
83
|
+
|
|
84
|
+
const th = window.th;
|
|
85
|
+
|
|
86
|
+
function init_dropdown() {
|
|
87
|
+
const selector = document.getElementById("fth-select");
|
|
88
|
+
|
|
89
|
+
if (selector) {
|
|
90
|
+
const OPTIONS = {
|
|
91
|
+
light: { id: 'fth-olight', text: 'Light', value: 'light' },
|
|
92
|
+
dark: { id: 'fth-odark', text: 'Dark', value: 'dark' },
|
|
93
|
+
system: { id: 'fth-osystem', text: 'System', value: 'system' }
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
function createOrUpdateOption(theme, config) {
|
|
97
|
+
let option = document.getElementById(config.id);
|
|
98
|
+
|
|
99
|
+
if (!option) {
|
|
100
|
+
option = document.createElement("option");
|
|
101
|
+
option.id = config.id;
|
|
102
|
+
option.value = config.value; // Usa el valor definido en OPTIONS
|
|
103
|
+
option.textContent = config.text;
|
|
104
|
+
selector.appendChild(option);
|
|
105
|
+
}
|
|
106
|
+
return option;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const options = Object.values(OPTIONS).map(config => createOrUpdateOption(config.value, config));
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function setSelectedOption(theme) {
|
|
113
|
+
const optionToSelect = options.find(option => option.value === theme);
|
|
114
|
+
if (optionToSelect) {
|
|
115
|
+
optionToSelect.selected = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const currentTheme = localStorage.getItem('[fx-theme]') ?? 'system';
|
|
120
|
+
setSelectedOption(currentTheme);
|
|
121
|
+
|
|
122
|
+
selector.addEventListener("change", (event) => {
|
|
123
|
+
const newTheme = event.target.value;
|
|
124
|
+
window.th.setTheme(newTheme);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
document.addEventListener('th-changed', (event) => {
|
|
128
|
+
if (event.detail.isSistem) setSelectedOption(OPTIONS.system);
|
|
129
|
+
else setSelectedOption(event.detail.theme);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { init_dropdown, th };
|
|
135
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/core.js","../src/index.js"],"sourcesContent":["const THEME_STORAGE_KEY = '[fx-theme]';\nconst META_ID = 'fth-meta';\n\nwindow.th = {\n verbose: false,\n themes: Object.freeze({\n light: 'light',\n dark: 'dark',\n system: 'dark light'\n }),\n\n setMetaTag(content) {\n let meta = document.getElementById(META_ID);\n if (!meta) {\n meta = document.createElement('meta');\n meta.id = META_ID;\n meta.name = 'color-scheme';\n document.head.appendChild(meta);\n }\n meta.content = content;\n },\n\n getSystemTheme() {\n return window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n },\n\n setTheme(theme) {\n if (!(theme in this.themes)) {\n console.warn(`Invalid theme: ${theme}. Falling back to system theme.`);\n theme = 'system';\n }\n \n this.setMetaTag(this.themes[theme] || this.themes.system);\n \n const finalTheme = theme === 'system' ? this.getSystemTheme() : theme;\n \n document.documentElement.setAttribute('theme', finalTheme);\n \n try { localStorage.setItem(THEME_STORAGE_KEY, theme); }\n catch (e) { \n if (this.verbose) console.debug(\"Error saving the theme:\", e)\n }\n \n this.dispatchThemeChangeEvent(finalTheme, theme === 'system');\n \n return finalTheme;\n },\n \n dispatchThemeChangeEvent(theme, isSistem) {\n const event = new CustomEvent('th-changed', { detail: { theme, isSistem } });\n document.dispatchEvent(event);\n },\n \n init() {\n try {\n const savedTheme = localStorage.getItem(THEME_STORAGE_KEY) ?? 'system';\n this.setTheme(savedTheme);\n } catch (error) {\n if (this.verbose) console.debug('Error loading theme:', error);\n this.setTheme('system');\n }\n \n if (!('matchMedia' in window)) {\n if (this.verbose) console.debug(\"The 'matchMedia' parameter is not present\")\n }\n \n const listener = () => {\n const currentTheme = localStorage.getItem(THEME_STORAGE_KEY);\n if (currentTheme === 'system') { this.setTheme('system'); }\n }\n \n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener);\n \n return () => {\n window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener);\n }\n }\n}\n\nwindow.th.remove = window.th.init();\n","import './core.js';\n\nexport const th = window.th;\n\nexport function init_dropdown() {\n// ./components/dropdown.js\n}\n"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,OAAO,GAAG,UAAU,CAAC;AAC3B;AACA,MAAM,CAAC,EAAE,GAAG;AACZ,IAAI,OAAO,EAAE,KAAK;AAClB,IAAI,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;AAC1B,QAAQ,KAAK,EAAE,OAAO;AACtB,QAAQ,IAAI,EAAE,MAAM;AACpB,QAAQ,MAAM,EAAE,YAAY;AAC5B,KAAK,CAAC;AACN;AACA,IAAI,UAAU,CAAC,OAAO,EAAE;AACxB,QAAQ,IAAI,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACpD,QAAQ,IAAI,CAAC,IAAI,EAAE;AACnB,YAAY,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAClD,YAAY,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC;AAC9B,YAAY,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;AACvC,YAAY,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC5C,SAAS;AACT,QAAQ,IAAI,CAAC,OAAO,G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,EAAA,MAAA,CAAA,CAAA,CAAA;AAAA;AAAA;AAAA,IAAA,SAAA,iBAAA,CAAA,KAAA,EAAA;AAAA,QAAA,MAAA,cAAA,GAAA,OAAA,CAAA,IAAA,CAAA,MAAA,IAAA,MAAA,CAAA,KAAA,KAAA,KAAA,CAAA,CAAA;AAAA,QAAA,IAAA,cAAA,EAAA;AAAA,YAAA,cAAA,CAAA,QAAA,GAAA,IAAA,CAAA;AAAA,SAAA;AAAA,KAAA;AAAA;AAAA,IAAA,MAAA,YAAA,GAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,IAAA,QAAA,CAAA;AAAA,IAAA,iBAAA,CAAA,YAAA,CAAA,CAAA;AAAA;AAAA,IAAA,QAAA,CAAA,gBAAA,CAAA,QAAA,EAAA,CAAA,KAAA,KAAA;AAAA,QAAA,MAAA,QAAA,GAAA,KAAA,CAAA,MAAA,CAAA,KAAA,CAAA;AAAA,QAAA,MAAA,CAAA,EAAA,CAAA,QAAA,CAAA,QAAA,CAAA,CAAA;AAAA,KAAA,CAAA,CAAA;AAAA;AAAA,IAAA,QAAA,CAAA,gBAAA,CAAA,YAAA,EAAA,CAAA,KAAA,KAAA;AAAA,QAAA,IAAA,KAAA,CAAA,MAAA,CAAA,QAAA,EAAA,iBAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA;AAAA,aAAA,iBAAA,CAAA,KAAA,CAAA,MAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KAAA,CAAA,CAAA;AAAA,CAAA;AACA;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@feraxjs/thselector",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The simplest way to add theme management to your HTML. Easy to configure and set up.",
|
|
5
|
+
"author": "feraxhp",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.cjs",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"browser": "dist/index.js",
|
|
10
|
+
"directories": {
|
|
11
|
+
"doc": "docs"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rm -fr dist && rollup -c",
|
|
18
|
+
"build:prod": "rm -fr dist && NODE_ENV=production rollup -c",
|
|
19
|
+
"prepublishOnly": "pnpm run build:prod"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"theme",
|
|
23
|
+
"dark-mode",
|
|
24
|
+
"light-mode",
|
|
25
|
+
"system-theme",
|
|
26
|
+
"javascript"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
31
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
32
|
+
"rollup": "^2.79.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@rollup/plugin-replace": "^6.0.3"
|
|
36
|
+
}
|
|
37
|
+
}
|