Skip to content

Commit 2a50f4b

Browse files
authored
Merge pull request #353 from appwrite/feat-add-badge-to-fieldset
2 parents 3f81097 + d93a5e9 commit 2a50f4b

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

v2/pink-sb/src/lib/Fieldset.svelte

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
<script lang="ts">
2+
import Badge from './Badge.svelte';
3+
import Stack from './layout/Stack.svelte';
4+
25
export let legend: string;
6+
export let badge: string | undefined = undefined;
7+
export let badgeVariant: 'primary' | 'secondary' | 'accent' = 'secondary';
38
</script>
49

510
<fieldset>
6-
<legend><span>{legend}</span></legend>
11+
<legend>
12+
<span>
13+
<Stack inline direction="row" alignItems="center" gap="xxs">
14+
<span class="legend-text">{legend}</span>
15+
{#if badge}
16+
<Badge content={badge} variant={badgeVariant} size="xs" />
17+
{/if}
18+
</Stack>
19+
</span>
20+
</legend>
721
<div class="content"><slot /></div>
822
</fieldset>
923

@@ -20,8 +34,7 @@
2034
margin-left: var(--space-6, 12px);
2135
}
2236
23-
span {
24-
padding: 0 var(--space-2, 4px);
37+
.legend-text {
2538
font-family: var(--font-family-sansserif);
2639
font-size: var(--font-size-xs, 12px);
2740
font-style: normal;

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
component: Fieldset,
99
args: {
1010
legend: 'Legend'
11+
},
12+
argTypes: {
13+
badge: {
14+
control: { type: 'text' }
15+
},
16+
badgeVariant: {
17+
control: { type: 'select' },
18+
options: ['primary', 'secondary', 'accent']
19+
}
1120
}
1221
};
1322
</script>
@@ -17,6 +26,12 @@
1726
<Story name="Default" let:args>
1827
<Fieldset {...args}><div class="demo-block">Demo block</div></Fieldset>
1928
</Story>
29+
30+
<Story name="With Badge" let:args>
31+
<Fieldset {...args} badge="New">
32+
<div class="demo-block">Demo block with badge</div>
33+
</Fieldset>
34+
</Story>
2035
</div>
2136
</div>
2237

0 commit comments

Comments
 (0)