Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use static token map in Stack for build-time fallback injection
  • Loading branch information
mirka committed Feb 24, 2026
commit 0e64b790a8cc7a14c780cd12fe326d532328310e
15 changes: 14 additions & 1 deletion packages/ui/src/stack/stack.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { useRender, mergeProps } from '@base-ui/react';
import { forwardRef } from '@wordpress/element';
import type { GapSize } from '@wordpress/theme';
import { type StackProps } from './types';
import styles from './style.module.css';

// Static map so that the build-time token fallback plugin can inject fallback
// values into each `var()` call.
const gapTokens: Record< GapSize, string > = {
xs: 'var(--wpds-dimension-gap-xs)',
sm: 'var(--wpds-dimension-gap-sm)',
md: 'var(--wpds-dimension-gap-md)',
lg: 'var(--wpds-dimension-gap-lg)',
xl: 'var(--wpds-dimension-gap-xl)',
'2xl': 'var(--wpds-dimension-gap-2xl)',
'3xl': 'var(--wpds-dimension-gap-3xl)',
};

/**
* A flexible layout component using CSS Flexbox for consistent spacing and alignment.
* Built on design tokens for predictable spacing values.
Expand All @@ -12,7 +25,7 @@ export const Stack = forwardRef< HTMLDivElement, StackProps >( function Stack(
ref
) {
const style: React.CSSProperties = {
gap: gap && `var(--wpds-dimension-gap-${ gap })`,
gap: gap && gapTokens[ gap ],
alignItems: align,
justifyContent: justify,
flexDirection: direction,
Expand Down
Loading