@swr-data-lab/components 2.13.1 → 2.14.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.
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">import { shades, semantics } from './Tokens';
2
- let { children } = $props();
2
+ import isDarkMode from '../isDarkMode';
3
+ let { theme = 'auto', children } = $props();
4
+ let computedTheme = $derived(theme === 'auto' ? ($isDarkMode ? 'dark' : 'light') : theme);
3
5
  const colours = { ...shades, ...semantics };
4
6
  const rules = [
5
7
  ...Object.keys(colours).map((key) => {
@@ -15,7 +17,7 @@ const rules = [
15
17
  ];
16
18
  </script>
17
19
 
18
- <div class="container" style={rules.join(';')}>
20
+ <div class="container" style={rules.join(';')} data-theme={computedTheme}>
19
21
  {#if children}
20
22
  {@render children()}
21
23
  {/if}
@@ -41,15 +43,13 @@ const rules = [
41
43
  --color-pageFill: var(--pageFill-light);
42
44
  --color-surfaceFill: var(--surfaceFill-light);
43
45
  }
44
- @media (prefers-color-scheme: dark) {
45
- .container {
46
- --color-logoFill: var(--logoFill-dark);
47
- --color-pageFill: var(--pageFill-dark);
48
- --color-surfaceFill: var(--surfaceFill-dark);
49
- --color-textPrimary: var(--textPrimary-dark);
50
- --color-textSecondary: var(--textSecondary-dark);
51
- --color-textSecondaryHover: var(--textSecondaryHover-dark);
52
- }
46
+ .container[data-theme=dark] {
47
+ --color-logoFill: var(--logoFill-dark);
48
+ --color-pageFill: var(--pageFill-dark);
49
+ --color-surfaceFill: var(--surfaceFill-dark);
50
+ --color-textPrimary: var(--textPrimary-dark);
51
+ --color-textSecondary: var(--textSecondary-dark);
52
+ --color-textSecondaryHover: var(--textSecondaryHover-dark);
53
53
  }
54
54
  .container {
55
55
  --swr-text: "SWR-VAR-Text", sans-serif;
@@ -1,5 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  interface DesignTokensProps {
3
+ theme?: 'light' | 'dark' | 'auto';
3
4
  children?: Snippet;
4
5
  }
5
6
  declare const DesignTokens: import("svelte").Component<DesignTokensProps, {}, "">;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as DesignTokens } from "./DesignTokens/DesignTokens.svelte";
2
2
  export { tokens } from "./DesignTokens/index.js";
3
+ export { default as isDarkMode } from "./isDarkMode/isDarkMode.svelte";
3
4
  export { default as Headline } from "./Headline/Headline.svelte";
4
5
  export { default as Copy } from "./Copy/Copy.svelte";
5
6
  export { default as Caption } from "./Caption/Caption.svelte";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // Design Tokens
2
2
  export { default as DesignTokens } from './DesignTokens/DesignTokens.svelte';
3
3
  export { tokens as tokens } from './DesignTokens/index.js';
4
+ export { default as isDarkMode } from './isDarkMode/isDarkMode.svelte';
4
5
 
5
6
  // Typography
6
7
  export { default as Headline } from './Headline/Headline.svelte';
@@ -0,0 +1,2 @@
1
+ export default isDarkMode;
2
+ import isDarkMode from './isDarkMode.svelte.js';
@@ -0,0 +1,2 @@
1
+ import isDarkMode from './isDarkMode.svelte.js';
2
+ export default isDarkMode;
@@ -0,0 +1,2 @@
1
+ export default isDarkMode;
2
+ declare const isDarkMode: import("svelte/store").Readable<boolean>;
@@ -0,0 +1,6 @@
1
+ import { MediaQuery } from 'svelte/reactivity';
2
+ import { readable } from 'svelte/store';
3
+
4
+ const dm = new MediaQuery('prefers-color-scheme: dark', false);
5
+ const isDarkMode = readable(dm.current);
6
+ export default isDarkMode;
@@ -32,10 +32,8 @@ onDestroy(() => tooltip.remove());
32
32
  <style>.container {
33
33
  background: white;
34
34
  padding: 0.75em;
35
- border-radius: 2px;
36
35
  border: 1px solid rgba(0, 0, 0, 0.75);
37
- border-radius: var(--br-small);
38
- filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.1));
36
+ filter: drop-shadow(2px 2px 1px rgba(0, 0, 0, 0.1));
39
37
  pointer-events: none;
40
38
  }
41
39
 
@@ -98,23 +96,24 @@ onDestroy(() => tooltip.remove());
98
96
  }
99
97
  :global(.maplibregl-popup-close-button) {
100
98
  position: absolute;
101
- top: 0.5em;
102
- right: 0.5em;
99
+ top: 0.35em;
100
+ right: 0.35em;
103
101
  cursor: pointer;
104
102
  border-radius: 2px;
105
103
  display: flex;
106
104
  justify-content: center;
107
105
  align-items: center;
108
106
  padding-bottom: 0.15em;
109
- font-size: 1.25rem;
107
+ font-size: 1.2rem;
110
108
  width: 1.1em;
111
109
  height: 1.1em;
112
110
  z-index: 100;
113
111
  background: white;
112
+ color: var(--gray-dark-5);
114
113
  border: 1px solid var(--gray-dark-5);
115
114
  }
116
115
  :global(.maplibregl-popup-close-button:hover),
117
- :global(.maplibregl-popup-close-button:focus) {
116
+ :global(.maplibregl-popup-close-button:focus-visible) {
118
117
  background: var(--gray-light-5);
119
118
  }
120
119
  :global(.maplibregl-popup-tip) {
@@ -122,7 +121,7 @@ onDestroy(() => tooltip.remove());
122
121
  height: 0.65rem;
123
122
  background: white;
124
123
  position: absolute;
125
- border-right: 1px solid rgba(0, 0, 0, 0.75);
126
- border-bottom: 1px solid rgba(0, 0, 0, 0.75);
124
+ border-right: 1px solid var(--gray-dark-5);
125
+ border-bottom: 1px solid var(--gray-dark-5);
127
126
  z-index: 10;
128
127
  }</style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swr-data-lab/components",
3
3
  "description": "SWR Data Lab component library",
4
- "version": "2.13.1",
4
+ "version": "2.14.0",
5
5
  "author": "SWR Data Lab",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",