@lpdsgn/astro-themes 0.1.0 → 0.1.2
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.md +21 -0
- package/README.md +12 -22
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +2 -0
- package/dist/index.d.ts +0 -12
- package/dist/index.js +2 -53
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -10
- package/package.json +65 -62
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Luigi Pedata
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -21,22 +21,22 @@ Perfect dark mode in Astro with no flash. An Astro integration that mirrors the
|
|
|
21
21
|
### 1. Install
|
|
22
22
|
|
|
23
23
|
```sh frame="none"
|
|
24
|
-
pnpm astro add astro-themes
|
|
24
|
+
pnpm astro add @lpdsgn/astro-themes
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
```sh frame="none"
|
|
28
|
-
npx astro add astro-themes
|
|
28
|
+
npx astro add @lpdsgn/astro-themes
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
```sh frame="none"
|
|
32
|
-
yarn astro add astro-themes
|
|
32
|
+
yarn astro add @lpdsgn/astro-themes
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### 2. Add ThemeProvider
|
|
36
36
|
|
|
37
37
|
```astro frame="code" title="src/layouts/Layout.astro"
|
|
38
38
|
---
|
|
39
|
-
import ThemeProvider from "astro-themes/
|
|
39
|
+
import { ThemeProvider } from "@lpdsgn/astro-themes/components";
|
|
40
40
|
---
|
|
41
41
|
|
|
42
42
|
<!doctype html>
|
|
@@ -56,7 +56,7 @@ That's it! Your Astro app now supports dark mode with system preference detectio
|
|
|
56
56
|
|
|
57
57
|
### CSS Variables
|
|
58
58
|
|
|
59
|
-
By default,
|
|
59
|
+
By default, `@lpdsgn/astro-themes` sets `data-theme` on the `<html>` element:
|
|
60
60
|
|
|
61
61
|
```css frame="code" title="src/styles/global.css"
|
|
62
62
|
:root {
|
|
@@ -108,7 +108,7 @@ Now use dark-mode classes:
|
|
|
108
108
|
|
|
109
109
|
```astro
|
|
110
110
|
<script>
|
|
111
|
-
import { setTheme, toggleTheme, onThemeChange, getResolvedTheme } from 'astro-themes
|
|
111
|
+
import { setTheme, toggleTheme, onThemeChange, getResolvedTheme } from '@lpdsgn/astro-themes';
|
|
112
112
|
|
|
113
113
|
// Toggle between light and dark
|
|
114
114
|
toggleTheme();
|
|
@@ -159,22 +159,16 @@ Now use dark-mode classes:
|
|
|
159
159
|
|
|
160
160
|
### Integration Options
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
The integration can be configured in your `astro.config.mjs`:
|
|
163
163
|
|
|
164
164
|
```js frame="code" title="astro.config.mjs"
|
|
165
165
|
import { defineConfig } from "astro/config";
|
|
166
|
-
import astroThemes from "astro-themes";
|
|
166
|
+
import astroThemes from "@lpdsgn/astro-themes";
|
|
167
167
|
|
|
168
168
|
export default defineConfig({
|
|
169
169
|
integrations: [
|
|
170
170
|
astroThemes({
|
|
171
|
-
|
|
172
|
-
defaultProps: {
|
|
173
|
-
attribute: "class",
|
|
174
|
-
defaultTheme: "system",
|
|
175
|
-
themes: ["light", "dark"],
|
|
176
|
-
},
|
|
177
|
-
devToolbar: true, // Enable Dev Toolbar App
|
|
171
|
+
devToolbar: true, // Enable Dev Toolbar App (default: true)
|
|
178
172
|
}),
|
|
179
173
|
],
|
|
180
174
|
});
|
|
@@ -182,11 +176,7 @@ export default defineConfig({
|
|
|
182
176
|
|
|
183
177
|
| Option | Type | Default | Description |
|
|
184
178
|
|--------|------|---------|-------------|
|
|
185
|
-
| `
|
|
186
|
-
| `defaultProps` | `object` | `{}` | Default theme configuration (same options as **[ThemeProvider Props](#themeprovider-props)**) |
|
|
187
|
-
| `devToolbar` | `boolean` | `true` | Enable the Dev Toolbar App |
|
|
188
|
-
|
|
189
|
-
> **Tip:** Use `injectScript: true` for consistent settings across all pages. You can still use `ThemeProvider` with `forcedTheme` on specific pages.
|
|
179
|
+
| `devToolbar` | `boolean` | `true` | Enable the Dev Toolbar App for theme switching during development |
|
|
190
180
|
|
|
191
181
|
## Examples
|
|
192
182
|
|
|
@@ -194,7 +184,7 @@ export default defineConfig({
|
|
|
194
184
|
|
|
195
185
|
```astro frame="code" title="src/pages/dark-only.astro"
|
|
196
186
|
---
|
|
197
|
-
import ThemeProvider from "astro-themes/
|
|
187
|
+
import { ThemeProvider } from "@lpdsgn/astro-themes/components";
|
|
198
188
|
import Layout from "../layouts/Layout.astro";
|
|
199
189
|
---
|
|
200
190
|
|
|
@@ -235,7 +225,7 @@ import Layout from "../layouts/Layout.astro";
|
|
|
235
225
|
|
|
236
226
|
### Client Helpers
|
|
237
227
|
|
|
238
|
-
Import from
|
|
228
|
+
Import from `@lpdsgn/astro-themes`:
|
|
239
229
|
|
|
240
230
|
| Function | Description |
|
|
241
231
|
|----------|-------------|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,18 +3,6 @@ export { AstroThemesConfig, Attribute, ScriptProps, ThemeProviderProps, ThemeSta
|
|
|
3
3
|
export { getResolvedTheme, getSystemTheme, getTheme, getThemes, isForcedTheme, onThemeChange, setTheme, toggleTheme } from './client.js';
|
|
4
4
|
|
|
5
5
|
declare const integration: (options?: {
|
|
6
|
-
injectScript?: boolean | undefined;
|
|
7
|
-
defaultProps?: {
|
|
8
|
-
storageKey?: string | undefined;
|
|
9
|
-
defaultTheme?: string | undefined;
|
|
10
|
-
forcedTheme?: string | undefined;
|
|
11
|
-
enableSystem?: boolean | undefined;
|
|
12
|
-
enableColorScheme?: boolean | undefined;
|
|
13
|
-
disableTransitionOnChange?: boolean | undefined;
|
|
14
|
-
value?: Record<string, string> | undefined;
|
|
15
|
-
themes?: string[] | undefined;
|
|
16
|
-
attribute?: string | string[] | undefined;
|
|
17
|
-
} | undefined;
|
|
18
6
|
devToolbar?: boolean | undefined;
|
|
19
7
|
} | undefined) => astro.AstroIntegration & {};
|
|
20
8
|
|
package/dist/index.js
CHANGED
|
@@ -1,55 +1,4 @@
|
|
|
1
|
-
import{defineIntegration as
|
|
2
|
-
(function() {
|
|
3
|
-
var el = document.documentElement;
|
|
4
|
-
var attribute = ${JSON.stringify(r)};
|
|
5
|
-
var storageKey = ${JSON.stringify(t)};
|
|
6
|
-
var defaultTheme = ${JSON.stringify(n)};
|
|
7
|
-
var forcedTheme = ${JSON.stringify(o)};
|
|
8
|
-
var themes = ${JSON.stringify(a)};
|
|
9
|
-
var value = ${JSON.stringify(s)};
|
|
10
|
-
var enableSystem = ${JSON.stringify(m)};
|
|
11
|
-
var enableColorScheme = ${JSON.stringify(h)};
|
|
12
|
-
var systemThemes = ['light', 'dark'];
|
|
13
|
-
|
|
14
|
-
function updateDOM(theme) {
|
|
15
|
-
var attributes = Array.isArray(attribute) ? attribute : [attribute];
|
|
16
|
-
attributes.forEach(function(attr) {
|
|
17
|
-
var isClass = attr === 'class';
|
|
18
|
-
var classes = isClass && value ? themes.map(function(t) { return value[t] || t; }) : themes;
|
|
19
|
-
if (isClass) {
|
|
20
|
-
el.classList.remove.apply(el.classList, classes);
|
|
21
|
-
el.classList.add(value && value[theme] ? value[theme] : theme);
|
|
22
|
-
} else {
|
|
23
|
-
el.setAttribute(attr, value && value[theme] ? value[theme] : theme);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
setColorScheme(theme);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function setColorScheme(theme) {
|
|
30
|
-
if (enableColorScheme && systemThemes.indexOf(theme) !== -1) {
|
|
31
|
-
el.style.colorScheme = theme;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getSystemTheme() {
|
|
36
|
-
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (forcedTheme) {
|
|
40
|
-
updateDOM(forcedTheme);
|
|
41
|
-
} else {
|
|
42
|
-
try {
|
|
43
|
-
var themeName = localStorage.getItem(storageKey) || defaultTheme;
|
|
44
|
-
var isSystem = enableSystem && themeName === 'system';
|
|
45
|
-
var theme = isSystem ? getSystemTheme() : themeName;
|
|
46
|
-
updateDOM(theme);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
updateDOM(defaultTheme === 'system' && enableSystem ? getSystemTheme() : defaultTheme);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
})();
|
|
52
|
-
`.trim()}function l(r,t,n,o,a,s,m,h){return c(r,t,n,o,a,s,m,h).replace(/\s+/g," ").replace(/\s*{\s*/g,"{").replace(/\s*}\s*/g,"}").replace(/\s*;\s*/g,";").replace(/\s*,\s*/g,",").replace(/\s*\(\s*/g,"(").replace(/\s*\)\s*/g,")").trim()}var f="theme",u="system",p=["light","dark"],T="data-theme",v=e.object({injectScript:e.boolean().default(!1),defaultProps:e.object({storageKey:e.string().default(f),defaultTheme:e.string().default(u),forcedTheme:e.string().optional(),enableSystem:e.boolean().default(!0),enableColorScheme:e.boolean().default(!0),disableTransitionOnChange:e.boolean().default(!1),themes:e.array(e.string()).default(p),attribute:e.union([e.string(),e.array(e.string())]).default(T),value:e.record(e.string()).optional()}).default({}),devToolbar:e.boolean().default(!0)}).default({}),d=g({name:"astro-themes",optionsSchema:v,setup({options:r}){return{hooks:{"astro:config:setup":({logger:t,injectScript:n,addDevToolbarApp:o,command:a})=>{if(t.info("astro-themes initialized"),r.injectScript){let s=r.defaultProps,m=l(s.attribute,s.storageKey,s.defaultTheme,s.forcedTheme,s.themes,s.value,s.enableSystem,s.enableColorScheme);n("head-inline",m),t.info("Flash-prevention script injected via integration")}r.devToolbar&&a==="dev"&&(o({id:"astro-themes-toolbar",name:"Theme Switcher",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg>',entrypoint:"astro-themes/toolbar"}),t.debug("Dev Toolbar App registered"))},"astro:config:done":({injectTypes:t})=>{t({filename:"types.d.ts",content:`declare global {
|
|
1
|
+
import{defineIntegration as h}from"astro-integration-kit";import{z as n}from"astro/zod";var m=n.object({devToolbar:n.boolean().default(!0)}).default({}),i=h({name:"astro-themes",optionsSchema:m,setup({options:t}){return{hooks:{"astro:config:setup":({logger:e,addDevToolbarApp:r,command:s})=>{e.info("astro-themes initialized"),t.devToolbar&&s==="dev"&&(r({id:"astro-themes-toolbar",name:"Theme Switcher",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg>',entrypoint:"@lpdsgn/astro-themes/toolbar"}),e.debug("Dev Toolbar App registered"))},"astro:config:done":({injectTypes:e})=>{e({filename:"types.d.ts",content:`declare global {
|
|
53
2
|
interface Window {
|
|
54
3
|
__ASTRO_THEMES__?: {
|
|
55
4
|
theme: string;
|
|
@@ -61,5 +10,5 @@ import{defineIntegration as g}from"astro-integration-kit";import{z as e}from"ast
|
|
|
61
10
|
};
|
|
62
11
|
}
|
|
63
12
|
}
|
|
64
|
-
export {};`})}}}}});function
|
|
13
|
+
export {};`})}}}}});function o(){if(!(typeof window>"u"))return window.__ASTRO_THEMES__}function d(t){let e=o();e&&e.setTheme(t)}function a(){return o()?.resolvedTheme}function p(){return o()?.systemTheme}function g(){return!!o()?.forcedTheme}function T(){return o()?.themes??[]}function f(t){if(typeof window>"u")return()=>{};let e=r=>{t(r.detail)};return window.addEventListener("astro-themes:change",e),()=>{window.removeEventListener("astro-themes:change",e)}}function l(){let t=o();if(!t)return;let e=t.resolvedTheme;t.setTheme(e==="light"?"dark":"light")}var y=i;export{y as default,a as getResolvedTheme,p as getSystemTheme,o as getTheme,T as getThemes,i as integration,g as isForcedTheme,f as onThemeChange,d as setTheme,l as toggleTheme};
|
|
65
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/integration.ts","../src/script.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import { defineIntegration } from \"astro-integration-kit\";\nimport { z } from \"astro/zod\";\nimport type { AstroThemesConfig, ThemeProviderProps } from \"./types.js\";\nimport { getMinifiedInlineScript } from \"./script.js\";\n\n// Default configuration values\nconst DEFAULT_STORAGE_KEY = \"theme\";\nconst DEFAULT_THEME = \"system\";\nconst DEFAULT_THEMES = [\"light\", \"dark\"];\nconst DEFAULT_ATTRIBUTE = \"data-theme\";\n\n// Options schema for the integration\nconst optionsSchema = z\n\t.object({\n\t\t/**\n\t\t * Inject the flash-prevention script automatically via integration\n\t\t * When true, you don't need to use ThemeProvider component\n\t\t * @default false\n\t\t */\n\t\tinjectScript: z.boolean().default(false),\n\t\t/**\n\t\t * Default theme configuration used when injectScript is true\n\t\t */\n\t\tdefaultProps: z\n\t\t\t.object({\n\t\t\t\tstorageKey: z.string().default(DEFAULT_STORAGE_KEY),\n\t\t\t\tdefaultTheme: z.string().default(DEFAULT_THEME),\n\t\t\t\tforcedTheme: z.string().optional(),\n\t\t\t\tenableSystem: z.boolean().default(true),\n\t\t\t\tenableColorScheme: z.boolean().default(true),\n\t\t\t\tdisableTransitionOnChange: z.boolean().default(false),\n\t\t\t\tthemes: z.array(z.string()).default(DEFAULT_THEMES),\n\t\t\t\tattribute: z\n\t\t\t\t\t.union([z.string(), z.array(z.string())])\n\t\t\t\t\t.default(DEFAULT_ATTRIBUTE),\n\t\t\t\tvalue: z.record(z.string()).optional(),\n\t\t\t})\n\t\t\t.default({}),\n\t\t/**\n\t\t * Enable the Dev Toolbar App for theme switching during development\n\t\t * @default true\n\t\t */\n\t\tdevToolbar: z.boolean().default(true),\n\t})\n\t.default({});\n\nexport const integration = defineIntegration({\n\tname: \"astro-themes\",\n\toptionsSchema,\n\tsetup({ options }) {\n\t\treturn {\n\t\t\thooks: {\n\t\t\t\t\"astro:config:setup\": ({\n\t\t\t\t\tlogger,\n\t\t\t\t\tinjectScript,\n\t\t\t\t\taddDevToolbarApp,\n\t\t\t\t\tcommand,\n\t\t\t\t}) => {\n\t\t\t\t\tlogger.info(\"astro-themes initialized\");\n\n\t\t\t\t\t// Inject flash-prevention script if enabled\n\t\t\t\t\tif (options.injectScript) {\n\t\t\t\t\t\tconst props = options.defaultProps;\n\t\t\t\t\t\tconst script = getMinifiedInlineScript(\n\t\t\t\t\t\t\tprops.attribute,\n\t\t\t\t\t\t\tprops.storageKey,\n\t\t\t\t\t\t\tprops.defaultTheme,\n\t\t\t\t\t\t\tprops.forcedTheme,\n\t\t\t\t\t\t\tprops.themes,\n\t\t\t\t\t\t\tprops.value,\n\t\t\t\t\t\t\tprops.enableSystem,\n\t\t\t\t\t\t\tprops.enableColorScheme\n\t\t\t\t\t\t);\n\t\t\t\t\t\tinjectScript(\"head-inline\", script);\n\t\t\t\t\t\tlogger.info(\"Flash-prevention script injected via integration\");\n\t\t\t\t\t}\n\n\t\t\t\t\t// Add Dev Toolbar App in dev mode\n\t\t\t\t\tif (options.devToolbar && command === \"dev\") {\n\t\t\t\t\t\taddDevToolbarApp({\n\t\t\t\t\t\t\tid: \"astro-themes-toolbar\",\n\t\t\t\t\t\t\tname: \"Theme Switcher\",\n\t\t\t\t\t\t\ticon: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"4\"/><path d=\"M12 2v2\"/><path d=\"M12 20v2\"/><path d=\"m4.93 4.93 1.41 1.41\"/><path d=\"m17.66 17.66 1.41 1.41\"/><path d=\"M2 12h2\"/><path d=\"M20 12h2\"/><path d=\"m6.34 17.66-1.41 1.41\"/><path d=\"m19.07 4.93-1.41 1.41\"/></svg>`,\n\t\t\t\t\t\t\tentrypoint: \"astro-themes/toolbar\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tlogger.debug(\"Dev Toolbar App registered\");\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"astro:config:done\": ({ injectTypes }) => {\n\t\t\t\t\t// Inject global types for window.__ASTRO_THEMES__\n\t\t\t\t\tinjectTypes({\n\t\t\t\t\t\tfilename: \"types.d.ts\",\n\t\t\t\t\t\tcontent: `declare global {\n interface Window {\n __ASTRO_THEMES__?: {\n theme: string;\n resolvedTheme: string;\n systemTheme: \"dark\" | \"light\";\n forcedTheme?: string;\n themes: string[];\n setTheme: (theme: string | ((prevTheme: string) => string)) => void;\n };\n }\n}\nexport {};`,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport type { AstroThemesConfig, ThemeProviderProps };\n","/**\n * Inline script that runs before page render to prevent flash\n * This script is injected into the head and executes immediately\n */\nexport function getInlineScript(\n\tattribute: string | string[],\n\tstorageKey: string,\n\tdefaultTheme: string,\n\tforcedTheme: string | undefined,\n\tthemes: string[],\n\tvalue: Record<string, string> | undefined,\n\tenableSystem: boolean,\n\tenableColorScheme: boolean\n): string {\n\t// The script must be minified and self-contained\n\tconst script = `\n(function() {\n var el = document.documentElement;\n var attribute = ${JSON.stringify(attribute)};\n var storageKey = ${JSON.stringify(storageKey)};\n var defaultTheme = ${JSON.stringify(defaultTheme)};\n var forcedTheme = ${JSON.stringify(forcedTheme)};\n var themes = ${JSON.stringify(themes)};\n var value = ${JSON.stringify(value)};\n var enableSystem = ${JSON.stringify(enableSystem)};\n var enableColorScheme = ${JSON.stringify(enableColorScheme)};\n var systemThemes = ['light', 'dark'];\n\n function updateDOM(theme) {\n var attributes = Array.isArray(attribute) ? attribute : [attribute];\n attributes.forEach(function(attr) {\n var isClass = attr === 'class';\n var classes = isClass && value ? themes.map(function(t) { return value[t] || t; }) : themes;\n if (isClass) {\n el.classList.remove.apply(el.classList, classes);\n el.classList.add(value && value[theme] ? value[theme] : theme);\n } else {\n el.setAttribute(attr, value && value[theme] ? value[theme] : theme);\n }\n });\n setColorScheme(theme);\n }\n\n function setColorScheme(theme) {\n if (enableColorScheme && systemThemes.indexOf(theme) !== -1) {\n el.style.colorScheme = theme;\n }\n }\n\n function getSystemTheme() {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n\n if (forcedTheme) {\n updateDOM(forcedTheme);\n } else {\n try {\n var themeName = localStorage.getItem(storageKey) || defaultTheme;\n var isSystem = enableSystem && themeName === 'system';\n var theme = isSystem ? getSystemTheme() : themeName;\n updateDOM(theme);\n } catch (e) {\n updateDOM(defaultTheme === 'system' && enableSystem ? getSystemTheme() : defaultTheme);\n }\n }\n})();\n`.trim();\n\n\treturn script;\n}\n\n/**\n * Returns a minified version of the inline script\n */\nexport function getMinifiedInlineScript(\n\tattribute: string | string[],\n\tstorageKey: string,\n\tdefaultTheme: string,\n\tforcedTheme: string | undefined,\n\tthemes: string[],\n\tvalue: Record<string, string> | undefined,\n\tenableSystem: boolean,\n\tenableColorScheme: boolean\n): string {\n\t// Minified version for production\n\treturn getInlineScript(\n\t\tattribute,\n\t\tstorageKey,\n\t\tdefaultTheme,\n\t\tforcedTheme,\n\t\tthemes,\n\t\tvalue,\n\t\tenableSystem,\n\t\tenableColorScheme\n\t)\n\t\t.replace(/\\s+/g, \" \")\n\t\t.replace(/\\s*{\\s*/g, \"{\")\n\t\t.replace(/\\s*}\\s*/g, \"}\")\n\t\t.replace(/\\s*;\\s*/g, \";\")\n\t\t.replace(/\\s*,\\s*/g, \",\")\n\t\t.replace(/\\s*\\(\\s*/g, \"(\")\n\t\t.replace(/\\s*\\)\\s*/g, \")\")\n\t\t.trim();\n}\n","/**\n * Client-side helpers for interacting with the theme\n * These are meant to be used in client-side scripts\n */\n\nimport type { ThemeState } from \"./types.js\";\n\ndeclare global {\n\tinterface Window {\n\t\t__ASTRO_THEMES__?: ThemeState;\n\t}\n}\n\n/**\n * Get the current theme state\n * Returns undefined if ThemeProvider is not mounted\n */\nexport function getTheme(): ThemeState | undefined {\n\tif (typeof window === \"undefined\") return undefined;\n\treturn window.__ASTRO_THEMES__;\n}\n\n/**\n * Set the theme\n * @param theme - Theme name or function that receives current theme and returns new theme\n */\nexport function setTheme(theme: string | ((prevTheme: string) => string)): void {\n\tconst state = getTheme();\n\tif (state) {\n\t\tstate.setTheme(theme);\n\t}\n}\n\n/**\n * Get the resolved theme (system theme resolved to actual value)\n */\nexport function getResolvedTheme(): string | undefined {\n\treturn getTheme()?.resolvedTheme;\n}\n\n/**\n * Get the system theme preference\n */\nexport function getSystemTheme(): \"dark\" | \"light\" | undefined {\n\treturn getTheme()?.systemTheme;\n}\n\n/**\n * Check if theme is forced for the current page\n */\nexport function isForcedTheme(): boolean {\n\treturn !!getTheme()?.forcedTheme;\n}\n\n/**\n * Get the list of available themes\n */\nexport function getThemes(): string[] {\n\treturn getTheme()?.themes ?? [];\n}\n\n/**\n * Subscribe to theme changes\n * @param callback - Function called when theme changes\n * @returns Cleanup function to unsubscribe\n */\nexport function onThemeChange(\n\tcallback: (detail: { theme: string; resolvedTheme: string }) => void\n): () => void {\n\tif (typeof window === \"undefined\") return () => {};\n\n\tconst handler = (e: CustomEvent<{ theme: string; resolvedTheme: string }>) => {\n\t\tcallback(e.detail);\n\t};\n\n\twindow.addEventListener(\"astro-themes:change\", handler as EventListener);\n\n\treturn () => {\n\t\twindow.removeEventListener(\"astro-themes:change\", handler as EventListener);\n\t};\n}\n\n/**\n * Toggle between light and dark themes\n * If current theme is neither light nor dark, switches to light\n */\nexport function toggleTheme(): void {\n\tconst state = getTheme();\n\tif (!state) return;\n\n\tconst resolved = state.resolvedTheme;\n\tstate.setTheme(resolved === \"light\" ? \"dark\" : \"light\");\n}\n","// Main integration export\nimport { integration } from \"./integration.js\";\n\nexport default integration;\n\n// Re-export integration\nexport { integration };\n\n// Re-export types\nexport type {\n\tAttribute,\n\tValueObject,\n\tScriptProps,\n\tThemeProviderProps,\n\tThemeState,\n\tAstroThemesConfig,\n} from \"./types.js\";\n\n// Re-export client helpers\nexport {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rCD,EAAiB,CAChB,GAAI,uBACJ,KAAM,iBACN,KAAM,+aACN,WAAY,sBACb,CAAC,EACDF,EAAO,MAAM,4BAA4B,EAE3C,EACA,oBAAqB,CAAC,CAAE,YAAAO,CAAY,IAAM,CAEzCA,EAAY,CACX,SAAU,aACV,QAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAaV,CAAC,CACF,CACD,CACD,CACD,CACD,CAAC,EE7FM,SAASC,GAAmC,CAClD,GAAI,SAAO,OAAW,KACtB,OAAO,OAAO,gBACf,CAMO,SAASC,EAASC,EAAuD,CAC/E,IAAMC,EAAQH,EAAS,EACnBG,GACHA,EAAM,SAASD,CAAK,CAEtB,CAKO,SAASE,GAAuC,CACtD,OAAOJ,EAAS,GAAG,aACpB,CAKO,SAASK,GAA+C,CAC9D,OAAOL,EAAS,GAAG,WACpB,CAKO,SAASM,GAAyB,CACxC,MAAO,CAAC,CAACN,EAAS,GAAG,WACtB,CAKO,SAASO,GAAsB,CACrC,OAAOP,EAAS,GAAG,QAAU,CAAC,CAC/B,CAOO,SAASQ,EACfC,EACa,CACb,GAAI,OAAO,OAAW,IAAa,MAAO,IAAM,CAAC,EAEjD,IAAMC,EAAWC,GAA6D,CAC7EF,EAASE,EAAE,MAAM,CAClB,EAEA,cAAO,iBAAiB,sBAAuBD,CAAwB,EAEhE,IAAM,CACZ,OAAO,oBAAoB,sBAAuBA,CAAwB,CAC3E,CACD,CAMO,SAASE,GAAoB,CACnC,IAAMT,EAAQH,EAAS,EACvB,GAAI,CAACG,EAAO,OAEZ,IAAMU,EAAWV,EAAM,cACvBA,EAAM,SAASU,IAAa,QAAU,OAAS,OAAO,CACvD,CCzFA,IAAOC,EAAQC","names":["defineIntegration","z","getInlineScript","attribute","storageKey","defaultTheme","forcedTheme","themes","value","enableSystem","enableColorScheme","getMinifiedInlineScript","DEFAULT_STORAGE_KEY","DEFAULT_THEME","DEFAULT_THEMES","DEFAULT_ATTRIBUTE","optionsSchema","z","integration","defineIntegration","options","logger","injectScript","addDevToolbarApp","command","props","script","getMinifiedInlineScript","injectTypes","getTheme","setTheme","theme","state","getResolvedTheme","getSystemTheme","isForcedTheme","getThemes","onThemeChange","callback","handler","e","toggleTheme","resolved","index_default","integration"]}
|
|
1
|
+
{"version":3,"sources":["../src/integration.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import { defineIntegration } from \"astro-integration-kit\";\nimport { z } from \"astro/zod\";\nimport type { AstroThemesConfig, ThemeProviderProps } from \"./types.js\";\n\n// Options schema for the integration\nconst optionsSchema = z\n\t.object({\n\t\t/**\n\t\t * Enable the Dev Toolbar App for theme switching during development\n\t\t * @default true\n\t\t */\n\t\tdevToolbar: z.boolean().default(true),\n\t})\n\t.default({});\n\nexport const integration = defineIntegration({\n\tname: \"astro-themes\",\n\toptionsSchema,\n\tsetup({ options }) {\n\t\treturn {\n\t\t\thooks: {\n\t\t\t\t\"astro:config:setup\": ({\n\t\t\t\t\tlogger,\n\t\t\t\t\taddDevToolbarApp,\n\t\t\t\t\tcommand,\n\t\t\t\t}) => {\n\t\t\t\t\tlogger.info(\"astro-themes initialized\");\n\n\t\t\t\t\t// Add Dev Toolbar App in dev mode\n\t\t\t\t\tif (options.devToolbar && command === \"dev\") {\n\t\t\t\t\t\taddDevToolbarApp({\n\t\t\t\t\t\t\tid: \"astro-themes-toolbar\",\n\t\t\t\t\t\t\tname: \"Theme Switcher\",\n\t\t\t\t\t\t\ticon: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"4\"/><path d=\"M12 2v2\"/><path d=\"M12 20v2\"/><path d=\"m4.93 4.93 1.41 1.41\"/><path d=\"m17.66 17.66 1.41 1.41\"/><path d=\"M2 12h2\"/><path d=\"M20 12h2\"/><path d=\"m6.34 17.66-1.41 1.41\"/><path d=\"m19.07 4.93-1.41 1.41\"/></svg>`,\n\t\t\t\t\t\t\tentrypoint: \"@lpdsgn/astro-themes/toolbar\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tlogger.debug(\"Dev Toolbar App registered\");\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"astro:config:done\": ({ injectTypes }) => {\n\t\t\t\t\t// Inject global types for window.__ASTRO_THEMES__\n\t\t\t\t\tinjectTypes({\n\t\t\t\t\t\tfilename: \"types.d.ts\",\n\t\t\t\t\t\tcontent: `declare global {\n interface Window {\n __ASTRO_THEMES__?: {\n theme: string;\n resolvedTheme: string;\n systemTheme: \"dark\" | \"light\";\n forcedTheme?: string;\n themes: string[];\n setTheme: (theme: string | ((prevTheme: string) => string)) => void;\n };\n }\n}\nexport {};`,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport type { AstroThemesConfig, ThemeProviderProps };\n","/**\n * Client-side helpers for interacting with the theme\n * These are meant to be used in client-side scripts\n */\n\nimport type { ThemeState } from \"./types.js\";\n\ndeclare global {\n\tinterface Window {\n\t\t__ASTRO_THEMES__?: ThemeState;\n\t}\n}\n\n/**\n * Get the current theme state\n * Returns undefined if ThemeProvider is not mounted\n */\nexport function getTheme(): ThemeState | undefined {\n\tif (typeof window === \"undefined\") return undefined;\n\treturn window.__ASTRO_THEMES__;\n}\n\n/**\n * Set the theme\n * @param theme - Theme name or function that receives current theme and returns new theme\n */\nexport function setTheme(theme: string | ((prevTheme: string) => string)): void {\n\tconst state = getTheme();\n\tif (state) {\n\t\tstate.setTheme(theme);\n\t}\n}\n\n/**\n * Get the resolved theme (system theme resolved to actual value)\n */\nexport function getResolvedTheme(): string | undefined {\n\treturn getTheme()?.resolvedTheme;\n}\n\n/**\n * Get the system theme preference\n */\nexport function getSystemTheme(): \"dark\" | \"light\" | undefined {\n\treturn getTheme()?.systemTheme;\n}\n\n/**\n * Check if theme is forced for the current page\n */\nexport function isForcedTheme(): boolean {\n\treturn !!getTheme()?.forcedTheme;\n}\n\n/**\n * Get the list of available themes\n */\nexport function getThemes(): string[] {\n\treturn getTheme()?.themes ?? [];\n}\n\n/**\n * Subscribe to theme changes\n * @param callback - Function called when theme changes\n * @returns Cleanup function to unsubscribe\n */\nexport function onThemeChange(\n\tcallback: (detail: { theme: string; resolvedTheme: string }) => void\n): () => void {\n\tif (typeof window === \"undefined\") return () => {};\n\n\tconst handler = (e: CustomEvent<{ theme: string; resolvedTheme: string }>) => {\n\t\tcallback(e.detail);\n\t};\n\n\twindow.addEventListener(\"astro-themes:change\", handler as EventListener);\n\n\treturn () => {\n\t\twindow.removeEventListener(\"astro-themes:change\", handler as EventListener);\n\t};\n}\n\n/**\n * Toggle between light and dark themes\n * If current theme is neither light nor dark, switches to light\n */\nexport function toggleTheme(): void {\n\tconst state = getTheme();\n\tif (!state) return;\n\n\tconst resolved = state.resolvedTheme;\n\tstate.setTheme(resolved === \"light\" ? \"dark\" : \"light\");\n}\n","// Main integration export\nimport { integration } from \"./integration.js\";\n\nexport default integration;\n\n// Re-export integration\nexport { integration };\n\n// Re-export types\nexport type {\n\tAttribute,\n\tValueObject,\n\tScriptProps,\n\tThemeProviderProps,\n\tThemeState,\n\tAstroThemesConfig,\n} from \"./types.js\";\n\n// Re-export client helpers\nexport {\n\tgetTheme,\n\tsetTheme,\n\tgetResolvedTheme,\n\tgetSystemTheme,\n\tisForcedTheme,\n\tgetThemes,\n\tonThemeChange,\n\ttoggleTheme,\n} from \"./client.js\";\n"],"mappings":"AAAA,OAAS,qBAAAA,MAAyB,wBAClC,OAAS,KAAAC,MAAS,YAIlB,IAAMC,EAAgBD,EACpB,OAAO,CAKP,WAAYA,EAAE,QAAQ,EAAE,QAAQ,EAAI,CACrC,CAAC,EACA,QAAQ,CAAC,CAAC,EAECE,EAAcH,EAAkB,CAC5C,KAAM,eACN,cAAAE,EACA,MAAM,CAAE,QAAAE,CAAQ,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IAAOC,EAAQC","names":["defineIntegration","z","optionsSchema","integration","options","logger","addDevToolbarApp","command","injectTypes","getTheme","setTheme","theme","state","getResolvedTheme","getSystemTheme","isForcedTheme","getThemes","onThemeChange","callback","handler","e","toggleTheme","resolved","index_default","integration"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -97,16 +97,6 @@ interface ThemeState {
|
|
|
97
97
|
* Configuration for the astro-themes integration
|
|
98
98
|
*/
|
|
99
99
|
interface AstroThemesConfig {
|
|
100
|
-
/**
|
|
101
|
-
* Inject the flash-prevention script automatically via integration
|
|
102
|
-
* When true, you don't need to use ThemeProvider component for basic setup
|
|
103
|
-
* @default false
|
|
104
|
-
*/
|
|
105
|
-
injectScript?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Default props for the ThemeProvider component or injected script
|
|
108
|
-
*/
|
|
109
|
-
defaultProps?: Partial<ThemeProviderProps>;
|
|
110
100
|
/**
|
|
111
101
|
* Enable the Dev Toolbar App for theme switching during development
|
|
112
102
|
* @default true
|
package/package.json
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
2
|
+
"name": "@lpdsgn/astro-themes",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Perfect dark mode in Astro with no flash. System preference, multiple themes, and sync across tabs.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./components": {
|
|
13
|
+
"types": "./dist/components/index.d.ts",
|
|
14
|
+
"default": "./dist/components/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./components/ThemeProvider.astro": "./dist/components/ThemeProvider.astro",
|
|
17
|
+
"./client": {
|
|
18
|
+
"types": "./dist/client.d.ts",
|
|
19
|
+
"default": "./dist/client.js"
|
|
20
|
+
},
|
|
21
|
+
"./types": {
|
|
22
|
+
"types": "./dist/types.d.ts",
|
|
23
|
+
"default": "./dist/types.js"
|
|
24
|
+
},
|
|
25
|
+
"./toolbar": {
|
|
26
|
+
"types": "./dist/toolbar/app.d.ts",
|
|
27
|
+
"default": "./dist/toolbar/app.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"astro-integration",
|
|
35
|
+
"astro-component",
|
|
36
|
+
"withastro",
|
|
37
|
+
"astro",
|
|
38
|
+
"dark-mode",
|
|
39
|
+
"themes",
|
|
40
|
+
"theme-provider",
|
|
41
|
+
"next-themes"
|
|
42
|
+
],
|
|
43
|
+
"author": "",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/LPdsgn/astro-themes.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": "https://github.com/LPdsgn/astro-themes/issues",
|
|
49
|
+
"homepage": "https://github.com/LPdsgn/astro-themes#readme",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"astro": "^5.1.3"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"astro-integration-kit": "0.19.1",
|
|
56
|
+
"zod": "^4.3.5"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^25.0.8",
|
|
60
|
+
"tsup": "8.5.1"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"dev": "tsup --watch",
|
|
64
|
+
"build": "tsup && node -e \"require('fs').copyFileSync('src/components/index.d.ts', 'dist/components/index.d.ts')\""
|
|
65
|
+
}
|
|
66
|
+
}
|