An open source design system that's fully customizable and agent ready
TypeScript
feat(core): mirror directional icons under RTL via shared style (#4438)
nynexman44648bf2d3b93659
diff --git a/.changeset/rtl-directional-icons.md b/.changeset/rtl-directional-icons.mdnew file mode 100644index 0000000000..61fe399ce3--- /dev/null+++ b/.changeset/rtl-directional-icons.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[feat] RTL: mirror directional disclosure/navigation chevrons under RTL via a shared `rtlStyles.mirror` CSS transform, applied to the icon wrapper in Lightbox and the Table tree / grouped-rows / row-expansion plugins. The mirror composes correctly with the Table chevrons' state-rotation (expanded chevrons still point down under RTL). Semantic aria-labels are unchanged.++@nynexman4464diff --git a/packages/core/src/Lightbox/Lightbox.tsx b/packages/core/src/Lightbox/Lightbox.tsxindex e006b2257c..ebb2beeacb 100644--- a/packages/core/src/Lightbox/Lightbox.tsx+++ b/packages/core/src/Lightbox/Lightbox.tsx@@ -32,7 +32,7 @@ import {IconButton} from '../IconButton';import {useAnnounce} from '../hooks/useAnnounce';import {useScrollLock} from '../hooks/useScrollLock';import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';-import {mergeProps, mergeRefs} from '../utils';+import {mergeProps, mergeRefs, rtlStyles} from '../utils';import type {BaseProps} from '../BaseProps';import {themeProps} from '../utils/themeProps';import {useTranslator} from '../i18n';@@ -532,7 +532,11 @@ export function Lightbox({{isGallery && (<div {...stylex.props(styles.navButton, styles.navPrev)}><IconButton- icon={<Icon icon="chevronLeft" size="sm" color="inherit" />}+ icon={+ <span {...stylex.props(rtlStyles.mirror)}>+ <Icon icon="chevronLeft" size="sm" color="inherit" />+ </span>+ }label={t('@astryx.lightbox.previous')}variant="ghost"isDisabled={!canPrev}@@ -587,7 +591,11 @@ export function Lightbox({{isGallery && (<div {...stylex.props(styles.navButton, styles.navNext)}><IconButton- icon={<Icon icon="chevronRight" size="sm" color="inherit" />}+ icon={+ <span {...stylex.props(rtlStyles.mirror)}>+ <Icon icon="chevronRight" size="sm" color="inherit" />+ </span>+ }label={t('@astryx.lightbox.next')}variant="ghost"isDisabled={!canNext}diff --git a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsxindex f18e90e679..4ec1b0a182 100644--- a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx+++ b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx@@ -20,6 +20,7 @@ import {fontWeightVars,} from '../../../theme/tokens.stylex';import {Icon} from '../../../Icon';+import {rtlStyles} from '../../../utils';import type {TablePlugin} from '../../types';import {useTranslator} from '../../../i18n';@@ -333,12 +334,14 @@ export function useTableGroupedRows<T extends Record<string, unknown>>(})}aria-expanded={!collapsed}>- <span- {...stylex.props(- styles.chevronIcon,- !collapsed && styles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />+ <span {...stylex.props(rtlStyles.mirror)}>+ <span+ {...stylex.props(+ styles.chevronIcon,+ !collapsed && styles.chevronExpanded,+ )}>+ <Icon icon="chevronRight" size="xsm" />+ </span></span></button>{content}diff --git a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsxindex e5ac94258b..a12939081e 100644--- a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx+++ b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx@@ -16,6 +16,7 @@ import {useCallback, useMemo, useRef, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import {spacingVars, colorVars, radiusVars} from '../../../theme/tokens.stylex';import {Icon} from '../../../Icon';+import {rtlStyles} from '../../../utils';import {resolveContextActions} from '../../tableContextMenu';import {useTranslator} from '../../../i18n';import type {@@ -361,12 +362,14 @@ function ExpansionChevron({}}aria-label={ariaLabel}aria-expanded={isExpanded}>- <span- {...stylex.props(- expansionStyles.chevronIcon,- isExpanded && expansionStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />+ <span {...stylex.props(rtlStyles.mirror)}>+ <span+ {...stylex.props(+ expansionStyles.chevronIcon,+ isExpanded && expansionStyles.chevronExpanded,+ )}>+ <Icon icon="chevronRight" size="xsm" />+ </span></span></button>);@@ -533,12 +536,14 @@ export function useTableRowExpansion<T extends Record<string, unknown>>(? t('@astryx.tableRowExpansion.collapseAllRows'): t('@astryx.tableRowExpansion.expandAllRows')}>- <span- {...stylex.props(- expansionStyles.chevronIcon,- allExpanded && expansionStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />+ <span {...stylex.props(rtlStyles.mirror)}>+ <span+ {...stylex.props(+ expansionStyles.chevronIcon,+ allExpanded && expansionStyles.chevronExpanded,+ )}>+ <Icon icon="chevronRight" size="xsm" />+ </span></span></button>),@@ -573,11 +578,13 @@ export function useTableRowExpansion<T extends Record<string, unknown>>(group: 'row-expansion',label: isExpanded ? 'Collapse row' : 'Expand row',icon: (- <Icon- icon={isExpanded ? 'chevronDown' : 'chevronRight'}- size="xsm"- aria-hidden- />+ <span {...stylex.props(rtlStyles.mirror)}>+ <Icon+ icon={isExpanded ? 'chevronDown' : 'chevronRight'}+ size="xsm"+ aria-hidden+ />+ </span>),onSelect: () => onToggle(key),},diff --git a/packages/core/src/Table/plugins/tree/useTableTreeData.tsx b/packages/core/src/Table/plugins/tree/useTableTreeData.tsxindex abb797f699..65318f5c8c 100644--- a/packages/core/src/Table/plugins/tree/useTableTreeData.tsx+++ b/packages/core/src/Table/plugins/tree/useTableTreeData.tsx@@ -42,7 +42,7 @@ import {import * as stylex from '@stylexjs/stylex';import {colorVars, radiusVars, spacingVars} from '../../../theme/tokens.stylex';import {Icon} from '../../../Icon';-import {mergeRefs} from '../../../utils';+import {mergeRefs, rtlStyles} from '../../../utils';import type {TablePlugin,TableColumn,@@ -299,12 +299,14 @@ function TreeExpander({: t('@astryx.tableTree.expandRow')}aria-expanded={isExpanded}>- <span- {...stylex.props(- treeStyles.chevron,- isExpanded && treeStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />+ <span {...stylex.props(rtlStyles.mirror)}>+ <span+ {...stylex.props(+ treeStyles.chevron,+ isExpanded && treeStyles.chevronExpanded,+ )}>+ <Icon icon="chevronRight" size="xsm" />+ </span></span></button>);@@ -346,12 +348,14 @@ function TreeExpandAllToggle({: t('@astryx.tableTree.expandAllRows')}aria-expanded={allExpanded}>- <span- {...stylex.props(- treeStyles.chevron,- allExpanded && treeStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />+ <span {...stylex.props(rtlStyles.mirror)}>+ <span+ {...stylex.props(+ treeStyles.chevron,+ allExpanded && treeStyles.chevronExpanded,+ )}>+ <Icon icon="chevronRight" size="xsm" />+ </span></span></button>);diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.tsindex 34b204a811..da7e7d0954 100644--- a/packages/core/src/utils/index.ts+++ b/packages/core/src/utils/index.ts@@ -98,3 +98,5 @@ export {export type {RGBA} from './color';export {devWarn, devError, warnOnce, formatDevMessage} from './devWarning';++export {rtlStyles} from './rtlStyles';diff --git a/packages/core/src/utils/rtlStyles.ts b/packages/core/src/utils/rtlStyles.tsnew file mode 100644index 0000000000..40185df092--- /dev/null+++ b/packages/core/src/utils/rtlStyles.ts@@ -0,0 +1,27 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file rtlStyles.ts+ * @input None+ * @output Shared StyleX style that horizontally mirrors an element under RTL+ * @position Core utility; applied to directional-icon wrappers in Calendar,+ * Lightbox, and the Table expand/disclosure plugins+ *+ * `mirror` flips its element on the horizontal axis only when an ancestor+ * carries `dir="rtl"`. Using `scaleX(-1)` (not `scale(-1, -1)`) keeps the+ * vertical axis intact, and applying it OUTSIDE any state-driven rotation lets+ * it compose correctly — e.g. a Table disclosure chevron still rotates to point+ * down when expanded under RTL. The `:is([dir="rtl"] *)` selector matches the+ * MobileNav drawer convention; a bare `direction: rtl` alone won't trigger it.+ *+ * SYNC: When modified, update:+ * - /packages/core/src/utils/index.ts+ */++import * as stylex from '@stylexjs/stylex';++export const rtlStyles = stylex.create({+ mirror: {+ transform: {default: null, ':is([dir="rtl"] *)': 'scaleX(-1)'},+ },+});