|
| 1 | +<script lang="ts"> |
| 2 | + import { ToggleGroup, ToggleOption, Kbd } from 'svelte-ux'; |
| 3 | +
|
| 4 | + import Code from '$lib/docs/Code.svelte'; |
| 5 | + import Blockquote from '$lib/docs/Blockquote.svelte'; |
| 6 | +
|
| 7 | + let selectedTab = 'svelte-ux'; |
| 8 | +</script> |
| 9 | + |
| 10 | +<div class="prose max-w-none bg-surface-100 rounded border p-4 mt-4 m-2"> |
| 11 | + <h1>Getting started</h1> |
| 12 | + |
| 13 | + <h2>Installation</h2> |
| 14 | + <ToggleGroup |
| 15 | + bind:value={selectedTab} |
| 16 | + variant="underline" |
| 17 | + classes={{ options: 'justify-start h-10 mb-3' }} |
| 18 | + > |
| 19 | + <ToggleOption value="svelte-ux">with Svelte UX</ToggleOption> |
| 20 | + <ToggleOption value="standalone">Standalone</ToggleOption> |
| 21 | + </ToggleGroup> |
| 22 | + |
| 23 | + <div class="grid gap-3"> |
| 24 | + {#if selectedTab === 'svelte-ux'} |
| 25 | + <div> |
| 26 | + <h2>Setup project</h2> |
| 27 | + <p> |
| 28 | + Follow the |
| 29 | + <a href="https://svelte-ux.techniq.dev/">Svelte UX</a> instructions to create a new project |
| 30 | + </p> |
| 31 | + </div> |
| 32 | + {:else if selectedTab === 'standalone'} |
| 33 | + <div> |
| 34 | + <h2>Setup project</h2> |
| 35 | + Use can use LayerChart with your existing project, such as |
| 36 | + <a href="https://www.skeleton.dev/" target="_blank">Skeleton</a>, |
| 37 | + <a href="https://www.shadcn-svelte.com/" target="_blank">shadcn-svelte</a>, or |
| 38 | + <a href="https://daisyui.com/" target="_blank">Daisy UI</a>, although we are still |
| 39 | + evaluating the best integration approach and would love your feedback (<a |
| 40 | + href="https://discord.gg/697JhMPD3t" |
| 41 | + target="_blank">Discord</a |
| 42 | + > |
| 43 | + or <a href="https://github.com/techniq/layerchart/pulls" target="_blank">pull requests</a>). |
| 44 | + |
| 45 | + <p> |
| 46 | + You can also create a new Tailwind project following their |
| 47 | + <a href="https://tailwindcss.com/docs/guides/sveltekit" target="_blank">guide</a> |
| 48 | + or use |
| 49 | + <a href="https://github.com/svelte-add/tailwindcss" target="_blank">svelte-add</a>. |
| 50 | + </p> |
| 51 | + |
| 52 | + <Blockquote> |
| 53 | + <div> |
| 54 | + Ongoing investigation to support non-Tailwind projects is being investigated, including |
| 55 | + using <a href="https://unocss.dev/" target="_blank">UnoCSS</a> or vanilla CSS, but they are |
| 56 | + undocumented and unsupported at this time. |
| 57 | + </div> |
| 58 | + </Blockquote> |
| 59 | + </div> |
| 60 | + {:else if selectedTab === 'manual'} |
| 61 | + <div> |
| 62 | + Follow the Tailwind <a href="https://tailwindcss.com/docs/guides/sveltekit" target="_blank"> |
| 63 | + guide |
| 64 | + </a> to setup a new SvelteKit project with Tailwind. |
| 65 | + </div> |
| 66 | + |
| 67 | + <div>Add Svelte UX package</div> |
| 68 | + <Code source={`npm install svelte-ux`} language="sh" /> |
| 69 | + {/if} |
| 70 | + </div> |
| 71 | + |
| 72 | + <h2>Install package</h2> |
| 73 | + |
| 74 | + <div>Install <code>layerchart</code> package</div> |
| 75 | + <Code source={`npm install layerchart`} language="sh" /> |
| 76 | + |
| 77 | + <Blockquote> |
| 78 | + <div> |
| 79 | + <div class="mb-1"> |
| 80 | + Depending on the example, you will typically need additional <code>d3</code> packages such |
| 81 | + as <code>d3-scale</code> and <code>d3-array</code> |
| 82 | + </div> |
| 83 | + <Code source={`npm install d3-scale d3-array`} language="sh" /> |
| 84 | + </div> |
| 85 | + </Blockquote> |
| 86 | + |
| 87 | + <div>Update LayerChart components to <code>tailwind.config.cjs</code> content</div> |
| 88 | + <Code |
| 89 | + source={`module.exports = { |
| 90 | + content: [ |
| 91 | + './src/**/*.{html,svelte}', |
| 92 | + './node_modules/svelte-ux/**/*.{svelte,js}', |
| 93 | + './node_modules/layerchart/**/*.{svelte,js}' // <--- Add this |
| 94 | + ], |
| 95 | +};`} |
| 96 | + language="js" |
| 97 | + /> |
| 98 | + |
| 99 | + <h2>Usage</h2> |
| 100 | + |
| 101 | + <p>LayerChart components can be easily imported into your project.</p> |
| 102 | + |
| 103 | + <Code |
| 104 | + source={`<script> |
| 105 | + import { Chart, Svg, Axis, Bars } from 'layerchart'; |
| 106 | +</script>`} |
| 107 | + language="svelte" |
| 108 | + /> |
| 109 | + |
| 110 | + <p> |
| 111 | + Search docs using <Kbd command class="text-xs">K</Kbd> or browse using the sidebar navigation. |
| 112 | + </p> |
| 113 | + |
| 114 | + <h2>Examples</h2> |
| 115 | + |
| 116 | + <p> |
| 117 | + This site has many examples of creating visualizations using LayerChart components. Below each |
| 118 | + example has a <strong>Show code</strong> link that displays the code for that visualization. |
| 119 | + </p> |
| 120 | + |
| 121 | + <p> |
| 122 | + The examples do not currently show the importing of LayerChart components, utilties, or external |
| 123 | + libraries (i.e.<code>{'<script>'}</code> |
| 124 | + block). You can view the full page source by clicking on <strong>Page source</strong> at the top |
| 125 | + of each examples page. This will show you all of the imports used for that page. |
| 126 | + <Blockquote> |
| 127 | + <div> |
| 128 | + <strong>Note:</strong> This site is built directly from LayerChart's codebase and does not |
| 129 | + <code>npm install layerchart</code>. Therefore it imports components from LayerChart |
| 130 | + differently. |
| 131 | + </div> |
| 132 | + </Blockquote> |
| 133 | + </p> |
| 134 | + |
| 135 | + <p>The page source will show:</p> |
| 136 | + <Code |
| 137 | + source={`import Chart, { Svg } from '$lib/components/Chart.svelte'; |
| 138 | +import Axis from '$lib/components/Axis.svelte'; |
| 139 | +import Bars from '$lib/components/Bars.svelte';`} |
| 140 | + language="js" |
| 141 | + /> |
| 142 | + |
| 143 | + <p>If you followed instructions to `npm install layerchart` your code should be:</p> |
| 144 | + <Code source={`import { Chart, Svg, Axis, Bars } from 'layerchart';`} language="js" /> |
| 145 | + |
| 146 | + <h2>Layer Cake</h2> |
| 147 | + |
| 148 | + It is also recommmended to read through |
| 149 | + <a href="https://layercake.graphics/">Layer Cake</a>'s documentation for a deeper understanding of |
| 150 | + how LayerChart works. |
| 151 | + |
| 152 | + <h2>Svelte UX</h2> |
| 153 | + |
| 154 | + Lastly, take a look at the complement project |
| 155 | + <a href="https://svelte-ux.techniq.dev/">Svelte UX</a> for a large collection of Svelte components, |
| 156 | + actions, stores, and utilities to build highly interactive applications. |
| 157 | +</div> |
0 commit comments