Skip to content

Commit 1cbdaba

Browse files
committed
feat(StaticChip): add height prop, improve defaults styles, width expands with content. styles overridable
1 parent 29119df commit 1cbdaba

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
<script>
22
/** @type {string} the background color of the chip */
33
export let bgColor = '#e5e5e5'
4+
/** @type {string} sets the height of the component not including margin*/
5+
export let height = '36px'
46
</script>
57

68
<style>
79
.chip {
810
background-color: var(--theme-color);
9-
height: 36px;
11+
height: var(--theme-height);
12+
display: inline-flex;
1013
}
1114
1215
.chip-content {
16+
display: flex;
1317
padding-left: 12px;
1418
padding-right: 12px;
19+
vertical-align: middle;
20+
align-items: center;
21+
font-size: 14px;
1522
}
1623
</style>
1724

1825
<div
19-
class="mdc-typography chip black flex justify-center align-items-center mb-1 mr-2 fs-14 br-16px {$$props.class || ''}"
20-
style="--theme-color: {bgColor}"
26+
class="mdc-typography chip br-16px {$$props.class || ''}"
27+
style="--theme-color: {bgColor}; --theme-height: {height}"
2128
>
22-
<div class="chip-content flex align-items-center">
29+
<div class="chip-content">
2330
<slot />
2431
</div>
2532
</div>

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ declare module '@silintl/ui-components' {
375375

376376
interface StaticChipProps {
377377
bgColor?: string
378+
height?: string
378379
class?: string
379380
}
380381
export class StaticChip extends SvelteComponentTyped<StaticChipProps> {}

stories/StaticChip.stories.svelte

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
<script>
2-
import { Meta, Template, Story } from '@storybook/addon-svelte-csf'
2+
import { copyAndModifyArgs } from './helpers.js'
33
import { StaticChip } from '../components/custom'
4+
import { Meta, Template, Story } from '@storybook/addon-svelte-csf'
45
56
const args = {
67
class: '', //only works for global classes
8+
bgColor: '#e5e5e5',
9+
height: '36px',
710
}
11+
12+
const chips = ['chip 1', 'CHIP TWO', 'chip three is longer...................']
813
</script>
914

1015
<Meta title="Atoms/StaticChip" component={StaticChip} />
1116

1217
<Template let:args>
13-
<StaticChip {...args}>A Chip</StaticChip>
18+
<div>
19+
{#each chips as chip}
20+
<StaticChip {...args}>{chip}</StaticChip>
21+
{/each}
22+
</div>
1423
</Template>
1524

1625
<Story name="Default" {args} />
26+
<Story name="bgColor" args={copyAndModifyArgs(args, { bgColor: 'green' })} />
27+
<Story name="height" args={copyAndModifyArgs(args, { height: '28px' })} />

0 commit comments

Comments
 (0)