@likable-hair/svelte 3.0.7 → 3.0.10

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/dist/index.d.ts CHANGED
@@ -42,6 +42,7 @@ export { default as ProgressBar } from './components/simple/progress/ProgressBar
42
42
  export { default as ProductCard } from './components/composed/shop/ProductCard.svelte';
43
43
  export { default as ProductsGrid } from './components/composed/shop/ProductsGrid.svelte';
44
44
  export { default as mediaQuery } from './stores/mediaQuery';
45
+ export { default as theme, toggleTheme, setTheme } from './stores/theme';
45
46
  export { default as SimpleTimeLine } from './components/simple/timeline/SimpleTimeLine.svelte';
46
47
  export { default as CollapsibleSideBarLayout } from './components/layouts/CollapsibleSideBarLayout.svelte';
47
48
  export { default as StableDividedSideBarLayout } from './components/layouts/StableDividedSideBarLayout.svelte';
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ export { default as ProgressBar } from './components/simple/progress/ProgressBar
42
42
  export { default as ProductCard } from './components/composed/shop/ProductCard.svelte';
43
43
  export { default as ProductsGrid } from './components/composed/shop/ProductsGrid.svelte';
44
44
  export { default as mediaQuery } from './stores/mediaQuery';
45
+ export { default as theme, toggleTheme, setTheme } from './stores/theme';
45
46
  export { default as SimpleTimeLine } from './components/simple/timeline/SimpleTimeLine.svelte';
46
47
  export { default as CollapsibleSideBarLayout } from './components/layouts/CollapsibleSideBarLayout.svelte';
47
48
  export { default as StableDividedSideBarLayout } from './components/layouts/StableDividedSideBarLayout.svelte';
@@ -11,12 +11,22 @@ export type Shades = {
11
11
  900: string;
12
12
  };
13
13
  type Colors = Record<string, {
14
- background?: Shades;
15
- contrast?: Shades;
16
- primary?: Shades;
17
- secondary?: Shades;
18
- error?: Shades;
19
- warning?: Shades;
14
+ dark: {
15
+ background?: Shades;
16
+ contrast?: Shades;
17
+ primary?: Shades;
18
+ secondary?: Shades;
19
+ error?: Shades;
20
+ warning?: Shades;
21
+ };
22
+ light: {
23
+ background?: Shades;
24
+ contrast?: Shades;
25
+ primary?: Shades;
26
+ secondary?: Shades;
27
+ error?: Shades;
28
+ warning?: Shades;
29
+ };
20
30
  }>;
21
31
  type ThemeStore = {
22
32
  colors?: Colors;
@@ -1,8 +1,8 @@
1
1
  import { writable } from 'svelte/store';
2
2
  import { BROWSER } from 'esm-env';
3
3
  const theme = writable({
4
- active: 'light',
5
- disabled: true,
4
+ active: 'default',
5
+ disabled: false,
6
6
  dark: false
7
7
  });
8
8
  if (BROWSER) {
@@ -21,6 +21,18 @@ if (BROWSER) {
21
21
  return v;
22
22
  });
23
23
  }
24
+ else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
25
+ theme.update((v) => {
26
+ v.dark = true;
27
+ return v;
28
+ });
29
+ }
30
+ else {
31
+ theme.update((v) => {
32
+ v.dark = false;
33
+ return v;
34
+ });
35
+ }
24
36
  }
25
37
  export function setTheme(th) {
26
38
  localStorage.setItem('theme', th);
@@ -63,7 +75,7 @@ theme.subscribe(value => {
63
75
  styleTag = document.createElement("style");
64
76
  let styleBuilder = `:root {`;
65
77
  if (!!value.colors) {
66
- const activeTheme = value.active || 'light';
78
+ const activeTheme = value.active || 'default';
67
79
  if (!!value.colors[activeTheme]) {
68
80
  for (const [colorType, shades] of Object.entries(value.colors[activeTheme])) {
69
81
  for (const [shade, color] of Object.entries(shades)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likable-hair/svelte",
3
3
  "description": "A Svelte component for likablehair",
4
- "version": "3.0.7",
4
+ "version": "3.0.10",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run package",