-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Manager: Added tokens and a dark color scheme for status colors #33081
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
Changes from all commits
b4cdec3
0d1d5be
4783203
a0e1c79
703b32c
7dd9f92
9702ffb
b7bcfe0
4a3efd8
e4fcfec
1c6e4b2
258e11a
21fb70c
a4250a6
af9f167
3121128
e6139eb
2e1e5f5
a5954ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ import { styled, useTheme } from 'storybook/theming'; | |
|
|
||
| import type { Link } from '../../../components/components/tooltip/TooltipLinkList'; | ||
| import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants'; | ||
| import { getGroupStatus, getMostCriticalStatusValue, statusMapping } from '../../utils/status'; | ||
| import { getGroupStatus, getMostCriticalStatusValue, getStatus } from '../../utils/status'; | ||
| import { | ||
| createId, | ||
| getAncestorIds, | ||
|
|
@@ -214,6 +214,7 @@ const Node = React.memo<NodeProps>(function Node(props) { | |
| onSelectStoryId, | ||
| api, | ||
| } = props; | ||
| const theme = useTheme(); | ||
| const { isDesktop, isMobile, setMobileMenuOpen } = useLayout(); | ||
| const { counts, statusesByValue } = useStatusSummary(item); | ||
|
|
||
|
|
@@ -282,6 +283,71 @@ const Node = React.memo<NodeProps>(function Node(props) { | |
| ? useContextMenu(item, statusLinks, api) | ||
| : { node: null, onMouseEnter: () => {} }; | ||
|
|
||
| if ( | ||
| (item.type === 'story' && | ||
| !('children' in item && item.children) && | ||
| (!('subtype' in item) || item.subtype !== 'test')) || | ||
| item.type === 'docs' | ||
| ) { | ||
| const LeafNode = item.type === 'docs' ? DocumentNode : StoryNode; | ||
|
|
||
| const statusValue = getMostCriticalStatusValue( | ||
| Object.values(statuses || {}).map((s) => s.value) | ||
| ); | ||
| const [icon, textColor] = getStatus(theme, statusValue); | ||
|
|
||
| return ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a sanity check as I didn't expect you'd need to rework the tree structure. Is this new branch intentional or could it be caused by a merge autoresolution?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could have been via merge. @ghengeveld helped me with the initial work and I don't have a solid grasp of this specific set of changes. |
||
| <LeafNodeStyleWrapper | ||
| key={id} | ||
| className="sidebar-item" | ||
| data-selected={isSelected} | ||
| data-ref-id={refId} | ||
| data-item-id={item.id} | ||
| data-parent-id={item.parent} | ||
| data-nodetype={item.type === 'docs' ? 'document' : 'story'} | ||
| data-highlightable={isDisplayed} | ||
| onMouseEnter={contextMenu.onMouseEnter} | ||
| > | ||
| <LeafNode | ||
| // @ts-expect-error (non strict) | ||
| style={isSelected ? {} : { color: textColor }} | ||
|
MichaelArestad marked this conversation as resolved.
|
||
| href={getLink(item, refId)} | ||
| id={id} | ||
| depth={isOrphan ? item.depth : item.depth - 1} | ||
| onClick={(event) => { | ||
| event.preventDefault(); | ||
| onSelectStoryId(item.id); | ||
|
|
||
| if (isMobile) { | ||
| setMobileMenuOpen(false); | ||
| } | ||
| }} | ||
| {...(item.type === 'docs' && { docsMode })} | ||
| > | ||
| {(item.renderLabel as (i: typeof item, api: API) => React.ReactNode)?.(item, api) || | ||
| item.name} | ||
| </LeafNode> | ||
| {isSelected && ( | ||
| <SkipToContentLink asChild ariaLabel={false}> | ||
| <a href="#storybook-preview-wrapper">Skip to canvas</a> | ||
| </SkipToContentLink> | ||
| )} | ||
| {contextMenu.node} | ||
| {icon ? ( | ||
| <StatusButton | ||
| ariaLabel={`Test status: ${statusValue.replace('status-value:', '')}`} | ||
| data-testid="tree-status-button" | ||
| type="button" | ||
| status={statusValue} | ||
| selectedItem={isSelected} | ||
| > | ||
| {icon} | ||
| </StatusButton> | ||
| ) : null} | ||
| </LeafNodeStyleWrapper> | ||
| ); | ||
| } | ||
|
|
||
| if (item.type === 'root') { | ||
| return ( | ||
| <RootNode | ||
|
|
@@ -327,7 +393,7 @@ const Node = React.memo<NodeProps>(function Node(props) { | |
| } | ||
|
|
||
| const itemStatus = getMostCriticalStatusValue(Object.values(statuses || {}).map((s) => s.value)); | ||
| const [itemIcon, itemColor] = statusMapping[itemStatus]; | ||
| const [itemIcon, itemColor] = getStatus(theme, itemStatus); | ||
| const itemStatusButton = itemIcon ? ( | ||
| <StatusButton | ||
| ariaLabel={`Test status: ${itemStatus.replace('status-value:', '')}`} | ||
|
|
@@ -349,7 +415,7 @@ const Node = React.memo<NodeProps>(function Node(props) { | |
| const { children = [] } = item; | ||
| const BranchNode = { component: ComponentNode, group: GroupNode, story: StoryNode }[item.type]; | ||
| const status = getMostCriticalStatusValue([itemStatus, groupStatus?.[item.id]]); | ||
| const color = status ? statusMapping[status][1] : null; | ||
| const color = status ? getStatus(theme, status)[1] : null; | ||
| const showBranchStatus = status === 'status-value:error' || status === 'status-value:warning'; | ||
|
|
||
| return ( | ||
|
|
@@ -454,7 +520,6 @@ const Node = React.memo<NodeProps>(function Node(props) { | |
| setMobileMenuOpen(false); | ||
| } | ||
| }} | ||
| {...(item.type === 'docs' && { docsMode })} | ||
| > | ||
| {(item.renderLabel as (i: typeof item, api: API) => React.ReactNode)?.(item, api) || | ||
| item.name} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -381,6 +381,7 @@ export default { | |
| 'lighten', | ||
| 'styled', | ||
| 'themes', | ||
| 'tokens', | ||
| 'typography', | ||
| 'useTheme', | ||
| 'withTheme', | ||
|
|
||
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.
To sum it up, we want a status only on docs and stories entries that do not contain child tests. Is that so?
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.
IIRC, status should be for:
The logic here is muddy to me.
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.
Feel free to make changes.
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.
I do think this is inconsistent with line 418 on the same file, but the Vitest addon on the monorepo does not run on my machine so I can't investigate this right now. :(