An open source design system that's fully customizable and agent ready
TypeScript
fix: extend XDSBaseProps in Banner and Breadcrumbs (#1780)
Cindy Zhanga18aaaa45fd0
diff --git a/packages/core/src/Banner/XDSBanner.tsx b/packages/core/src/Banner/XDSBanner.tsxindex a7c4085ddb..dd4d109b71 100644--- a/packages/core/src/Banner/XDSBanner.tsx+++ b/packages/core/src/Banner/XDSBanner.tsx@@ -22,7 +22,7 @@import {useState, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';-import type {StyleXStyles} from '@stylexjs/stylex';+import type {XDSBaseProps} from '../XDSBaseProps';import {XDSButton} from '../Button';import {XDSIcon} from '../Icon';import type {XDSIconName} from '../Icon';@@ -92,7 +92,7 @@ export interface XDSBannerContainerMap {*/export type XDSBannerContainer = keyof XDSBannerContainerMap;-export interface XDSBannerProps {+export interface XDSBannerProps extends XDSBaseProps<HTMLDivElement> {/** Ref forwarded to the root element */ref?: React.Ref<HTMLDivElement>;/**@@ -152,31 +152,6 @@ export interface XDSBannerProps {* When provided, a collapse/expand toggle button appears in the header.*/children?: ReactNode;- /**- * StyleX styles created via `stylex.create()`. Merged with the component's- * base styles inside a single `stylex.props()` call for optimal deduplication.- *- * @example- * ```- * const overrides = stylex.create({ root: { marginBottom: 8 } });- * <Component xstyle={overrides.root} />- * ```- */- xstyle?: StyleXStyles;- /**- * CSS class name(s) appended to the root element.- * If you're using StyleX, prefer `xstyle` for optimal style deduplication.- */- className?: string;- /**- * Inline styles to apply to the root element. Spread after StyleX- * inline styles, so these values take priority.- */- style?: React.CSSProperties;- /**- * Test ID for the root element.- */- 'data-testid'?: string;}// =============================================================================@@ -385,8 +360,8 @@ export function XDSBanner({xstyle,className,style,- 'data-testid': testId,ref,+ ...rest}: XDSBannerProps) {const [isDismissed, setIsDismissed] = useState(false);const [isExpanded, setIsExpanded] = useState(defaultIsExpanded);@@ -419,7 +394,6 @@ export function XDSBanner({<divref={ref}role={role}- data-testid={testId}{...mergeProps(xdsClassName('banner', {container, status}),stylex.props(@@ -430,7 +404,8 @@ export function XDSBanner({),className,style,- )}>+ )}+ {...rest}>{/* Header: colored status background */}<div{...stylex.props(diff --git a/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsx b/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsxindex 54285edd16..49b1dbdfc9 100644--- a/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsx+++ b/packages/core/src/Breadcrumbs/XDSBreadcrumbs.tsx@@ -16,9 +16,9 @@import {createContext, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';-import type {StyleXStyles} from '@stylexjs/stylex';import {spacingVars} from '../theme/tokens.stylex';import {xdsClassName, mergeProps} from '../utils';+import type {XDSBaseProps} from '../XDSBaseProps';// =============================================================================// Variant type@@ -70,7 +70,7 @@ export const BreadcrumbCtx = createContext<BreadcrumbContextValue>({// Props// =============================================================================-export interface XDSBreadcrumbsProps {+export interface XDSBreadcrumbsProps extends XDSBaseProps<HTMLElement> {/** Ref forwarded to the root element */ref?: React.Ref<HTMLElement>;/**@@ -89,36 +89,11 @@ export interface XDSBreadcrumbsProps {* @default 'default'*/variant?: XDSBreadcrumbsVariant;- /**- * StyleX styles created via `stylex.create()`. Merged with the component's- * base styles inside a single `stylex.props()` call for optimal deduplication.- *- * @example- * ```- * const overrides = stylex.create({ root: { marginBottom: 8 } });- * <Component xstyle={overrides.root} />- * ```- */- xstyle?: StyleXStyles;- /**- * CSS class name(s) appended to the root element.- * If you're using StyleX, prefer `xstyle` for optimal style deduplication.- */- className?: string;- /**- * Inline styles to apply to the root element. Spread after StyleX- * inline styles, so these values take priority.- */- style?: React.CSSProperties;/*** Accessible label for the nav landmark.* @default 'Breadcrumb'*/label?: string;- /**- * Test ID for the nav element.- */- 'data-testid'?: string;}// =============================================================================@@ -172,8 +147,8 @@ export function XDSBreadcrumbs({className,style,label = 'Breadcrumb',- 'data-testid': testId,ref,+ ...rest}: XDSBreadcrumbsProps) {const ctxValue: BreadcrumbContextValue = {variant, separator};@@ -182,13 +157,13 @@ export function XDSBreadcrumbs({<navref={ref}aria-label={label}- data-testid={testId}{...mergeProps(xdsClassName('breadcrumbs', {variant}),stylex.props(navStyles.root, xstyle),className,style,- )}>+ )}+ {...rest}><ol {...stylex.props(listStyles.root)}>{children}</ol></nav></BreadcrumbCtx.Provider>