From 1696cf0da6370a7605b315b40458511710e00184 Mon Sep 17 00:00:00 2001 From: Sean Lynch Date: Fri, 17 Nov 2023 21:36:05 -0500 Subject: [PATCH] Add format() playground --- .../src/routes/docs/utils/format/+page.svelte | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/packages/svelte-ux/src/routes/docs/utils/format/+page.svelte b/packages/svelte-ux/src/routes/docs/utils/format/+page.svelte index 7e44e4b25..e1839e59e 100644 --- a/packages/svelte-ux/src/routes/docs/utils/format/+page.svelte +++ b/packages/svelte-ux/src/routes/docs/utils/format/+page.svelte @@ -3,6 +3,14 @@ import { format } from '$lib/utils/format'; import { PeriodType } from '$lib/utils/date'; import Code from '$lib/components/Code.svelte'; + import TextField from '$lib/components/TextField.svelte'; + import MenuField from '$lib/components/MenuField.svelte'; + import type { FormatNumberStyle } from '$lib/utils/number'; + + let value = 1234.56; + let style: FormatNumberStyle = 'decimal'; + let locales: string = 'en'; // + let currency: string = 'USD'; const date = new Date('1982-03-30T00:00:00'); @@ -13,6 +21,36 @@

Examples

+

Playground

+ +
+ + + ({ label: value, value }) + )} + /> + + ({ label: value, value }))} + /> + + ({ label: value, value }))} + /> +
+ + +
{format(value, style, { locales, currency })}
+
+

number formats (defaut settings)

@@ -52,4 +90,6 @@
{format(date, PeriodType.Month)}
{format(date, PeriodType.CalendarYear)}
{format(date, PeriodType.Day, 'short')}
+
{format(date, PeriodType.Month, 'short')}
+
{format(date, PeriodType.CalendarYear, 'short')}