lapikit 0.1.8 → 0.1.9
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,18 +1,36 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { BROWSER } from 'esm-env';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
colorSchemeSystem,
|
|
5
|
+
modalOpen,
|
|
6
|
+
setOpenModal,
|
|
7
|
+
updateThemeStore
|
|
8
|
+
} from '../../stores/index.js';
|
|
4
9
|
import type { Snippet } from 'svelte';
|
|
5
10
|
let { children }: { children: Snippet } = $props();
|
|
6
11
|
|
|
7
12
|
$effect.pre(() => {
|
|
8
13
|
if (!BROWSER) return;
|
|
14
|
+
// system
|
|
15
|
+
if (window.matchMedia) {
|
|
16
|
+
colorSchemeSystem.set(
|
|
17
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// listener
|
|
22
|
+
window
|
|
23
|
+
.matchMedia('(prefers-color-scheme: dark)')
|
|
24
|
+
.addEventListener('change', (event: MediaQueryListEvent) => {
|
|
25
|
+
colorSchemeSystem.set(event.matches ? 'dark' : 'light');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// local
|
|
9
29
|
const local = localStorage.getItem('@lapikit/theme');
|
|
10
|
-
if (local !== null) updateThemeStore(local as 'dark' | 'light' | '
|
|
30
|
+
if (local !== null) updateThemeStore(local as 'dark' | 'light' | 'system');
|
|
11
31
|
});
|
|
12
32
|
</script>
|
|
13
33
|
|
|
14
|
-
{$modalOpen ? ($modalOpen === 'persistent' ? 'persistent' : 'true') : 'false'}
|
|
15
|
-
|
|
16
34
|
{@render children?.()}
|
|
17
35
|
|
|
18
36
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
package/dist/preset.js
CHANGED
package/dist/stores/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type Writable } from 'svelte/store';
|
|
2
|
-
export declare const colorScheme: Writable<'
|
|
2
|
+
export declare const colorScheme: Writable<'system' | 'dark' | 'light'>;
|
|
3
|
+
export declare const colorSchemeSystem: Writable<'dark' | 'light'>;
|
|
3
4
|
export declare const modalOpen: Writable<boolean | 'persistent'>;
|
|
4
5
|
export declare const modalStack: Writable<string[]>;
|
|
5
|
-
export declare function updateThemeStore(update: '
|
|
6
|
-
export declare function setColorScheme(scheme: '
|
|
6
|
+
export declare function updateThemeStore(update: 'system' | 'dark' | 'light'): void;
|
|
7
|
+
export declare function setColorScheme(scheme: 'system' | 'dark' | 'light'): void;
|
|
7
8
|
export declare function setOpenModal(state: boolean | 'persistent'): void;
|
|
8
9
|
export declare const pushModal: (id: string) => void;
|
|
9
10
|
export declare const popModal: (id: string) => void;
|
package/dist/stores/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { disabledScroll } from '../internal/scroll.js';
|
|
2
2
|
import { writable } from 'svelte/store';
|
|
3
3
|
// states
|
|
4
|
-
const colorScheme_default = '
|
|
4
|
+
const colorScheme_default = 'system';
|
|
5
5
|
const modalOpen_default = false;
|
|
6
6
|
const isBrowser = typeof window !== 'undefined';
|
|
7
7
|
export const colorScheme = writable(colorScheme_default);
|
|
8
|
+
export const colorSchemeSystem = writable('light');
|
|
8
9
|
export const modalOpen = writable(modalOpen_default);
|
|
9
10
|
export const modalStack = writable([]);
|
|
10
11
|
export function updateThemeStore(update) {
|
|
11
12
|
colorScheme.update(() => {
|
|
12
13
|
if (isBrowser) {
|
|
13
14
|
const ref = document.documentElement.classList;
|
|
14
|
-
if (update === '
|
|
15
|
+
if (update === 'system')
|
|
15
16
|
ref.remove('light', 'dark');
|
|
16
17
|
else {
|
|
17
18
|
ref.remove(update === 'dark' ? 'light' : 'dark');
|
|
@@ -6,12 +6,12 @@ export const devices = (config) => {
|
|
|
6
6
|
tablet: config.breakpoints.tabletBreakpoint,
|
|
7
7
|
laptop: config.breakpoints.laptopBreakpoint
|
|
8
8
|
};
|
|
9
|
-
css += `@media screen and (max-width: ${setUnit(config.breakpoints.thresholds[list.
|
|
9
|
+
css += `@media screen and (max-width: ${setUnit(config.breakpoints.thresholds[list.mobile])}) {\n`;
|
|
10
10
|
css += `.hidden-mobile {\n`;
|
|
11
11
|
css += `display: none !important;\n`;
|
|
12
12
|
css += `}\n`;
|
|
13
13
|
css += `}\n`;
|
|
14
|
-
css += `@media screen and (min-width: ${setUnit(config.breakpoints.thresholds[list.
|
|
14
|
+
css += `@media screen and (min-width: ${setUnit(config.breakpoints.thresholds[list.mobile])}) {\n`;
|
|
15
15
|
css += `.display-mobile {\n`;
|
|
16
16
|
css += `display: none !important;\n`;
|
|
17
17
|
css += `}\n`;
|