-
Notifications
You must be signed in to change notification settings - Fork 808
feat(core): add useTableRowStatus plugin #3757
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
humbertovirtudes
merged 6 commits into
facebook:main
from
humbertovirtudes:navi/feat/table-row-status
Jul 23, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
530a0b3
feat(core): add useTableRowStatus plugin
humbertovirtudes 0882ad9
feat(core): semantic colors + icon signifier for useTableRowStatus
humbertovirtudes 490c4ab
feat(core): render useTableRowStatus as a status dot (addresses review)
humbertovirtudes 90a6088
fix(core): require label and use Tooltip in useTableRowStatus
humbertovirtudes 666e96d
docs(core): inline literal values in useTableRowStatus getStatus doc
humbertovirtudes c11540b
Merge remote-tracking branch 'origin/main' into pr3757-update
humbertovirtudes 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
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,20 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [feat] Add `useTableRowStatus`, a plugin that prepends a narrow column | ||
| signaling per-row status. | ||
|
|
||
| - Compact per-row status signal (error, warning, unread, etc.) without a | ||
| dedicated status column: a colored status dot by default, or an icon when | ||
| provided. | ||
| - `getStatus(item)` maps a row to `{color, icon?, label?}`, or `null` for no | ||
| indicator. `color` accepts a semantic status name | ||
| (`success`/`error`/`warning`/`accent`/`red`/`green`/etc.) mapped to a theme | ||
| token, or a raw CSS color as an escape hatch. | ||
| - `icon` renders the status as a shape signifier instead of the dot, which is | ||
| more accessible than color alone when multiple statuses coexist. `label` | ||
| supplies the accessible name. | ||
| - Memoize `getStatus` with `useCallback` for a stable plugin identity. | ||
|
|
||
| @humbertovirtudes |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,101 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
|
||
| import type {Meta, StoryObj} from '@storybook/react'; | ||
| import { | ||
| Table, | ||
| useTableRowStatus, | ||
| proportional, | ||
| pixel, | ||
| } from '@astryxdesign/core/Table'; | ||
| import type {TableColumn, TableRowStatus} from '@astryxdesign/core/Table'; | ||
|
|
||
| // ============================================================================= | ||
| // Sample Data | ||
| // ============================================================================= | ||
|
|
||
| interface Job extends Record<string, unknown> { | ||
| id: string; | ||
| name: string; | ||
| owner: string; | ||
| state: 'failed' | 'running' | 'queued' | 'succeeded'; | ||
| } | ||
|
|
||
| const jobs: Job[] = [ | ||
| {id: 'j1', name: 'build-core', owner: 'Ava', state: 'failed'}, | ||
| {id: 'j2', name: 'lint', owner: 'Liam', state: 'running'}, | ||
| {id: 'j3', name: 'unit-tests', owner: 'Zoe', state: 'succeeded'}, | ||
| {id: 'j4', name: 'docsite-deploy', owner: 'Max', state: 'queued'}, | ||
| {id: 'j5', name: 'smoke-test', owner: 'Mia', state: 'succeeded'}, | ||
| ]; | ||
|
|
||
| const columns: TableColumn<Job>[] = [ | ||
| {key: 'name', header: 'Job', width: proportional(2)}, | ||
| {key: 'owner', header: 'Owner', width: pixel(120)}, | ||
| {key: 'state', header: 'State', width: pixel(120)}, | ||
| ]; | ||
|
|
||
| function jobStatus(job: Job): TableRowStatus | null { | ||
| switch (job.state) { | ||
| case 'failed': | ||
| return {color: 'error', icon: 'error', label: 'Failed'}; | ||
| case 'running': | ||
| return {color: 'warning', icon: 'warning', label: 'Running'}; | ||
| case 'queued': | ||
| return {color: 'gray', label: 'Queued'}; | ||
| default: | ||
| return null; // succeeded: no indicator | ||
| } | ||
| } | ||
|
|
||
| const meta: Meta = { | ||
| title: 'Core/TableRowStatus', | ||
| tags: ['autodocs'], | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj; | ||
|
|
||
| /** | ||
| * A small colored dot in a leading gutter column signals per-row status. | ||
| * Rows whose `getStatus` returns `null` (here: succeeded jobs) show no dot. | ||
| * Hover a dot to see its accessible label. | ||
| */ | ||
| export const Default: Story = { | ||
| render: () => { | ||
| const rowStatus = useTableRowStatus<Job>({getStatus: jobStatus}); | ||
| return ( | ||
| <Table | ||
| data={jobs} | ||
| columns={columns} | ||
| idKey="id" | ||
| hasHover | ||
| plugins={{rowStatus}} | ||
| /> | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * Any CSS color works: here raw hex values instead of theme tokens. | ||
| */ | ||
| export const RawColors: Story = { | ||
| render: () => { | ||
| const rowStatus = useTableRowStatus<Job>({ | ||
| getStatus: job => | ||
| job.state === 'failed' | ||
| ? {color: '#dc2626', label: 'Failed'} | ||
| : job.state === 'running' | ||
| ? {color: '#f59e0b', label: 'Running'} | ||
| : null, | ||
| }); | ||
| return ( | ||
| <Table | ||
| data={jobs} | ||
| columns={columns} | ||
| idKey="id" | ||
| hasHover | ||
| plugins={{rowStatus}} | ||
| /> | ||
| ); | ||
| }, | ||
| }; |
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.
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.