@ims360/svelte-ivory 0.4.0 → 0.4.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/dist/colorTheme.svelte.d.ts +1 -1
- package/dist/colorTheme.svelte.d.ts.map +1 -1
- package/dist/colorTheme.svelte.js +8 -3
- package/dist/components/basic/{ThemeController.svelte → ThemeSelect.svelte} +1 -1
- package/dist/components/basic/ThemeSelect.svelte.d.ts +8 -0
- package/dist/components/basic/ThemeSelect.svelte.d.ts.map +1 -0
- package/dist/components/basic/index.d.ts +1 -0
- package/dist/components/basic/index.d.ts.map +1 -1
- package/dist/components/basic/index.js +1 -0
- package/package.json +2 -2
- package/src/lib/colorTheme.svelte.ts +6 -3
- package/src/lib/components/basic/{ThemeController.svelte → ThemeSelect.svelte} +1 -1
- package/src/lib/components/basic/index.ts +1 -0
- package/dist/components/basic/ThemeController.svelte.d.ts +0 -8
- package/dist/components/basic/ThemeController.svelte.d.ts.map +0 -1
|
@@ -4,7 +4,7 @@ declare class ThemeController {
|
|
|
4
4
|
private currentTheme;
|
|
5
5
|
constructor();
|
|
6
6
|
get theme(): ColorThemePreference;
|
|
7
|
-
get
|
|
7
|
+
get current(): "light" | "dark";
|
|
8
8
|
set theme(value: ColorThemePreference);
|
|
9
9
|
/** Add to hook sequence to enable correct prerendering ot the theme */
|
|
10
10
|
handle: Handle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorTheme.svelte.d.ts","sourceRoot":"","sources":["../src/lib/colorTheme.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"colorTheme.svelte.d.ts","sourceRoot":"","sources":["../src/lib/colorTheme.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/D,cAAM,eAAe;IACjB,OAAO,CAAC,YAAY,CAA0C;;IAY9D,IAAI,KAAK,IAWQ,oBAAoB,CATpC;IAED,IAAI,OAAO,qBAKV;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,oBAAoB,EAepC;IAED,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAcZ;CACL;AAED,eAAO,MAAM,UAAU,iBAAwB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { browser } from '$app/environment';
|
|
2
|
-
import { cookie } from '
|
|
2
|
+
import { cookie } from './utils/functions';
|
|
3
3
|
const COOKIE_THEME_KEY = 'theme';
|
|
4
4
|
class ThemeController {
|
|
5
5
|
currentTheme = $state('system');
|
|
@@ -17,8 +17,13 @@ class ThemeController {
|
|
|
17
17
|
get theme() {
|
|
18
18
|
return this.currentTheme;
|
|
19
19
|
}
|
|
20
|
-
get
|
|
21
|
-
|
|
20
|
+
get current() {
|
|
21
|
+
if (this.currentTheme === 'dark' || this.currentTheme === 'light')
|
|
22
|
+
return this.currentTheme;
|
|
23
|
+
if (!browser)
|
|
24
|
+
return 'light';
|
|
25
|
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
26
|
+
return prefersDark ? 'dark' : 'light';
|
|
22
27
|
}
|
|
23
28
|
set theme(value) {
|
|
24
29
|
if (!browser)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ColorTheme, type ColorThemePreference } from '../../colorTheme.svelte';
|
|
3
|
-
import { merge } from '
|
|
3
|
+
import { merge } from '../../utils/functions';
|
|
4
4
|
import { Icon, Monitor, Moon, Sun } from '@lucide/svelte';
|
|
5
5
|
import type { ClassValue } from 'svelte/elements';
|
|
6
6
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
type Props = {
|
|
3
|
+
class: ClassValue;
|
|
4
|
+
};
|
|
5
|
+
declare const ThemeSelect: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type ThemeSelect = ReturnType<typeof ThemeSelect>;
|
|
7
|
+
export default ThemeSelect;
|
|
8
|
+
//# sourceMappingURL=ThemeSelect.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeSelect.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/basic/ThemeSelect.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9C,KAAK,KAAK,GAAG;IACT,KAAK,EAAE,UAAU,CAAC;CACrB,CAAC;AA6CN,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -2,5 +2,6 @@ export { default as Checkbox, type CheckboxProps } from './checkbox/Checkbox.sve
|
|
|
2
2
|
export { default as Element, type AnchorAttributes, type ButtonAttributes, type ElementProps } from './Element.svelte';
|
|
3
3
|
export { default as MarkedText, type MarkedTextProps } from './MarkedText.svelte';
|
|
4
4
|
export { default as Textarea } from './Textarea.svelte';
|
|
5
|
+
export { default as ThemeSelect } from './ThemeSelect.svelte';
|
|
5
6
|
export { default as Toggle, type ToggleProps } from './toggle/Toggle.svelte';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/basic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EACH,OAAO,IAAI,OAAO,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/basic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EACH,OAAO,IAAI,OAAO,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -2,4 +2,5 @@ export { default as Checkbox } from './checkbox/Checkbox.svelte';
|
|
|
2
2
|
export { default as Element } from './Element.svelte';
|
|
3
3
|
export { default as MarkedText } from './MarkedText.svelte';
|
|
4
4
|
export { default as Textarea } from './Textarea.svelte';
|
|
5
|
+
export { default as ThemeSelect } from './ThemeSelect.svelte';
|
|
5
6
|
export { default as Toggle } from './toggle/Toggle.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { browser } from '$app/environment';
|
|
2
|
-
import { cookie } from '@ims360/svelte-ivory/utils/functions';
|
|
3
2
|
import type { Handle } from '@sveltejs/kit';
|
|
3
|
+
import { cookie } from './utils/functions';
|
|
4
4
|
|
|
5
5
|
const COOKIE_THEME_KEY = 'theme';
|
|
6
6
|
|
|
@@ -23,8 +23,11 @@ class ThemeController {
|
|
|
23
23
|
return this.currentTheme;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
get
|
|
27
|
-
return this.currentTheme;
|
|
26
|
+
get current() {
|
|
27
|
+
if (this.currentTheme === 'dark' || this.currentTheme === 'light') return this.currentTheme;
|
|
28
|
+
if (!browser) return 'light';
|
|
29
|
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
30
|
+
return prefersDark ? 'dark' : 'light';
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
set theme(value: ColorThemePreference) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ColorTheme, type ColorThemePreference } from '$lib/colorTheme.svelte';
|
|
3
|
-
import { merge } from '
|
|
3
|
+
import { merge } from '$lib/utils/functions';
|
|
4
4
|
import { Icon, Monitor, Moon, Sun } from '@lucide/svelte';
|
|
5
5
|
import type { ClassValue } from 'svelte/elements';
|
|
6
6
|
|
|
@@ -7,4 +7,5 @@ export {
|
|
|
7
7
|
} from './Element.svelte';
|
|
8
8
|
export { default as MarkedText, type MarkedTextProps } from './MarkedText.svelte';
|
|
9
9
|
export { default as Textarea } from './Textarea.svelte';
|
|
10
|
+
export { default as ThemeSelect } from './ThemeSelect.svelte';
|
|
10
11
|
export { default as Toggle, type ToggleProps } from './toggle/Toggle.svelte';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ClassValue } from 'svelte/elements';
|
|
2
|
-
type Props = {
|
|
3
|
-
class: ClassValue;
|
|
4
|
-
};
|
|
5
|
-
declare const ThemeController: import("svelte").Component<Props, {}, "">;
|
|
6
|
-
type ThemeController = ReturnType<typeof ThemeController>;
|
|
7
|
-
export default ThemeController;
|
|
8
|
-
//# sourceMappingURL=ThemeController.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeController.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/basic/ThemeController.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9C,KAAK,KAAK,GAAG;IACT,KAAK,EAAE,UAAU,CAAC;CACrB,CAAC;AA6CN,QAAA,MAAM,eAAe,2CAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|