From 10cab60d633cb935a5625db51aac57d7e61254b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Mon, 12 Feb 2024 12:32:08 +0100 Subject: [PATCH] docs: create story for Created.svelte MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will need a refactor at some point by computing the formatted value as reactive variable depending on the created_at and locale. Signed-off-by: André Jaenisch --- stories/atoms/Created.stories.ts | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 stories/atoms/Created.stories.ts diff --git a/stories/atoms/Created.stories.ts b/stories/atoms/Created.stories.ts new file mode 100644 index 0000000..3d284f9 --- /dev/null +++ b/stories/atoms/Created.stories.ts @@ -0,0 +1,34 @@ +import type { Meta, StoryObj } from '@storybook/svelte'; + +import Created from '$lib/components/atoms/Created.svelte'; + +const meta = { + title: 'Atoms/Created', + component: Created, + tags: ['autodocs'], + argTypes: { + created_at: { + control: 'date', + description: 'Date of creation' + }, + created_at_formatted: { + control: 'text', + description: 'Localised version of created_at' + } + } +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Plain: Story = { + args: { + created_at: new Date(), + created_at_formatted: (function () { + const locale = 'en-US'; + return new Intl.DateTimeFormat(locale).format(new Date()); + })() + } +}; + +export const Missing: Story = {};