-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(styles, docs, migrations): create the chip component (#2855)
- Loading branch information
1 parent
3987cb0
commit bde5675
Showing
29 changed files
with
863 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@swisspost/design-system-migrations': minor | ||
--- | ||
|
||
Added migrations to turn badges into chips. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@swisspost/design-system-documentation': major | ||
--- | ||
|
||
Renamed badge into "chip" and improved related examples. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@swisspost/design-system-styles': major | ||
--- | ||
|
||
Renamed the badge into "chip", added a disable state and updated its styles. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
packages/documentation/cypress/snapshots/components/badge.snapshot.ts
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
packages/documentation/cypress/snapshots/components/chip.snapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe('Chip', () => { | ||
it('default', () => { | ||
cy.visit('/iframe.html?id=snapshots--chip'); | ||
cy.get('.chip', { timeout: 30000 }).should('be.visible'); | ||
cy.percySnapshot('Chips', { widths: [1440] }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/documentation/src/stories/components/chip/chip.docs.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Canvas, Controls, Meta } from '@storybook/blocks'; | ||
import { PostAlert } from '@swisspost/design-system-components-react'; | ||
import * as ChipStories from './chip.stories'; | ||
import StylesPackageImport from '../../../shared/styles-package-import.mdx'; | ||
|
||
<Meta of={ChipStories} /> | ||
|
||
# Chip | ||
|
||
<div className="lead"> | ||
Display small pieces of information with which users can interact. | ||
</div> | ||
|
||
<Canvas sourceState="shown" of={ChipStories.Default} /> | ||
<div className="hide-col-default"> | ||
<Controls of={ChipStories.Default} /> | ||
</div> | ||
|
||
<StylesPackageImport components={['chip']} /> | ||
|
||
## Examples | ||
|
||
### Filter Chip | ||
|
||
Filter chips provide a simple means to refine content or search results based on specific attributes. | ||
They are personalized checkboxes, allowing users to toggle them to filter content effectively. | ||
|
||
<Canvas of={ChipStories.FilterCheckboxChip} /> | ||
|
||
Alternatively, filter chips may be used with radio inputs when a single filter selection is needed. | ||
|
||
<Canvas of={ChipStories.FilterRadioChip} /> | ||
|
||
### Dismissible Chip | ||
|
||
Dismissible chips represent pieces of information entered by a user. | ||
Each chip includes a close button, enabling users to conveniently remove them from view. | ||
|
||
It's important to note that the close icon lacks visible text. | ||
Therefore, it's imperative to include a visually hidden label to ensure accessibility for users relying on assistive technologies. | ||
|
||
<Canvas of={ChipStories.Dismissible} /> |
43 changes: 43 additions & 0 deletions
43
packages/documentation/src/stories/components/chip/chip.snapshot.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; | ||
import meta from './chip.stories'; | ||
import { html } from 'lit'; | ||
import { bombArgs } from '../../../utils'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
||
export default { | ||
...metaWithoutId, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Chip: Story = { | ||
render: (_args: Args, context: StoryContext) => { | ||
return html` | ||
<div class="d-flex flex-wrap gap-1 align-items-start"> | ||
${['bg-white', 'bg-dark'].map( | ||
bg => html` | ||
<div class="${bg} d-flex flex-wrap align-items-start gap-regular p-regular"> | ||
${bombArgs({ | ||
text: [ | ||
'Malakceptebla Insigno', | ||
'Contentus momentus vero siteos et accusam iretea et justo.', | ||
], | ||
size: context.argTypes.size.options, | ||
type: context.argTypes.type.options, | ||
badge: [false, true], | ||
active: [false, true], | ||
disabled: [false, true], | ||
dismissed: [false], | ||
}) | ||
.filter(args => !(args.type !== 'filter' && args.active === true)) | ||
.filter(args => !(args.type !== 'filter' && args.badge === true)) | ||
.map((args: Args) => meta.render?.({ ...context.args, ...args }, context))} | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`; | ||
}, | ||
}; |
Oops, something went wrong.