Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions v2/pink-sb/src/lib/selector/Base.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@

<Layout.Stack inline gap="s" alignItems="flex-start" direction="row">
<slot />

{#if label}
<Layout.Stack inline gap="xxs">
<label for={id}>
<Typography.Text variant="m-500">{label}</Typography.Text>
</label>
{#if description}
<Typography.Text variant="m-400" color="--fgcolor-neutral-tertiary"
>{description}</Typography.Text
>
{:else if $$slots.description}
<slot name="description"></slot>
{/if}

<div class="description">
{#if description}
<Typography.Text variant="m-400" color="--fgcolor-neutral-tertiary">
{description}
</Typography.Text>
{:else if $$slots.description}
<slot name="description"></slot>
{/if}
</div>
</Layout.Stack>
{/if}
</Layout.Stack>
Expand All @@ -28,4 +32,8 @@
label {
cursor: pointer;
}

.description:empty {
display: none;
}
</style>
6 changes: 3 additions & 3 deletions v2/pink-sb/src/lib/selector/Checkbox.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import { createCheckbox } from '@melt-ui/svelte';
import { IconCheck, IconMinusSm } from '@appwrite.io/pink-icons-svelte';
import { createEventDispatcher } from 'svelte';
import Base from './Base.svelte';
import Icon from '$lib/Icon.svelte';
import { createEventDispatcher } from 'svelte';
import { createCheckbox } from '@melt-ui/svelte';
import { IconCheck, IconMinusSm } from '@appwrite.io/pink-icons-svelte';

export let disabled: boolean = false;
export let id: string | undefined = undefined;
Expand Down
2 changes: 1 addition & 1 deletion v2/pink-sb/src/lib/selector/Switch.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import Base from './Base.svelte';
import { createSwitch } from '@melt-ui/svelte';
import { createEventDispatcher } from 'svelte';
import Base from './Base.svelte';

export let checked: boolean = false;
export let disabled: boolean = false;
Expand Down
26 changes: 25 additions & 1 deletion v2/pink-sb/src/stories/Checkbox.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<script>
import { Story, Template } from '@storybook/addon-svelte-csf';
import { expect, within } from '@storybook/test';
import Anchor from '$lib/link/Anchor.svelte';
import Stack from '$lib/layout/Stack.svelte';
import Text from '../lib/typography/Text.svelte';
</script>

<Template let:args>
Expand All @@ -46,7 +49,28 @@

<Story name="Default" />
<Story name="Checked" args={{ checked: true }} />
<Story name="With description" args={{ description: 'This is a description text' }} />
<Story name="Indeterminate" args={{ checked: 'indeterminate' }} />
<Story name="Disabled" args={{ disabled: true }} />
<Story name="Focus" {play} />
<Story name="Descriptions">
<Stack gap="xxxl">
<Stack>
<Text variant="m-400">1. No description</Text>
<Selector.Checkbox label="Checkbox" />
</Stack>

<Stack>
<Text variant="m-400">2. Prop description</Text>
<Selector.Checkbox label="Checkbox" description="This is a description text" />
</Stack>

<Stack>
<Text variant="m-400">3. Slot description</Text>
<Selector.Checkbox label="Checkbox">
<Text variant="m-400" color="--fgcolor-neutral-tertiary" slot="description">
This is a description as a slot. Here's a <Anchor href="#">link</Anchor> for demo.
</Text>
</Selector.Checkbox>
</Stack>
</Stack>
</Story>
34 changes: 33 additions & 1 deletion v2/pink-sb/src/stories/Radio.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<script>
import { Story, Template } from '@storybook/addon-svelte-csf';
import { expect, within } from '@storybook/test';
import Anchor from '$lib/link/Anchor.svelte';
import Stack from '$lib/layout/Stack.svelte';
import Text from '../lib/typography/Text.svelte';
</script>

<Template let:args>
Expand All @@ -39,7 +42,6 @@

<Story name="Default" />
<Story name="Checked" args={{ checked: true }} />
<Story name="With description" args={{ description: 'This is a description text' }} />
<Story name="Disabled" args={{ disabled: true }} />
<Story name="Focus" {play} />
<Story name="Group">
Expand All @@ -49,3 +51,33 @@
<Selector.Radio id="id3" label="Option 3" group="group" name="group" value="3" />
</Layout.Stack>
</Story>

<Story name="Descriptions">
<Stack gap="xxxl">
<Stack>
<Text variant="m-400">1. No description</Text>
<Selector.Radio label="Radio" value="1" id="id1" group="group" name="group" />
</Stack>

<Stack>
<Text variant="m-400">2. Prop description</Text>
<Selector.Radio
label="Radio"
value="2"
id="id2"
group="group"
name="group"
description="This is a description text"
/>
</Stack>

<Stack>
<Text variant="m-400">3. Slot description</Text>
<Selector.Radio label="Radio" value="3" id="id3" group="group" name="group">
<Text variant="m-400" color="--fgcolor-neutral-tertiary" slot="description">
This is a description as a slot. Here's a <Anchor href="#">link</Anchor> for demo.
</Text>
</Selector.Radio>
</Stack>
</Stack>
</Story>
32 changes: 25 additions & 7 deletions v2/pink-sb/src/stories/Switch.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,38 @@
<script>
import { Story, Template } from '@storybook/addon-svelte-csf';
import { expect, within } from '@storybook/test';
import Anchor from '$lib/link/Anchor.svelte';
import Stack from '$lib/layout/Stack.svelte';
import Text from '../lib/typography/Text.svelte';
</script>

<Template let:args>
<Selector.Switch {...args} />
</Template>

<Story name="Default" />
<Story
name="With description"
args={{
description:
' Provide a fallback file for advanced routing and proper page handling in SPA mode.'
}}
/>
<Story name="Checked" args={{ checked: true }} />
<Story name="Disabled" args={{ disabled: true }} />
<Story name="Focus" {play} />
<Story name="Descriptions">
<Stack gap="xxxl">
<Stack>
<Text variant="m-400">1. No description</Text>
<Selector.Switch label="Switch" />
</Stack>

<Stack>
<Text variant="m-400">2. Prop description</Text>
<Selector.Switch label="Switch" description="This is a description text" />
</Stack>

<Stack>
<Text variant="m-400">3. Slot description</Text>
<Selector.Switch label="Switch">
<Text variant="m-400" color="--fgcolor-neutral-tertiary" slot="description">
This is a description as a slot. Here's a <Anchor href="#">link</Anchor> for demo.
</Text>
</Selector.Switch>
</Stack>
</Stack>
</Story>
Loading