-
Notifications
You must be signed in to change notification settings - Fork 460
feat(ui): add Mosaic Item component #9234
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
71b7813
fix(ui): resolve @clerk/headless types from source in Mosaic dts build
alexcarpenter af52934
feat(ui): add Mosaic Item component with StyleX styling
alexcarpenter 526e8e6
refactor(ui): simplify Mosaic Item styles and API
alexcarpenter c066685
docs(repo): update Mosaic styling contract to the StyleX class approach
alexcarpenter 46d0634
refactor(ui): adopt shared MosaicComponentProps in Mosaic Item
alexcarpenter d8c39c4
fix(ui): update Mosaic Item styles to current token scale
alexcarpenter d93a7fa
dial in item component
alexcarpenter 7ccd7be
simplify
alexcarpenter 150f757
feat(ui): single-line truncate Mosaic Item title and description
alexcarpenter 38821c6
button up story
alexcarpenter 6905db8
feat(ui): derive Mosaic Item density from variant
alexcarpenter 85c95c0
fix(swingset): remove unused ArrowIcon from Item stories
alexcarpenter bdfacdd
fix(ui): drop role=list from Mosaic Item Group
alexcarpenter 280ce8f
add size fit option to avatar
alexcarpenter c8a8e3e
update stories
alexcarpenter 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
Some comments aren't visible on the classic Files Changed page.
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,2 @@ | ||
| --- | ||
| --- |
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,89 @@ | ||
| import * as ItemStories from './item.stories'; | ||
|
|
||
| # Item | ||
|
|
||
| Item is a flexible row for lists of accounts, organizations, and settings in Mosaic. It's composed from parts via dot syntax (`Item.Root`, `Item.Media`, `Item.Content`, `Item.Title`, …). `Item.Root` renders as a `<div>` by default; pass it a `render` prop to make a row an interactive link or button, which adds hover and cursor affordances. | ||
|
|
||
| ## Example | ||
|
|
||
| <Story | ||
| name='Default' | ||
| storyModule={ItemStories} | ||
| /> | ||
|
|
||
| ### Interactive | ||
|
|
||
| <Story | ||
| name='Interactive' | ||
| storyModule={ItemStories} | ||
| /> | ||
|
|
||
| ### Group | ||
|
|
||
| <Story | ||
| name='Group' | ||
| storyModule={ItemStories} | ||
| /> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```tsx | ||
| import { Avatar } from '@clerk/ui/mosaic/components/avatar'; | ||
| import { Item } from '@clerk/ui/mosaic/components/item'; | ||
|
|
||
| <Item.Group> | ||
| <Item.Root render={({ children, ...props }) => <a {...props} href='/org'>{children}</a>}> | ||
| <Item.Media> | ||
| <Avatar.Root shape='square' size='md'> | ||
| <Avatar.Image src={org.imageUrl} alt='' /> | ||
| <Avatar.Fallback>{org.name[0]}</Avatar.Fallback> | ||
| </Avatar.Root> | ||
| </Item.Media> | ||
| <Item.Content> | ||
| <Item.Title>Test Organization</Item.Title> | ||
| <Item.Description>Member</Item.Description> | ||
| </Item.Content> | ||
| <Item.Actions> | ||
| <Button variant='outline'>Manage</Button> | ||
| </Item.Actions> | ||
| </Item.Root> | ||
| </Item.Group>; | ||
| ``` | ||
|
|
||
| ## Parts | ||
|
|
||
| | Part | Class | Description | | ||
| | -------------------- | ------------------------ | -------------------------------------------------------------------- | | ||
| | `Item.Root` | `cl-item` | Root row. Renders a `<div>`, or a custom element via `render`. | | ||
| | `Item.Media` | `cl-item-media` | Leading (or trailing) media: icon, image, or avatar. | | ||
| | `Item.Content` | `cl-item-content` | Vertical stack that grows to fill the row between media and actions. | | ||
| | `Item.Title` | `cl-item-title` | Primary label. | | ||
| | `Item.Description` | `cl-item-description` | Secondary text. Renders a `<p>`. | | ||
| | `Item.Actions` | `cl-item-actions` | Trailing controls (buttons, badges). | | ||
| | `Item.Header` | `cl-item-header` | Header row above a group: a label with optional actions. | | ||
| | `Item.HeaderTitle` | `cl-item-header-title` | Label text within an `Item.Header`. | | ||
| | `Item.HeaderActions` | `cl-item-header-actions` | Trailing controls within an `Item.Header`. | | ||
| | `Item.Group` | `cl-item-group` | Vertical wrapper around a set of rows (layout only, no role). | | ||
| | `Item.Separator` | `cl-item-separator` | Thin divider (`<hr>`) between rows. | | ||
|
|
||
| Every part accepts a `render` prop for element polymorphism and forwards a ref. | ||
|
|
||
| ## Styling | ||
|
|
||
| The root reflects its state as `data-*` attributes on `.cl-item`, so consumers can scope overrides without touching StyleX's hashed atoms: | ||
|
|
||
| | Prop | Attribute | Values | Default | | ||
| | --------- | ------------------ | ----------------------------------- | -------- | | ||
| | `variant` | `data-variant` | `entity` \| `action` | `entity` | | ||
| | `render` | `data-interactive` | present when a `render` is provided | — | | ||
|
|
||
| `variant` sets the row's vertical density (`entity` is standard, `action` is denser) and, on interactive rows, promotes the title color. | ||
|
|
||
| ```css | ||
| /* Re-theme interactive rows */ | ||
| .cl-item[data-interactive] { | ||
| background-color: var(--cl-color-card); | ||
| } | ||
| ``` | ||
|
|
||
| `Item.Media` sizes to its child and centers it; its height follows the row. Bring your own icon, avatar, or image at whatever dimensions you need, then size the slot by sizing that child. Colors, radii, and spacing all resolve from the Mosaic tokens (`--cl-color-*`, `--cl-radius-*`, `--cl-spacing`). | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.