layerchart 0.15.1 → 0.15.3

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,6 +1,33 @@
1
1
  <script>
2
- // TODO: Improve code highlighting, add quick copy buttons, support REPL, etc
3
- // console.log($$props, $$slots);
2
+ import Prism from 'prismjs';
3
+ import 'prism-svelte';
4
+ import { mdiContentCopy } from '@mdi/js';
5
+ import { Button } from 'svelte-ux';
6
+ import { cls } from 'svelte-ux/utils/styles';
7
+ export let code = null;
8
+ export let language = 'svelte';
9
+ export let highlightedCode = code
10
+ ? Prism.highlight(code, Prism.languages[language], language)
11
+ : '';
4
12
  </script>
5
13
 
6
- <slot />
14
+ <div class={cls('rounded', $$restProps.class)}>
15
+ {#if code}
16
+ <div class="relative">
17
+ <pre class="language-{language} rounded" style="margin: 0; white-space: normal;">
18
+ <code class="language-{language}">{@html highlightedCode}</code>
19
+ </pre>
20
+
21
+ <div class="absolute top-0 right-0 p-2">
22
+ <Button
23
+ icon={mdiContentCopy}
24
+ class="text-white/70 hover:bg-white/20 py-1"
25
+ size="sm"
26
+ on:click={() => navigator.clipboard.writeText(code ?? '')}
27
+ >
28
+ Copy
29
+ </Button>
30
+ </div>
31
+ </div>
32
+ {/if}
33
+ </div>
@@ -2,12 +2,13 @@
2
2
  /** @typedef {typeof __propDef.events} CodeEvents */
3
3
  /** @typedef {typeof __propDef.slots} CodeSlots */
4
4
  export default class Code extends SvelteComponentTyped<{
5
- [x: string]: never;
5
+ [x: string]: any;
6
+ code?: null | undefined;
7
+ language?: string | undefined;
8
+ highlightedCode?: any;
6
9
  }, {
7
10
  [evt: string]: CustomEvent<any>;
8
- }, {
9
- default: {};
10
- }> {
11
+ }, {}> {
11
12
  }
12
13
  export type CodeProps = typeof __propDef.props;
13
14
  export type CodeEvents = typeof __propDef.events;
@@ -15,13 +16,14 @@ export type CodeSlots = typeof __propDef.slots;
15
16
  import { SvelteComponentTyped } from "svelte";
16
17
  declare const __propDef: {
17
18
  props: {
18
- [x: string]: never;
19
+ [x: string]: any;
20
+ code?: null | undefined;
21
+ language?: string | undefined;
22
+ highlightedCode?: any;
19
23
  };
20
24
  events: {
21
25
  [evt: string]: CustomEvent<any>;
22
26
  };
23
- slots: {
24
- default: {};
25
- };
27
+ slots: {};
26
28
  };
27
29
  export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Sean Lynch <techniq35@gmail.com>",
4
4
  "license": "MIT",
5
5
  "repository": "techniq/layerchart",
6
- "version": "0.15.1",
6
+ "version": "0.15.3",
7
7
  "scripts": {
8
8
  "dev": "vite dev",
9
9
  "build": "vite build",
@@ -73,7 +73,7 @@
73
73
  "layercake": "^7.4.0",
74
74
  "lodash-es": "^4.17.21",
75
75
  "svelte": "^3.58.0",
76
- "svelte-ux": "^0.33.6",
76
+ "svelte-ux": "^0.34.0",
77
77
  "topojson-client": "^3.1.0"
78
78
  },
79
79
  "main": "./dist/index.js",