Skip to content

Commit 69dd826

Browse files
committed
Start to improve getting started docs
1 parent a6d0aeb commit 69dd826

4 files changed

Lines changed: 160 additions & 98 deletions

File tree

packages/layerchart/src/routes/getting-started/+layout.svelte

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/layerchart/src/routes/getting-started/+page.md

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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+
Follow the <a href="https://svelte-ux.techniq.dev/">Svelte UX</a> instructions to create a new
27+
project
28+
</div>
29+
30+
<div>Install <code>layerchart</code> package</div>
31+
<Code source={`npm install layerchart`} language="sh" />
32+
33+
<div>Update LayerChart components to <code>tailwind.config.cjs</code> content</div>
34+
<Code
35+
source={`module.exports = {
36+
content: [
37+
'./src/**/*.{html,svelte}',
38+
'./node_modules/svelte-ux/**/*.{svelte,js}',
39+
'./node_modules/layerchart/**/*.{svelte,js}' // <--- Add this
40+
],
41+
};`}
42+
language="js"
43+
/>
44+
{:else if selectedTab === 'standalone'}
45+
<div>
46+
Follow the Tailwind <a href="https://tailwindcss.com/docs/guides/sveltekit" target="_blank">
47+
guide
48+
</a> to setup a new SvelteKit project with Tailwind.
49+
</div>
50+
51+
<div>OR</div>
52+
53+
<div>Start a new project SvelteKit project</div>
54+
<Code source={`npm create svelte@latest`} language="sh" />
55+
56+
<div>Install <code>layerchart</code> package</div>
57+
<Code source={`npm install layerchart`} language="sh" />
58+
59+
<div>
60+
Add and setup Tailwind using <a
61+
href="https://github.com/svelte-add/tailwindcss"
62+
target="_blank"
63+
>
64+
svelte-add
65+
</a>
66+
</div>
67+
<Code source={`npx svelte-add@latest tailwindcss`} language="sh" />
68+
{:else if selectedTab === 'manual'}
69+
<div>
70+
Follow the Tailwind <a href="https://tailwindcss.com/docs/guides/sveltekit" target="_blank">
71+
guide
72+
</a> to setup a new SvelteKit project with Tailwind.
73+
</div>
74+
75+
<div>Add Svelte UX package</div>
76+
<Code source={`npm install svelte-ux`} language="sh" />
77+
{/if}
78+
</div>
79+
80+
<h2>Usage</h2>
81+
82+
<p>LayerChart components can be easily imported into your project.</p>
83+
84+
<Code
85+
source={`<script>
86+
import { Chart, Svg, Axis, Bars } from 'layerchart';
87+
</script>`}
88+
language="svelte"
89+
/>
90+
91+
<p>
92+
Search docs using <Kbd command class="text-xs">K</Kbd> or browse using the sidebar navigation.
93+
</p>
94+
95+
<h2>Examples</h2>
96+
97+
<p>
98+
This site has many examples of creating visualizations using LayerChart components. Below each
99+
example has a <strong>Show code</strong> link that displays the code for that visualization.
100+
</p>
101+
102+
<p>
103+
The examples do not currently show the importing of LayerChart components, utilties, external
104+
libraries (i.e.<code>{'<script>'}</code>
105+
block). You can view the full page source by clicking on **Page source** at the top of each examples
106+
page. This will show you all of the imports used for that page.
107+
<Blockquote>
108+
<div>
109+
<strong>Note:</strong> This site is built directly from LayerChart's codebase and does not
110+
<code>npm install layerchart</code>. Therefore it imports components from LayerChart
111+
differently.
112+
</div>
113+
</Blockquote>
114+
</p>
115+
116+
<p>The page source will show:</p>
117+
<Code
118+
source={`import Chart, { Svg } from '$lib/components/Chart.svelte';
119+
import Axis from '$lib/components/Axis.svelte';
120+
import Bars from '$lib/components/Bars.svelte';`}
121+
language="js"
122+
/>
123+
124+
<p>If you followed instructions to `npm install layerchart` your code should be:</p>
125+
<Code source={`import { Chart, Svg, Axis, Bars } from 'layerchart';`} language="js" />
126+
127+
<h2>Layer Cake</h2>
128+
129+
It is also recommmended to read through
130+
<a href="https://layercake.graphics/">Layer Cake</a>'s documentation for a deeper understanding of
131+
how LayerChart works.
132+
133+
<h2>Svelte UX</h2>
134+
135+
Lastly, take a look at the complement project
136+
<a href="https://svelte-ux.techniq.dev/">Svelte UX</a> for a large collection of Svelte components,
137+
actions, stores, and utilities to build highly interactive applications.
138+
</div>

packages/layerchart/tailwind.config.cjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,28 @@ module.exports = {
2020
// },
2121
},
2222
theme: {
23-
extend: {},
23+
extend: {
24+
typography: (theme) => ({
25+
DEFAULT: {
26+
css: {
27+
// Reduce font size
28+
h1: {
29+
fontSize: theme('fontSize.2xl')[0],
30+
fontWeight: theme('fontWeight.extrabold'),
31+
},
32+
h2: {
33+
fontSize: theme('fontSize.xl')[0],
34+
fontWeight: theme('fontWeight.bold'),
35+
marginTop: theme('spacing.3'),
36+
},
37+
h3: {
38+
fontSize: theme('fontSize.lg')[0],
39+
fontWeight: theme('fontWeight.semibold'),
40+
},
41+
},
42+
},
43+
}),
44+
},
2445
},
2546
plugins: [require('@tailwindcss/typography'), svelteUx],
2647
};

0 commit comments

Comments
 (0)