@times-design-system/components-wordpress 1.2.2-alpha.1 → 1.2.2-alpha.4

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.
@@ -68,13 +68,63 @@ Use this checklist when creating each new WordPress block from a React component
68
68
  - [ ] Confirmed HTML output in pattern matches `render.php` structure
69
69
  - [ ] Included proper ARIA attributes
70
70
 
71
- ## 6. Styling
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
+
98
+ **Checklist**:
99
+
100
+ - [ ] All hex color values are used directly (e.g., `#005c8a`, never `var(--color-*)`)
101
+ - [ ] All spacing uses pixel values (e.g., `8px`, never `var(--spacing-05)`)
102
+ - [ ] All typography uses concrete values (font-family, font-weight, font-size all explicit)
103
+ - [ ] Border radius values are hardcoded (e.g., `4px`, `9999px`)
104
+ - [ ] No CSS custom property fallbacks (e.g., no `var(--spacing-05, 8px)`)
105
+ - [ ] Blocks work in any WordPress theme (no theme-scss dependency needed)
106
+ - [ ] All color values from design tokens are accurate
107
+
108
+ **Reference**: See `SCSS_VARIABLES_REFERENCE.md` for the complete value mapping
109
+
110
+ ### 6c. Variant Coverage
111
+
112
+ - [ ] **Intent variants**: primary, secondary, negative (if applicable) with unique color tokens
113
+ - [ ] **Size variants**: small, medium, large (if applicable) with appropriate padding/font-size
114
+ - [ ] **Behaviour variants**: full width, hug content, etc.
115
+ - [ ] **State handlers**: hover, active, focus-visible with box-shadow rings, disabled with opacity/color changes
116
+ - [ ] **Channel/toggle states**: for components like Chip (on/off states with different colors)
117
+
118
+ ### 6d. Testing & Validation
72
119
 
73
- - [ ] Updated `style.css` with component styles
74
- - [ ] Used CSS custom properties for design tokens
75
- - [ ] Followed BEM naming: `.tds-<component>`, `.tds-<component>--modifier`
76
120
  - [ ] Tested styles on editor and frontend
77
- - [ ] Added `style-editor.css` for editor-specific overrides (if needed)
121
+ - [ ] Verified all variant combinations render correctly with proper colors/sizing
122
+ - [ ] Checked focus/hover/active states work as expected
123
+ - [ ] Tested disabled state (proper cursor, opacity, color changes)
124
+ - [ ] Tested responsive breakpoints if applicable
125
+ - [ ] Added `style-editor.css` for editor-specific overrides (only if needed)
126
+ - [ ] Confirmed line count of `style.css` is comparable to React component (similar complexity = similar coverage)
127
+ - [ ] Visual comparison: side-by-side React vs WordPress block in patterns/editor to confirm parity
78
128
 
79
129
  ## 7. Utilities
80
130
 
@@ -160,10 +210,49 @@ Event handler → Not supported (use editor preview only)
160
210
 
161
211
  **Solution**: Verify CSS paths in `block.json` and ensure theme-scss is in dependencies
162
212
 
213
+ ### Issue: Styles incomplete or missing variants
214
+
215
+ **Solution**: Compare `style.css` line count to React component to identify gaps
216
+ ```bash
217
+ # Check line count
218
+ wc -l src/blocks/<component>/style.css
219
+ wc -l packages/components-react/src/<ComponentName>/<ComponentName>.scss
220
+
221
+ # If WordPress component is <50% of React component, styles are incomplete
222
+ # Copy missing variant modifiers from React component:
223
+ grep 'tds-<component>--' packages/components-react/src/<ComponentName>/<ComponentName>.scss
224
+ # Ensure all variants are in WordPress style.css
225
+ ```
226
+
227
+ **Typical missing patterns**:
228
+ - Intent variant modifiers (primary, secondary, negative)
229
+ - Size variant modifiers (small, medium, large)
230
+ - State handlers (hover, focus-visible, active, disabled)
231
+ - Focus ring styling with ::after pseudo-element
232
+ - Behaviour modifiers (full, hug)
233
+
234
+ ### Issue: Block styles differ from React component
235
+
236
+ **Solution**: Use visual regression testing
237
+ 1. Open React component in Storybook
238
+ 2. Render WordPress block in editor side-by-side
239
+ 3. Compare colors, spacing, typography for each variant
240
+ 4. Verify all CSS custom properties use `var(--token-name)` format
241
+ 5. Copy any missing styles from React component
242
+
163
243
  ### Issue: Inspector controls not working
164
244
 
165
245
  **Solution**: Verify `setAttributes()` is called with correct attribute name and value
166
246
 
247
+ ### Issue: Block renders in editor but not in patterns
248
+
249
+ **Solution**: Verify server-side render callback is properly configured
250
+ 1. Check `render.php` exists in block directory
251
+ 2. Verify `block.json` contains `"render": "file:./render.php"`
252
+ 3. Rebuild: `npm run build` (copies render.php to dist/)
253
+ 4. Verify render.php HTML structure matches save.js exactly
254
+ 5. Test render.php independently in WordPress patterns
255
+
167
256
  ---
168
257
 
169
258
  ## Helpful Commands
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,314 @@
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
+ ### Breakpoint Variables
80
+
81
+ | SCSS Variable | CSS Property | Value | Usage |
82
+ | -------------------- | --------------------- | ------ | ---------------- |
83
+ | `$breakpoint-small` | `--breakpoint-small` | 0px | Mobile (base) |
84
+ | `$breakpoint-medium` | `--breakpoint-medium` | 440px | Tablet portrait |
85
+ | `$breakpoint-large` | `--breakpoint-large` | 1024px | Tablet landscape |
86
+ | `$breakpoint-xLarge` | `--breakpoint-xLarge` | 1440px | Desktop |
87
+
88
+ **Example Media Query Usage**:
89
+
90
+ ```css
91
+ @media (min-width: var(--breakpoint-large)) {
92
+ .tds-ad-container {
93
+ min-height: 400px;
94
+ }
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Design Token Variables (from tokens package)
101
+
102
+ These CSS custom properties are compiled from the design tokens package and available in client WordPress installations through the imported theme.
103
+
104
+ ### Typography Variables
105
+
106
+ | CSS Property | Purpose | Example Value |
107
+ | --------------------- | ---------------- | ----------------- |
108
+ | `--fontFamily010` | Brand serif font | Times Modern |
109
+ | `--fontFamily020` | Brand font | Times Digital W04 |
110
+ | `--fontFamily040` | Standard font | Roboto |
111
+ | `--fontWeight040` | Regular weight | 400 |
112
+ | `--fontWeight050` | Medium weight | 500 |
113
+ | `--fontWeight070` | Bold weight | 700 |
114
+ | `--fontSize010` | XS text | 12px |
115
+ | `--fontSize020` | S text | 14px |
116
+ | `--fontSize030` | M text | 16px |
117
+ | `--fontSize040` | L text | 18px/1.125rem |
118
+ | `--fontLineHeight010` | Tight leading | 1 |
119
+ | `--fontLineHeight020` | Compact leading | 1.125 |
120
+ | `--fontLineHeight040` | Normal leading | 1.5 |
121
+
122
+ ### Interactive State Colors
123
+
124
+ | CSS Property Group | Variants | Usage |
125
+ | ---------------------------------- | -------------------------------------------- | ------------------ |
126
+ | `--interactive-primary-*` | fill, text, border (default, hover, pressed) | Primary actions |
127
+ | `--interactive-secondary-*` | fill, text, border (default, hover, pressed) | Secondary actions |
128
+ | `--interactive-negative-*` | fill, text, border (default, hover, pressed) | Destructive action |
129
+ | `--interactive-chip-primary-on-*` | fill, text, icon (default, hover, pressed) | Selected chip |
130
+ | `--interactive-chip-primary-off-*` | fill, text, icon (default, hover, pressed) | Unselected chip |
131
+ | `--interactive-disabled-*` | Colors for disabled states | Disabled UI |
132
+ | `--interactive-link-primary-*` | text, underline (default, hover, visited) | Primary links |
133
+ | `--interactive-link-secondary-*` | text, underline (default, hover, visited) | Secondary links |
134
+
135
+ ### Messaging Colors
136
+
137
+ | CSS Property | Value | Usage |
138
+ | ---------------------- | ----- | ------------- |
139
+ | `--toast-fill-success` | Green | Success toast |
140
+ | `--toast-text-success` | White | Success text |
141
+ | `--toast-fill-error` | Red | Error toast |
142
+ | `--toast-text-error` | White | Error text |
143
+ | `--toast-fill-warning` | Gold | Warning toast |
144
+ | `--toast-text-warning` | Black | Warning text |
145
+ | `--toast-fill-info` | Blue | Info toast |
146
+ | `--toast-text-info` | White | Info text |
147
+
148
+ ### Border Colors
149
+
150
+ | CSS Property | Usage |
151
+ | ------------------- | ------------------------ |
152
+ | `--border-primary` | Standard borders |
153
+ | `--border-disabled` | Disabled element borders |
154
+ | `--focus-border` | Focus ring color |
155
+
156
+ ### Text Colors
157
+
158
+ | CSS Property | Usage |
159
+ | ---------------------------- | -------------- |
160
+ | `--text-primary` | Body text |
161
+ | `--text-secondary` | Secondary text |
162
+ | `--text-disabled` | Disabled text |
163
+ | `--text-interactive-primary` | Link text |
164
+
165
+ ---
166
+
167
+ ## Common CSS Variable Patterns
168
+
169
+ ### Button Component
170
+
171
+ ```css
172
+ .tds-button {
173
+ /* Color tokens from interactive palette */
174
+ --tds-button-bg: var(--interactive-primary-fill-default);
175
+ --tds-button-fg: var(--interactive-primary-text-default);
176
+ --tds-button-border: var(--interactive-primary-border-default);
177
+
178
+ /* Spacing tokens from layout */
179
+ gap: var(--spacing-03);
180
+ padding: 0 var(--spacing-09);
181
+
182
+ /* Typography tokens */
183
+ font-family: var(--fontFamily040);
184
+ font-weight: var(--fontWeight050);
185
+ font-size: var(--fontSize030);
186
+ }
187
+
188
+ .tds-button--size-small {
189
+ min-height: var(--spacing-15);
190
+ padding: 0 var(--spacing-07);
191
+ }
192
+
193
+ .tds-button--intent-secondary {
194
+ --tds-button-bg: var(--interactive-secondary-fill-default);
195
+ --tds-button-fg: var(--interactive-secondary-text-default);
196
+ }
197
+ ```
198
+
199
+ ### Toast Component
200
+
201
+ ```css
202
+ .tds-toast {
203
+ /* Elevation shadow */
204
+ box-shadow: var(--shadow-elevation-down-level-3);
205
+
206
+ /* Spacing */
207
+ padding: var(--spacing-07) var(--spacing-09);
208
+ gap: var(--spacing-07);
209
+
210
+ /* Intent colors */
211
+ background: var(--toast-fill-success);
212
+ color: var(--toast-text-success);
213
+ }
214
+
215
+ .tds-toast--intent-error {
216
+ background: var(--toast-fill-error);
217
+ color: var(--toast-text-error);
218
+ }
219
+ ```
220
+
221
+ ### Chip Component
222
+
223
+ ```css
224
+ .tds-chip {
225
+ /* Custom properties for state variations */
226
+ --tds-chip-bg: var(--interactive-chip-primary-on-fill-default);
227
+ --tds-chip-fg: var(--interactive-chip-primary-on-text-default);
228
+
229
+ /* Rounding */
230
+ border-radius: calc(var(--border-radius-full) * 1px);
231
+
232
+ /* Sizing */
233
+ min-height: var(--spacing-16);
234
+ padding: 0 var(--spacing-07);
235
+ }
236
+
237
+ .tds-chip--size-large {
238
+ min-height: var(--spacing-18);
239
+ padding: 0 var(--spacing-09);
240
+ }
241
+ ```
242
+
243
+ ---
244
+
245
+ ## Best Practices for Block Styling
246
+
247
+ ### ✅ DO:
248
+
249
+ - ✅ Always use CSS custom properties for colors, spacing, typography
250
+ - ✅ Define component-specific custom properties (e.g., `--tds-button-bg`) that reference design tokens
251
+ - ✅ Use tokens for ALL hardcoded values (no hex colors, no pixel dimensions)
252
+ - ✅ Reference `--spacing-*` for all gaps, margins, and padding
253
+ - ✅ Reference `--border-radius-*` for all rounding
254
+ - ✅ Use `--fontFamily*` and `--fontWeight*` for typography
255
+
256
+ ### ❌ DON'T:
257
+
258
+ - ❌ Hardcode hex colors: `color: #000000;` → Use `color: var(--text-primary);`
259
+ - ❌ Hardcode pixel values: `padding: 16px;` → Use `padding: var(--spacing-09);`
260
+ - ❌ Create custom color/spacing values not in the token system
261
+ - ❌ Skip typography customization: Always specify font, weight, and size via tokens
262
+ - ❌ Duplicate token definitions across files
263
+
264
+ ---
265
+
266
+ ## Testing CSS Variables
267
+
268
+ To verify CSS variables are resolving correctly:
269
+
270
+ 1. **In browser DevTools**: Inspect a rendered block element
271
+ 2. **Check computed styles**: Look for `--spacing-*`, `--interactive-*` properties
272
+ 3. **Verify colors**: Hover over color properties to see actual hex values
273
+ 4. **Check fallback values**: If variable is undefined, CSS fallback is used
274
+
275
+ ```css
276
+ /* Safe fallback pattern (if variable not available) */
277
+ color: var(--text-primary, #1a1a1a);
278
+ border-color: var(--border-primary, #999999);
279
+ gap: var(--spacing-03, 4px);
280
+ ```
281
+
282
+ ---
283
+
284
+ ## For New Block Developers
285
+
286
+ When creating a new WordPress block:
287
+
288
+ 1. **Copy styles from React component**: Start with the React component's CSS
289
+ 2. **Replace hardcoded values with variables**: Every color → `var(--...)`, every space → `var(--spacing-...)`
290
+ 3. **Reference this guide**: Use the variable mappings above
291
+ 4. **Test in WordPress**: Ensure CSS custom properties resolve in both editor and frontend
292
+ 5. **Compare with existing blocks**: Use Button or Input as a reference model
293
+
294
+ ---
295
+
296
+ ## Troubleshooting
297
+
298
+ **Problem**: CSS variables not resolving (seeing empty/default values)
299
+ **Solution**: Verify `theme-scss` is installed and theme files are enqueued. Check browser DevTools computed styles.
300
+
301
+ **Problem**: Colors looking different than expected
302
+ **Solution**: Design token hex values may vary. Check actual hex in design tokens or use DevTools color picker.
303
+
304
+ **Problem**: Spacing values too large/small
305
+ **Solution**: Verify you're using the correct `--spacing-*` variable. Reference the table above.
306
+
307
+ ---
308
+
309
+ ## Reference Files
310
+
311
+ - SCSS Source: `packages/theme-scss/src/tds-layout.scss`
312
+ - CSS Output: `build/css/variables.css`
313
+ - Token Definitions: `packages/tokens/src/tokens.json`
314
+ - Example Block Styles: `packages/components-wordpress/src/blocks/button/style.css`