Skip to content

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

TypeScript

fix: hardening sweep for #840 (#968)

Cindy Zhang0042f0accec4
diff --git a/apps/storybook/stories/List.stories.tsx b/apps/storybook/stories/List.stories.tsx
index 0133aa25bd..7d1035abfa 100644
--- a/apps/storybook/stories/List.stories.tsx
+++ b/apps/storybook/stories/List.stories.tsx
@@ -197,20 +197,20 @@ export const WithMedia: Story = {
<XDSListItem
label="Alex Johnson"
description="Hey, are we still on for lunch tomorrow?"
- startContent={<XDSAvatar name="Alex Johnson" size="md" />}
+ startContent={<XDSAvatar name="Alex Johnson" size={40} />}
onClick={() => {}}
endContent={<XDSBadge label="2" />}
/>
<XDSListItem
label="Sam Rivera"
description="I pushed the latest changes to the repo"
- startContent={<XDSAvatar name="Sam Rivera" size="md" />}
+ startContent={<XDSAvatar name="Sam Rivera" size={40} />}
onClick={() => {}}
/>
<XDSListItem
label="Jordan Lee"
description="Can you review the design spec when you get a chance?"
- startContent={<XDSAvatar name="Jordan Lee" size="md" />}
+ startContent={<XDSAvatar name="Jordan Lee" size={40} />}
onClick={() => {}}
endContent={<XDSBadge label="5" />}
/>
diff --git a/apps/storybook/stories/Popover.stories.tsx b/apps/storybook/stories/Popover.stories.tsx
index 65c994bb12..008f44be7a 100644
--- a/apps/storybook/stories/Popover.stories.tsx
+++ b/apps/storybook/stories/Popover.stories.tsx
@@ -122,7 +122,7 @@ function FilterContent({onApply}: {onApply?: () => void}) {
onChange={() => toggle('shared')}
/>
<XDSDivider />
- <XDSHStack gap={2}>
+ <XDSHStack gap={2} hAlign="end">
<XDSButton label="Apply" variant="primary" onClick={onApply}>
Apply
</XDSButton>
@@ -181,7 +181,7 @@ function ConfirmContent({
This will permanently delete the project and all its data. This action
cannot be undone.
</XDSText>
- <XDSHStack gap={2}>
+ <XDSHStack gap={2} hAlign="end">
<XDSButton label="Delete" variant="destructive" onClick={onConfirm}>
Delete
</XDSButton>
diff --git a/apps/storybook/stories/Text.stories.tsx b/apps/storybook/stories/Text.stories.tsx
index 64270c167f..d568db52c6 100644
--- a/apps/storybook/stories/Text.stories.tsx
+++ b/apps/storybook/stories/Text.stories.tsx
@@ -538,7 +538,7 @@ export const CardExample: Story = {
export const MetricsExample: Story = {
render: () => (
<div style={{display: 'flex', gap: '24px'}}>
- <div style={{textAlign: 'center'}}>
+ <div style={{textAlign: 'start'}}>
<XDSText type="body" color="secondary" display="block">
Revenue
</XDSText>
@@ -546,7 +546,7 @@ export const MetricsExample: Story = {
$1,234,567.89
</XDSText>
</div>
- <div style={{textAlign: 'center'}}>
+ <div style={{textAlign: 'start'}}>
<XDSText type="body" color="secondary" display="block">
Users
</XDSText>
@@ -554,7 +554,7 @@ export const MetricsExample: Story = {
12,345
</XDSText>
</div>
- <div style={{textAlign: 'center'}}>
+ <div style={{textAlign: 'start'}}>
<XDSText type="body" color="secondary" display="block">
Conversion
</XDSText>
diff --git a/apps/storybook/stories/Tooltip.stories.tsx b/apps/storybook/stories/Tooltip.stories.tsx
index 0b13383b9d..3ba79bf9e6 100644
--- a/apps/storybook/stories/Tooltip.stories.tsx
+++ b/apps/storybook/stories/Tooltip.stories.tsx
@@ -78,11 +78,20 @@ export const CustomDelay: Story = {
};
export const Disabled: Story = {
+ name: 'Disabled Tooltip',
args: {
placement: 'above',
isEnabled: false,
content: 'You should not see this',
- children: <XDSButton label="Tooltip disabled">Tooltip disabled</XDSButton>,
+ children: <XDSButton label="Hover me">Hover me</XDSButton>,
+ },
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'Demonstrates disabling the tooltip via the `isEnabled` prop. When `isEnabled` is `false`, the tooltip will not appear on hover or focus, even though the trigger element remains fully interactive. This is useful for conditionally showing tooltips based on application state.',
+ },
+ },
},
};
diff --git a/packages/core/src/List/XDSList.test.tsx b/packages/core/src/List/XDSList.test.tsx
index 48efef59fc..a3d2b030a0 100644
--- a/packages/core/src/List/XDSList.test.tsx
+++ b/packages/core/src/List/XDSList.test.tsx
@@ -540,21 +540,44 @@ describe('XDSList', () => {
</XDSList>,
);
const item = screen.getByTestId('item');
- // When markers are shown, inner content is wrapped in a div
- const innerWrapper = item.querySelector('div');
- expect(innerWrapper).toBeInTheDocument();
+ // Custom marker rendered as a span (dot marker container)
+ const markerContainer = item.querySelector(':scope > span:first-child');
+ expect(markerContainer).toBeInTheDocument();
+ // The dot itself is a nested span
+ const dot = markerContainer?.querySelector('span');
+ expect(dot).toBeInTheDocument();
});
- it('does not wrap content when listStyle is none', () => {
+ it('renders list markers for decimal style', () => {
render(
- <XDSList listStyle="none">
- <XDSListItem label="Plain item" data-testid="item" />
+ <XDSList listStyle="decimal">
+ <XDSListItem label="Numbered item" data-testid="item" />
</XDSList>,
);
const item = screen.getByTestId('item');
- // No inner div wrapper when no markers
- const innerDiv = item.querySelector(':scope > div');
- expect(innerDiv).not.toBeInTheDocument();
+ // Number marker uses CSS counter via ::before pseudo-element
+ const marker = item.querySelector(':scope > span:first-child');
+ expect(marker).toBeInTheDocument();
+ });
+
+ it('does not render markers when listStyle is none', () => {
+ const {container} = render(
+ <XDSList listStyle="disc">
+ <XDSListItem label="With marker" data-testid="with-marker" />
+ </XDSList>,
+ );
+ const withMarker = screen.getByTestId('with-marker');
+ const markerCount = withMarker.children.length;
+
+ const {container: container2} = render(
+ <XDSList listStyle="none">
+ <XDSListItem label="Plain item" data-testid="no-marker" />
+ </XDSList>,
+ );
+ const noMarker = screen.getByTestId('no-marker');
+ // Without markers, the item should have fewer direct children
+ // (no marker container element)
+ expect(noMarker.children.length).toBeLessThan(markerCount);
});
// ===========================================================================
diff --git a/packages/core/src/List/XDSList.tsx b/packages/core/src/List/XDSList.tsx
index a2491f9372..601818dad2 100644
--- a/packages/core/src/List/XDSList.tsx
+++ b/packages/core/src/List/XDSList.tsx
@@ -13,22 +13,21 @@
* - /apps/storybook/stories/List.stories.tsx
*/
-
import {useId, useMemo, type ReactNode} from 'react';
import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {spacingVars} from '../theme/tokens.stylex';
-import {XDSListContext, type XDSListDensity} from './XDSListContext';
+import {
+ XDSListContext,
+ type XDSListDensity,
+ type XDSListMarkerStyle,
+} from './XDSListContext';
import {xdsClassName, mergeProps} from '../utils';
-// =============================================================================
-// Types
-// =============================================================================
-
-/** List marker style. */
-export type XDSListStyle = 'none' | 'disc' | 'decimal' | 'circle';
-
-export {type XDSListDensity} from './XDSListContext';
+export {
+ type XDSListDensity,
+ type XDSListMarkerStyle as XDSListStyle,
+} from './XDSListContext';
export interface XDSListProps {
/** Ref forwarded to the root element */
@@ -64,7 +63,7 @@ export interface XDSListProps {
* When 'decimal', renders an `<ol>`. Otherwise renders a `<ul>`.
* @default 'none'
*/
- listStyle?: XDSListStyle;
+ listStyle?: XDSListMarkerStyle;
/**
* StyleX styles created via `stylex.create()`. Merged with the component's
@@ -102,30 +101,16 @@ const styles = stylex.create({
list: {
margin: 0,
paddingInlineStart: 0,
+ listStyleType: 'none',
},
- listWithMarkers: {
- paddingInlineStart: spacingVars['--spacing-6'],
+ withCounter: {
+ counterReset: 'xds-list',
},
header: {
marginBottom: spacingVars['--spacing-2'],
},
});
-const listStyleTypes = stylex.create({
- none: {
- listStyleType: 'none',
- },
- disc: {
- listStyleType: 'disc',
- },
- decimal: {
- listStyleType: 'decimal',
- },
- circle: {
- listStyleType: 'circle',
- },
-});
-
// =============================================================================
// Component
// =============================================================================
@@ -162,12 +147,11 @@ export function XDSList({
}: XDSListProps) {
const headerId = useId();
const isOrdered = listStyle === 'decimal';
- const hasMarkers = listStyle !== 'none';
const Tag = isOrdered ? 'ol' : 'ul';
const contextValue = useMemo(
- () => ({density, hasDividers, hasMarkers}),
- [density, hasDividers, hasMarkers],
+ () => ({density, hasDividers, listStyle}),
+ [density, hasDividers, listStyle],
);
return (
@@ -186,8 +170,7 @@ export function XDSList({
xdsClassName('list', {density, listStyle}),
stylex.props(
styles.list,
- listStyleTypes[listStyle],
- hasMarkers && styles.listWithMarkers,
+ listStyle !== 'none' && styles.withCounter,
xstyle,
),
className,
diff --git a/packages/core/src/List/XDSListContext.tsx b/packages/core/src/List/XDSListContext.tsx
index 71cfd1035f..5d368c0c95 100644
--- a/packages/core/src/List/XDSListContext.tsx
+++ b/packages/core/src/List/XDSListContext.tsx
@@ -7,15 +7,15 @@
* @position Internal context; consumed by XDSList.tsx and XDSListItem.tsx
*/
-
import {createContext} from 'react';
export type XDSListDensity = 'compact' | 'balanced' | 'spacious';
+export type XDSListMarkerStyle = 'none' | 'disc' | 'decimal' | 'circle';
export interface XDSListContextValue {
density: XDSListDensity;
hasDividers: boolean;
- hasMarkers: boolean;
+ listStyle: XDSListMarkerStyle;
}
export const XDSListContext = createContext<XDSListContextValue | null>(null);
diff --git a/packages/core/src/List/XDSListItem.tsx b/packages/core/src/List/XDSListItem.tsx
index c098756e32..9d4a0dc9cc 100644
--- a/packages/core/src/List/XDSListItem.tsx
+++ b/packages/core/src/List/XDSListItem.tsx
@@ -122,33 +122,24 @@ export interface XDSListItemProps {
// =============================================================================
const styles = stylex.create({
- // Default layout: <li> is the flex container
+ // <li> is always a flex container — markers are rendered as custom
+ // components rather than native list-style (avoids cross-browser issues
+ // with display:list-item + list-style-position:inside on mobile Safari).
item: {
display: 'flex',
alignItems: 'center',
- gap: spacingVars['--spacing-3'],
+ gap: spacingVars['--spacing-2'],
paddingInline: spacingVars['--spacing-2'],
position: 'relative',
boxSizing: 'border-box',
textAlign: 'start',
},
- // When list has markers (disc/decimal/circle), <li> must be list-item
- // so the browser renders the ::marker. Flex layout moves to inner wrapper.
- itemWithMarker: {
- display: 'list-item',
- paddingInline: spacingVars['--spacing-2'],
- position: 'relative',
- boxSizing: 'border-box',
- textAlign: 'start',
- },
- // Inner flex wrapper used when markers are shown
- innerWrapper: {
- display: 'flex',
- alignItems: 'center',
- gap: spacingVars['--spacing-3'],
+ // When markers are active, bump the CSS counter
+ withCounter: {
+ counterIncrement: 'xds-list',
},
withRadius: {
- borderRadius: radiusVars['--radius-inner'],
+ borderRadius: radiusVars['--radius-element'],
},
noRadius: {
borderRadius: 0,
@@ -267,6 +258,54 @@ const densityStyles = stylex.create({
},
});
+// =============================================================================
+// Marker styles — custom-rendered markers instead of native list-style-type.
+// Uses CSS counters for numbers (same pattern as WWW XDS).
+// =============================================================================
+
+const MARKER_DOT_SIZE = 6;
+
+const markerStyles = stylex.create({
+ container: {
+ alignSelf: 'baseline',
+ boxSizing: 'border-box',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ flexShrink: 0,
+ width: spacingVars['--spacing-3'],
+ // Vertically center the dot/circle with the first line of text:
+ // shift down by (lineHeight - dotSize) / 2
+ marginTop: `calc((1em * ${typeScaleVars['--text-body-leading']} - ${MARKER_DOT_SIZE}px) / 2)`,
+ },
+ dot: {
+ width: MARKER_DOT_SIZE,
+ height: MARKER_DOT_SIZE,
+ borderRadius: '50%',
+ backgroundColor: colorVars['--color-text-primary'],
+ },
+ circle: {
+ width: MARKER_DOT_SIZE,
+ height: MARKER_DOT_SIZE,
+ borderRadius: '50%',
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: colorVars['--color-text-primary'],
+ backgroundColor: 'transparent',
+ },
+ number: {
+ alignSelf: 'baseline',
+ flexShrink: 0,
+ color: colorVars['--color-text-primary'],
+ fontSize: typeScaleVars['--text-body-size'],
+ lineHeight: typeScaleVars['--text-body-leading'],
+ width: spacingVars['--spacing-3'],
+ '::before': {
+ content: 'counter(xds-list) "."',
+ },
+ },
+});
+
const descriptionSizeStyles = stylex.create({
compact: {
fontSize: typeScaleVars['--text-supporting-size'],
@@ -319,7 +358,8 @@ export function XDSListItem({
const ctx = useContext(XDSListContext);
const density = ctx?.density ?? 'balanced';
const hasDividers = ctx?.hasDividers ?? false;
- const hasMarkers = ctx?.hasMarkers ?? false;
+ const listStyle = ctx?.listStyle ?? 'none';
+ const hasMarkers = listStyle !== 'none';
const isInteractive = onClick != null || href != null;
const isStringDescription = typeof description === 'string';
@@ -381,6 +421,19 @@ export function XDSListItem({
</>
);
+ const marker =
+ listStyle === 'disc' ? (
+ <span {...stylex.props(markerStyles.container)}>
+ <span {...stylex.props(markerStyles.dot)} />
+ </span>
+ ) : listStyle === 'circle' ? (
+ <span {...stylex.props(markerStyles.container)}>
+ <span {...stylex.props(markerStyles.circle)} />
+ </span>
+ ) : listStyle === 'decimal' ? (
+ <span {...stylex.props(markerStyles.number)} />
+ ) : null;
+
return (
<li
ref={ref}
@@ -390,7 +443,8 @@ export function XDSListItem({
{...mergeProps(
xdsClassName('list-item'),
stylex.props(
- hasMarkers ? styles.itemWithMarker : styles.item,
+ styles.item,
+ hasMarkers && styles.withCounter,
densityStyles[density],
hasDividers ? styles.noRadius : styles.withRadius,
hasDividers && styles.withDivider,
@@ -404,11 +458,8 @@ export function XDSListItem({
style,
)}
onClick={isInteractive ? handleContainerClick : undefined}>
- {hasMarkers ? (
- <div {...stylex.props(styles.innerWrapper)}>{innerContent}</div>
- ) : (
- innerContent
- )}
+ {marker}
+ {innerContent}
</li>
);
}
diff --git a/packages/core/src/RadioList/XDSRadioList.tsx b/packages/core/src/RadioList/XDSRadioList.tsx
index ca6119375b..6868d35575 100644
--- a/packages/core/src/RadioList/XDSRadioList.tsx
+++ b/packages/core/src/RadioList/XDSRadioList.tsx
@@ -42,13 +42,14 @@ export const XDSRadioListContext =
const styles = stylex.create({
radiogroup: {
display: 'flex',
- gap: spacingVars['--spacing-2'],
},
vertical: {
flexDirection: 'column',
+ gap: spacingVars['--spacing-2'],
},
horizontal: {
flexDirection: 'row',
+ gap: spacingVars['--spacing-5'],
},
});
diff --git a/packages/core/src/RadioList/XDSRadioListItem.tsx b/packages/core/src/RadioList/XDSRadioListItem.tsx
index 9a3e729655..88d9f88dc4 100644
--- a/packages/core/src/RadioList/XDSRadioListItem.tsx
+++ b/packages/core/src/RadioList/XDSRadioListItem.tsx
@@ -31,7 +31,7 @@ import {xdsClassName, mergeProps} from '../utils';
const styles = stylex.create({
container: {
display: 'flex',
- alignItems: 'flex-start',
+ alignItems: 'center',
gap: spacingVars['--spacing-2'],
},
radioWrapper: {
@@ -118,7 +118,6 @@ const styles = stylex.create({
display: 'flex',
flexDirection: 'column',
gap: spacingVars['--spacing-0-5'],
- marginTop: 1,
},
label: {
fontFamily: typographyVars['--font-family-body'],
@@ -183,15 +182,6 @@ const dotSizeStyles = stylex.create({
},
});
-const labelWrapperSizeStyles = stylex.create({
- sm: {
- marginTop: 1,
- },
- md: {
- marginTop: 3,
- },
-});
-
export interface XDSRadioListItemProps {
/**
* Label text for the radio item.
@@ -264,9 +254,6 @@ export function XDSRadioListItem({
xdsClassName('radio-list-item'),
stylex.props(styles.container, !isDisabled && stylex.defaultMarker()),
)}>
- {startContent && (
- <div {...stylex.props(styles.startContent)}>{startContent}</div>
- )}
<div
{...stylex.props(
styles.radioWrapper,
@@ -315,19 +302,22 @@ export function XDSRadioListItem({
)}
</div>
</div>
- <div {...stylex.props(styles.labelWrapper, labelWrapperSizeStyles[size])}>
+ {startContent != null && (
+ <div {...stylex.props(styles.startContent)}>{startContent}</div>
+ )}
+ <div {...stylex.props(styles.labelWrapper)}>
<label
htmlFor={id}
{...stylex.props(styles.label, isDisabled && styles.labelDisabled)}>
{label}
</label>
- {description && (
+ {description != null && (
<span id={descriptionID} {...stylex.props(styles.description)}>
{description}
</span>
)}
</div>
- {endContent && (
+ {endContent != null && (
<div {...stylex.props(styles.endContent)}>{endContent}</div>
)}
</div>
diff --git a/packages/core/src/Tooltip/useXDSTooltip.tsx b/packages/core/src/Tooltip/useXDSTooltip.tsx
index 2fc9f04c31..b7f04f9b3b 100644
--- a/packages/core/src/Tooltip/useXDSTooltip.tsx
+++ b/packages/core/src/Tooltip/useXDSTooltip.tsx
@@ -41,7 +41,7 @@ const styles = stylex.create({
// Inverted color palette: dark background, light text
backgroundColor: colorVars['--color-text-primary'],
color: colorVars['--color-background-surface'],
- borderRadius: radiusVars['--radius-element'],
+ borderRadius: radiusVars['--radius-container'],
// Typography
fontFamily: typographyVars['--font-family-body'],
fontSize: typeScaleVars['--text-body-size'],
diff --git a/packages/core/src/TreeList/XDSTreeListBranches.tsx b/packages/core/src/TreeList/XDSTreeListBranches.tsx
index f247b17d3d..5b89d701e5 100644
--- a/packages/core/src/TreeList/XDSTreeListBranches.tsx
+++ b/packages/core/src/TreeList/XDSTreeListBranches.tsx
@@ -10,17 +10,25 @@
* - /packages/core/src/TreeList/XDSTreeListItem.tsx
*/
-
import * as stylex from '@stylexjs/stylex';
-import {colorVars} from '../theme/tokens.stylex';
+import {colorVars, spacingVars} from '../theme/tokens.stylex';
const LINE_WIDTH = 2;
+/**
+ * Branch margin from the left edge. No exact spacing token for 10px,
+ * so we use calc(--spacing-2 + --spacing-0-5) = 8 + 2 = 10.
+ */
+const BRANCH_MARGIN = `calc(${spacingVars['--spacing-2']} + ${spacingVars['--spacing-0-5']})`;
+
+/** Per-level indent width, matching --spacing-5 (20px). */
+const LEVEL_INDENT = spacingVars['--spacing-5'];
+
const styles = stylex.create({
container: {
height: '100%',
position: 'absolute',
- width: 20,
+ width: spacingVars['--spacing-5'],
},
verticalLine: {
borderRadius: 1,
@@ -37,9 +45,13 @@ const styles = stylex.create({
verticalToHalf: {
height: '50%',
},
+ verticalToHalfWithTerminus: {
+ height: '50%',
+ borderBottomRightRadius: LINE_WIDTH * 2,
+ },
connectorContainer: {
position: 'absolute',
- width: 20,
+ width: spacingVars['--spacing-5'],
height: '100%',
top: 0,
},
@@ -65,15 +77,11 @@ const styles = stylex.create({
interface XDSTreeListBranchesProps {
ancestorsIsLast: ReadonlyArray<boolean>;
isLast: boolean;
- levelIndent: number;
- marginLeft: number;
nestedLevel: number;
}
interface XDSTreeListHorizontalConnectorProps {
hasChildren: boolean;
- levelIndent: number;
- marginLeft: number;
nestedLevel: number;
}
@@ -88,19 +96,23 @@ interface XDSTreeListHorizontalConnectorProps {
export function XDSTreeListBranches({
ancestorsIsLast,
isLast,
- levelIndent,
- marginLeft,
nestedLevel,
}: XDSTreeListBranchesProps) {
return (
<>
{ancestorsIsLast.map(
(ancestorIsLast, level) =>
- !ancestorIsLast && (
+ // Skip the level that the current-item connector occupies
+ // (nestedLevel - 1), since that position is rendered below
+ // with the correct terminus/continuation style.
+ !ancestorIsLast &&
+ level !== nestedLevel - 1 && (
<div
key={level}
{...stylex.props(styles.container)}
- style={{left: marginLeft + level * levelIndent}}>
+ style={{
+ left: `calc(${BRANCH_MARGIN} + ${level} * ${LEVEL_INDENT})`,
+ }}>
<div
{...stylex.props(styles.verticalLine, styles.verticalFull)}
/>
@@ -110,11 +122,13 @@ export function XDSTreeListBranches({
{nestedLevel > 0 && (
<div
{...stylex.props(styles.container)}
- style={{left: marginLeft + (nestedLevel - 1) * levelIndent}}>
+ style={{
+ left: `calc(${BRANCH_MARGIN} + ${nestedLevel - 1} * ${LEVEL_INDENT})`,
+ }}>
<div
{...stylex.props(
styles.verticalLine,
- isLast ? styles.verticalToHalf : styles.verticalFull,
+ isLast ? styles.verticalToHalfWithTerminus : styles.verticalFull,
)}
/>
</div>
@@ -130,8 +144,6 @@ export function XDSTreeListBranches({
*/
export function XDSTreeListHorizontalConnector({
hasChildren,
- levelIndent,
- marginLeft,
nestedLevel,
}: XDSTreeListHorizontalConnectorProps) {
if (nestedLevel <= 0) return null;
@@ -139,7 +151,9 @@ export function XDSTreeListHorizontalConnector({
return (
<div
{...stylex.props(styles.connectorContainer)}
- style={{left: marginLeft + (nestedLevel - 1) * levelIndent}}>
+ style={{
+ left: `calc(${BRANCH_MARGIN} + ${nestedLevel - 1} * ${LEVEL_INDENT})`,
+ }}>
<div
{...stylex.props(
styles.horizontalLine,
diff --git a/packages/core/src/TreeList/XDSTreeListItem.tsx b/packages/core/src/TreeList/XDSTreeListItem.tsx
index 292821bdc7..8b971b7c83 100644
--- a/packages/core/src/TreeList/XDSTreeListItem.tsx
+++ b/packages/core/src/TreeList/XDSTreeListItem.tsx
@@ -29,15 +29,6 @@ import {
} from './XDSTreeListBranches';
import type {XDSTreeListDensity} from './XDSTreeListTypes';
-// =============================================================================
-// Constants
-// =============================================================================
-
-const INDENT = 20;
-const CHEVRON_SIZE = 16;
-const CHEVRON_MARGIN = 8;
-const BRANCH_MARGIN_LEFT = 9;
-
// =============================================================================
// Styles
// =============================================================================
@@ -56,13 +47,13 @@ const styles = stylex.create({
listStyleType: 'none',
},
treeBranches: {
- paddingInlineStart: BRANCH_MARGIN_LEFT,
+ paddingInlineStart: `calc(${spacingVars['--spacing-2']} + ${spacingVars['--spacing-0-5']})`,
},
rowWrapper: {
position: 'relative',
},
contentWrapper: {
- borderRadius: radiusVars['--radius-inner'],
+ borderRadius: radiusVars['--radius-element'],
display: 'flex',
alignItems: 'center',
gap: spacingVars['--spacing-2'],
@@ -156,27 +147,31 @@ const styles = stylex.create({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
- width: CHEVRON_SIZE,
- height: CHEVRON_SIZE,
- fontSize: CHEVRON_SIZE,
+ width: spacingVars['--spacing-4'],
+ height: spacingVars['--spacing-4'],
+ fontSize: spacingVars['--spacing-4'],
cursor: 'pointer',
border: 'none',
background: 'none',
padding: 0,
color: colorVars['--color-icon-secondary'],
borderRadius: radiusVars['--radius-inner'],
+ marginInlineStart: spacingVars['--spacing-1'],
+ marginInlineEnd: `calc(${spacingVars['--spacing-1']} * -1)`,
},
chevronButton: {
all: 'unset',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
- width: CHEVRON_SIZE,
- height: CHEVRON_SIZE,
- fontSize: CHEVRON_SIZE,
+ width: spacingVars['--spacing-4'],
+ height: spacingVars['--spacing-4'],
+ fontSize: spacingVars['--spacing-4'],
cursor: 'pointer',
color: colorVars['--color-icon-secondary'],
borderRadius: radiusVars['--radius-inner'],
+ marginInlineStart: spacingVars['--spacing-1'],
+ marginInlineEnd: `calc(${spacingVars['--spacing-1']} * -1)`,
},
chevronSvg: {
display: 'flex',
@@ -308,10 +303,8 @@ export function XDSTreeListItem({
}, [onClick, hasChildren, onToggle, id, isDisabled]);
const computedMarginLeft = hasChildren
- ? nestedLevel * INDENT
- : nestedLevel * INDENT +
- CHEVRON_SIZE +
- (startContent != null ? 0 : CHEVRON_MARGIN);
+ ? `calc(${nestedLevel} * ${spacingVars['--spacing-5']})`
+ : `calc(${nestedLevel} * ${spacingVars['--spacing-5']} + ${spacingVars['--spacing-4']} + ${spacingVars['--spacing-2']})`;
const labelAndDescription = (
<>
@@ -402,16 +395,12 @@ export function XDSTreeListItem({
<XDSTreeListBranches
ancestorsIsLast={ancestorsIsLast}
isLast={isLast}
- levelIndent={INDENT}
- marginLeft={BRANCH_MARGIN_LEFT}
nestedLevel={nestedLevel}
/>
</div>
<div {...stylex.props(styles.rowWrapper)}>
<XDSTreeListHorizontalConnector
hasChildren={hasChildren}
- levelIndent={INDENT}
- marginLeft={BRANCH_MARGIN_LEFT}
nestedLevel={nestedLevel}
/>
<div