An open source design system that's fully customizable and agent ready
TypeScript
fix(StatusDot): harden neutral color, add tooltip, fix tests (#2294)
Andrey Goder37a31d3f5a6c
diff --git a/apps/storybook/stories/StatusDot.stories.tsx b/apps/storybook/stories/StatusDot.stories.tsxindex 2d8540ef8b..41fe1bc574 100644--- a/apps/storybook/stories/StatusDot.stories.tsx+++ b/apps/storybook/stories/StatusDot.stories.tsx@@ -21,6 +21,10 @@ const meta: Meta<typeof XDSStatusDot> = {control: 'boolean',description: 'Pulse animation',},+ tooltip: {+ control: 'text',+ description: 'Tooltip text on hover',+ },},};@@ -78,3 +82,14 @@ export const StatusIndicators: Story = {</div>),};++export const WithTooltip: Story = {+ render: () => (+ <div style={{display: 'flex', gap: '16px', alignItems: 'center'}}>+ <XDSStatusDot variant="success" label="Online" tooltip="Online" />+ <XDSStatusDot variant="warning" label="Away" tooltip="Away" />+ <XDSStatusDot variant="error" label="Offline" tooltip="Offline" />+ <XDSStatusDot variant="neutral" label="Unknown" tooltip="Unknown" />+ </div>+ ),+};diff --git a/packages/core/src/StatusDot/StatusDot.doc.mjs b/packages/core/src/StatusDot/StatusDot.doc.mjsindex bbb8ae433c..dd44642f7a 100644--- a/packages/core/src/StatusDot/StatusDot.doc.mjs+++ b/packages/core/src/StatusDot/StatusDot.doc.mjs@@ -25,6 +25,12 @@ export const docs = {'Enables a pulse animation; respects prefers-reduced-motion: reduce.',default: 'false',},+ {+ name: 'tooltip',+ type: 'string',+ description:+ 'Tooltip text shown on hover to explain the status meaning.',+ },{name: 'xstyle',type: 'StyleXStyles',@@ -113,6 +119,7 @@ export const docsDense = {variant: 'Semantic color variant.',label: 'Accessible label via aria-label.',isPulsing: 'Pulse animation; respects prefers-reduced-motion: reduce.',+ tooltip: 'Tooltip text on hover to explain status meaning.',xstyle: 'StyleX layout styles; must be stylex.create() value.',},};\ No newline at end of filediff --git a/packages/core/src/StatusDot/XDSStatusDot.test.tsx b/packages/core/src/StatusDot/XDSStatusDot.test.tsxindex b32d959007..a540106396 100644--- a/packages/core/src/StatusDot/XDSStatusDot.test.tsx+++ b/packages/core/src/StatusDot/XDSStatusDot.test.tsx@@ -75,4 +75,10 @@ describe('XDSStatusDot', () => {const dot = screen.getByRole('img', {name: 'Online'});expect(dot).toBeInTheDocument();});++ it('renders with tooltip', () => {+ render(<XDSStatusDot variant="success" label="Online" tooltip="Online" />);+ const dot = screen.getByRole('img', {name: 'Online'});+ expect(dot).toBeInTheDocument();+ });});diff --git a/packages/core/src/StatusDot/XDSStatusDot.tsx b/packages/core/src/StatusDot/XDSStatusDot.tsxindex 08d35aaab8..c76232f6d5 100644--- a/packages/core/src/StatusDot/XDSStatusDot.tsx+++ b/packages/core/src/StatusDot/XDSStatusDot.tsx@@ -19,6 +19,7 @@import * as stylex from '@stylexjs/stylex';import {colorVars} from '../theme/tokens.stylex';import {XDSBaseProps} from '../XDSBaseProps';+import {XDSTooltip} from '../Tooltip/XDSTooltip';import {xdsClassName, mergeProps} from '../utils';/**@@ -71,7 +72,7 @@ const variants = stylex.create({backgroundColor: colorVars['--color-accent'],},neutral: {- backgroundColor: colorVars['--color-neutral'],+ backgroundColor: colorVars['--color-icon-secondary'],},});@@ -119,6 +120,11 @@ export interface XDSStatusDotProps extends XDSBaseProps<HTMLSpanElement> {* @default false*/isPulsing?: boolean;+ /**+ * Tooltip text shown on hover to explain the status meaning.+ * When omitted, no tooltip is rendered.+ */+ tooltip?: string;}/**@@ -133,19 +139,21 @@ export interface XDSStatusDotProps extends XDSBaseProps<HTMLSpanElement> {* <XDSStatusDot variant="success" label="Online" />* <XDSStatusDot variant="error" label="Offline" />* <XDSStatusDot variant="success" label="Live" isPulsing />+ * <XDSStatusDot variant="success" label="Online" tooltip="Online" />* ```*/export function XDSStatusDot({variant,label,isPulsing = false,+ tooltip,xstyle,className,style,ref,...props}: XDSStatusDotProps) {- return (+ const dot = (<spanref={ref}role="img"@@ -165,6 +173,12 @@ export function XDSStatusDot({{...props}/>);++ if (tooltip) {+ return <XDSTooltip content={tooltip}>{dot}</XDSTooltip>;+ }++ return dot;}XDSStatusDot.displayName = 'XDSStatusDot';