Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix: avatar status dot sizes + icon non-semantic colors (#929) (#944)

Cindy Zhangeb8a84d43c39
diff --git a/apps/storybook/stories/Icon.stories.tsx b/apps/storybook/stories/Icon.stories.tsx
index 0dc000e30e..b99fea5922 100644
--- a/apps/storybook/stories/Icon.stories.tsx
+++ b/apps/storybook/stories/Icon.stories.tsx
@@ -1,5 +1,7 @@
import type {Meta, StoryObj} from '@storybook/react';
import {XDSIcon} from '@xds/core/Icon';
+import {XDSHStack, XDSVStack} from '@xds/core/Layout';
+import {XDSText} from '@xds/core/Text';
import {
HomeIcon,
HeartIcon,
@@ -246,3 +248,16 @@ export const InheritColor: Story = {
</div>
),
};
+
+export const NonSemanticColors: Story = {
+ render: () => (
+ <XDSHStack gap={4} wrap="wrap">
+ {(['blue', 'red', 'green', 'gray', 'cyan', 'teal', 'yellow', 'orange', 'pink', 'purple'] as const).map(color => (
+ <XDSVStack key={color} gap={1} hAlign="center">
+ <XDSIcon icon={StarIcon} color={color} />
+ <XDSText type="supporting">{color}</XDSText>
+ </XDSVStack>
+ ))}
+ </XDSHStack>
+ ),
+};
diff --git a/packages/core/src/Avatar/XDSAvatarStatusDot.tsx b/packages/core/src/Avatar/XDSAvatarStatusDot.tsx
index 07b9ba925e..4f8f8c95d5 100644
--- a/packages/core/src/Avatar/XDSAvatarStatusDot.tsx
+++ b/packages/core/src/Avatar/XDSAvatarStatusDot.tsx
@@ -28,9 +28,9 @@ import {xdsClassName, mergeProps} from '../utils';
*
* | Avatar size | Dot | Border | Icon |
* |--------------|------|--------|------|
- * | ≤ 36px | 8px | 1px | — |
- * | 40–72px | 16px | 2px | 10px |
- * | ≥ 96px | 24px | 4px | 14px |
+ * | ≤ 36px | 10px | 1px | — |
+ * | 40–72px | 20px | 2px | 12px |
+ * | ≥ 96px | 32px | 4px | 18px |
*
* Icons are not rendered at the smallest tier — there isn't enough
* room for them to be legible.
@@ -41,12 +41,12 @@ function resolveStatusDotSize(avatarSize: number): {
iconSize: number;
} {
if (avatarSize <= 36) {
- return {dotSize: 8, borderWidth: 1, iconSize: 0};
+ return {dotSize: 10, borderWidth: 1, iconSize: 0};
}
if (avatarSize <= 72) {
- return {dotSize: 16, borderWidth: 2, iconSize: 10};
+ return {dotSize: 20, borderWidth: 2, iconSize: 12};
}
- return {dotSize: 24, borderWidth: 4, iconSize: 14};
+ return {dotSize: 32, borderWidth: 4, iconSize: 18};
}
/**
diff --git a/packages/core/src/Icon/XDSIcon.test.tsx b/packages/core/src/Icon/XDSIcon.test.tsx
index aaff4f669c..d33389aaf9 100644
--- a/packages/core/src/Icon/XDSIcon.test.tsx
+++ b/packages/core/src/Icon/XDSIcon.test.tsx
@@ -54,6 +54,34 @@ describe('XDSIcon', () => {
expect(screen.getByTestId('icon')).toBeInTheDocument();
});
+ it('renders with non-semantic color variants', () => {
+ const nonSemanticColors = [
+ 'blue',
+ 'red',
+ 'green',
+ 'gray',
+ 'cyan',
+ 'teal',
+ 'yellow',
+ 'orange',
+ 'pink',
+ 'purple',
+ ] as const;
+ const {rerender} = render(
+ <XDSIcon
+ icon={HomeIcon}
+ color={nonSemanticColors[0]}
+ data-testid="icon"
+ />,
+ );
+ expect(screen.getByTestId('icon')).toBeInTheDocument();
+
+ for (const c of nonSemanticColors.slice(1)) {
+ rerender(<XDSIcon icon={HomeIcon} color={c} data-testid="icon" />);
+ expect(screen.getByTestId('icon')).toBeInTheDocument();
+ }
+ });
+
it('renders with different size variants', () => {
const {rerender} = render(
<XDSIcon icon={HomeIcon} size="xsm" data-testid="icon" />,
diff --git a/packages/core/src/Icon/XDSIcon.tsx b/packages/core/src/Icon/XDSIcon.tsx
index f5e0808fc0..984fa20e0a 100644
--- a/packages/core/src/Icon/XDSIcon.tsx
+++ b/packages/core/src/Icon/XDSIcon.tsx
@@ -19,7 +19,6 @@
* - /apps/storybook/stories/Icon.stories.tsx (storybook stories)
*/
-
import {type ComponentType, type SVGProps} from 'react';
import * as stylex from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
@@ -72,6 +71,37 @@ const colorStyles = stylex.create({
inherit: {
color: 'inherit',
},
+ // Non-semantic colors
+ blue: {
+ color: colorVars['--color-icon-blue'],
+ },
+ red: {
+ color: colorVars['--color-icon-red'],
+ },
+ green: {
+ color: colorVars['--color-icon-green'],
+ },
+ gray: {
+ color: colorVars['--color-icon-gray'],
+ },
+ cyan: {
+ color: colorVars['--color-icon-cyan'],
+ },
+ teal: {
+ color: colorVars['--color-icon-teal'],
+ },
+ yellow: {
+ color: colorVars['--color-icon-yellow'],
+ },
+ orange: {
+ color: colorVars['--color-icon-orange'],
+ },
+ pink: {
+ color: colorVars['--color-icon-pink'],
+ },
+ purple: {
+ color: colorVars['--color-icon-purple'],
+ },
});
/**