Skip to content

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

TypeScript

fix(theme): xdsClassName for TimeInput and Tooltip, fix hardcoded fontSize (#749)

Cindy Zhang9eb8b007b82a
diff --git a/packages/core/src/Layer/useXDSLayer.tsx b/packages/core/src/Layer/useXDSLayer.tsx
index f9adf10a29..36d7f63f73 100644
--- a/packages/core/src/Layer/useXDSLayer.tsx
+++ b/packages/core/src/Layer/useXDSLayer.tsx
@@ -73,6 +73,16 @@ export interface ContextRenderProps {
* StyleX styles for the popover container.
*/
xstyle?: StyleXStyles;
+ /**
+ * Additional CSS class name(s) for the popover container.
+ * Use with xdsClassName() for theme targeting.
+ */
+ className?: string;
+ /**
+ * Inline styles for the popover container.
+ * Merged after StyleX and anchor positioning styles.
+ */
+ style?: React.CSSProperties;
}
/**
@@ -81,6 +91,20 @@ export interface ContextRenderProps {
export interface FixedRenderProps {
x: number;
y: number;
+ /**
+ * StyleX styles for the popover container.
+ */
+ xstyle?: StyleXStyles;
+ /**
+ * Additional CSS class name(s) for the popover container.
+ * Use with xdsClassName() for theme targeting.
+ */
+ className?: string;
+ /**
+ * Inline styles for the popover container.
+ * Merged after StyleX and position styles.
+ */
+ style?: React.CSSProperties;
}
/**
@@ -329,7 +353,13 @@ export function useXDSLayer(
// Render function for context mode
const renderContext = useCallback(
(children: ReactNode, props?: ContextRenderProps) => {
- const {placement = 'above', alignment = 'center', xstyle} = props || {};
+ const {
+ placement = 'above',
+ alignment = 'center',
+ xstyle,
+ className: extraClassName,
+ style: extraStyle,
+ } = props || {};
// CSS anchor positioning (dynamic, not in StyleX)
const anchorStyle: React.CSSProperties = {
@@ -338,13 +368,18 @@ export function useXDSLayer(
positionTryFallbacks: 'flip-block, flip-inline, flip-block flip-inline',
} as React.CSSProperties;
+ const stylexResult = stylex.props(styles.base, xstyle);
+ const combinedClassName = extraClassName
+ ? `${extraClassName} ${stylexResult.className ?? ''}`
+ : stylexResult.className;
+
return (
<div
ref={popoverRefCallback}
id={id}
popover={lightDismiss ? 'auto' : 'manual'}
- {...stylex.props(styles.base, xstyle)}
- style={anchorStyle}>
+ className={combinedClassName}
+ style={{...stylexResult.style, ...anchorStyle, ...extraStyle}}>
{children}
</div>
);
@@ -355,7 +390,13 @@ export function useXDSLayer(
// Render function for fixed mode
const renderFixed = useCallback(
(children: ReactNode, props: FixedRenderProps) => {
- const {x, y} = props;
+ const {
+ x,
+ y,
+ xstyle,
+ className: extraClassName,
+ style: extraStyle,
+ } = props;
// Dynamic position values
const positionStyle: React.CSSProperties = {
@@ -363,13 +404,18 @@ export function useXDSLayer(
left: x,
};
+ const stylexResult = stylex.props(styles.base, styles.fixed, xstyle);
+ const combinedClassName = extraClassName
+ ? `${extraClassName} ${stylexResult.className ?? ''}`
+ : stylexResult.className;
+
return (
<div
ref={popoverRefCallback}
id={id}
popover={lightDismiss ? 'auto' : 'manual'}
- {...stylex.props(styles.base, styles.fixed)}
- style={positionStyle}>
+ className={combinedClassName}
+ style={{...stylexResult.style, ...positionStyle, ...extraStyle}}>
{children}
</div>
);
diff --git a/packages/core/src/TimeInput/XDSTimeInput.tsx b/packages/core/src/TimeInput/XDSTimeInput.tsx
index 09aafbb699..259b1a5396 100644
--- a/packages/core/src/TimeInput/XDSTimeInput.tsx
+++ b/packages/core/src/TimeInput/XDSTimeInput.tsx
@@ -53,6 +53,8 @@ import {
formatISOTime,
adjustTime,
isTimeInRange,
+ xdsClassName,
+ mergeProps,
} from '../utils';
const styles = stylex.create({
@@ -495,13 +497,16 @@ export function XDSTimeInput({
}
labelTooltip={labelTooltip}>
<div
- {...stylex.props(
- inputWrapperStyles.base,
- sizeStyles[size],
- isDisabled && inputWrapperStyles.disabled,
- status && inputStatusBorderStyles[status.type],
- status && inputStatusHoverShadowStyles[status.type],
- status && inputStatusFocusWithinStyles[status.type],
+ {...mergeProps(
+ xdsClassName('time-input', {size}),
+ stylex.props(
+ inputWrapperStyles.base,
+ sizeStyles[size],
+ isDisabled && inputWrapperStyles.disabled,
+ status && inputStatusBorderStyles[status.type],
+ status && inputStatusHoverShadowStyles[status.type],
+ status && inputStatusFocusWithinStyles[status.type],
+ ),
)}>
<div {...stylex.props(styles.icon)}>
<XDSIcon icon="clock" size="sm" color="secondary" />
diff --git a/packages/core/src/Tooltip/useXDSTooltip.tsx b/packages/core/src/Tooltip/useXDSTooltip.tsx
index 0d2b646f54..2b1fb9f8b4 100644
--- a/packages/core/src/Tooltip/useXDSTooltip.tsx
+++ b/packages/core/src/Tooltip/useXDSTooltip.tsx
@@ -31,8 +31,10 @@ import {
radiusVars,
spacingVars,
typographyVars,
+ textSizeVars,
lineHeightVars,
} from '../theme/tokens.stylex';
+import {xdsClassName} from '../utils';
const styles = stylex.create({
// Base container styles - inverted colors for high contrast
@@ -43,7 +45,7 @@ const styles = stylex.create({
borderRadius: radiusVars['--radius-2'],
// Typography
fontFamily: typographyVars['--font-body'],
- fontSize: 14,
+ fontSize: textSizeVars['--text-base'],
lineHeight: lineHeightVars['--leading-base'],
// Animation: closed state (default) and open state
opacity: {
@@ -396,6 +398,7 @@ export function useXDSTooltip(
placement: props?.placement ?? placement,
alignment: props?.alignment ?? alignment,
xstyle: popoverXstyle,
+ className: xdsClassName('tooltip'),
};
return layer.render(