diff --git a/code/ui/components/src/components/tooltip/WithTooltip.tsx b/code/ui/components/src/components/tooltip/WithTooltip.tsx index 058d7140c2a1..bece4bc64278 100644 --- a/code/ui/components/src/components/tooltip/WithTooltip.tsx +++ b/code/ui/components/src/components/tooltip/WithTooltip.tsx @@ -1,4 +1,4 @@ -import type { FC, ReactNode } from 'react'; +import type { ComponentProps, FC, ReactNode } from 'react'; import React, { useCallback, useState, useEffect } from 'react'; import ReactDOM from 'react-dom'; import { styled } from '@storybook/theming'; @@ -28,6 +28,7 @@ interface WithHideFn { export interface WithTooltipPureProps extends Omit, + Omit, 'trigger'>, PopperOptions { svg?: boolean; withArrows?: boolean; @@ -129,7 +130,7 @@ const WithTooltipPure: FC = ({ return ( <> - + {children} {isVisible && ReactDOM.createPortal(tooltipComponent, document.body)} diff --git a/code/ui/manager/src/components/sidebar/SearchResults.tsx b/code/ui/manager/src/components/sidebar/SearchResults.tsx index 8cca81f84cb1..2ce58aba337b 100644 --- a/code/ui/manager/src/components/sidebar/SearchResults.tsx +++ b/code/ui/manager/src/components/sidebar/SearchResults.tsx @@ -172,14 +172,12 @@ const Result: FC< node = ; } - const [i, iconColor] = item.status ? statusMapping[item.status] : []; + const [i] = item.status ? statusMapping[item.status] : []; return ( {node} - {item.status ? ( - - ) : null} + {item.status ? i : null} ); }); diff --git a/code/ui/manager/src/components/sidebar/Tree.tsx b/code/ui/manager/src/components/sidebar/Tree.tsx index 8d5ac50484ea..dadff45d9988 100644 --- a/code/ui/manager/src/components/sidebar/Tree.tsx +++ b/code/ui/manager/src/components/sidebar/Tree.tsx @@ -37,44 +37,47 @@ import { } from '../../utils/tree'; import { statusMapping, getHighestStatus, getGroupStatus } from '../../utils/status'; -export const Action = styled.button(({ theme }) => ({ - display: 'inline-flex', - alignItems: 'center', - justifyContent: 'center', - width: 20, - height: 20, - margin: 0, - marginLeft: 'auto', - padding: 0, - outline: 0, - lineHeight: 'normal', - background: 'none', - border: `1px solid transparent`, - borderRadius: '100%', - cursor: 'pointer', - transition: 'all 150ms ease-out', - color: - theme.base === 'light' - ? transparentize(0.3, theme.color.defaultText) - : transparentize(0.6, theme.color.defaultText), - - '&:hover': { - color: theme.color.secondary, - }, - '&:focus': { - color: theme.color.secondary, - borderColor: theme.color.secondary, +export const Action = styled.button<{ height?: number; width?: number }>( + ({ theme, height, width }) => ({ + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + width: width || 20, + height: height || 20, + boxSizing: 'border-box', + margin: 0, + marginLeft: 'auto', + padding: 0, + outline: 0, + lineHeight: 'normal', + background: 'none', + border: `1px solid transparent`, + borderRadius: '100%', + cursor: 'pointer', + transition: 'all 150ms ease-out', + color: + theme.base === 'light' + ? transparentize(0.3, theme.color.defaultText) + : transparentize(0.6, theme.color.defaultText), + + '&:hover': { + color: theme.color.secondary, + }, + '&:focus': { + color: theme.color.secondary, + borderColor: theme.color.secondary, - '&:not(:focus-visible)': { - borderColor: 'transparent', + '&:not(:focus-visible)': { + borderColor: 'transparent', + }, }, - }, - svg: { - width: 10, - height: 10, - }, -})); + svg: { + width: 10, + height: 10, + }, + }) +); const CollapseButton = styled.button(({ theme }) => ({ // Reset button @@ -207,7 +210,7 @@ const Node = React.memo(function Node({ const LeafNode = item.type === 'docs' ? DocumentNode : StoryNode; const statusValue = getHighestStatus(Object.values(status || {}).map((s) => s.status)); - const [icon, iconColor, textColor] = statusMapping[statusValue]; + const [icon, textColor] = statusMapping[statusValue]; return ( (function Node({ {icon ? ( ( ({ id: k, title: v.title, description: v.description, - right: ( - - ), + right: statusMapping[v.status][0], }))} /> )} closeOnOutsideClick > - - + + {icon} ) : null} @@ -530,7 +529,7 @@ export const Tree = React.memo<{ } const isDisplayed = !item.parent || ancestry[itemId].every((a: string) => expanded[a]); - const color = groupStatus[itemId] ? statusMapping[groupStatus[itemId]][2] : null; + const color = groupStatus[itemId] ? statusMapping[groupStatus[itemId]][1] : null; return ( ({ + // specificity hack + animation: `${animation.glow} 1.5s ease-in-out infinite`, + color: base === 'light' ? color.mediumdark : color.darker, +})); + export const statusPriority: API_StatusValue[] = ['unknown', 'pending', 'success', 'warn', 'error']; -export const statusMapping: Record< - API_StatusValue, - [ComponentProps['icon'] | null, string | null, string | null] -> = { - unknown: [null, null, null], - pending: ['watch', 'currentColor', 'currentColor'], - success: ['circle', 'green', 'currentColor'], - warn: ['circle', 'orange', '#A15C20'], - error: ['circle', 'red', 'brown'], +export const statusMapping: Record = { + unknown: [null, null], + pending: [, 'currentColor'], + success: [, 'currentColor'], + warn: [, '#A15C20'], + error: [, 'brown'], }; export const getHighestStatus = (statuses: API_StatusValue[]): API_StatusValue => {