-
Notifications
You must be signed in to change notification settings - Fork 62
DS 2.0: Chip component #87
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
Open
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f99fc5d
feat(ui): add Chip component
librowski 5838857
refactor(sdk): render the conditions counter tag with Chip
librowski 1e2947f
docs: add the Chip component page
librowski 21f8a79
fix(ui): apply Chip review findings
librowski b3b2e26
docs(ui): sharpen Chip prop contracts
librowski cf339fe
fix(ui): chip outline ring sits outside the box
librowski 5b609f7
docs(ui): cut chip comments down to the exceptions
librowski 172db68
docs(ui): drop the outline chip comments
librowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| --- | ||
| '@workflowbuilder/ui': minor | ||
| --- | ||
|
|
||
| Add the `Chip` component — a compact tag in the DS 2.0 solid and outline treatments, four sizes (`s`–`xl`), optional prefix icon and close affordance. |
This file contains hidden or 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 @@ | ||
| --- | ||
| '@workflowbuilder/sdk': patch | ||
| --- | ||
|
|
||
| The dynamic-conditions counter tag is rendered with the UI `Chip` component. Same neutral surface colors; the tag gets the DS 2.0 chip metrics — 10px label (was 12px) in a 20px-tall pill with slightly tighter padding. |
This file contains hidden or 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
This file contains hidden or 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,17 @@ | ||
| import { Tag } from '@phosphor-icons/react'; | ||
| import { Chip } from '@workflowbuilder/ui'; | ||
|
|
||
| import { ComponentPreview } from './component-preview'; | ||
|
|
||
| export function ChipsExample() { | ||
| return ( | ||
| <ComponentPreview> | ||
| <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}> | ||
| <Chip label="tag label" /> | ||
| <Chip label="tag label" variant="outline" /> | ||
| <Chip label="with icon" size="l" prefixIcon={<Tag />} /> | ||
| <Chip label="removable" size="l" variant="outline" onClose={() => {}} /> | ||
| </div> | ||
| </ComponentPreview> | ||
| ); | ||
| } |
33 changes: 33 additions & 0 deletions
33
apps/docs/src/content/docs/ui-library/ui-components/chips.mdx
This file contains hidden or 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,33 @@ | ||
| --- | ||
| title: Chip | ||
| description: Compact tag for labeling and filtering, in solid and outline treatments. | ||
| --- | ||
|
|
||
| import CssVariablesTable from '../../../../components/api/css-variables-table.astro'; | ||
| import PropsTable from '../../../../components/api/props-table.astro'; | ||
| import { ChipsExample } from '../../../../components/ui-examples/chips'; | ||
|
|
||
| A `Chip` is a compact tag in one of two treatments: `solid` on the neutral | ||
| chip surface, or `outline` with the brand border and accent. Four sizes | ||
| (`s`, `m`, `l`, `xl`), an optional prefix icon, and an optional close | ||
| affordance. | ||
|
|
||
| <ChipsExample client:visible /> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```tsx | ||
| import { Chip } from '@workflowbuilder/ui'; | ||
|
|
||
| function Example() { | ||
| return <Chip label="tag label" variant="outline" size="l" onClose={() => remove()} />; | ||
| } | ||
| ``` | ||
|
|
||
| ## Props | ||
|
|
||
| <PropsTable slug="chips" /> | ||
|
|
||
| ## CSS variables | ||
|
|
||
| <CssVariablesTable slug="chips" /> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,69 @@ | ||
| @layer ui.component { | ||
| .chip { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| gap: var(--wb-space-50); | ||
| border-radius: var(--wb-radius-50); | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .solid { | ||
| background-color: var(--wb-components-chips-solid); | ||
| color: var(--wb-components-chips-solid-text); | ||
| } | ||
|
|
||
| .outline { | ||
| background-color: var(--wb-components-chips-inset-outline); | ||
| background-image: linear-gradient( | ||
| var(--wb-components-chips-overlay-outline), | ||
| var(--wb-components-chips-overlay-outline) | ||
| ); | ||
| box-shadow: 0 0 0 var(--wb-size-12) var(--wb-components-chips-inset-outline); | ||
| color: var(--wb-components-chips-inset-outline); | ||
| } | ||
|
|
||
| .s { | ||
| height: 0.875rem; | ||
| padding-inline: var(--wb-space-50); | ||
| } | ||
|
|
||
| .m { | ||
| height: 1rem; | ||
| padding-inline: var(--wb-space-50); | ||
| } | ||
|
|
||
| .l { | ||
| height: 1.25rem; | ||
| padding-inline: var(--wb-space-75); | ||
| } | ||
|
|
||
| .xl { | ||
| height: 1.375rem; | ||
| padding-inline: var(--wb-space-75); | ||
| } | ||
|
|
||
| .icon, | ||
| .close { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .icon svg, | ||
| .close svg { | ||
| width: 0.625rem; | ||
| height: 0.625rem; | ||
| } | ||
|
|
||
| .close { | ||
| padding: 0; | ||
| border: none; | ||
| background: none; | ||
| color: inherit; | ||
| cursor: pointer; | ||
|
|
||
| &:focus-visible { | ||
| box-shadow: 0 0 0 2px var(--ax-focus-ring-element); | ||
| outline: none; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,51 @@ | ||
| import { X } from '@phosphor-icons/react'; | ||
| import clsx from 'clsx'; | ||
| import { HTMLAttributes, ReactNode, forwardRef } from 'react'; | ||
|
|
||
| import styles from './chips.module.css'; | ||
|
|
||
| export type ChipProps = { | ||
| label: string; | ||
| /** | ||
| * @default 'solid' | ||
| */ | ||
| variant?: ChipVariant; | ||
| /** | ||
| * @default 'm' | ||
| */ | ||
| size?: ChipSize; | ||
| prefixIcon?: ReactNode; | ||
| /** | ||
| * When set, a close affordance is rendered and invokes this callback. | ||
| */ | ||
| onClose?: () => void; | ||
| /** | ||
| * Accessible name of the close affordance. | ||
| * @default `Remove ${label}` | ||
| */ | ||
| closeLabel?: string; | ||
| } & HTMLAttributes<HTMLSpanElement>; | ||
|
|
||
| export type ChipVariant = 'solid' | 'outline'; | ||
| export type ChipSize = 's' | 'm' | 'l' | 'xl'; | ||
|
|
||
| export const Chip = forwardRef<HTMLSpanElement, ChipProps>( | ||
| ({ label, variant = 'solid', size = 'm', prefixIcon, onClose, closeLabel, className, ...rest }, ref) => { | ||
| return ( | ||
| <span ref={ref} {...rest} className={clsx(styles['chip'], styles[variant], styles[size], className)}> | ||
| {prefixIcon && <span className={styles['icon']}>{prefixIcon}</span>} | ||
| <span className="wb-text-label-s">{label}</span> | ||
|
librowski marked this conversation as resolved.
|
||
| {onClose && ( | ||
| <button | ||
| type="button" | ||
| className={styles['close']} | ||
| aria-label={closeLabel ?? `Remove ${label}`} | ||
| onClick={onClose} | ||
| > | ||
| <X /> | ||
| </button> | ||
| )} | ||
| </span> | ||
| ); | ||
| }, | ||
| ); | ||
This file contains hidden or 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 @@ | ||
| export * from './chips'; |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file is named
chips/chips.tsx. It probably should bechip/chip.tsxto match the rest of the application.