Skip to content

Commit b1988af

Browse files
authored
Merge pull request #383 from appwrite/feat-truncate-checkboxes
2 parents 7361c25 + abfd081 commit b1988af

File tree

7 files changed

+50
-15
lines changed

7 files changed

+50
-15
lines changed

v2/pink-sb/src/lib/selector/Base.svelte

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@
44
export let id: string | null | undefined;
55
export let label: string | undefined;
66
export let description: string | undefined;
7+
export let truncate: boolean = false;
78
</script>
89

910
<Layout.Stack inline gap="s" alignItems="flex-start" direction="row">
1011
<slot />
1112
{#if label}
12-
<Layout.Stack inline gap="xxs">
13-
<label for={id}>
14-
<Typography.Text variant="m-500">{label}</Typography.Text>
15-
</label>
16-
{#if description}
17-
<Typography.Text variant="m-400" color="--fgcolor-neutral-tertiary"
18-
>{description}</Typography.Text
19-
>
20-
{:else if $$slots.description}
21-
<slot name="description"></slot>
22-
{/if}
23-
</Layout.Stack>
13+
<div style={truncate ? 'min-width: 0' : undefined}>
14+
<Layout.Stack inline gap="xxs">
15+
<label for={id}>
16+
<Typography.Text variant="m-500" {truncate}>{label}</Typography.Text>
17+
</label>
18+
{#if description}
19+
<Typography.Text variant="m-400" color="--fgcolor-neutral-tertiary" {truncate}
20+
>{description}</Typography.Text
21+
>
22+
{:else if $$slots.description}
23+
<slot name="description"></slot>
24+
{/if}
25+
</Layout.Stack>
26+
</div>
2427
{/if}
2528
</Layout.Stack>
2629

v2/pink-sb/src/lib/selector/Checkbox.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
export let description: string | undefined = undefined;
1212
export let checked: boolean | 'indeterminate' = false;
1313
export let required: boolean = false;
14+
export let truncate: boolean = false;
1415
1516
/* disable checkbox but keep colors */
1617
export let showDisabledState: boolean = true;
@@ -32,7 +33,7 @@
3233
}
3334
</script>
3435

35-
<Base {label} {id} {description}>
36+
<Base {label} {id} {description} {truncate}>
3637
<button
3738
bind:this={element}
3839
{disabled}

v2/pink-sb/src/lib/selector/Radio.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
export let label: $$Props['label'] = undefined;
1919
export let description: string | undefined = undefined;
2020
export let radioInput: $$Props['radioInput'] = undefined;
21+
export let truncate: boolean = false;
2122
</script>
2223

23-
<Base {label} {id} {description}>
24+
<Base {label} {id} {description} {truncate}>
2425
<input
2526
type="radio"
2627
bind:this={radioInput}

v2/pink-sb/src/lib/selector/Switch.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
export let label: string | undefined = undefined;
1111
export let description: string | undefined = undefined;
1212
export let required: boolean = false;
13+
export let truncate: boolean = false;
1314
1415
const dispatch = createEventDispatcher();
1516
@@ -30,7 +31,7 @@
3031
$: localChecked.set(checked);
3132
</script>
3233

33-
<Base {label} {id} {description}>
34+
<Base {label} {id} {description} {truncate}>
3435
<button {...$root} use:root {disabled}>
3536
<span class="thumb" />
3637
<input {...$input} use:input on:invalid on:change {id} {required} />

v2/pink-sb/src/stories/Checkbox.stories.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@
5151
<Story name="Disabled" args={{ disabled: true }} />
5252
<Story name="Disabled but checked" args={{ disabled: true, checked: true }} />
5353
<Story name="Focus" {play} />
54+
<Story
55+
name="Truncated"
56+
args={{
57+
label: 'This is a very long label that should be truncated with an ellipsis when the truncate prop is enabled',
58+
description:
59+
'This is a very long description that should also be truncated with an ellipsis when the truncate prop is enabled',
60+
truncate: true
61+
}}
62+
/>

v2/pink-sb/src/stories/Radio.stories.svelte

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,14 @@
4949
<Selector.Radio id="id3" label="Option 3" group="group" name="group" value="3" />
5050
</Layout.Stack>
5151
</Story>
52+
<Story
53+
name="Truncated"
54+
args={{
55+
value: '1',
56+
group: 'truncate-group',
57+
label: 'This is a very long label that should be truncated with an ellipsis when the truncate prop is enabled',
58+
description:
59+
'This is a very long description that should also be truncated with an ellipsis when the truncate prop is enabled',
60+
truncate: true
61+
}}
62+
/>

v2/pink-sb/src/stories/Switch.stories.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@
4242
<Story name="Checked" args={{ checked: true }} />
4343
<Story name="Disabled" args={{ disabled: true }} />
4444
<Story name="Focus" {play} />
45+
<Story
46+
name="Truncated"
47+
args={{
48+
label: 'This is a very long label that should be truncated with an ellipsis when the truncate prop is enabled',
49+
description:
50+
'This is a very long description that should also be truncated with an ellipsis when the truncate prop is enabled',
51+
truncate: true
52+
}}
53+
/>

0 commit comments

Comments
 (0)