|
9 | 9 | import { highlighter } from "$lib/shiki" |
10 | 10 | import File from "$lib/icons/_file.svelte" |
11 | 11 | import { copyToClipboard } from "$lib/utils" |
| 12 | + import Binary from "$lib/icons/binary.svelte" |
12 | 13 |
|
13 | 14 | let selected = $state<SupportedExport>("vscode") |
14 | 15 |
|
15 | | - type SupportedExport = "vscode" | "vim" | "filetypes" |
| 16 | + type SupportedExport = "vscode" | "vim" | "filetypes" | "base16" |
16 | 17 | type Exportable = { |
17 | 18 | name: string |
18 | 19 | Icon: Component |
|
33 | 34 | name: "Filetypes", |
34 | 35 | value: "filetypes", |
35 | 36 | Icon: File |
| 37 | + }, |
| 38 | + { |
| 39 | + name: "Base16", |
| 40 | + value: "base16", |
| 41 | + Icon: Binary |
36 | 42 | } |
37 | 43 | ] |
38 | 44 |
|
@@ -70,6 +76,30 @@ ${Object.entries($colors$) |
70 | 76 | { lang: "bash", theme: "theme" } |
71 | 77 | ) |
72 | 78 | } |
| 79 | +
|
| 80 | + async function createBase16Snippet() { |
| 81 | + const hl = await highlighter |
| 82 | +
|
| 83 | + return hl.codeToHtml( |
| 84 | + `base00: "${formatHex($colors$.base)}" # base |
| 85 | +base01: "${formatHex($colors$.mantle)}" # mantle |
| 86 | +base02: "${formatHex($colors$.surface0)}" # surface0 |
| 87 | +base03: "${formatHex($colors$.surface1)}" # surface1 |
| 88 | +base04: "${formatHex($colors$.surface2)}" # surface2 |
| 89 | +base05: "${formatHex($colors$.text)}" # text |
| 90 | +base06: "${formatHex($colors$.rosewater)}" # rosewater |
| 91 | +base07: "${formatHex($colors$.lavender)}" # lavender |
| 92 | +base08: "${formatHex($colors$.red)}" # red |
| 93 | +base09: "${formatHex($colors$.peach)}" # peach |
| 94 | +base0A: "${formatHex($colors$.yellow)}" # yellow |
| 95 | +base0B: "${formatHex($colors$.green)}" # green |
| 96 | +base0C: "${formatHex($colors$.teal)}" # teal |
| 97 | +base0D: "${formatHex($colors$.blue)}" # blue |
| 98 | +base0E: "${formatHex($colors$.mauve)}" # mauve |
| 99 | +base0F: "${formatHex($colors$.flamingo)}" # flamingo`, |
| 100 | + { lang: "bash", theme: "theme" } |
| 101 | + ) |
| 102 | + } |
73 | 103 | </script> |
74 | 104 |
|
75 | 105 | <svelte:head> |
@@ -134,6 +164,10 @@ ${Object.entries($colors$) |
134 | 164 | {#await createAppSnippet() then snippet} |
135 | 165 | {@render Code(snippet)} |
136 | 166 | {/await} |
| 167 | + {:else if selected === "base16"} |
| 168 | + {#await createBase16Snippet() then snippet} |
| 169 | + {@render Code(snippet)} |
| 170 | + {/await} |
137 | 171 | {/if} |
138 | 172 | </div> |
139 | 173 | </div> |
|
0 commit comments