Skip to content

Commit

Permalink
Merge pull request #242 from silinternational/feature/improve-StaticChip
Browse files Browse the repository at this point in the history
feat(StaticChip): add height prop, improve defaults styles, width exp…
  • Loading branch information
hobbitronics committed Jan 18, 2024
2 parents 0273664 + 1b30767 commit 3762cdf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
18 changes: 12 additions & 6 deletions components/custom/StaticChip/StaticChip.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
<script>
/** @type {string} the background color of the chip */
export let bgColor = '#e5e5e5'
/** @type {string} sets the height of the component not including margin*/
export let height = '36px'
</script>

<style>
.chip {
background-color: var(--theme-color);
height: 36px;
height: var(--theme-height);
display: inline-flex;
margin: 0 2rem 1rem 0;
border-radius: 16px;
}
.chip-content {
display: flex;
padding-left: 12px;
padding-right: 12px;
vertical-align: middle;
align-items: center;
font-size: 14px;
}
</style>

<div
class="mdc-typography chip black flex justify-center align-items-center mb-1 mr-2 fs-14 br-16px {$$props.class || ''}"
style="--theme-color: {bgColor}"
>
<div class="chip-content flex align-items-center">
<div class="mdc-typography chip {$$props.class || ''}" style="--theme-color: {bgColor}; --theme-height: {height}">
<div class="chip-content">
<slot />
</div>
</div>
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ declare module '@silintl/ui-components' {

interface StaticChipProps {
bgColor?: string
height?: string
class?: string
}
export class StaticChip extends SvelteComponentTyped<StaticChipProps> {}
Expand Down
15 changes: 13 additions & 2 deletions stories/StaticChip.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<script>
import { Meta, Template, Story } from '@storybook/addon-svelte-csf'
import { copyAndModifyArgs } from './helpers.js'
import { StaticChip } from '../components/custom'
import { Meta, Template, Story } from '@storybook/addon-svelte-csf'
const args = {
class: '', //only works for global classes
bgColor: '#e5e5e5',
height: '36px',
}
const chips = ['chip 1', 'CHIP TWO', 'chip three is longer...................']
</script>

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

<Template let:args>
<StaticChip {...args}>A Chip</StaticChip>
<div>
{#each chips as chip}
<StaticChip {...args}>{chip}</StaticChip>
{/each}
</div>
</Template>

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

0 comments on commit 3762cdf

Please sign in to comment.