@times-design-system/components-wordpress 1.2.2-alpha.0 → 1.2.2-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/BLOCK_CREATION_CHECKLIST.md +132 -19
  2. package/README.md +10 -4
  3. package/SCSS_VARIABLES_REFERENCE.md +316 -0
  4. package/STYLING_SYNC_GUIDE.md +306 -0
  5. package/TRANSFORMATION_GUIDE.md +286 -13
  6. package/dist/blocks/ad-container/block.json +1 -0
  7. package/dist/blocks/ad-container/render.php +27 -0
  8. package/dist/blocks/ad-container/style.css +23 -20
  9. package/dist/blocks/button/block.json +1 -0
  10. package/dist/blocks/button/render.php +71 -0
  11. package/dist/blocks/button/style-resolved.css +153 -0
  12. package/dist/blocks/button/style.css +138 -18
  13. package/dist/blocks/chip/block.json +1 -0
  14. package/dist/blocks/chip/render.php +40 -0
  15. package/dist/blocks/chip/style.css +68 -29
  16. package/dist/blocks/divider/block.json +1 -0
  17. package/dist/blocks/divider/render.php +31 -0
  18. package/dist/blocks/divider/style.css +25 -13
  19. package/dist/blocks/flag/block.json +1 -0
  20. package/dist/blocks/flag/render.php +34 -0
  21. package/dist/blocks/flag/style.css +39 -30
  22. package/dist/blocks/icon-button/block.json +1 -0
  23. package/dist/blocks/icon-button/render.php +46 -0
  24. package/dist/blocks/icon-button/style.css +21 -22
  25. package/dist/blocks/input/block.json +1 -0
  26. package/dist/blocks/input/render.php +39 -0
  27. package/dist/blocks/input/style.css +40 -17
  28. package/dist/blocks/link/block.json +1 -0
  29. package/dist/blocks/link/render.php +44 -0
  30. package/dist/blocks/link/style.css +87 -34
  31. package/dist/blocks/text/block.json +1 -0
  32. package/dist/blocks/text/render.php +26 -0
  33. package/dist/blocks/text/style.css +5 -18
  34. package/dist/blocks/toast/block.json +1 -0
  35. package/dist/blocks/toast/render.php +37 -0
  36. package/dist/blocks/toast/style.css +50 -34
  37. package/dist/index.cjs +20 -0
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.js +20 -0
  40. package/dist/index.js.map +1 -1
  41. package/package.json +3 -3
  42. package/src/blocks/ad-container/block.json +1 -0
  43. package/src/blocks/ad-container/render.php +27 -0
  44. package/src/blocks/ad-container/style.css +23 -20
  45. package/src/blocks/button/block.json +1 -0
  46. package/src/blocks/button/render.php +71 -0
  47. package/src/blocks/button/style-resolved.css +153 -0
  48. package/src/blocks/button/style.css +138 -18
  49. package/src/blocks/chip/block.json +1 -0
  50. package/src/blocks/chip/render.php +40 -0
  51. package/src/blocks/chip/style.css +68 -29
  52. package/src/blocks/divider/block.json +1 -0
  53. package/src/blocks/divider/render.php +31 -0
  54. package/src/blocks/divider/style.css +25 -13
  55. package/src/blocks/flag/block.json +1 -0
  56. package/src/blocks/flag/render.php +34 -0
  57. package/src/blocks/flag/style.css +39 -30
  58. package/src/blocks/icon-button/block.json +1 -0
  59. package/src/blocks/icon-button/render.php +46 -0
  60. package/src/blocks/icon-button/style.css +21 -22
  61. package/src/blocks/input/block.json +1 -0
  62. package/src/blocks/input/render.php +39 -0
  63. package/src/blocks/input/style.css +40 -17
  64. package/src/blocks/link/block.json +1 -0
  65. package/src/blocks/link/render.php +44 -0
  66. package/src/blocks/link/style.css +87 -34
  67. package/src/blocks/text/block.json +1 -0
  68. package/src/blocks/text/render.php +26 -0
  69. package/src/blocks/text/style.css +5 -18
  70. package/src/blocks/toast/block.json +1 -0
  71. package/src/blocks/toast/render.php +37 -0
  72. package/src/blocks/toast/style.css +50 -34
@@ -16,7 +16,8 @@ Use this checklist when creating each new WordPress block from a React component
16
16
  - [ ] Created `block.json` manifest
17
17
  - [ ] Created `index.js` registration file
18
18
  - [ ] Created `edit.js` editor component
19
- - [ ] Created `save.js` frontend component
19
+ - [ ] Created `save.js` frontend component (static output only, no event handlers)
20
+ - [ ] Created `render.php` server-side rendering callback
20
21
  - [ ] Created `style.css` frontend styles
21
22
  - [ ] Created `style-editor.css` (if needed)
22
23
 
@@ -24,6 +25,7 @@ Use this checklist when creating each new WordPress block from a React component
24
25
 
25
26
  - [ ] Set `name` to `tds/<component-name>`
26
27
  - [ ] Set descriptive `title`
28
+ - [ ] Added `"render": "file:./render.php"` for server-side rendering
27
29
  - [ ] Added all React props as `attributes`
28
30
  - [ ] Set appropriate `type` for each attribute
29
31
  - [ ] Added `enum` arrays for variant props
@@ -45,19 +47,85 @@ Use this checklist when creating each new WordPress block from a React component
45
47
 
46
48
  ## 5. save.js
47
49
 
48
- - [ ] Used `useBlockProps.save()`
49
- - [ ] Returned valid, deterministic HTML
50
- - [ ] Output matches React component structure
51
- - [ ] No event handlers or dynamic behavior
50
+ - [ ] Used `useBlockProps.save()` (no event handlers or state)
51
+ - [ ] Output structure matches what `render.php` outputs
52
+ - [ ] No dynamic behavior or client-side logic
52
53
  - [ ] Included proper ARIA attributes
53
54
 
54
- ## 6. Styling
55
+ ## 5b. render.php
56
+
57
+ - [ ] Created PHP file that mirrors `save.js` output
58
+ - [ ] Used `sanitize_*()` and `esc_*()` functions for all attributes
59
+ - [ ] Used `get_block_wrapper_attributes()` for wrapper
60
+ - [ ] Used `wp_kses_post()` for any rich content
61
+ - [ ] Conditionally rendered elements based on attributes
62
+ - [ ] Added proper PHPDoc header with @package taghavior
63
+
64
+ ## 6b. Pattern Testing
65
+
66
+ - [ ] Verified block renders in patterns (server-side rendering)
67
+ - [ ] Tested block with various attribute combinations in patterns
68
+ - [ ] Confirmed HTML output in pattern matches `render.php` structure
69
+ - [ ] Included proper ARIA attributes
70
+
71
+ ## 6. Styling — Full Parity with React Components
72
+
73
+ ### 6a. Copy Styles from React Component
74
+
75
+ - [ ] Located React component styles in `packages/components-react/src/<ComponentName>/<ComponentName>.scss` or `.css`
76
+ - [ ] Identified all style segments: base styles, variant modifiers, state handlers (hover, focus, active, disabled)
77
+ - [ ] Copied complete CSS from React component to WordPress `style.css`
78
+ - [ ] **CRITICAL**: All CSS custom properties (design tokens) are preserved — NO hardcoded values
79
+ - [ ] Followed BEM naming: `.tds-<component>`, `.tds-<component>--modifier` (intent variants, size variants, behaviour variants)
80
+ - [ ] Ensured state handlers (hover, focus, active, disabled) are included
81
+ - [ ] Verified transitions and animations are preserved
82
+
83
+ ### 6b. Resolved Design Token Values
84
+
85
+ WordPress blocks use **resolved design token values** — actual hex colors, pixel sizes, and font definitions compiled directly into CSS. This makes blocks completely self-contained.
86
+
87
+ **Conversion Process**:
88
+
89
+ For each CSS property in the React component:
90
+
91
+ 1. Identify the design token it references (e.g., `--spacing-05`, `--interactive-primary-fill-default`)
92
+ 2. Look up the resolved value in [SCSS_VARIABLES_REFERENCE.md](./SCSS_VARIABLES_REFERENCE.md)
93
+ 3. Replace the variable with the actual value:
94
+ - `gap: var(--spacing-03)` → `gap: 4px`
95
+ - `background: var(--interactive-primary-fill-default)` → `background: #005c8a`
96
+ - `font-family: var(--fontFamily040)` → `font-family: Roboto`
97
+ - `font-size: var(--fontSize030)` → `font-size: 1.6rem` (always use rem units from theme-scss)
98
+
99
+ **Checklist**:
100
+
101
+ - [ ] All hex color values are used directly (e.g., `#005c8a`, never `var(--color-*)`)
102
+ - [ ] All spacing uses pixel values (e.g., `8px`, never `var(--spacing-05)`)
103
+ - [ ] All typography uses concrete values (font-family, font-weight, font-size all explicit)
104
+ - [ ] Border radius values are hardcoded (e.g., `4px`, `9999px`)
105
+ - [ ] No CSS custom property fallbacks (e.g., no `var(--spacing-05, 8px)`)
106
+ - [ ] Blocks work in any WordPress theme (no theme-scss dependency needed)
107
+ - [ ] All color values from design tokens are accurate
108
+
109
+ **Reference**: See `SCSS_VARIABLES_REFERENCE.md` for the complete value mapping
110
+
111
+ ### 6c. Variant Coverage
112
+
113
+ - [ ] **Intent variants**: primary, secondary, negative (if applicable) with unique color tokens
114
+ - [ ] **Size variants**: small, medium, large (if applicable) with appropriate padding/font-size
115
+ - [ ] **Behaviour variants**: full width, hug content, etc.
116
+ - [ ] **State handlers**: hover, active, focus-visible with box-shadow rings, disabled with opacity/color changes
117
+ - [ ] **Channel/toggle states**: for components like Chip (on/off states with different colors)
118
+
119
+ ### 6d. Testing & Validation
55
120
 
56
- - [ ] Updated `style.css` with component styles
57
- - [ ] Used CSS custom properties for design tokens
58
- - [ ] Followed BEM naming: `.tds-<component>`, `.tds-<component>--modifier`
59
121
  - [ ] Tested styles on editor and frontend
60
- - [ ] Added `style-editor.css` for editor-specific overrides (if needed)
122
+ - [ ] Verified all variant combinations render correctly with proper colors/sizing
123
+ - [ ] Checked focus/hover/active states work as expected
124
+ - [ ] Tested disabled state (proper cursor, opacity, color changes)
125
+ - [ ] Tested responsive breakpoints if applicable
126
+ - [ ] Added `style-editor.css` for editor-specific overrides (only if needed)
127
+ - [ ] Confirmed line count of `style.css` is comparable to React component (similar complexity = similar coverage)
128
+ - [ ] Visual comparison: side-by-side React vs WordPress block in patterns/editor to confirm parity
61
129
 
62
130
  ## 7. Utilities
63
131
 
@@ -111,15 +179,21 @@ Track which components have been transformed:
111
179
 
112
180
  ## Quick Reference: Prop Type → Block Attribute
113
181
 
114
- ```
115
- React Type → Block.json Type & Example
182
+ Issue: Block doesn't render in patterns
183
+
184
+ **Solution**: Verify `render.php` exists and is referenced in `block.json` with `"render": "file:./render.php"`. Render callbacks provide server-side rendering for patterns.
185
+
186
+ ### Issue: Block appears but styles are missing in patterns
187
+
188
+ **Solution**: Ensure theme/plugin enqueues block CSS with `wp_enqueue_style()` on both frontend and editor
116
189
  ─────────────────────────────────────────────────
117
- string → "type": "string", "default": ""
118
- boolean → "type": "boolean", "default": false
119
- enum (union) → "enum": ["a", "b"], "default": "a"
120
- number → "type": "number", "default": 0
121
- Event handler → Not supported (use editor preview only)
122
- ```
190
+ string → "type": "string", "default": ""
191
+ boolean → "type": "boolean", "default": false
192
+ enum (union) → "enum": ["a", "b"], "default": "a"
193
+ number → "type": "number", "default": 0
194
+ Event handler → Not supported (use editor preview only)
195
+
196
+ ````
123
197
 
124
198
  ---
125
199
 
@@ -137,10 +211,49 @@ Event handler → Not supported (use editor preview only)
137
211
 
138
212
  **Solution**: Verify CSS paths in `block.json` and ensure theme-scss is in dependencies
139
213
 
214
+ ### Issue: Styles incomplete or missing variants
215
+
216
+ **Solution**: Compare `style.css` line count to React component to identify gaps
217
+ ```bash
218
+ # Check line count
219
+ wc -l src/blocks/<component>/style.css
220
+ wc -l packages/components-react/src/<ComponentName>/<ComponentName>.scss
221
+
222
+ # If WordPress component is <50% of React component, styles are incomplete
223
+ # Copy missing variant modifiers from React component:
224
+ grep 'tds-<component>--' packages/components-react/src/<ComponentName>/<ComponentName>.scss
225
+ # Ensure all variants are in WordPress style.css
226
+ ```
227
+
228
+ **Typical missing patterns**:
229
+ - Intent variant modifiers (primary, secondary, negative)
230
+ - Size variant modifiers (small, medium, large)
231
+ - State handlers (hover, focus-visible, active, disabled)
232
+ - Focus ring styling with ::after pseudo-element
233
+ - Behaviour modifiers (full, hug)
234
+
235
+ ### Issue: Block styles differ from React component
236
+
237
+ **Solution**: Use visual regression testing
238
+ 1. Open React component in Storybook
239
+ 2. Render WordPress block in editor side-by-side
240
+ 3. Compare colors, spacing, typography for each variant
241
+ 4. Verify all CSS custom properties use `var(--token-name)` format
242
+ 5. Copy any missing styles from React component
243
+
140
244
  ### Issue: Inspector controls not working
141
245
 
142
246
  **Solution**: Verify `setAttributes()` is called with correct attribute name and value
143
247
 
248
+ ### Issue: Block renders in editor but not in patterns
249
+
250
+ **Solution**: Verify server-side render callback is properly configured
251
+ 1. Check `render.php` exists in block directory
252
+ 2. Verify `block.json` contains `"render": "file:./render.php"`
253
+ 3. Rebuild: `npm run build` (copies render.php to dist/)
254
+ 4. Verify render.php HTML structure matches save.js exactly
255
+ 5. Test render.php independently in WordPress patterns
256
+
144
257
  ---
145
258
 
146
259
  ## Helpful Commands
@@ -157,4 +270,4 @@ npm run build
157
270
 
158
271
  # Validate JSON
159
272
  npm run test
160
- ```
273
+ ````
package/README.md CHANGED
@@ -929,12 +929,15 @@ npm run build && npm run build:plugin # Build for plugin distrib
929
929
  ### Get Help
930
930
 
931
931
  1. **Check Documentation**:
932
- - [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md) — Technical details
933
- - [BLOCK_CREATION_CHECKLIST.md](./BLOCK_CREATION_CHECKLIST.md) — Verify setup
932
+ - [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md) — Complete transformation process and testing
933
+ - [BLOCK_CREATION_CHECKLIST.md](./BLOCK_CREATION_CHECKLIST.md) — Step-by-step implementation verification
934
+ - [SCSS_VARIABLES_REFERENCE.md](./SCSS_VARIABLES_REFERENCE.md) — Design token CSS custom properties guide
935
+ - [STYLING_SYNC_GUIDE.md](./STYLING_SYNC_GUIDE.md) — Ensure CSS feature parity with React components
934
936
 
935
937
  2. **Common Issues**:
936
938
  - See "Troubleshooting Integration" section above
937
939
  - Check plugin debug log: `/wp-content/debug.log`
940
+ - **Styling gaps**: Use [STYLING_SYNC_GUIDE.md](./STYLING_SYNC_GUIDE.md) and [SCSS_VARIABLES_REFERENCE.md](./SCSS_VARIABLES_REFERENCE.md) to validate style completeness
938
941
 
939
942
  3. **Report Issues**:
940
943
  - GitHub: [times-design-system/issues](https://github.com/newsuk/times-design-system/issues)
@@ -946,8 +949,11 @@ To add new blocks or improve existing ones:
946
949
 
947
950
  1. Review [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md)
948
951
  2. Follow [BLOCK_CREATION_CHECKLIST.md](./BLOCK_CREATION_CHECKLIST.md)
949
- 3. Test thoroughly before submitting
950
- 4. Submit PR with detailed description
952
+ 3. **Style using design tokens**: Reference [SCSS_VARIABLES_REFERENCE.md](./SCSS_VARIABLES_REFERENCE.md) for CSS custom properties
953
+ 4. **Synchronize styling** using [STYLING_SYNC_GUIDE.md](./STYLING_SYNC_GUIDE.md) — critical for feature parity
954
+ 5. Run testing workflow from TRANSFORMATION_GUIDE.md
955
+ 6. Test thoroughly before submitting
956
+ 7. Submit PR with detailed description
951
957
 
952
958
  ## License
953
959
 
@@ -0,0 +1,316 @@
1
+ # Design Token Values Reference for WordPress Blocks
2
+
3
+ This document provides resolved design token values (actual hex colors, pixel sizes, and font definitions) used directly in WordPress block styles.
4
+
5
+ ## Important: Resolved Values Architecture
6
+
7
+ WordPress blocks use **resolved design token values** directly in CSS rather than CSS custom properties. This approach:
8
+
9
+ - ✅ Makes blocks **self-contained** and independent of theme-scss loading
10
+ - ✅ Ensures **consistent appearance** across different WordPress installations
11
+ - ✅ Eliminates dependency on CSS variables being defined
12
+ - ✅ Makes blocks work reliably in any WordPress theme context
13
+
14
+ **No CSS custom properties are required at runtime** — all values are baked directly into the compiled block CSS.
15
+
16
+ ---
17
+
18
+ ## Available SCSS Variables
19
+
20
+ All variables from `packages/theme-scss/src/tds-layout.scss` are compiled to CSS custom properties and available in block styles.
21
+
22
+ ### Spacing Variables
23
+
24
+ | SCSS Variable | CSS Property | Value | Usage |
25
+ | ------------- | -------------- | ----- | ---------------------------- |
26
+ | `$spacing-01` | `--spacing-01` | 2px | Borders, minimal gaps |
27
+ | `$spacing-02` | `--spacing-02` | 3px | Fine-tuning |
28
+ | `$spacing-03` | `--spacing-03` | 4px | Tight spacing in components |
29
+ | `$spacing-04` | `--spacing-04` | 6px | Small gaps, padding |
30
+ | `$spacing-05` | `--spacing-05` | 8px | Common padding |
31
+ | `$spacing-06` | `--spacing-06` | 10px | Medium gaps |
32
+ | `$spacing-07` | `--spacing-07` | 12px | Medium-large gaps |
33
+ | `$spacing-08` | `--spacing-08` | 14px | Standard gap |
34
+ | `$spacing-09` | `--spacing-09` | 16px | Common gap (1rem equivalent) |
35
+ | `$spacing-10` | `--spacing-10` | 18px | Large gap |
36
+ | `$spacing-11` | `--spacing-11` | 20px | Larger spacing |
37
+ | `$spacing-12` | `--spacing-12` | 23px | Component sizing |
38
+ | `$spacing-13` | `--spacing-13` | 24px | Section divider spacing |
39
+ | `$spacing-14` | `--spacing-14` | 28px | Block separator |
40
+ | `$spacing-15` | `--spacing-15` | 32px | Small component height |
41
+ | `$spacing-16` | `--spacing-16` | 36px | Medium component height |
42
+ | `$spacing-17` | `--spacing-17` | 40px | Large component height |
43
+ | `$spacing-18` | `--spacing-18` | 48px | XL component height |
44
+ | `$spacing-19` | `--spacing-19` | 56px | Block spacing |
45
+ | `$spacing-20` | `--spacing-20` | 64px | Large section spacing |
46
+ | `$spacing-21` | `--spacing-21` | 80px | XL section spacing |
47
+
48
+ ### Border Radius Variables
49
+
50
+ | SCSS Variable | CSS Property | Value | Usage |
51
+ | --------------------- | ---------------------- | ------ | ------------------------------ |
52
+ | `$border-radius-50` | `--border-radius-50` | 2px | Minimal rounding |
53
+ | `$border-radius-100` | `--border-radius-100` | 4px | Subtle rounding |
54
+ | `$border-radius-150` | `--border-radius-150` | 6px | Standard rounding |
55
+ | `$border-radius-200` | `--border-radius-200` | 8px | Medium rounding |
56
+ | `$border-radius-300` | `--border-radius-300` | 12px | Larger rounding |
57
+ | `$border-radius-400` | `--border-radius-400` | 16px | XL rounding |
58
+ | `$border-radius-full` | `--border-radius-full` | 9999px | Fully rounded (pills, circles) |
59
+
60
+ ### Shadow Variables
61
+
62
+ | SCSS Variable | CSS Property | Usage |
63
+ | -------------------------------- | --------------------------------- | ----------------------- |
64
+ | `$shadow-elevation-down-level-2` | `--shadow-elevation-down-level-2` | Subtle elevation shadow |
65
+ | `$shadow-elevation-down-level-3` | `--shadow-elevation-down-level-3` | Medium elevation shadow |
66
+ | `$shadow-elevation-down-level-4` | `--shadow-elevation-down-level-4` | Strong elevation shadow |
67
+ | `$shadow-elevation-up-level-2` | `--shadow-elevation-up-level-2` | Upward subtle shadow |
68
+ | `$shadow-elevation-up-level-3` | `--shadow-elevation-up-level-3` | Upward medium shadow |
69
+ | `$shadow-elevation-up-level-4` | `--shadow-elevation-up-level-4` | Upward strong shadow |
70
+
71
+ **Example Shadow Usage**:
72
+
73
+ ```css
74
+ .tds-toast {
75
+ box-shadow: var(--shadow-elevation-down-level-3);
76
+ }
77
+ ```
78
+
79
+ **Note**: While this example shows CSS variables for illustration, WordPress blocks use **resolved values** (actual hex, pixel sizes, and font names) compiled directly into CSS, not CSS variables.
80
+
81
+ ### Breakpoint Variables
82
+
83
+ | SCSS Variable | CSS Property | Value | Usage |
84
+ | -------------------- | --------------------- | ------ | ---------------- |
85
+ | `$breakpoint-small` | `--breakpoint-small` | 0px | Mobile (base) |
86
+ | `$breakpoint-medium` | `--breakpoint-medium` | 440px | Tablet portrait |
87
+ | `$breakpoint-large` | `--breakpoint-large` | 1024px | Tablet landscape |
88
+ | `$breakpoint-xLarge` | `--breakpoint-xLarge` | 1440px | Desktop |
89
+
90
+ **Example Media Query Usage**:
91
+
92
+ ```css
93
+ @media (min-width: var(--breakpoint-large)) {
94
+ .tds-ad-container {
95
+ min-height: 400px;
96
+ }
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Design Token Variables (from tokens package)
103
+
104
+ These CSS custom properties are compiled from the design tokens package and available in client WordPress installations through the imported theme.
105
+
106
+ ### Typography Variables
107
+
108
+ | CSS Property | Purpose | Example Value |
109
+ | --------------------- | ---------------- | ----------------- |
110
+ | `--fontFamily010` | Brand serif font | Times Modern |
111
+ | `--fontFamily020` | Brand font | Times Digital W04 |
112
+ | `--fontFamily040` | Standard font | Roboto |
113
+ | `--fontWeight040` | Regular weight | 400 |
114
+ | `--fontWeight050` | Medium weight | 500 |
115
+ | `--fontWeight070` | Bold weight | 700 |
116
+ | `--fontSize010` | XS text | 1.2rem |
117
+ | `--fontSize020` | S text | 1.4rem |
118
+ | `--fontSize030` | M text | 1.6rem |
119
+ | `--fontSize040` | L text | 1.8rem |
120
+ | `--fontLineHeight010` | Tight leading | 1 |
121
+ | `--fontLineHeight020` | Compact leading | 1.125 |
122
+ | `--fontLineHeight040` | Normal leading | 1.5 |
123
+
124
+ ### Interactive State Colors
125
+
126
+ | CSS Property Group | Variants | Usage |
127
+ | ---------------------------------- | -------------------------------------------- | ------------------ |
128
+ | `--interactive-primary-*` | fill, text, border (default, hover, pressed) | Primary actions |
129
+ | `--interactive-secondary-*` | fill, text, border (default, hover, pressed) | Secondary actions |
130
+ | `--interactive-negative-*` | fill, text, border (default, hover, pressed) | Destructive action |
131
+ | `--interactive-chip-primary-on-*` | fill, text, icon (default, hover, pressed) | Selected chip |
132
+ | `--interactive-chip-primary-off-*` | fill, text, icon (default, hover, pressed) | Unselected chip |
133
+ | `--interactive-disabled-*` | Colors for disabled states | Disabled UI |
134
+ | `--interactive-link-primary-*` | text, underline (default, hover, visited) | Primary links |
135
+ | `--interactive-link-secondary-*` | text, underline (default, hover, visited) | Secondary links |
136
+
137
+ ### Messaging Colors
138
+
139
+ | CSS Property | Value | Usage |
140
+ | ---------------------- | ----- | ------------- |
141
+ | `--toast-fill-success` | Green | Success toast |
142
+ | `--toast-text-success` | White | Success text |
143
+ | `--toast-fill-error` | Red | Error toast |
144
+ | `--toast-text-error` | White | Error text |
145
+ | `--toast-fill-warning` | Gold | Warning toast |
146
+ | `--toast-text-warning` | Black | Warning text |
147
+ | `--toast-fill-info` | Blue | Info toast |
148
+ | `--toast-text-info` | White | Info text |
149
+
150
+ ### Border Colors
151
+
152
+ | CSS Property | Usage |
153
+ | ------------------- | ------------------------ |
154
+ | `--border-primary` | Standard borders |
155
+ | `--border-disabled` | Disabled element borders |
156
+ | `--focus-border` | Focus ring color |
157
+
158
+ ### Text Colors
159
+
160
+ | CSS Property | Usage |
161
+ | ---------------------------- | -------------- |
162
+ | `--text-primary` | Body text |
163
+ | `--text-secondary` | Secondary text |
164
+ | `--text-disabled` | Disabled text |
165
+ | `--text-interactive-primary` | Link text |
166
+
167
+ ---
168
+
169
+ ## Common CSS Variable Patterns
170
+
171
+ ### Button Component
172
+
173
+ ```css
174
+ .tds-button {
175
+ /* Color tokens from interactive palette */
176
+ --tds-button-bg: var(--interactive-primary-fill-default);
177
+ --tds-button-fg: var(--interactive-primary-text-default);
178
+ --tds-button-border: var(--interactive-primary-border-default);
179
+
180
+ /* Spacing tokens from layout */
181
+ gap: var(--spacing-03);
182
+ padding: 0 var(--spacing-09);
183
+
184
+ /* Typography tokens */
185
+ font-family: var(--fontFamily040);
186
+ font-weight: var(--fontWeight050);
187
+ font-size: var(--fontSize030);
188
+ }
189
+
190
+ .tds-button--size-small {
191
+ min-height: var(--spacing-15);
192
+ padding: 0 var(--spacing-07);
193
+ }
194
+
195
+ .tds-button--intent-secondary {
196
+ --tds-button-bg: var(--interactive-secondary-fill-default);
197
+ --tds-button-fg: var(--interactive-secondary-text-default);
198
+ }
199
+ ```
200
+
201
+ ### Toast Component
202
+
203
+ ```css
204
+ .tds-toast {
205
+ /* Elevation shadow */
206
+ box-shadow: var(--shadow-elevation-down-level-3);
207
+
208
+ /* Spacing */
209
+ padding: var(--spacing-07) var(--spacing-09);
210
+ gap: var(--spacing-07);
211
+
212
+ /* Intent colors */
213
+ background: var(--toast-fill-success);
214
+ color: var(--toast-text-success);
215
+ }
216
+
217
+ .tds-toast--intent-error {
218
+ background: var(--toast-fill-error);
219
+ color: var(--toast-text-error);
220
+ }
221
+ ```
222
+
223
+ ### Chip Component
224
+
225
+ ```css
226
+ .tds-chip {
227
+ /* Custom properties for state variations */
228
+ --tds-chip-bg: var(--interactive-chip-primary-on-fill-default);
229
+ --tds-chip-fg: var(--interactive-chip-primary-on-text-default);
230
+
231
+ /* Rounding */
232
+ border-radius: calc(var(--border-radius-full) * 1px);
233
+
234
+ /* Sizing */
235
+ min-height: var(--spacing-16);
236
+ padding: 0 var(--spacing-07);
237
+ }
238
+
239
+ .tds-chip--size-large {
240
+ min-height: var(--spacing-18);
241
+ padding: 0 var(--spacing-09);
242
+ }
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Best Practices for Block Styling
248
+
249
+ ### ✅ DO:
250
+
251
+ - ✅ Always use CSS custom properties for colors, spacing, typography
252
+ - ✅ Define component-specific custom properties (e.g., `--tds-button-bg`) that reference design tokens
253
+ - ✅ Use tokens for ALL hardcoded values (no hex colors, no pixel dimensions)
254
+ - ✅ Reference `--spacing-*` for all gaps, margins, and padding
255
+ - ✅ Reference `--border-radius-*` for all rounding
256
+ - ✅ Use `--fontFamily*` and `--fontWeight*` for typography
257
+
258
+ ### ❌ DON'T:
259
+
260
+ - ❌ Hardcode hex colors: `color: #000000;` → Use `color: var(--text-primary);`
261
+ - ❌ Hardcode pixel values: `padding: 16px;` → Use `padding: var(--spacing-09);`
262
+ - ❌ Create custom color/spacing values not in the token system
263
+ - ❌ Skip typography customization: Always specify font, weight, and size via tokens
264
+ - ❌ Duplicate token definitions across files
265
+
266
+ ---
267
+
268
+ ## Testing CSS Variables
269
+
270
+ To verify CSS variables are resolving correctly:
271
+
272
+ 1. **In browser DevTools**: Inspect a rendered block element
273
+ 2. **Check computed styles**: Look for `--spacing-*`, `--interactive-*` properties
274
+ 3. **Verify colors**: Hover over color properties to see actual hex values
275
+ 4. **Check fallback values**: If variable is undefined, CSS fallback is used
276
+
277
+ ```css
278
+ /* Safe fallback pattern (if variable not available) */
279
+ color: var(--text-primary, #1a1a1a);
280
+ border-color: var(--border-primary, #999999);
281
+ gap: var(--spacing-03, 4px);
282
+ ```
283
+
284
+ ---
285
+
286
+ ## For New Block Developers
287
+
288
+ When creating a new WordPress block:
289
+
290
+ 1. **Copy styles from React component**: Start with the React component's CSS
291
+ 2. **Replace hardcoded values with variables**: Every color → `var(--...)`, every space → `var(--spacing-...)`
292
+ 3. **Reference this guide**: Use the variable mappings above
293
+ 4. **Test in WordPress**: Ensure CSS custom properties resolve in both editor and frontend
294
+ 5. **Compare with existing blocks**: Use Button or Input as a reference model
295
+
296
+ ---
297
+
298
+ ## Troubleshooting
299
+
300
+ **Problem**: CSS variables not resolving (seeing empty/default values)
301
+ **Solution**: Verify `theme-scss` is installed and theme files are enqueued. Check browser DevTools computed styles.
302
+
303
+ **Problem**: Colors looking different than expected
304
+ **Solution**: Design token hex values may vary. Check actual hex in design tokens or use DevTools color picker.
305
+
306
+ **Problem**: Spacing values too large/small
307
+ **Solution**: Verify you're using the correct `--spacing-*` variable. Reference the table above.
308
+
309
+ ---
310
+
311
+ ## Reference Files
312
+
313
+ - SCSS Source: `packages/theme-scss/src/tds-layout.scss`
314
+ - CSS Output: `build/css/variables.css`
315
+ - Token Definitions: `packages/tokens/src/tokens.json`
316
+ - Example Block Styles: `packages/components-wordpress/src/blocks/button/style.css`