Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(styles, docs, migrations): create the chip component #2855

Merged
merged 49 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6a0d457
feat(styles): turn badge into chip and update its styles
alizedebray Mar 21, 2024
7608637
fix the version of the styles package in the demo app
alizedebray Mar 21, 2024
57707e1
feat(docs): update chip documentation
alizedebray Mar 21, 2024
f513eec
feat(migrations): add migrations for the chip
alizedebray Mar 27, 2024
39cac1f
Merge branch 'main' into 2198-styles-chip
alizedebray Mar 27, 2024
aca177f
feat(docs) update chip examples
alizedebray Mar 27, 2024
48550b2
revert: fix the version of the styles package in the demo app
alizedebray Mar 27, 2024
8747c5a
Fix code smells
alizedebray Mar 27, 2024
dd3acf1
Merge branch 'main' into 2198-styles-chip
alizedebray Mar 27, 2024
5030123
feat(docs): update badges documentation
alizedebray Mar 21, 2024
3aa0c26
feat(docs): update badges documentation
alizedebray Mar 21, 2024
ec745c2
Merge branch '2841-badge-component-style-updates' of https://github.c…
alizedebray Mar 28, 2024
7954f43
fix code smell
alizedebray Mar 28, 2024
7728f6e
fix outline on empty badge
alizedebray Mar 28, 2024
a34fa9d
Update documentation lead
alizedebray Mar 28, 2024
c2e6167
Update borders
alizedebray Mar 28, 2024
83f4a87
Merge branch 'main' into 2841-badge-component-style-updates
alizedebray Mar 28, 2024
db299ca
Merge branch 'main' into 2198-styles-chip
alizedebray Mar 28, 2024
71502db
Merge branch '2841-badge-component-style-updates' into 2198-styles-chip
alizedebray Mar 28, 2024
470eb17
merge new badges styles into chips
alizedebray Mar 28, 2024
e4e3d8c
Merge branch 'main' into 2841-badge-component-style-updates
alizedebray Apr 2, 2024
3939e57
Fix duplicated badge
alizedebray Apr 2, 2024
f6cd985
Add migration to move the close button as first child
alizedebray Apr 2, 2024
04fb5e0
fix sass variable not defined
alizedebray Apr 2, 2024
01c3062
Merge branch '2841-badge-component-style-updates' into 2198-styles-chip
alizedebray Apr 2, 2024
7b931c0
Merge branch 'main' into 2841-badge-component-style-updates
alizedebray Apr 2, 2024
07bd0aa
Fix badges
alizedebray Apr 2, 2024
a67c296
Update badge.stories.ts
alizedebray Apr 2, 2024
55b61dc
Merge branch '2841-badge-component-style-updates' into 2198-styles-chip
alizedebray Apr 2, 2024
9ca74a7
Update chip controls
alizedebray Apr 4, 2024
67fd6c3
Add .chip-text class
alizedebray Apr 4, 2024
3849047
Rename "chip-check" to "chip-filter"
alizedebray Apr 4, 2024
f801175
Update focus-style for form check and form range
alizedebray Apr 4, 2024
c49ba14
Update disabled-style mixin
alizedebray Apr 4, 2024
bddd331
Rename default chip to chip-dismissible
alizedebray Apr 4, 2024
3a8bac5
Move the .chip-sm class to the container instead of the label
alizedebray Apr 4, 2024
a99abe1
Update dismissible chip structure
alizedebray Apr 4, 2024
4c4e798
Update dismissible badge styles
alizedebray Apr 4, 2024
d9a0265
Update chip-filter styles
alizedebray Apr 4, 2024
359e74e
Use mixins instead of placeholders
alizedebray Apr 5, 2024
399e82d
Improve HCM styles
alizedebray Apr 5, 2024
791aefa
Merge branch 'main' into 2198-styles-chip
alizedebray Apr 5, 2024
94655ec
Merge branch 'main' into 2198-styles-chip
alizedebray Apr 5, 2024
3012053
Add radio filter chip story
alizedebray Apr 5, 2024
d7134db
Add dismiss label on dismissible chips
alizedebray Apr 5, 2024
0a5f455
Update migrations
alizedebray Apr 5, 2024
0bbd232
Fix code smell
alizedebray Apr 5, 2024
fc13c12
fix styles linting
alizedebray Apr 8, 2024
421e4c0
Update chip.stories.ts
alizedebray Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-mugs-design.md
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.
5 changes: 5 additions & 0 deletions .changeset/selfish-lions-tap.md
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.
5 changes: 5 additions & 0 deletions .changeset/sweet-clouds-scream.md
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.
1 change: 1 addition & 0 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@popperjs/core": "2.11.8",
"@swimlane/ngx-datatable": "20.1.0",
"@swisspost/design-system-intranet-header": "workspace:5.0.11",
"@swisspost/design-system-migrations": "workspace:1.0.2",
"@swisspost/design-system-styles": "workspace:6.6.4",
"bootstrap": "5.3.2",
"core-js": "3.36.1",
Expand Down

This file was deleted.

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] });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { html, nothing } from 'lit';
import { MetaComponent } from '../../../../types';
import backgroundColors from '../../../shared/background-colors.module.scss';
import { coloredBackground } from '../../../shared/decorators/dark-background';
import chipMeta from '../chip/chip.stories';

const meta: MetaComponent = {
id: 'bec68e8b-445e-4760-8bd7-1b9970206d8d',
Expand Down Expand Up @@ -113,11 +114,8 @@ export const LargeNumber: Story = {
};

export const Position: Story = {
render: args => html`
<div class="chip">
Filter
<div class="badge bg-gray">1</div>
</div>
render: (_args, context) => html`
${chipMeta.render?.({ ...chipMeta.args, badge: true }, context)}

<div class="position-relative d-inline">
<post-icon name="2026" class="fs-large"></post-icon>
Expand All @@ -126,7 +124,7 @@ export const Position: Story = {
`,
decorators: [
(story: StoryFn, { args, context }: StoryContext) => html`
<div class="d-flex gap-large">${story(args, context)}</div>
<div class="d-flex gap-large align-items-center">${story(args, context)}</div>
`,
],
};
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} />
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>
`;
},
};
Loading
Loading