svelteplot 0.7.0-pr-275.6 → 0.7.0-pr-276.1

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,4 +1,5 @@
1
1
  type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
2
+ export declare function loadCSV(fetch: Fetch, dataset: string): Promise<any[]>;
2
3
  export declare function loadJSON(fetch: Fetch, dataset: string): Promise<any>;
3
4
  /**
4
5
  * helper function used in the SveltePlot docs to load example datasets
@@ -1,5 +1,5 @@
1
1
  import { csvParse, autoType } from 'd3-dsv';
2
- async function loadCSV(fetch, dataset) {
2
+ export async function loadCSV(fetch, dataset) {
3
3
  const res = await fetch(`/data/${dataset}.csv`);
4
4
  const text = await res.text();
5
5
  return csvParse(text, autoType);
@@ -1,14 +1,28 @@
1
1
  <script>
2
2
  import { resolve } from '$app/paths';
3
+ import { useDark } from './isDark.svelte';
3
4
  let { examples } = $props();
5
+
6
+ const exampleImages = import.meta.glob('../../snapshots/*/*.png', {
7
+ eager: true,
8
+ query: {
9
+ enhanced: true,
10
+ w: 640
11
+ }
12
+ });
13
+
14
+ const ds = useDark();
4
15
  </script>
5
16
 
6
17
  <div class="list">
7
18
  {#each examples as page, i (i)}
8
19
  <a href={resolve(page.url)}>
9
20
  <div>
10
- {#if page.screenshot}
11
- <img src={page.screenshot} alt={page.title} />{/if}
21
+ <enhanced:img
22
+ src={ds.isDark
23
+ ? exampleImages[`../../snapshots/${page.key}.dark.png`].default.img.src
24
+ : exampleImages[`../../snapshots/${page.key}.png`].default.img.src}
25
+ alt={page.title} />
12
26
  </div>
13
27
  <h4>
14
28
  {page.title}
@@ -49,7 +63,7 @@
49
63
  }
50
64
  }
51
65
 
52
- .list img {
66
+ .list :global(img) {
53
67
  width: 100%;
54
68
  box-sizing: border-box;
55
69
  border-radius: 3px;
@@ -1,7 +1,8 @@
1
1
  <script lang="ts">
2
2
  import { resolve } from '$app/paths';
3
+ import { useDark } from './isDark.svelte';
3
4
 
4
- const exampleImages = import.meta.glob('../../../static/examples/*/*.png', {
5
+ const exampleImages = import.meta.glob('../../snapshots/*/*.png', {
5
6
  eager: true,
6
7
  query: {
7
8
  enhanced: true,
@@ -11,8 +12,7 @@
11
12
 
12
13
  let {
13
14
  paths,
14
- pages,
15
- isDark
15
+ pages
16
16
  }: {
17
17
  paths: Record<string, string[]>;
18
18
  pages: Record<
@@ -24,9 +24,10 @@
24
24
  transforms?: string[];
25
25
  }
26
26
  >;
27
- isDark: boolean;
28
27
  } = $props();
29
28
 
29
+ const ds = useDark();
30
+
30
31
  function sortPages(a: string, b: string) {
31
32
  const sortA = pages[a].sortKey ?? 10;
32
33
  const sortB = pages[b].sortKey ?? 10;
@@ -53,9 +54,9 @@
53
54
  <enhanced:img
54
55
  title={pages[page].title}
55
56
  src={exampleImages[
56
- `../../../static/examples/${page
57
+ `../../snapshots/${page
57
58
  .replace('./', '')
58
- .replace('.svelte', isDark ? '.dark.png' : '.png')}`
59
+ .replace('.svelte', ds.isDark ? '.dark.png' : '.png')}`
59
60
  ].default}
60
61
  alt={pages[page].title} />
61
62
  <div class="title">{pages[page].title}</div>
@@ -6,7 +6,6 @@ type $$ComponentProps = {
6
6
  sortKey?: number;
7
7
  transforms?: string[];
8
8
  }>;
9
- isDark: boolean;
10
9
  };
11
10
  declare const ExamplesPagePreview: import("svelte").Component<$$ComponentProps, {}, "">;
12
11
  type ExamplesPagePreview = ReturnType<typeof ExamplesPagePreview>;
@@ -0,0 +1,6 @@
1
+ declare class DarkState {
2
+ isDark: boolean;
3
+ constructor();
4
+ }
5
+ export declare function useDark(): DarkState;
6
+ export {};
@@ -0,0 +1,10 @@
1
+ class DarkState {
2
+ isDark = $state(false);
3
+ constructor() {
4
+ this.isDark = false;
5
+ }
6
+ }
7
+ const darkState = new DarkState();
8
+ export function useDark() {
9
+ return darkState;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.7.0-pr-275.6",
3
+ "version": "0.7.0-pr-276.1",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",