Skip to content

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

TypeScript

fix(theme): deprecate run-together theme target names onto <component-kebab>-<part> (#5449)

Cindy Zhangf747a49f2cca
diff --git a/.changeset/theme-target-kebab-names.md b/.changeset/theme-target-kebab-names.md
new file mode 100644
index 0000000000..876ad3a389
--- /dev/null
+++ b/.changeset/theme-target-kebab-names.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Seven theme target roots that ran a compound component name together are deprecated onto the `<component-kebab>-<part>` spelling the component's name implies: `codeblock` → `code-block` (with `-copy-button`, `-header`, `-title`), `progressbar` → `progress-bar` (with `-fill`, `-mark`, `-track`), `hovercard` → `hover-card`, `statusdot` → `status-dot`, `textarea` → `text-area`, `navicon` → `nav-icon`, and Table's second root `base-table` → `table` (both named the same `<table>` element). A `defineTheme` key that matches no target fails silently — no error, no warning, the rule never emits — so someone who read `ProgressBar` and wrote `'progress-bar'` got nothing and no explanation. Nothing breaks: every component renders both classes and both keys resolve, including the derived vars a renamed key expands into. The old spellings drop in the next major.
+
+@cixzhang
diff --git a/apps/storybook/stories/ProgressBar.stories.tsx b/apps/storybook/stories/ProgressBar.stories.tsx
index d7b7b48c89..16461940b4 100644
--- a/apps/storybook/stories/ProgressBar.stories.tsx
+++ b/apps/storybook/stories/ProgressBar.stories.tsx
@@ -324,7 +324,7 @@ export const ThemedMarks: Story = {
<div style={{width: '320px'}}>
<style>{`
@layer astryx-theme {
- .themed-marks-demo .astryx-progressbar-mark {
+ .themed-marks-demo .astryx-progress-bar-mark {
background-color: red;
--_progressbar-mark-width: 3px;
--_progressbar-mark-height: 14px;
diff --git a/packages/cli/api/theme/build/build.mjs b/packages/cli/api/theme/build/build.mjs
index a5070c4329..f701280765 100644
--- a/packages/cli/api/theme/build/build.mjs
+++ b/packages/cli/api/theme/build/build.mjs
@@ -349,8 +349,8 @@ const _augmentationTargetCache = new Map();
* Resolve a rendered theme class token (the key without `astryx-`) to candidate
* public core subpaths and interface prefixes that may own its augmentable prop
* maps. Some tokens are subtargets documented by a parent component
- * (`avatar-status-dot` augments `@astryxdesign/core/Avatar`), and some stable
- * class tokens intentionally omit word separators (`progressbar`, `statusdot`)
+ * (`avatar-status-dot` augments `@astryxdesign/core/Avatar`), and some
+ * deprecated tokens still omit word separators (`progressbar`, `statusdot`)
* while the public API keeps `ProgressBar`/`StatusDot` casing. Component docs
* are the source of truth for the target token → owning component relationship.
*
@@ -428,8 +428,8 @@ async function resolveAugmentationTargetCandidates(componentName) {
// Try the exact rendered token first for documented subtargets such as
// avatar-status-dot → AvatarStatusDotVariantMap, then the owning public
- // component name for unhyphenated public casings such as progressbar →
- // ProgressBarVariantMap/statusdot → StatusDotVariantMap.
+ // component name for the deprecated unhyphenated tokens such as
+ // progressbar → ProgressBarVariantMap/statusdot → StatusDotVariantMap.
addCandidate(moduleName, toPascalCase(componentName));
addCandidate(moduleName, moduleName);
if (Array.isArray(doc?.components)) {
diff --git a/packages/cli/clients/cli/lib/component-format.mjs b/packages/cli/clients/cli/lib/component-format.mjs
index 8585ee5698..6bef6d03af 100644
--- a/packages/cli/clients/cli/lib/component-format.mjs
+++ b/packages/cli/clients/cli/lib/component-format.mjs
@@ -13,8 +13,8 @@ import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
*
* Override keys are the component's stable class name with the `astryx-`
* namespace prefix stripped — `generateThemeRules` re-adds the prefix when it
- * builds the `.astryx-*` selector. So `astryx-base-table` → key `base-table`
- * (→ `.astryx-base-table`), and `astryx-button` → key `button`.
+ * builds the `.astryx-*` selector. So `astryx-table-cell` → key `table-cell`
+ * (→ `.astryx-table-cell`), and `astryx-button` → key `button`.
*
* Keep the `astryx-` literal in sync with packages/core/src/naming.ts
* (NAMESPACE / classPrefix), the same way build-theme.mjs mirrors it.
diff --git a/packages/core/src/CodeBlock/CodeBlock.doc.mjs b/packages/core/src/CodeBlock/CodeBlock.doc.mjs
index 918da14481..62502964d9 100644
--- a/packages/core/src/CodeBlock/CodeBlock.doc.mjs
+++ b/packages/core/src/CodeBlock/CodeBlock.doc.mjs
@@ -147,10 +147,16 @@ export const docs = {
theming: {
targets: [
{className: 'astryx-code', visualProps: ['color']},
- {className: 'astryx-codeblock', visualProps: ['size', 'language', 'container']},
- {className: 'astryx-codeblock-header', visualProps: ['size', 'language', 'container']},
- {className: 'astryx-codeblock-title', visualProps: ['size', 'language']},
- {className: 'astryx-codeblock-copy-button'},
+ {className: 'astryx-code-block', visualProps: ['size', 'language', 'container']},
+ {className: 'astryx-code-block-header', visualProps: ['size', 'language', 'container']},
+ {className: 'astryx-code-block-title', visualProps: ['size', 'language']},
+ {className: 'astryx-code-block-copy-button'},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-codeblock', visualProps: ['size', 'language', 'container'], deprecatedFor: 'code-block'},
+ {className: 'astryx-codeblock-header', visualProps: ['size', 'language', 'container'], deprecatedFor: 'code-block-header'},
+ {className: 'astryx-codeblock-title', visualProps: ['size', 'language'], deprecatedFor: 'code-block-title'},
+ {className: 'astryx-codeblock-copy-button', deprecatedFor: 'code-block-copy-button'},
],
vars: [
{name: '--_codeblock-gutter-width', description: 'Width of the line-number gutter, computed from the digit count of the last line so the code column starts at a stable offset.', default: '2ch', private: true},
diff --git a/packages/core/src/CodeBlock/CodeBlock.test.tsx b/packages/core/src/CodeBlock/CodeBlock.test.tsx
index a263ad464b..8d30083cd5 100644
--- a/packages/core/src/CodeBlock/CodeBlock.test.tsx
+++ b/packages/core/src/CodeBlock/CodeBlock.test.tsx
@@ -396,3 +396,40 @@ describe('CodeBlock', () => {
});
});
});
+
+describe('CodeBlock theme target names', () => {
+ it('renders the deprecated classes beside the current ones', () => {
+ const {container} = render(
+ <CodeBlock
+ code="const x = 1;"
+ language="javascript"
+ title="example.js"
+ />,
+ );
+ expect(container.querySelector('.astryx-code-block')).toHaveClass(
+ 'astryx-codeblock',
+ );
+ expect(container.querySelector('.astryx-code-block-header')).toHaveClass(
+ 'astryx-codeblock-header',
+ );
+ expect(container.querySelector('.astryx-code-block-title')).toHaveClass(
+ 'astryx-codeblock-title',
+ );
+ expect(screen.getByRole('button', {name: 'Copy code'})).toHaveClass(
+ 'astryx-code-block-copy-button',
+ );
+ });
+
+ it('reaches the header and title through the current defineTheme keys', () => {
+ const theme = defineTheme({
+ name: 'code-block-header-target-test',
+ components: {
+ 'code-block-header': {base: {paddingBlock: 'var(--spacing-1)'}},
+ 'code-block-title': {base: {fontSize: 'var(--text-body-size)'}},
+ },
+ });
+ const css = generateThemeTestCSS(theme);
+ expect(css).toContain('.astryx-code-block-header');
+ expect(css).toContain('.astryx-code-block-title');
+ });
+});
diff --git a/packages/core/src/CodeBlock/CodeBlock.tsx b/packages/core/src/CodeBlock/CodeBlock.tsx
index 2bb0b42a96..d8946d3d66 100644
--- a/packages/core/src/CodeBlock/CodeBlock.tsx
+++ b/packages/core/src/CodeBlock/CodeBlock.tsx
@@ -810,14 +810,20 @@ export function CodeBlock({
void handleCopy();
}}
xstyle={[styles.copyButton, !showHeader && styles.copyButtonAbsolute]}
- {...themeProps('codeblock-copy-button')}
+ {...themeProps('code-block-copy-button', undefined, {
+ legacyNames: ['codeblock-copy-button'],
+ })}
/>
) : null;
const headerEl = showHeader ? (
<div
{...mergeProps(
- themeProps('codeblock-header', {size, language, container}),
+ themeProps(
+ 'code-block-header',
+ {size, language, container},
+ {legacyNames: ['codeblock-header']},
+ ),
stylex.props(
styles.headerRow,
hasLineNumbers ? styles.headerWithDivider : styles.headerCompact,
@@ -845,7 +851,11 @@ export function CodeBlock({
)}>
<span
{...mergeProps(
- themeProps('codeblock-title', {size, language}),
+ themeProps(
+ 'code-block-title',
+ {size, language},
+ {legacyNames: ['codeblock-title']},
+ ),
stylex.props(styles.headerTitle),
)}>
{canCollapse && (
@@ -917,7 +927,13 @@ export function CodeBlock({
<pre
ref={ref}
{...mergeProps(
- themeProps('codeblock', {size, language, container}),
+ themeProps(
+ 'code-block',
+ {size, language, container},
+ // `codeblock` ran the compound name together; themes styling it keep
+ // working until the next major.
+ {legacyNames: ['codeblock']},
+ ),
stylex.props(
styles.root,
dynamicStyles.width(widthProp),
diff --git a/packages/core/src/CodeBlock/highlightRanges.ts b/packages/core/src/CodeBlock/highlightRanges.ts
index 5ae2a3ab6d..b37c26a32a 100644
--- a/packages/core/src/CodeBlock/highlightRanges.ts
+++ b/packages/core/src/CodeBlock/highlightRanges.ts
@@ -67,7 +67,7 @@ function ensureDynamicHighlightType(tokenType: string): void {
const name = `astryx-${tokenType}`;
const colorVar = `var(--color-syntax-${tokenType}, currentColor)`;
dynamicStyleSheet.insertRule(
- `.astryx-codeblock code::highlight(${name}), .astryx-codeeditor code::highlight(${name}) { color: ${colorVar}; }`,
+ `.astryx-code-block code::highlight(${name}), .astryx-codeeditor code::highlight(${name}) { color: ${colorVar}; }`,
);
}
diff --git a/packages/core/src/CodeBlock/highlightStyles.ts b/packages/core/src/CodeBlock/highlightStyles.ts
index cc88d31ef1..1dc7d2e466 100644
--- a/packages/core/src/CodeBlock/highlightStyles.ts
+++ b/packages/core/src/CodeBlock/highlightStyles.ts
@@ -30,31 +30,31 @@ const FALLBACK_TOKENS = `:root {\n${Object.entries(syntaxTokenDefaults)
const HIGHLIGHT_STYLES = `
${FALLBACK_TOKENS}
-.astryx-codeblock code::highlight(astryx-keyword),
+.astryx-code-block code::highlight(astryx-keyword),
.astryx-codeeditor code::highlight(astryx-keyword) { color: var(--color-syntax-keyword); }
-.astryx-codeblock code::highlight(astryx-string),
+.astryx-code-block code::highlight(astryx-string),
.astryx-codeeditor code::highlight(astryx-string) { color: var(--color-syntax-string); }
-.astryx-codeblock code::highlight(astryx-comment),
+.astryx-code-block code::highlight(astryx-comment),
.astryx-codeeditor code::highlight(astryx-comment) { color: var(--color-syntax-comment); }
-.astryx-codeblock code::highlight(astryx-number),
+.astryx-code-block code::highlight(astryx-number),
.astryx-codeeditor code::highlight(astryx-number) { color: var(--color-syntax-number); }
-.astryx-codeblock code::highlight(astryx-function),
+.astryx-code-block code::highlight(astryx-function),
.astryx-codeeditor code::highlight(astryx-function) { color: var(--color-syntax-function); }
-.astryx-codeblock code::highlight(astryx-type),
+.astryx-code-block code::highlight(astryx-type),
.astryx-codeeditor code::highlight(astryx-type) { color: var(--color-syntax-type); }
-.astryx-codeblock code::highlight(astryx-tag),
+.astryx-code-block code::highlight(astryx-tag),
.astryx-codeeditor code::highlight(astryx-tag) { color: var(--color-syntax-tag); }
-.astryx-codeblock code::highlight(astryx-attribute),
+.astryx-code-block code::highlight(astryx-attribute),
.astryx-codeeditor code::highlight(astryx-attribute) { color: var(--color-syntax-attribute); }
-.astryx-codeblock code::highlight(astryx-property),
+.astryx-code-block code::highlight(astryx-property),
.astryx-codeeditor code::highlight(astryx-property) { color: var(--color-syntax-property); }
-.astryx-codeblock code::highlight(astryx-operator),
+.astryx-code-block code::highlight(astryx-operator),
.astryx-codeeditor code::highlight(astryx-operator) { color: var(--color-syntax-operator); }
-.astryx-codeblock code::highlight(astryx-constant),
+.astryx-code-block code::highlight(astryx-constant),
.astryx-codeeditor code::highlight(astryx-constant) { color: var(--color-syntax-constant); }
-.astryx-codeblock code::highlight(astryx-punctuation),
+.astryx-code-block code::highlight(astryx-punctuation),
.astryx-codeeditor code::highlight(astryx-punctuation) { color: var(--color-syntax-punctuation); }
-.astryx-codeblock code::highlight(astryx-variable),
+.astryx-code-block code::highlight(astryx-variable),
.astryx-codeeditor code::highlight(astryx-variable) { color: var(--color-syntax-variable); }
/* Span-based fallback classes — used when highlightMode='spans' or
diff --git a/packages/core/src/HoverCard/HoverCard.doc.mjs b/packages/core/src/HoverCard/HoverCard.doc.mjs
index 3ddde4caa0..283ab36643 100644
--- a/packages/core/src/HoverCard/HoverCard.doc.mjs
+++ b/packages/core/src/HoverCard/HoverCard.doc.mjs
@@ -16,7 +16,10 @@ export const docs = {
},
theming: {
targets: [
- {className: 'astryx-hovercard'},
+ {className: 'astryx-hover-card'},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-hovercard', deprecatedFor: 'hover-card'},
],
vars: [
{name: '--_hovercard-radius', description: 'Border radius of the hover card', default: 'var(--radius-container)', private: true},
@@ -144,7 +147,10 @@ export const docsZh = {
displayName: 'Hover Card',
theming: {
targets: [
- {className: 'astryx-hovercard'},
+ {className: 'astryx-hover-card'},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-hovercard', deprecatedFor: 'hover-card'},
],
vars: [
{name: '--_hovercard-radius', description: 'Border radius of the hover card', default: 'var(--radius-container)', private: true},
diff --git a/packages/core/src/HoverCard/HoverCard.test.tsx b/packages/core/src/HoverCard/HoverCard.test.tsx
index 3bbda14c71..20ff3e9d8f 100644
--- a/packages/core/src/HoverCard/HoverCard.test.tsx
+++ b/packages/core/src/HoverCard/HoverCard.test.tsx
@@ -1074,3 +1074,20 @@ describe('HoverCard', () => {
});
});
});
+
+describe('HoverCard theme target names', () => {
+ it('renders the deprecated class beside the current one on the card surface', async () => {
+ render(
+ <HoverCard content={<span>Card content</span>} delay={0}>
+ <button type="button">Trigger</button>
+ </HoverCard>,
+ );
+ fireEvent.mouseEnter(screen.getByRole('button', {name: 'Trigger'}));
+
+ await waitFor(() => {
+ const layer = screen.getByText('Card content').closest('[popover]');
+ expect(layer).toHaveClass('astryx-hover-card');
+ expect(layer).toHaveClass('astryx-hovercard');
+ });
+ });
+});
diff --git a/packages/core/src/HoverCard/useHoverCard.tsx b/packages/core/src/HoverCard/useHoverCard.tsx
index 3ab90eccb5..8eafbe147e 100644
--- a/packages/core/src/HoverCard/useHoverCard.tsx
+++ b/packages/core/src/HoverCard/useHoverCard.tsx
@@ -605,7 +605,11 @@ export function useHoverCard(options: HoverCardOptions = {}): HoverCardReturn {
props?: Omit<ContextRenderProps, 'positioning'>,
): ReactNode => {
const renderPlacement = props?.placement ?? placement;
- const themeClassName = themeProps('hovercard').className;
+ const themeClassName = themeProps('hover-card', undefined, {
+ // `hovercard` ran the compound name together; themes styling it keep
+ // working until the next major.
+ legacyNames: ['hovercard'],
+ }).className;
const renderProps = {
placement: renderPlacement,
alignment: props?.alignment ?? alignment,
diff --git a/packages/core/src/NavIcon/NavIcon.doc.mjs b/packages/core/src/NavIcon/NavIcon.doc.mjs
index 83ebd40a92..72449e7cec 100644
--- a/packages/core/src/NavIcon/NavIcon.doc.mjs
+++ b/packages/core/src/NavIcon/NavIcon.doc.mjs
@@ -22,7 +22,10 @@ export const docs = {
],
theming: {
targets: [
- {className: 'astryx-navicon'},
+ {className: 'astryx-nav-icon'},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-navicon', deprecatedFor: 'nav-icon'},
],
},
usage: {
@@ -51,7 +54,10 @@ export const docsZh = {
],
theming: {
targets: [
- {className: 'astryx-navicon'},
+ {className: 'astryx-nav-icon'},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-navicon', deprecatedFor: 'nav-icon'},
],
},
usage: {
diff --git a/packages/core/src/NavIcon/NavIcon.test.tsx b/packages/core/src/NavIcon/NavIcon.test.tsx
index 745dbf4994..7394adc5b9 100644
--- a/packages/core/src/NavIcon/NavIcon.test.tsx
+++ b/packages/core/src/NavIcon/NavIcon.test.tsx
@@ -30,3 +30,12 @@ describe('NavIcon', () => {
expect(screen.getByTestId('nav-icon')).toBeInTheDocument();
});
});
+
+describe('NavIcon theme target names', () => {
+ it('renders the deprecated class beside the current one', () => {
+ render(<NavIcon icon={<span>Icon</span>} data-testid="nav-icon" />);
+ const root = screen.getByTestId('nav-icon');
+ expect(root).toHaveClass('astryx-nav-icon');
+ expect(root).toHaveClass('astryx-navicon');
+ });
+});
diff --git a/packages/core/src/NavIcon/NavIcon.tsx b/packages/core/src/NavIcon/NavIcon.tsx
index fe22ced7ea..0c8482dcab 100644
--- a/packages/core/src/NavIcon/NavIcon.tsx
+++ b/packages/core/src/NavIcon/NavIcon.tsx
@@ -79,7 +79,11 @@ export function NavIcon({
<span
ref={ref}
{...mergeProps(
- themeProps('navicon'),
+ themeProps('nav-icon', undefined, {
+ // `navicon` ran the compound name together; themes styling it keep
+ // working until the next major.
+ legacyNames: ['navicon'],
+ }),
stylex.props(styles.base, xstyle),
className,
style,
diff --git a/packages/core/src/ProgressBar/ProgressBar.doc.mjs b/packages/core/src/ProgressBar/ProgressBar.doc.mjs
index 9018f06d69..b27c45e3b8 100644
--- a/packages/core/src/ProgressBar/ProgressBar.doc.mjs
+++ b/packages/core/src/ProgressBar/ProgressBar.doc.mjs
@@ -77,12 +77,30 @@ export const docs = {
],
theming: {
targets: [
- {className: 'astryx-progressbar', visualProps: ['variant']},
- {className: 'astryx-progressbar-fill', visualProps: ['variant']},
- {className: 'astryx-progressbar-track'},
+ {className: 'astryx-progress-bar', visualProps: ['variant']},
+ {className: 'astryx-progress-bar-fill', visualProps: ['variant']},
+ {className: 'astryx-progress-bar-track'},
+ {
+ className: 'astryx-progress-bar-mark',
+ visualProps: ['variant', 'placement'],
+ },
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {
+ className: 'astryx-progressbar',
+ visualProps: ['variant'],
+ deprecatedFor: 'progress-bar',
+ },
+ {
+ className: 'astryx-progressbar-fill',
+ visualProps: ['variant'],
+ deprecatedFor: 'progress-bar-fill',
+ },
+ {className: 'astryx-progressbar-track', deprecatedFor: 'progress-bar-track'},
{
className: 'astryx-progressbar-mark',
visualProps: ['variant', 'placement'],
+ deprecatedFor: 'progress-bar-mark',
},
],
vars: [
@@ -182,12 +200,30 @@ export const docsZh = {
],
theming: {
targets: [
- {className: 'astryx-progressbar', visualProps: ['variant']},
- {className: 'astryx-progressbar-fill', visualProps: ['variant']},
- {className: 'astryx-progressbar-track'},
+ {className: 'astryx-progress-bar', visualProps: ['variant']},
+ {className: 'astryx-progress-bar-fill', visualProps: ['variant']},
+ {className: 'astryx-progress-bar-track'},
+ {
+ className: 'astryx-progress-bar-mark',
+ visualProps: ['variant', 'placement'],
+ },
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {
+ className: 'astryx-progressbar',
+ visualProps: ['variant'],
+ deprecatedFor: 'progress-bar',
+ },
+ {
+ className: 'astryx-progressbar-fill',
+ visualProps: ['variant'],
+ deprecatedFor: 'progress-bar-fill',
+ },
+ {className: 'astryx-progressbar-track', deprecatedFor: 'progress-bar-track'},
{
className: 'astryx-progressbar-mark',
visualProps: ['variant', 'placement'],
+ deprecatedFor: 'progress-bar-mark',
},
],
vars: [
diff --git a/packages/core/src/ProgressBar/ProgressBar.test.tsx b/packages/core/src/ProgressBar/ProgressBar.test.tsx
index 4f68d1155c..b2f5ec4f95 100644
--- a/packages/core/src/ProgressBar/ProgressBar.test.tsx
+++ b/packages/core/src/ProgressBar/ProgressBar.test.tsx
@@ -839,3 +839,27 @@ describe('ProgressBar', () => {
});
});
});
+
+describe('ProgressBar theme target names', () => {
+ it('renders the deprecated classes beside the current ones', () => {
+ const {container} = render(
+ <ProgressBar
+ value={50}
+ label="Progress"
+ marks={[{value: 80, label: 'M'}]}
+ />,
+ );
+ expect(container.querySelector('.astryx-progress-bar')).toHaveClass(
+ 'astryx-progressbar',
+ );
+ expect(container.querySelector('.astryx-progress-bar-track')).toHaveClass(
+ 'astryx-progressbar-track',
+ );
+ expect(container.querySelector('.astryx-progress-bar-fill')).toHaveClass(
+ 'astryx-progressbar-fill',
+ );
+ expect(container.querySelector('.astryx-progress-bar-mark')).toHaveClass(
+ 'astryx-progressbar-mark',
+ );
+ });
+});
diff --git a/packages/core/src/ProgressBar/ProgressBar.tsx b/packages/core/src/ProgressBar/ProgressBar.tsx
index 10831b671b..94b05cbcbc 100644
--- a/packages/core/src/ProgressBar/ProgressBar.tsx
+++ b/packages/core/src/ProgressBar/ProgressBar.tsx
@@ -479,7 +479,13 @@ export function ProgressBar({
<div
ref={ref}
{...mergeProps(
- themeProps('progressbar', {variant}),
+ themeProps(
+ 'progress-bar',
+ {variant},
+ // `progressbar` ran the compound name together; themes styling it
+ // keep working until the next major.
+ {legacyNames: ['progressbar']},
+ ),
stylex.props(styles.container, xstyle),
className,
style,
@@ -524,13 +530,19 @@ export function ProgressBar({
aria-labelledby={labelId}
aria-valuetext={isIndeterminate ? undefined : valueText}
{...mergeProps(
- themeProps('progressbar-track'),
+ themeProps('progress-bar-track', undefined, {
+ legacyNames: ['progressbar-track'],
+ }),
stylex.props(styles.track, isIndeterminate && styles.trackClipped),
)}>
{isIndeterminate ? (
<div
{...mergeProps(
- themeProps('progressbar-fill', {variant: fillVariant}),
+ themeProps(
+ 'progress-bar-fill',
+ {variant: fillVariant},
+ {legacyNames: ['progressbar-fill']},
+ ),
stylex.props(
styles.indeterminateFill,
variantStyles[fillVariant],
@@ -540,7 +552,11 @@ export function ProgressBar({
) : (
<div
{...mergeProps(
- themeProps('progressbar-fill', {variant: fillVariant}),
+ themeProps(
+ 'progress-bar-fill',
+ {variant: fillVariant},
+ {legacyNames: ['progressbar-fill']},
+ ),
stylex.props(styles.fill, variantStyles[fillVariant]),
)}
style={{width: `${percentage}%`}}
@@ -569,10 +585,14 @@ export function ProgressBar({
<span
tabIndex={0}
{...mergeProps(
- themeProps('progressbar-mark', {
- variant: fillVariant,
- placement: mark.isOnFill ? 'fill' : 'track',
- }),
+ themeProps(
+ 'progress-bar-mark',
+ {
+ variant: fillVariant,
+ placement: mark.isOnFill ? 'fill' : 'track',
+ },
+ {legacyNames: ['progressbar-mark']},
+ ),
stylex.props(
focusOutlineStyles.focusVisible,
styles.mark,
diff --git a/packages/core/src/SideNav/SideNavHeading.tsx b/packages/core/src/SideNav/SideNavHeading.tsx
index fe90aa8ae8..0692943541 100644
--- a/packages/core/src/SideNav/SideNavHeading.tsx
+++ b/packages/core/src/SideNav/SideNavHeading.tsx
@@ -60,7 +60,7 @@ const styles = stylex.create({
minHeight: spacingVars['--spacing-8'],
paddingInlineStart: {
default: spacingVars['--spacing-2'],
- ':has(.astryx-navicon)': 0,
+ ':has(.astryx-nav-icon)': 0,
},
paddingInlineEnd: spacingVars['--spacing-2'],
paddingBlock: 0,
@@ -212,7 +212,7 @@ const styles = stylex.create({
minHeight: spacingVars['--spacing-8'],
paddingInlineStart: {
default: spacingVars['--spacing-2'],
- ':has(.astryx-navicon)': 0,
+ ':has(.astryx-nav-icon)': 0,
},
paddingInlineEnd: spacingVars['--spacing-2'],
paddingBlock: 0,
diff --git a/packages/core/src/StatusDot/StatusDot.doc.mjs b/packages/core/src/StatusDot/StatusDot.doc.mjs
index cca7c94c5d..6b924b1af0 100644
--- a/packages/core/src/StatusDot/StatusDot.doc.mjs
+++ b/packages/core/src/StatusDot/StatusDot.doc.mjs
@@ -48,7 +48,10 @@ export const docs = {
],
theming: {
targets: [
- {className: 'astryx-statusdot', visualProps: ['variant']},
+ {className: 'astryx-status-dot', visualProps: ['variant']},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-statusdot', visualProps: ['variant'], deprecatedFor: 'status-dot'},
],
},
usage: {
@@ -105,7 +108,10 @@ export const docsZh = {
],
theming: {
targets: [
- {className: 'astryx-statusdot', visualProps: ['variant']},
+ {className: 'astryx-status-dot', visualProps: ['variant']},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-statusdot', visualProps: ['variant'], deprecatedFor: 'status-dot'},
],
},
usage: {
diff --git a/packages/core/src/StatusDot/StatusDot.test.tsx b/packages/core/src/StatusDot/StatusDot.test.tsx
index 29644be173..4eabfbdb97 100644
--- a/packages/core/src/StatusDot/StatusDot.test.tsx
+++ b/packages/core/src/StatusDot/StatusDot.test.tsx
@@ -189,3 +189,12 @@ describe('StatusDot', () => {
});
});
});
+
+describe('StatusDot theme target names', () => {
+ it('renders the deprecated class beside the current one', () => {
+ render(<StatusDot variant="success" label="Online" />);
+ const dot = screen.getByRole('img', {name: 'Online'});
+ expect(dot).toHaveClass('astryx-status-dot');
+ expect(dot).toHaveClass('astryx-statusdot');
+ });
+});
diff --git a/packages/core/src/StatusDot/StatusDot.tsx b/packages/core/src/StatusDot/StatusDot.tsx
index 6b5a935b1e..a3b3bdbeec 100644
--- a/packages/core/src/StatusDot/StatusDot.tsx
+++ b/packages/core/src/StatusDot/StatusDot.tsx
@@ -200,7 +200,13 @@ export function StatusDot({
role="img"
aria-label={label}
{...mergeProps(
- themeProps('statusdot', {variant}),
+ themeProps(
+ 'status-dot',
+ {variant},
+ // `statusdot` ran the compound name together; themes styling it keep
+ // working until the next major.
+ {legacyNames: ['statusdot']},
+ ),
stylex.props(
styles.base,
variants[variant],
diff --git a/packages/core/src/Table/BaseTable.tsx b/packages/core/src/Table/BaseTable.tsx
index d58f56a6dc..20c1db8db3 100644
--- a/packages/core/src/Table/BaseTable.tsx
+++ b/packages/core/src/Table/BaseTable.tsx
@@ -528,7 +528,12 @@ function BaseTableInner<T extends Record<string, unknown>>({
{...(ariaRowCount != null ? {'aria-rowcount': ariaRowCount} : null)}
{...tableRenderProps.htmlProps}
{...mergeProps(
- themeProps('base-table'),
+ themeProps('table', undefined, {
+ // `base-table` was a second root on the same <table> element that
+ // `table` names; themes styling it keep working until the next
+ // major.
+ legacyNames: ['base-table'],
+ }),
stylex.props(...tableRenderProps.xstyle, xstyle),
[tableRenderProps.htmlProps.className, className]
.filter(Boolean)
diff --git a/packages/core/src/Table/Table.doc.mjs b/packages/core/src/Table/Table.doc.mjs
index 544a3638a9..515aa729d0 100644
--- a/packages/core/src/Table/Table.doc.mjs
+++ b/packages/core/src/Table/Table.doc.mjs
@@ -24,7 +24,6 @@ export const docs = {
},
theming: {
targets: [
- {className: 'astryx-base-table'},
{className: 'astryx-table'},
{className: 'astryx-table-scroll-wrapper'},
{className: 'astryx-table-header'},
@@ -33,6 +32,9 @@ export const docs = {
{className: 'astryx-table-row'},
{className: 'astryx-table-cell', visualProps: ['density']},
{className: 'astryx-table-header-cell', visualProps: ['density']},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-base-table', deprecatedFor: 'table'},
],
},
description: 'Styled, data-driven table with density, dividers, hover highlight, striped rows, and named plugin support. T must extend Record<string, unknown>.',
diff --git a/packages/core/src/Table/Table.tsx b/packages/core/src/Table/Table.tsx
index 70bae50c2e..5aba50a7bd 100644
--- a/packages/core/src/Table/Table.tsx
+++ b/packages/core/src/Table/Table.tsx
@@ -186,16 +186,11 @@ function buildTableStylePlugin<
>(): TablePlugin<T> {
return {
transformTable(props: TableRenderProps): TableRenderProps {
- const existingClass = props.htmlProps.className ?? '';
- const tableClass = themeProps('table').className;
+ // The `astryx-table` class itself comes from BaseTable, which renders
+ // the <table> element and now names it `table` (with `base-table` as its
+ // legacy name). Adding it here too would put the token on twice.
return {
...props,
- htmlProps: {
- ...props.htmlProps,
- className: existingClass
- ? `${existingClass} ${tableClass}`
- : tableClass,
- },
xstyle: [...props.xstyle, tableStyles.base],
};
},
diff --git a/packages/core/src/TextArea/TextArea.doc.mjs b/packages/core/src/TextArea/TextArea.doc.mjs
index 872041fcce..f4b8c95330 100644
--- a/packages/core/src/TextArea/TextArea.doc.mjs
+++ b/packages/core/src/TextArea/TextArea.doc.mjs
@@ -186,7 +186,10 @@ export const docs = {
],
theming: {
targets: [
- {className: 'astryx-textarea', visualProps: ['size', 'status'], states: ['disabled', 'readonly']},
+ {className: 'astryx-text-area', visualProps: ['size', 'status'], states: ['disabled', 'readonly']},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-textarea', visualProps: ['size', 'status'], states: ['disabled', 'readonly'], deprecatedFor: 'text-area'},
],
vars: [
{
@@ -381,7 +384,10 @@ export const docsZh = {
],
theming: {
targets: [
- {className: 'astryx-textarea', visualProps: ['size', 'status'], states: ['disabled', 'readonly']},
+ {className: 'astryx-text-area', visualProps: ['size', 'status'], states: ['disabled', 'readonly']},
+ // Still emitted beside the names above, so themes written against
+ // them keep working. Drop in the next major.
+ {className: 'astryx-textarea', visualProps: ['size', 'status'], states: ['disabled', 'readonly'], deprecatedFor: 'text-area'},
],
vars: [
{
diff --git a/packages/core/src/TextArea/TextArea.test.tsx b/packages/core/src/TextArea/TextArea.test.tsx
index 9218a91ae8..acf7aa6811 100644
--- a/packages/core/src/TextArea/TextArea.test.tsx
+++ b/packages/core/src/TextArea/TextArea.test.tsx
@@ -1155,3 +1155,14 @@ describe('TextArea readonly theme state', () => {
expect(root).not.toHaveAttribute('data-readonly');
});
});
+
+describe('TextArea theme target names', () => {
+ it('renders the deprecated class beside the current one', () => {
+ const {container} = render(
+ <TextArea label="Notes" value="" onChange={() => {}} />,
+ );
+ const root = container.querySelector('.astryx-text-area');
+ expect(root).not.toBeNull();
+ expect(root).toHaveClass('astryx-textarea');
+ });
+});
diff --git a/packages/core/src/TextArea/TextArea.tsx b/packages/core/src/TextArea/TextArea.tsx
index 8cbeaf0213..263cb6370d 100644
--- a/packages/core/src/TextArea/TextArea.tsx
+++ b/packages/core/src/TextArea/TextArea.tsx
@@ -556,12 +556,18 @@ export function TextArea({
onClick={handleWrapperClick}
onMouseUp={handleWrapperMouseUp}
{...mergeProps(
- themeProps('textarea', {
- size,
- status: status?.type ?? null,
- disabled: isDisabled ? 'disabled' : null,
- readonly: isReadOnly ? 'readonly' : null,
- }),
+ themeProps(
+ 'text-area',
+ {
+ size,
+ status: status?.type ?? null,
+ disabled: isDisabled ? 'disabled' : null,
+ readonly: isReadOnly ? 'readonly' : null,
+ },
+ // `textarea` ran the compound name together; themes styling it
+ // keep working until the next major.
+ {legacyNames: ['textarea']},
+ ),
stylex.props(
inputWrapperStyles.base,
styles.wrapper,
diff --git a/packages/core/src/TopNav/TopNavHeading.tsx b/packages/core/src/TopNav/TopNavHeading.tsx
index cdb5b2f434..9e188186d0 100644
--- a/packages/core/src/TopNav/TopNavHeading.tsx
+++ b/packages/core/src/TopNav/TopNavHeading.tsx
@@ -54,7 +54,7 @@ const styles = stylex.create({
minHeight: spacingVars['--spacing-8'],
paddingInlineStart: {
default: spacingVars['--spacing-2'],
- ':has(.astryx-navicon)': 0,
+ ':has(.astryx-nav-icon)': 0,
},
paddingInlineEnd: spacingVars['--spacing-2'],
paddingBlock: 0,
@@ -190,7 +190,7 @@ const styles = stylex.create({
minHeight: spacingVars['--spacing-8'],
paddingInlineStart: {
default: spacingVars['--spacing-2'],
- ':has(.astryx-navicon)': 0,
+ ':has(.astryx-nav-icon)': 0,
},
paddingInlineEnd: spacingVars['--spacing-2'],
paddingBlock: 0,
diff --git a/packages/core/src/theme/derivedVarRegistry.test.ts b/packages/core/src/theme/derivedVarRegistry.test.ts
index f09aa223c8..dce0c7347b 100644
--- a/packages/core/src/theme/derivedVarRegistry.test.ts
+++ b/packages/core/src/theme/derivedVarRegistry.test.ts
@@ -222,13 +222,13 @@ const DIR_TO_REGISTRY_KEY: Record<string, string> = {
Dialog: 'dialog',
DropdownMenu: 'dropdown-menu',
Field: 'field',
- HoverCard: 'hovercard',
+ HoverCard: 'hover-card',
NumberInput: 'number-input',
Popover: 'popover',
- ProgressBar: 'progressbar-mark',
+ ProgressBar: 'progress-bar-mark',
Section: 'section',
SegmentedControl: 'segmented-control',
- TextArea: 'textarea',
+ TextArea: 'text-area',
};
/**
@@ -419,6 +419,21 @@ describe('getDerivedVars', () => {
expect(getDerivedVars('unknown', 'borderRadius')).toEqual([]);
});
+ it('resolves a deprecated key to the entries of the key that replaced it', () => {
+ // A theme written against the old spelling still selects the element (the
+ // component emits both classes), so its derived vars must still expand —
+ // otherwise the rule lands and the var half of it silently does nothing.
+ expect(getDerivedVars('hovercard', 'borderRadius')).toEqual(
+ getDerivedVars('hover-card', 'borderRadius'),
+ );
+ expect(getDerivedVars('textarea', 'paddingInline')).toEqual(
+ getDerivedVars('text-area', 'paddingInline'),
+ );
+ expect(getDerivedVars('progressbar-mark', 'width')).toEqual(
+ getDerivedVars('progress-bar-mark', 'width'),
+ );
+ });
+
it('returns empty for unregistered property', () => {
expect(getDerivedVars('card', 'color')).toEqual([]);
});
diff --git a/packages/core/src/theme/derivedVarRegistry.ts b/packages/core/src/theme/derivedVarRegistry.ts
index 7474bffb05..6ff692d6fb 100644
--- a/packages/core/src/theme/derivedVarRegistry.ts
+++ b/packages/core/src/theme/derivedVarRegistry.ts
@@ -67,13 +67,13 @@ export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
{property: 'padding', vars: ['--_dropdown-menu-padding']},
],
field: [{property: 'borderRadius', vars: ['--_field-radius']}],
- hovercard: [{property: 'borderRadius', vars: ['--_hovercard-radius']}],
+ 'hover-card': [{property: 'borderRadius', vars: ['--_hovercard-radius']}],
'number-input': [
{property: 'padding', expand: 'container'},
{property: 'borderRadius', vars: ['--_field-radius']},
],
popover: [{property: 'borderRadius', vars: ['--_popover-radius']}],
- 'progressbar-mark': [
+ 'progress-bar-mark': [
{property: 'width', vars: ['--_progressbar-mark-width'], replaces: true},
{property: 'height', vars: ['--_progressbar-mark-height'], replaces: true},
],
@@ -82,7 +82,7 @@ export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
{property: 'borderRadius', vars: ['--_segmented-control-radius']},
{property: 'padding', vars: ['--_segmented-control-padding']},
],
- textarea: [
+ 'text-area': [
{
property: 'paddingInline',
vars: ['--_textarea-inline-padding'],
@@ -91,6 +91,21 @@ export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
],
};
+/**
+ * Deprecated component keys → the key that superseded them.
+ *
+ * A renamed target keeps emitting its old class, so a theme written against
+ * the old key still selects the element. Without this the rule would land but
+ * its derived vars would not expand, and the half that travels through a var
+ * (a hover card's radius, a text area's inline padding) would silently do
+ * nothing. Drop these with the classes, in the next major.
+ */
+const DEPRECATED_REGISTRY_KEYS: Record<string, string> = {
+ hovercard: 'hover-card',
+ 'progressbar-mark': 'progress-bar-mark',
+ textarea: 'text-area',
+};
+
/**
* Look up derived var entries for a component + CSS property.
* Returns matching entries in priority order, or empty array if none.
@@ -99,7 +114,10 @@ export function getDerivedVars(
component: string,
property: string,
): DerivedVarEntry[] {
- const entries = derivedVarRegistry[component];
+ const renamedTo = DEPRECATED_REGISTRY_KEYS[component];
+ const entries =
+ derivedVarRegistry[component] ??
+ (renamedTo ? derivedVarRegistry[renamedTo] : undefined);
if (!entries) {
return [];
}
diff --git a/packages/core/src/theme/generateThemeRules.test.ts b/packages/core/src/theme/generateThemeRules.test.ts
index 154da0882f..335252c55f 100644
--- a/packages/core/src/theme/generateThemeRules.test.ts
+++ b/packages/core/src/theme/generateThemeRules.test.ts
@@ -702,3 +702,40 @@ describe('physical padding longhands', () => {
expect(rule).not.toContain('--_dropdown-menu-padding');
});
});
+
+describe('renamed theme targets', () => {
+ // The renamed targets emit both classes, so a rule written against either
+ // key selects the element. What is easy to miss is the derived-var half: a
+ // key the registry does not know still emits a rule, minus every var the
+ // component actually reads — the same silent nothing a misspelled key gives.
+ it('expands derived vars for a renamed key and its deprecated spelling', () => {
+ const rules = (component: string, styles: Record<string, string>) =>
+ generateThemeRules(
+ defineTheme({
+ name: `test-renamed-${component}`,
+ components: {[component]: {base: styles}},
+ }),
+ ).join('\n');
+
+ const hoverCard = rules('hover-card', {borderRadius: '9px'});
+ expect(hoverCard).toContain('.astryx-hover-card');
+ expect(hoverCard).toContain('--_hovercard-radius: 9px');
+ expect(rules('hovercard', {borderRadius: '9px'})).toContain(
+ '--_hovercard-radius: 9px',
+ );
+
+ const textArea = rules('text-area', {paddingInline: '11px'});
+ expect(textArea).toContain('.astryx-text-area');
+ expect(textArea).toContain('--_textarea-inline-padding: 11px');
+ expect(rules('textarea', {paddingInline: '11px'})).toContain(
+ '--_textarea-inline-padding: 11px',
+ );
+
+ const mark = rules('progress-bar-mark', {width: '3px'});
+ expect(mark).toContain('.astryx-progress-bar-mark');
+ expect(mark).toContain('--_progressbar-mark-width: 3px');
+ expect(rules('progressbar-mark', {width: '3px'})).toContain(
+ '--_progressbar-mark-width: 3px',
+ );
+ });
+});