@times-design-system/components-wordpress 0.1.1-alpha.831 → 0.7.2-alpha.2
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.
- package/BLOCK_CREATION_CHECKLIST.md +160 -0
- package/BUILD.md +411 -0
- package/CHANGELOG.md +30 -0
- package/LICENSE +29 -0
- package/README.md +972 -5
- package/TRANSFORMATION_GUIDE.md +635 -0
- package/block.json +10 -0
- package/dist/block.json +10 -0
- package/dist/blocks/ad-container/block.json +28 -0
- package/dist/blocks/ad-container/edit.js +42 -0
- package/dist/blocks/ad-container/index.js +10 -0
- package/dist/blocks/ad-container/save.js +16 -0
- package/dist/blocks/ad-container/style-editor.css +4 -0
- package/dist/blocks/ad-container/style.css +27 -0
- package/dist/blocks/button/block.json +89 -0
- package/dist/blocks/button/edit.js +187 -0
- package/dist/blocks/button/index.js +11 -0
- package/dist/blocks/button/save.js +52 -0
- package/dist/blocks/button/style-editor.css +15 -0
- package/dist/blocks/button/style.css +37 -0
- package/dist/blocks/chip/block.json +57 -0
- package/dist/blocks/chip/edit.js +113 -0
- package/dist/blocks/chip/index.js +10 -0
- package/dist/blocks/chip/save.js +36 -0
- package/dist/blocks/chip/style-editor.css +5 -0
- package/dist/blocks/chip/style.css +48 -0
- package/dist/blocks/divider/block.json +31 -0
- package/dist/blocks/divider/edit.js +42 -0
- package/dist/blocks/divider/index.js +10 -0
- package/dist/blocks/divider/save.js +18 -0
- package/dist/blocks/divider/style-editor.css +4 -0
- package/dist/blocks/divider/style.css +25 -0
- package/dist/blocks/flag/block.json +48 -0
- package/dist/blocks/flag/edit.js +82 -0
- package/dist/blocks/flag/index.js +10 -0
- package/dist/blocks/flag/save.js +25 -0
- package/dist/blocks/flag/style-editor.css +5 -0
- package/dist/blocks/flag/style.css +45 -0
- package/dist/blocks/icon-button/block.json +43 -0
- package/dist/blocks/icon-button/edit.js +82 -0
- package/dist/blocks/icon-button/index.js +10 -0
- package/dist/blocks/icon-button/save.js +29 -0
- package/dist/blocks/icon-button/style-editor.css +5 -0
- package/dist/blocks/icon-button/style.css +32 -0
- package/dist/blocks/input/block.json +47 -0
- package/dist/blocks/input/edit.js +78 -0
- package/dist/blocks/input/index.js +10 -0
- package/dist/blocks/input/save.js +27 -0
- package/dist/blocks/input/style-editor.css +8 -0
- package/dist/blocks/input/style.css +30 -0
- package/dist/blocks/link/block.json +71 -0
- package/dist/blocks/link/edit.js +151 -0
- package/dist/blocks/link/index.js +10 -0
- package/dist/blocks/link/save.js +46 -0
- package/dist/blocks/link/style-editor.css +5 -0
- package/dist/blocks/link/style.css +66 -0
- package/dist/blocks/text/block.json +32 -0
- package/dist/blocks/text/edit.js +56 -0
- package/dist/blocks/text/index.js +10 -0
- package/dist/blocks/text/save.js +18 -0
- package/dist/blocks/text/style-editor.css +4 -0
- package/dist/blocks/text/style.css +20 -0
- package/dist/blocks/toast/block.json +39 -0
- package/dist/blocks/toast/edit.js +85 -0
- package/dist/blocks/toast/index.js +10 -0
- package/dist/blocks/toast/save.js +29 -0
- package/dist/blocks/toast/style-editor.css +4 -0
- package/dist/blocks/toast/style.css +51 -0
- package/dist/index.cjs +2232 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +2196 -255
- package/dist/index.js.map +1 -1
- package/dist/plugin.php +79 -0
- package/dist/utils/classBuilder.js +53 -0
- package/package.json +39 -7
- package/plugin.php +79 -0
- package/rollup.config.js +39 -22
- package/scripts/build-plugin.cjs +121 -0
- package/scripts/create-block.sh +141 -0
- package/src/blocks/ad-container/block.json +28 -0
- package/src/blocks/ad-container/edit.js +42 -0
- package/src/blocks/ad-container/index.js +10 -0
- package/src/blocks/ad-container/save.js +16 -0
- package/src/blocks/ad-container/style-editor.css +4 -0
- package/src/blocks/ad-container/style.css +27 -0
- package/src/blocks/button/block.json +89 -0
- package/src/blocks/button/edit.js +187 -0
- package/src/blocks/button/index.js +11 -0
- package/src/blocks/button/save.js +52 -0
- package/src/blocks/button/style-editor.css +15 -0
- package/src/blocks/button/style.css +37 -0
- package/src/blocks/chip/block.json +57 -0
- package/src/blocks/chip/edit.js +113 -0
- package/src/blocks/chip/index.js +10 -0
- package/src/blocks/chip/save.js +36 -0
- package/src/blocks/chip/style-editor.css +5 -0
- package/src/blocks/chip/style.css +48 -0
- package/src/blocks/divider/block.json +31 -0
- package/src/blocks/divider/edit.js +42 -0
- package/src/blocks/divider/index.js +10 -0
- package/src/blocks/divider/save.js +18 -0
- package/src/blocks/divider/style-editor.css +4 -0
- package/src/blocks/divider/style.css +25 -0
- package/src/blocks/flag/block.json +48 -0
- package/src/blocks/flag/edit.js +82 -0
- package/src/blocks/flag/index.js +10 -0
- package/src/blocks/flag/save.js +25 -0
- package/src/blocks/flag/style-editor.css +5 -0
- package/src/blocks/flag/style.css +45 -0
- package/src/blocks/icon-button/block.json +43 -0
- package/src/blocks/icon-button/edit.js +82 -0
- package/src/blocks/icon-button/index.js +10 -0
- package/src/blocks/icon-button/save.js +29 -0
- package/src/blocks/icon-button/style-editor.css +5 -0
- package/src/blocks/icon-button/style.css +32 -0
- package/src/blocks/input/block.json +47 -0
- package/src/blocks/input/edit.js +78 -0
- package/src/blocks/input/index.js +10 -0
- package/src/blocks/input/save.js +27 -0
- package/src/blocks/input/style-editor.css +8 -0
- package/src/blocks/input/style.css +30 -0
- package/src/blocks/link/block.json +71 -0
- package/src/blocks/link/edit.js +151 -0
- package/src/blocks/link/index.js +10 -0
- package/src/blocks/link/save.js +46 -0
- package/src/blocks/link/style-editor.css +5 -0
- package/src/blocks/link/style.css +66 -0
- package/src/blocks/text/block.json +32 -0
- package/src/blocks/text/edit.js +56 -0
- package/src/blocks/text/index.js +10 -0
- package/src/blocks/text/save.js +18 -0
- package/src/blocks/text/style-editor.css +4 -0
- package/src/blocks/text/style.css +20 -0
- package/src/blocks/toast/block.json +39 -0
- package/src/blocks/toast/edit.js +85 -0
- package/src/blocks/toast/index.js +10 -0
- package/src/blocks/toast/save.js +29 -0
- package/src/blocks/toast/style-editor.css +4 -0
- package/src/blocks/toast/style.css +51 -0
- package/src/index.js +15 -12
- package/src/utils/classBuilder.js +53 -0
- package/tsconfig.json +4 -4
- package/__tests__/wordpress.test.js +0 -0
- package/dist/AdContainer/AdContainer.d.ts +0 -9
- package/dist/Article/ArticleMetaContainer/ArticleMetaContainer.d.ts +0 -8
- package/dist/Article/UpNextArticles/UpNextArticles.d.ts +0 -13
- package/dist/Button/Button.d.ts +0 -15
- package/dist/CommentsDisabled/CommentsDisabled.d.ts +0 -10
- package/dist/CommentsDisabled/CommentsDisabled.stories.d.ts +0 -44
- package/dist/CommentsDisabled/index.d.ts +0 -2
- package/dist/Divider/Divider.d.ts +0 -15
- package/dist/Input/Input.d.ts +0 -25
- package/dist/Link/Link.d.ts +0 -18
- package/dist/Text/Text.d.ts +0 -14
- package/dist/index.cjs.js +0 -299
- package/dist/index.cjs.js.map +0 -1
- package/dist/styles.css +0 -151
- package/dist/typographyStyles.css +0 -30
- package/dist/utils/cn.d.ts +0 -1
- package/dist/utils/hooks.d.ts +0 -8
- package/src/AdContainer/AdContainer.tsx +0 -31
- package/src/AdContainer/styles.css +0 -58
- package/src/Article/ArticleMetaContainer/ArticleMetaContainer.tsx +0 -14
- package/src/Article/ArticleMetaContainer/styles.css +0 -151
- package/src/Article/UpNextArticles/UpNextArticles.tsx +0 -69
- package/src/Article/UpNextArticles/styles.css +0 -151
- package/src/Button/Button.tsx +0 -36
- package/src/Button/styles.css +0 -30
- package/src/CommentsDisabled/CommentsDisabled.stories.tsx +0 -178
- package/src/CommentsDisabled/CommentsDisabled.tsx +0 -63
- package/src/CommentsDisabled/IMPLEMENTATION_SUMMARY.md +0 -305
- package/src/CommentsDisabled/README.md +0 -284
- package/src/CommentsDisabled/TOKEN_MAPPING.md +0 -269
- package/src/CommentsDisabled/index.ts +0 -2
- package/src/CommentsDisabled/styles.css +0 -82
- package/src/Divider/Divider.tsx +0 -41
- package/src/Divider/styles.css +0 -80
- package/src/Input/Input.tsx +0 -62
- package/src/Input/styles.css +0 -69
- package/src/Link/Link.tsx +0 -49
- package/src/Link/styles.css +0 -111
- package/src/Text/Text.tsx +0 -38
- package/src/Text/styles.css +0 -30
- package/src/Text/typographyStyles.css +0 -30
- package/src/utils/cn.js +0 -3
- package/src/utils/cn.tsx +0 -3
- package/src/utils/hooks.ts +0 -34
package/README.md
CHANGED
|
@@ -1,11 +1,978 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Times Design System - WordPress Components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
WordPress Gutenberg blocks built from Times Design System components. Provides Full Site Editing (FSE) compatible blocks for React-based design tokens and SCSS styling.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package transforms `@times-design-system/components-react` components into WordPress Gutenberg blocks:
|
|
8
|
+
|
|
9
|
+
- **Framework**: React-based Gutenberg blocks (`@wordpress/blocks`, `@wordpress/block-editor`)
|
|
10
|
+
- **Compatibility**: WordPress 6.0+ with Full Site Editing
|
|
11
|
+
- **Styling**: SCSS from `@times-design-system/theme-scss` with CSS design tokens
|
|
12
|
+
- **Distribution**: NPM package + WordPress plugin
|
|
13
|
+
- **Status**: Component transformation in progress
|
|
14
|
+
|
|
15
|
+
## Available Blocks
|
|
16
|
+
|
|
17
|
+
- ✅ **Button** — Interactive button component with intent/size/state variants
|
|
18
|
+
- ⏳ **Text** — Typography component
|
|
19
|
+
- ⏳ **Divider** — Visual separator
|
|
20
|
+
- ⏳ **Input** — Form input component
|
|
21
|
+
- ⏳ **Link** — Link component
|
|
22
|
+
- ⏳ **IconButton** — Icon-based button
|
|
23
|
+
- ⏳ **Chip** — Badge/chip component
|
|
24
|
+
- ⏳ **Flag** — Status flag component
|
|
25
|
+
- ⏳ **Toast** — Notification component
|
|
26
|
+
- ⏳ **AdContainer** — Advertisement container
|
|
27
|
+
|
|
28
|
+
## Installation & Integration
|
|
29
|
+
|
|
30
|
+
### Option 1: WordPress Plugin (Recommended for Most Users)
|
|
31
|
+
|
|
32
|
+
#### Installation
|
|
33
|
+
|
|
34
|
+
1. **Build the plugin**:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd packages/components-wordpress
|
|
38
|
+
npm install
|
|
39
|
+
npm run build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
2. **Deploy to WordPress**:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Copy the dist folder to WordPress plugins directory
|
|
46
|
+
cp -r dist/ /path/to/wordpress/wp-content/plugins/times-design-system-blocks/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. **Activate in WordPress**:
|
|
50
|
+
- Go to WordPress Admin → Plugins
|
|
51
|
+
- Find "Times Design System Blocks"
|
|
52
|
+
- Click "Activate"
|
|
53
|
+
|
|
54
|
+
4. **Verify Installation**:
|
|
55
|
+
- Go to any post/page editor
|
|
56
|
+
- Click the "+" button to insert a block
|
|
57
|
+
- Look for "Times Design System" category
|
|
58
|
+
- Available blocks should appear (Button, etc.)
|
|
59
|
+
|
|
60
|
+
#### Plugin Requirements
|
|
61
|
+
|
|
62
|
+
- **WordPress**: 6.0 or higher (Full Site Editing support)
|
|
63
|
+
- **PHP**: 7.4 or higher
|
|
64
|
+
- **Theme**: Should support Gutenberg/FSE (or use a block-based theme)
|
|
65
|
+
|
|
66
|
+
### Option 2: NPM Package (For Headless/Custom WordPress)
|
|
67
|
+
|
|
68
|
+
#### Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm install @times-design-system/components-wordpress
|
|
72
|
+
npm install @times-design-system/theme-scss
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Setup in Your Build Pipeline
|
|
76
|
+
|
|
77
|
+
**1. Register blocks in your entry point**:
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
// In your theme or plugin's JavaScript file
|
|
81
|
+
import '@times-design-system/components-wordpress';
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**2. Enqueue styles in your WordPress plugin/theme**:
|
|
85
|
+
|
|
86
|
+
```php
|
|
87
|
+
<?php
|
|
88
|
+
// functions.php or plugin file
|
|
89
|
+
|
|
90
|
+
function enqueue_tds_blocks() {
|
|
91
|
+
// Enqueue design system styles
|
|
92
|
+
wp_enqueue_style(
|
|
93
|
+
'times-design-system-blocks',
|
|
94
|
+
plugin_dir_url( __FILE__ ) . 'dist/blocks/button/style.css',
|
|
95
|
+
[],
|
|
96
|
+
'1.1.0'
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// Enqueue design tokens CSS
|
|
100
|
+
wp_enqueue_style(
|
|
101
|
+
'times-design-system-tokens',
|
|
102
|
+
plugin_dir_url( __FILE__ ) . 'path-to-token-vars/variables.css',
|
|
103
|
+
[],
|
|
104
|
+
'1.1.0'
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
add_action( 'wp_enqueue_scripts', 'enqueue_tds_blocks' );
|
|
109
|
+
add_action( 'admin_enqueue_scripts', 'enqueue_tds_blocks' );
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**3. Build and bundle**:
|
|
113
|
+
Use Rollup, Webpack, or your build tool to bundle:
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
// Your build config
|
|
117
|
+
import blocksPlugin from '@times-design-system/components-wordpress';
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Option 3: Docker/Development Environment
|
|
121
|
+
|
|
122
|
+
```dockerfile
|
|
123
|
+
# Dockerfile example
|
|
124
|
+
FROM wordpress:6.0-php7.4
|
|
125
|
+
|
|
126
|
+
# Copy plugin
|
|
127
|
+
COPY packages/components-wordpress/dist /var/www/html/wp-content/plugins/times-design-system-blocks
|
|
128
|
+
|
|
129
|
+
# Install and activate
|
|
130
|
+
RUN wp plugin activate times-design-system-blocks --allow-root
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Using the Blocks in WordPress
|
|
134
|
+
|
|
135
|
+
### Adding a Button Block
|
|
136
|
+
|
|
137
|
+
1. **In Post/Page Editor**:
|
|
138
|
+
- Click "+" to add a block
|
|
139
|
+
- Search for "Button" or browse "Times Design System" category
|
|
140
|
+
- Click "Button"
|
|
141
|
+
|
|
142
|
+
2. **Configure the Button**:
|
|
143
|
+
- In the block editor, you'll see a preview
|
|
144
|
+
- On the right sidebar (Inspector), configure:
|
|
145
|
+
- **Label**: The button text
|
|
146
|
+
- **Intent**: Visual style (Primary, Secondary, Negative)
|
|
147
|
+
- **Size**: Small, Medium, or Large
|
|
148
|
+
- **Behaviour**: Hug Content or Full Width
|
|
149
|
+
- **State**: Base, Hover, Pressed, Loading, Disabled, Focus
|
|
150
|
+
- **Disabled**: Toggle to disable the button
|
|
151
|
+
|
|
152
|
+
3. **Link Configuration** (if applicable):
|
|
153
|
+
- Expand "Link Settings" panel
|
|
154
|
+
- Enter URL, target, and rel attributes
|
|
155
|
+
|
|
156
|
+
4. **Advanced Options**:
|
|
157
|
+
- Button Type: button, submit, or reset
|
|
158
|
+
- Aria Label: For accessibility
|
|
159
|
+
- Icons: Left and right icon names
|
|
160
|
+
|
|
161
|
+
### Block Inspector Controls
|
|
162
|
+
|
|
163
|
+
Each block provides:
|
|
164
|
+
|
|
165
|
+
- **Main Settings Panel**: Core component properties
|
|
166
|
+
- **Link Settings Panel** (if applicable): URL configuration
|
|
167
|
+
- **Advanced Panel**: Technical and accessibility options
|
|
168
|
+
- **WordPress Native Options**: Spacing, alignment, custom CSS class
|
|
169
|
+
|
|
170
|
+
### Theme Compatibility
|
|
171
|
+
|
|
172
|
+
### Recommended Themes
|
|
173
|
+
|
|
174
|
+
Works best with block-based themes or modern theme frameworks:
|
|
175
|
+
|
|
176
|
+
- **WordPress.com Themes** — Full compatibility
|
|
177
|
+
- **Generate Blocks** — Full compatibility
|
|
178
|
+
- **Neve** — Full compatibility
|
|
179
|
+
- **Astra** — Full compatibility
|
|
180
|
+
- **TwentyTwentyThree+** — Full compatibility
|
|
181
|
+
|
|
182
|
+
### Classic Themes
|
|
183
|
+
|
|
184
|
+
Works with classic themes, but requires:
|
|
185
|
+
|
|
186
|
+
1. Gutenberg plugin installed and active
|
|
187
|
+
2. Theme uses `wp_body_open()` hook
|
|
188
|
+
3. Manual block registration in theme's `functions.php`
|
|
189
|
+
|
|
190
|
+
### Full Site Editing (FSE)
|
|
191
|
+
|
|
192
|
+
For full FSE support:
|
|
193
|
+
|
|
194
|
+
1. Use a block theme (or enable FSE via plugin)
|
|
195
|
+
2. Go to WordPress Admin → Appearance → Editor
|
|
196
|
+
3. Edit site-wide templates
|
|
197
|
+
4. Use Times Design System blocks in templates
|
|
198
|
+
|
|
199
|
+
## Block Features & Capabilities
|
|
200
|
+
|
|
201
|
+
### Shared Features (All Blocks)
|
|
202
|
+
|
|
203
|
+
- ✅ Responsive design
|
|
204
|
+
- ✅ Custom CSS classes
|
|
205
|
+
- ✅ Spacing controls (margin)
|
|
206
|
+
- ✅ Alignment options
|
|
207
|
+
- ✅ Accessibility attributes
|
|
208
|
+
- ✅ Dark mode support (via CSS variables)
|
|
209
|
+
- ✅ Design token integration
|
|
210
|
+
|
|
211
|
+
### Button Block Features
|
|
212
|
+
|
|
213
|
+
- **Variants**: Intent (primary/secondary/negative), Size (small/medium/large), Behaviour (hug/full)
|
|
214
|
+
- **States**: Base, hover, pressed, loading, disabled, focus
|
|
215
|
+
- **Links**: Full URL support with target and rel attributes
|
|
216
|
+
- **Icons**: Optional left/right icons
|
|
217
|
+
- **Accessibility**: Aria labels for icon-only buttons
|
|
218
|
+
|
|
219
|
+
### Planned Features (Coming Soon)
|
|
220
|
+
|
|
221
|
+
- Text block with typography variants
|
|
222
|
+
- Divider with customizable styling
|
|
223
|
+
- Input form fields
|
|
224
|
+
- Link component
|
|
225
|
+
- Icon buttons
|
|
226
|
+
- Chip/badge components
|
|
227
|
+
- Flag status indicators
|
|
228
|
+
- Toast notifications
|
|
229
|
+
- Ad containers
|
|
230
|
+
- Comment sections
|
|
231
|
+
- Related articles carousel
|
|
232
|
+
|
|
233
|
+
## Performance & Best Practices
|
|
234
|
+
|
|
235
|
+
### Load Time
|
|
236
|
+
|
|
237
|
+
- **Optimized**: CSS and JavaScript are code-split per block
|
|
238
|
+
- **Only loaded blocks** are included in page output
|
|
239
|
+
- **Minimal overhead**: ~2KB per block (minified)
|
|
240
|
+
|
|
241
|
+
### SEO
|
|
242
|
+
|
|
243
|
+
Blocks render semantic HTML:
|
|
244
|
+
|
|
245
|
+
- Buttons render as `<button>` or `<a>` tags
|
|
246
|
+
- Text uses appropriate heading levels (`<h1>`-`<h5>`)
|
|
247
|
+
- Proper ARIA labels for accessibility
|
|
248
|
+
- Schema markup ready (future enhancement)
|
|
249
|
+
|
|
250
|
+
### Best Practices
|
|
251
|
+
|
|
252
|
+
1. **Use Block Patterns**:
|
|
253
|
+
- Create reusable block layouts
|
|
254
|
+
- Admin → Patterns → Create block pattern
|
|
255
|
+
- Save as draft or publish
|
|
256
|
+
|
|
257
|
+
2. **Leverage Block Reusable Blocks**:
|
|
258
|
+
- Convert block groups to reusable blocks
|
|
259
|
+
- Edit once, update everywhere
|
|
260
|
+
- Right-click block → "Create reusable block"
|
|
261
|
+
|
|
262
|
+
3. **CSS Organization**:
|
|
263
|
+
- Use theme's CSS for customization
|
|
264
|
+
- Avoid inline styles
|
|
265
|
+
- Leverage design token variables
|
|
266
|
+
|
|
267
|
+
4. **Accessibility**:
|
|
268
|
+
- Always add aria-labels to icon-only buttons
|
|
269
|
+
- Use proper heading hierarchies
|
|
270
|
+
- Test with screen readers
|
|
271
|
+
|
|
272
|
+
## Troubleshooting Integration
|
|
273
|
+
|
|
274
|
+
### Blocks not appearing in editor?
|
|
275
|
+
|
|
276
|
+
**Check these steps in order**:
|
|
277
|
+
|
|
278
|
+
1. **Plugin activation**:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# In WordPress admin
|
|
282
|
+
Plugins → Times Design System Blocks → Check if "Active"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
2. **WordPress version**:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Requires 6.0+
|
|
289
|
+
# Check: WordPress Admin → Dashboard → At a Glance
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
3. **PHP version**:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Requires 7.4+
|
|
296
|
+
# Check: Tools → Site Health → PHP version
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
4. **Gutenberg support**:
|
|
300
|
+
- Theme must support Gutenberg
|
|
301
|
+
- Try with a block theme (TwentyTwentyThree)
|
|
302
|
+
- Or install Gutenberg plugin from WordPress.org
|
|
303
|
+
|
|
304
|
+
5. **Cache clearing**:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Clear all caches
|
|
308
|
+
# If using caching plugin: clear all caches
|
|
309
|
+
# Browser: Hard refresh (Cmd+Shift+R or Ctrl+Shift+F5)
|
|
310
|
+
# WordPress: Deactivate caching plugins temporarily
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
6. **JavaScript errors**:
|
|
314
|
+
- Open browser DevTools (F12)
|
|
315
|
+
- Check Console for errors
|
|
316
|
+
- Look for scripts blocked by security plugins
|
|
317
|
+
|
|
318
|
+
### Styles not appearing correctly?
|
|
319
|
+
|
|
320
|
+
**Diagnostic steps**:
|
|
321
|
+
|
|
322
|
+
1. **Check CSS files are loaded**:
|
|
323
|
+
- View page source
|
|
324
|
+
- Search for "times-design-system" in CSS imports
|
|
325
|
+
- Check Network tab in DevTools
|
|
326
|
+
|
|
327
|
+
2. **Verify design tokens loaded**:
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
# CSS variables should be defined
|
|
331
|
+
# In browser console, paste:
|
|
332
|
+
getComputedStyle(document.documentElement)
|
|
333
|
+
.getPropertyValue('--color-text-primary')
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
3. **Check for conflicting CSS**:
|
|
337
|
+
- Look for `!important` rules overriding styles
|
|
338
|
+
- Use DevTools Inspector to identify conflicting styles
|
|
339
|
+
|
|
340
|
+
4. **Theme compatibility**:
|
|
341
|
+
- Try with a neutral block theme
|
|
342
|
+
- Check theme doesn't have aggressive CSS resets
|
|
343
|
+
|
|
344
|
+
### Block saves but doesn't render?
|
|
345
|
+
|
|
346
|
+
1. **Check block.json is valid**:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
npm run test:json
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
2. **Verify save component structure**:
|
|
353
|
+
- Must return valid HTML
|
|
354
|
+
- Must match edit component
|
|
355
|
+
|
|
356
|
+
3. **Check for JavaScript errors**:
|
|
357
|
+
- Browser console (F12)
|
|
358
|
+
- WordPress debug log: `/wp-content/debug.log`
|
|
359
|
+
|
|
360
|
+
4. **Enable WordPress debugging**:
|
|
361
|
+
```php
|
|
362
|
+
// wp-config.php
|
|
363
|
+
define( 'WP_DEBUG', true );
|
|
364
|
+
define( 'WP_DEBUG_LOG', true );
|
|
365
|
+
define( 'WP_DEBUG_DISPLAY', false );
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Performance issues?
|
|
369
|
+
|
|
370
|
+
1. **Minimize number of blocks**:
|
|
371
|
+
- Only load blocks you use
|
|
372
|
+
- Edit plugin.php to comment out unused blocks
|
|
373
|
+
|
|
374
|
+
2. **Enable caching**:
|
|
375
|
+
- WP Super Cache
|
|
376
|
+
- W3 Total Cache
|
|
377
|
+
- Jetpack Boost
|
|
378
|
+
|
|
379
|
+
3. **Lazy load blocks**:
|
|
380
|
+
- Defer non-critical block JavaScript
|
|
381
|
+
- Use browser native lazy loading
|
|
382
|
+
|
|
383
|
+
## Deployment
|
|
384
|
+
|
|
385
|
+
### WordPress.com
|
|
386
|
+
|
|
387
|
+
1. Theme → Customize → Blocks (if enabled)
|
|
388
|
+
2. Use blocks directly in editor
|
|
389
|
+
3. No plugin installation needed for Free/Business tiers
|
|
390
|
+
|
|
391
|
+
### Self-Hosted WordPress
|
|
392
|
+
|
|
393
|
+
**Manual**:
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
# Build
|
|
397
|
+
npm run build
|
|
398
|
+
|
|
399
|
+
# Deploy
|
|
400
|
+
scp -r dist/* user@server:/path/to/wp-content/plugins/tds-blocks/
|
|
401
|
+
|
|
402
|
+
# Activate via SSH
|
|
403
|
+
wp plugin activate times-design-system-blocks --allow-root
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Automated (GitHub Actions)**:
|
|
407
|
+
|
|
408
|
+
```yaml
|
|
409
|
+
name: Deploy Blocks to WordPress
|
|
410
|
+
|
|
411
|
+
on:
|
|
412
|
+
push:
|
|
413
|
+
branches: [main]
|
|
414
|
+
|
|
415
|
+
jobs:
|
|
416
|
+
deploy:
|
|
417
|
+
runs-on: ubuntu-latest
|
|
418
|
+
steps:
|
|
419
|
+
- uses: actions/checkout@v2
|
|
420
|
+
- uses: actions/setup-node@v2
|
|
421
|
+
- run: cd packages/components-wordpress && npm install && npm run build
|
|
422
|
+
- uses: appleboy/scp-action@master
|
|
423
|
+
with:
|
|
424
|
+
host: ${{ secrets.HOST }}
|
|
425
|
+
username: ${{ secrets.USERNAME }}
|
|
426
|
+
key: ${{ secrets.SSH_KEY }}
|
|
427
|
+
source: 'packages/components-wordpress/dist/*'
|
|
428
|
+
target: '/path/to/wp-content/plugins/tds-blocks'
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### Docker
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
# Build Docker image with blocks
|
|
435
|
+
docker build -t wordpress-with-tds-blocks .
|
|
436
|
+
|
|
437
|
+
# Run
|
|
438
|
+
docker run -d -p 8000:80 wordpress-with-tds-blocks
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## Updating Blocks
|
|
442
|
+
|
|
443
|
+
### Check for Updates
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
# Check npm registry
|
|
447
|
+
npm outdated @times-design-system/components-wordpress
|
|
448
|
+
|
|
449
|
+
# Or update package.json version
|
|
450
|
+
npm update @times-design-system/components-wordpress
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Update Plugin
|
|
454
|
+
|
|
455
|
+
1. **Backup existing**:
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
cp -r wp-content/plugins/times-design-system-blocks wp-content/plugins/times-design-system-blocks-backup
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
2. **Download latest**:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
npm run build
|
|
465
|
+
cp -r dist/* wp-content/plugins/times-design-system-blocks/
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
3. **Deactivate and reactivate**:
|
|
469
|
+
- WordPress Admin → Plugins → Deactivate
|
|
470
|
+
- Then → Activate
|
|
471
|
+
|
|
472
|
+
4. **Clear caches**:
|
|
473
|
+
- If using caching plugin, clear all caches
|
|
474
|
+
- Browser hard refresh
|
|
475
|
+
|
|
476
|
+
### Version History
|
|
477
|
+
|
|
478
|
+
Check [CHANGELOG.md](./CHANGELOG.md) for:
|
|
479
|
+
|
|
480
|
+
- New blocks added
|
|
481
|
+
- Features changed
|
|
482
|
+
- Bug fixes
|
|
483
|
+
- Breaking changes
|
|
484
|
+
|
|
485
|
+
## Common Integration Scenarios
|
|
486
|
+
|
|
487
|
+
### Scenario 1: News Website with Hero Button
|
|
488
|
+
|
|
489
|
+
**Setup**:
|
|
490
|
+
|
|
491
|
+
1. Create page template with cover block
|
|
492
|
+
2. Add image background
|
|
493
|
+
3. Add Times Button block on top
|
|
494
|
+
4. Style with primary intent, large size
|
|
495
|
+
|
|
496
|
+
**Block Settings**:
|
|
497
|
+
|
|
498
|
+
```
|
|
499
|
+
Label: "Read the Story"
|
|
500
|
+
Intent: Primary
|
|
501
|
+
Size: Large
|
|
502
|
+
Behaviour: Full Width
|
|
503
|
+
Href: (link to article)
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Scenario 2: Multi-Purpose Landing Page
|
|
507
|
+
|
|
508
|
+
**Setup**:
|
|
509
|
+
|
|
510
|
+
1. Create hero section with multiple buttons
|
|
511
|
+
2. Use different intents and sizes for hierarchy
|
|
512
|
+
3. Add spacing between buttons
|
|
513
|
+
|
|
514
|
+
**Button Hierarchy**:
|
|
515
|
+
|
|
516
|
+
- **Primary CTA**: Intent = Primary, Size = Large
|
|
517
|
+
- **Secondary CTA**: Intent = Secondary, Size = Large
|
|
518
|
+
- **Tertiary**: Intent = Secondary, Size = Medium
|
|
519
|
+
|
|
520
|
+
### Scenario 3: Form with Submit Button
|
|
521
|
+
|
|
522
|
+
**Setup**:
|
|
523
|
+
|
|
524
|
+
1. Use form block (WordPress native)
|
|
525
|
+
2. Add Times Button at bottom
|
|
526
|
+
3. Set Button Type = Submit
|
|
527
|
+
4. Set Intent = Primary
|
|
528
|
+
|
|
529
|
+
**Configuration**:
|
|
530
|
+
|
|
531
|
+
```
|
|
532
|
+
Label: "Submit Form"
|
|
533
|
+
Type: Submit
|
|
534
|
+
Intent: Primary
|
|
535
|
+
Size: Large
|
|
536
|
+
Disabled: false
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### Scenario 4: Navigation/Menu Buttons
|
|
540
|
+
|
|
541
|
+
**Setup**:
|
|
542
|
+
|
|
543
|
+
1. Create button group using block columns
|
|
544
|
+
2. Add Times Buttons in each column
|
|
545
|
+
3. Link each button to different pages
|
|
546
|
+
4. Use Secondary intent for consistency
|
|
547
|
+
|
|
548
|
+
**Per Button**:
|
|
549
|
+
|
|
550
|
+
```
|
|
551
|
+
Label: "Page Name"
|
|
552
|
+
Intent: Secondary
|
|
553
|
+
Href: "/page-url"
|
|
554
|
+
Target: _self
|
|
555
|
+
Behaviour: Hug
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
## WordPress Ecosystem Integration
|
|
559
|
+
|
|
560
|
+
### WooCommerce Integration
|
|
561
|
+
|
|
562
|
+
Add "Shop Now" button linking to products:
|
|
563
|
+
|
|
564
|
+
1. Create button with Link Settings
|
|
565
|
+
2. Point href to `/shop/` or specific product
|
|
566
|
+
3. Use Primary intent to draw attention
|
|
567
|
+
4. Example: `href="/product/sample-product/"`
|
|
568
|
+
|
|
569
|
+
### Contact Forms (Gravity Forms, WPForms)
|
|
570
|
+
|
|
571
|
+
Add custom form submit button:
|
|
572
|
+
|
|
573
|
+
1. Form plugin settings → customize button
|
|
574
|
+
2. Or add Times Button with custom CSS class
|
|
575
|
+
3. Wire up with JavaScript if needed
|
|
576
|
+
|
|
577
|
+
**Custom JavaScript Integration**:
|
|
578
|
+
|
|
579
|
+
```javascript
|
|
580
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
581
|
+
const submitBtn = document.querySelector('.times-form-submit');
|
|
582
|
+
submitBtn.addEventListener('click', () => {
|
|
583
|
+
document.querySelector('form').submit();
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
### Beaver Builder
|
|
589
|
+
|
|
590
|
+
Not directly compatible (uses own block system). Workaround:
|
|
591
|
+
|
|
592
|
+
- Use Beaver's native button blocks
|
|
593
|
+
- Or convert Times blocks to static HTML snippets
|
|
594
|
+
|
|
595
|
+
### Elementor
|
|
596
|
+
|
|
597
|
+
Not compatible with Gutenberg blocks. Options:
|
|
598
|
+
|
|
599
|
+
- Switch to Gutenberg editor
|
|
600
|
+
- Use Elementor's native button widgets
|
|
601
|
+
- Or use hybrid approach with separate Gutenberg pages
|
|
602
|
+
|
|
603
|
+
### Multisite
|
|
604
|
+
|
|
605
|
+
**Installation on Multisite**:
|
|
606
|
+
|
|
607
|
+
1. **Network Activate** (all sites):
|
|
608
|
+
- WordPress Network Admin → Plugins
|
|
609
|
+
- Activate "Times Design System Blocks"
|
|
610
|
+
|
|
611
|
+
2. **Or per-site** (specific sites only):
|
|
612
|
+
- Each site → Plugins → Activate independently
|
|
613
|
+
- Blocks only available on activated sites
|
|
614
|
+
|
|
615
|
+
**Configuration**:
|
|
616
|
+
|
|
617
|
+
```php
|
|
618
|
+
// In wp-config.php for network settings
|
|
619
|
+
define( 'tds_blocks_MULTISITE_MODE', 'network' );
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
## Advanced WordPress Integration
|
|
623
|
+
|
|
624
|
+
### Custom Block Extensions
|
|
625
|
+
|
|
626
|
+
Extend blocks with custom functionality:
|
|
627
|
+
|
|
628
|
+
```javascript
|
|
629
|
+
// In your theme/plugin
|
|
630
|
+
import { addFilter } from '@wordpress/hooks';
|
|
631
|
+
|
|
632
|
+
addFilter(
|
|
633
|
+
'blocks.registerBlockType',
|
|
634
|
+
'my-plugin/modify-button',
|
|
635
|
+
(settings, name) => {
|
|
636
|
+
if (name === 'times/button') {
|
|
637
|
+
// Add custom attribute
|
|
638
|
+
settings.attributes.myCustomAttr = {
|
|
639
|
+
type: 'string',
|
|
640
|
+
default: ''
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
return settings;
|
|
644
|
+
}
|
|
645
|
+
);
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### Registering Custom Block Styles
|
|
649
|
+
|
|
650
|
+
```php
|
|
651
|
+
<?php
|
|
652
|
+
// In your theme functions.php
|
|
653
|
+
|
|
654
|
+
function register_times_block_styles() {
|
|
655
|
+
register_block_style(
|
|
656
|
+
'times/button',
|
|
657
|
+
[
|
|
658
|
+
'name' => 'gradient',
|
|
659
|
+
'label' => 'Gradient Style',
|
|
660
|
+
]
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
add_action( 'init', 'register_times_block_styles' );
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
Then use in CSS:
|
|
667
|
+
|
|
668
|
+
```css
|
|
669
|
+
.wp-block-times-button.is-style-gradient {
|
|
670
|
+
background: linear-gradient(
|
|
671
|
+
135deg,
|
|
672
|
+
var(--color-primary) 0%,
|
|
673
|
+
var(--color-primary-dark) 100%
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
### Enqueuing Custom Block Assets
|
|
679
|
+
|
|
680
|
+
```php
|
|
681
|
+
<?php
|
|
682
|
+
function enqueue_tds_blocks_custom() {
|
|
683
|
+
// Backend only
|
|
684
|
+
wp_enqueue_script(
|
|
685
|
+
'tds-blocks-custom',
|
|
686
|
+
get_template_directory_uri() . '/js/tds-blocks.js',
|
|
687
|
+
[ 'wp-blocks', 'wp-element' ],
|
|
688
|
+
'1.0.0'
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
// Frontend and backend
|
|
692
|
+
wp_enqueue_style(
|
|
693
|
+
'tds-blocks-custom-style',
|
|
694
|
+
get_template_directory_uri() . '/css/tds-blocks.css',
|
|
695
|
+
[],
|
|
696
|
+
'1.0.0'
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
add_action( 'enqueue_block_assets', 'enqueue_tds_blocks_custom' );
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
### Block Patterns for Reusability
|
|
703
|
+
|
|
704
|
+
Create reusable block patterns:
|
|
705
|
+
|
|
706
|
+
```php
|
|
707
|
+
<?php
|
|
708
|
+
// In your plugin/theme
|
|
709
|
+
register_block_pattern(
|
|
710
|
+
'times/hero-with-button',
|
|
711
|
+
[
|
|
712
|
+
'title' => 'Hero Section with Button',
|
|
713
|
+
'description' => 'Large hero section with Times Design System button',
|
|
714
|
+
'content' => '
|
|
715
|
+
<!-- wp:cover {"url":"...","minHeight":400} -->
|
|
716
|
+
<!-- wp:times/button {"label":"Learn More","intent":"primary","size":"large"} /-->
|
|
717
|
+
<!-- /wp:cover -->
|
|
718
|
+
',
|
|
719
|
+
'categories' => [ 'hero' ],
|
|
720
|
+
]
|
|
721
|
+
);
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
## Security Best Practices
|
|
725
|
+
|
|
726
|
+
### Content Security Policy (CSP)
|
|
727
|
+
|
|
728
|
+
If using CSP headers, ensure:
|
|
729
|
+
|
|
730
|
+
```apache
|
|
731
|
+
# WordPress header needed for block editor
|
|
732
|
+
Permissions-Policy: geolocation=(), microphone=(), camera=()
|
|
733
|
+
Content-Security-Policy: script-src 'unsafe-inline' 'unsafe-eval' ...
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
### Sanitization in Custom Code
|
|
737
|
+
|
|
738
|
+
```php
|
|
739
|
+
<?php
|
|
740
|
+
// Always sanitize user input in custom block extensions
|
|
741
|
+
|
|
742
|
+
function sanitize_block_button_label( $value ) {
|
|
743
|
+
return sanitize_text_field( $value );
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function escape_button_output( $output ) {
|
|
747
|
+
return wp_kses_post( $output );
|
|
748
|
+
}
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
### Plugin Hardening
|
|
752
|
+
|
|
753
|
+
The package includes:
|
|
754
|
+
|
|
755
|
+
- ✅ Input validation
|
|
756
|
+
- ✅ Output escaping (XSS prevention)
|
|
757
|
+
- ✅ WordPress nonce verification
|
|
758
|
+
- ✅ Capability checks
|
|
759
|
+
- ✅ CSRF protection
|
|
760
|
+
|
|
761
|
+
## Development
|
|
762
|
+
|
|
763
|
+
```bash
|
|
764
|
+
# Use scaffold script to create new block structure
|
|
765
|
+
./scripts/create-block.sh <component-name>
|
|
766
|
+
|
|
767
|
+
# Example:
|
|
768
|
+
./scripts/create-block.sh text
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
Then follow the [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md) for implementation details.
|
|
772
|
+
|
|
773
|
+
### Build Commands
|
|
774
|
+
|
|
775
|
+
```bash
|
|
776
|
+
npm run build # Full build (Rollup + plugin generation)
|
|
777
|
+
npm run build:rollup # Rollup bundling only
|
|
778
|
+
npm run build:plugin # Plugin structure generation only
|
|
779
|
+
npm run dev # Watch mode for development
|
|
780
|
+
npm run clean # Remove dist/ directory
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
## Project Structure
|
|
784
|
+
|
|
785
|
+
```
|
|
786
|
+
src/
|
|
787
|
+
├── blocks/
|
|
788
|
+
│ ├── button/ # Button block (reference implementation)
|
|
789
|
+
│ │ ├── block.json # Gutenberg block manifest
|
|
790
|
+
│ │ ├── index.js # Block registration
|
|
791
|
+
│ │ ├── edit.js # Editor component
|
|
792
|
+
│ │ ├── save.js # Frontend output
|
|
793
|
+
│ │ ├── style.css # Frontend styles
|
|
794
|
+
│ │ └── style-editor.css # Editor styles
|
|
795
|
+
│ └── [other blocks]/
|
|
796
|
+
├── utils/
|
|
797
|
+
│ └── classBuilder.js # BEM class name utilities
|
|
798
|
+
└── index.js # Main entry point (imports all blocks)
|
|
799
|
+
|
|
800
|
+
scripts/
|
|
801
|
+
├── create-block.sh # Block scaffold generator
|
|
802
|
+
└── build-plugin.js # Plugin structure builder
|
|
803
|
+
|
|
804
|
+
dist/ # Built output
|
|
805
|
+
├── plugin.php # WordPress plugin entry point
|
|
806
|
+
├── block.json # Root block manifest
|
|
807
|
+
└── blocks/ # Compiled block files
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
## Adding a New Block
|
|
811
|
+
|
|
812
|
+
See [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md) for complete instructions. Quick overview:
|
|
813
|
+
|
|
814
|
+
### 1. Generate Scaffold
|
|
815
|
+
|
|
816
|
+
```bash
|
|
817
|
+
./scripts/create-block.sh <component-name>
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
### 2. Update block.json with attributes
|
|
821
|
+
|
|
822
|
+
### 3. Implement edit.js (editor component)
|
|
823
|
+
|
|
824
|
+
### 4. Implement save.js (frontend output)
|
|
825
|
+
|
|
826
|
+
### 5. Add styles (style.css, style-editor.css)
|
|
827
|
+
|
|
828
|
+
### 6. Register block in src/index.js
|
|
829
|
+
|
|
830
|
+
### 7. Test and verify
|
|
831
|
+
|
|
832
|
+
## Resources
|
|
833
|
+
|
|
834
|
+
- [Complete Transformation Guide](./TRANSFORMATION_GUIDE.md) — Detailed step-by-step process
|
|
835
|
+
- [Block Creation Checklist](./BLOCK_CREATION_CHECKLIST.md) — Quality assurance checklist
|
|
836
|
+
- [WordPress Blocks Documentation](https://developer.wordpress.org/block-editor/)
|
|
837
|
+
- [Gutenberg Block API](https://developer.wordpress.org/block-editor/reference-guides/block-api/)
|
|
838
|
+
- [Times Design System](../tokens/README.md)
|
|
839
|
+
- [WordPress Plugin Development](https://developer.wordpress.org/plugins/)
|
|
840
|
+
- [Block Themes](https://developer.wordpress.org/block-editor/how-to-guides/themes/)
|
|
841
|
+
|
|
842
|
+
## Quick Reference
|
|
843
|
+
|
|
844
|
+
### Installation Methods
|
|
845
|
+
|
|
846
|
+
| Method | Best For | Ease |
|
|
847
|
+
| ------------------ | -------------------------- | -------------- |
|
|
848
|
+
| **Plugin** | Most users, shared hosting | ⭐⭐⭐ Easy |
|
|
849
|
+
| **NPM Package** | Custom builds, headless | ⭐⭐ Medium |
|
|
850
|
+
| **Docker** | Development, containerized | ⭐⭐ Medium |
|
|
851
|
+
| **GitHub Actions** | CI/CD, automated deploy | ⭐⭐⭐ Complex |
|
|
852
|
+
|
|
853
|
+
### Block Inspector Controls
|
|
854
|
+
|
|
855
|
+
Every block provides these panels:
|
|
856
|
+
|
|
857
|
+
1. **Component Settings** — Core block properties
|
|
858
|
+
2. **Link Settings** — URL, target, rel (if applicable)
|
|
859
|
+
3. **Advanced** — Button type, aria labels, icons
|
|
860
|
+
4. **WordPress Native** — Spacing, alignment, custom CSS
|
|
861
|
+
|
|
862
|
+
### Design Token Variables
|
|
863
|
+
|
|
864
|
+
Available in all blocks:
|
|
865
|
+
|
|
866
|
+
```css
|
|
867
|
+
/* Colors */
|
|
868
|
+
--color-text-primary
|
|
869
|
+
--color-text-secondary
|
|
870
|
+
--color-bg-primary
|
|
871
|
+
--color-border-primary
|
|
872
|
+
|
|
873
|
+
/* Typography */
|
|
874
|
+
--typography-font-family-body
|
|
875
|
+
--typography-font-size-body-md
|
|
876
|
+
--typography-font-weight-regular
|
|
877
|
+
|
|
878
|
+
/* Spacing */
|
|
879
|
+
--spacing-xs (4px)
|
|
880
|
+
--spacing-sm (8px)
|
|
881
|
+
--spacing-md (16px)
|
|
882
|
+
--spacing-lg (32px)
|
|
883
|
+
--spacing-xl (64px)
|
|
884
|
+
|
|
885
|
+
/* Radius */
|
|
886
|
+
--spacing-radius-sm
|
|
887
|
+
--spacing-radius-md
|
|
888
|
+
--spacing-radius-lg
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
### WordPress Compatibility Matrix
|
|
892
|
+
|
|
893
|
+
| WordPress Version | PHP Min | Status | Notes |
|
|
894
|
+
| ----------------- | ------- | --------------- | ---------------- |
|
|
895
|
+
| 6.4+ | 7.4+ | ✅ Full Support | Recommended |
|
|
896
|
+
| 6.2-6.3 | 7.4+ | ✅ Supported | Works fine |
|
|
897
|
+
| 6.0-6.1 | 7.4+ | ⚠️ Limited | Use with caution |
|
|
898
|
+
| < 6.0 | - | ❌ Unsupported | Requires upgrade |
|
|
899
|
+
|
|
900
|
+
### Common Commands
|
|
901
|
+
|
|
902
|
+
```bash
|
|
903
|
+
# Development
|
|
904
|
+
npm run dev # Watch and rebuild
|
|
905
|
+
npm run build # Full production build
|
|
906
|
+
npm run build:rollup # Bundling only
|
|
907
|
+
npm run clean # Remove dist/
|
|
908
|
+
|
|
909
|
+
# Testing
|
|
910
|
+
npm run test # Run tests
|
|
911
|
+
npm run test:json # Validate JSON manifests
|
|
912
|
+
|
|
913
|
+
# Deployment
|
|
914
|
+
npm run build && npm run build:plugin # Build for plugin distrib
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
## Troubleshooting Quick Fix Guide
|
|
918
|
+
|
|
919
|
+
| Issue | Cause | Solution |
|
|
920
|
+
| -------------------- | ------------------------ | --------------------------------------------- |
|
|
921
|
+
| Blocks not appearing | Plugin not active | Activate in WP Admin → Plugins |
|
|
922
|
+
| Blocks not appearing | Old WP version | Update to 6.0+ |
|
|
923
|
+
| Styles broken | theme-scss not installed | `npm install @times-design-system/theme-scss` |
|
|
924
|
+
| JavaScript errors | Cache issues | Clear browser + WP caches |
|
|
925
|
+
| Block won't save | Attribute mismatch | Check block.json attribute names |
|
|
926
|
+
|
|
927
|
+
## Support & Community
|
|
928
|
+
|
|
929
|
+
### Get Help
|
|
930
|
+
|
|
931
|
+
1. **Check Documentation**:
|
|
932
|
+
- [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md) — Technical details
|
|
933
|
+
- [BLOCK_CREATION_CHECKLIST.md](./BLOCK_CREATION_CHECKLIST.md) — Verify setup
|
|
934
|
+
|
|
935
|
+
2. **Common Issues**:
|
|
936
|
+
- See "Troubleshooting Integration" section above
|
|
937
|
+
- Check plugin debug log: `/wp-content/debug.log`
|
|
938
|
+
|
|
939
|
+
3. **Report Issues**:
|
|
940
|
+
- GitHub: [times-design-system/issues](https://github.com/newsuk/times-design-system/issues)
|
|
941
|
+
- Include WordPress version, PHP version, error messages
|
|
942
|
+
|
|
943
|
+
### Contributing
|
|
944
|
+
|
|
945
|
+
To add new blocks or improve existing ones:
|
|
946
|
+
|
|
947
|
+
1. Review [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md)
|
|
948
|
+
2. Follow [BLOCK_CREATION_CHECKLIST.md](./BLOCK_CREATION_CHECKLIST.md)
|
|
949
|
+
3. Test thoroughly before submitting
|
|
950
|
+
4. Submit PR with detailed description
|
|
951
|
+
|
|
952
|
+
## License
|
|
953
|
+
|
|
954
|
+
ISC License — See LICENSE file for details
|
|
955
|
+
|
|
956
|
+
---
|
|
957
|
+
|
|
958
|
+
## Next Steps
|
|
959
|
+
|
|
960
|
+
1. **Install the plugin** following "Installation & Integration" section
|
|
961
|
+
2. **Create a test page** and add a Button block
|
|
962
|
+
3. **Configure block settings** using the Inspector
|
|
963
|
+
4. **Check styling** with your design tokens
|
|
964
|
+
5. **Deploy to production** when ready
|
|
965
|
+
|
|
966
|
+
---
|
|
967
|
+
|
|
968
|
+
**Current Status**: Button block ✅ | 11 blocks pending transformation
|
|
969
|
+
|
|
970
|
+
For block creation instructions, see [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md).
|
|
971
|
+
|
|
972
|
+
For integration support, see [Troubleshooting Integration](#troubleshooting-integration) and [Common Integration Scenarios](#common-integration-scenarios).
|
|
973
|
+
|
|
974
|
+
**Version**: 1.1.0 | **Last Updated**: May 2026
|
|
6
975
|
|
|
7
976
|
```
|
|
8
|
-
const wordpress = require('wordpress');
|
|
9
977
|
|
|
10
|
-
// TODO: DEMONSTRATE API
|
|
11
978
|
```
|