|
1 | 1 | <script lang="ts"> |
2 | | - import Preview from '$lib/components/Preview.svelte'; |
3 | | - import { format } from '$lib/utils/format'; |
4 | | - import { PeriodType } from '$lib/utils/date'; |
| 2 | + import Preview from '$lib/components/Preview.svelte'; |
| 3 | + import { format } from '$lib/utils/format'; |
| 4 | + import { PeriodType } from '$lib/utils/date'; |
| 5 | + import Code from '$lib/components/Code.svelte'; |
5 | 6 |
|
6 | 7 | const date = new Date('1982-03-30T00:00:00'); |
7 | 8 | </script> |
8 | 9 |
|
9 | 10 | <h1>Usage</h1> |
10 | 11 |
|
11 | | -```svelte |
12 | | -<script> |
13 | | - import { format } from 'svelte-ux'; |
14 | | -</script> |
15 | | -``` |
| 12 | +<Code source={`import { format } from 'svelte-ux';`} language="javascript" class="mb-4" /> |
16 | 13 |
|
17 | 14 | <h1>Examples</h1> |
18 | 15 |
|
|
22 | 19 | <div>{format(1234.56, 'integer')}</div> |
23 | 20 | <div>{format(1234.56, 'decimal')}</div> |
24 | 21 | <div>{format(1234.56, 'currency')}</div> |
25 | | - <div>{format(.5678, 'percent')}</div> |
26 | | - <div>{format(.5678, 'percentRound')}</div> |
| 22 | + <div>{format(0.5678, 'percent')}</div> |
| 23 | + <div>{format(0.5678, 'percentRound')}</div> |
27 | 24 | <div>{format(1_234_567, 'metric')}</div> |
28 | 25 | <div>{format(1_200_000, 'metric')}</div> |
29 | | - <div>{format(.5678, 'percent', 1)}</div> |
| 26 | + <div>{format(0.5678, 'percent', 1)}</div> |
30 | 27 | </Preview> |
31 | 28 |
|
32 | 29 | <h2>Period formats</h2> |
|
0 commit comments