@times-design-system/components-wordpress 1.9.0 → 1.10.0
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/dist/blocks/ad-container/style.css +1 -30
- package/dist/blocks/ad-container/style.scss +70 -0
- package/dist/blocks/button/block.json +67 -1
- package/dist/blocks/button/init.js +45 -0
- package/dist/blocks/button/render.php +2 -0
- package/dist/blocks/button/style.css +1 -203
- package/dist/blocks/button/style.scss +204 -0
- package/dist/blocks/chip/ONCLICK_USAGE.md +263 -0
- package/dist/blocks/chip/block.json +22 -3
- package/dist/blocks/chip/init.js +60 -0
- package/dist/blocks/chip/render.php +7 -2
- package/dist/blocks/chip/style.css +1 -108
- package/dist/blocks/chip/style.scss +213 -0
- package/dist/blocks/dialog-box/style.css +1 -23
- package/dist/blocks/dialog-box/style.scss +113 -0
- package/dist/blocks/divider/style.css +1 -37
- package/dist/blocks/divider/style.scss +40 -0
- package/dist/blocks/icon/block.json +10 -1
- package/dist/blocks/icon/style.css +1 -23
- package/dist/blocks/icon/style.scss +10 -0
- package/dist/blocks/icon-button/block.json +41 -0
- package/dist/blocks/icon-button/init.js +56 -0
- package/dist/blocks/icon-button/render.php +5 -0
- package/dist/blocks/icon-button/style.css +1 -66
- package/dist/blocks/icon-button/style.scss +189 -0
- package/dist/blocks/input/style.css +1 -67
- package/dist/blocks/input/style.scss +72 -0
- package/dist/blocks/input-helper-message/style.css +1 -23
- package/dist/blocks/input-helper-message/style.scss +45 -0
- package/dist/blocks/link/block.json +86 -3
- package/dist/blocks/link/init.js +54 -0
- package/dist/blocks/link/render.php +22 -12
- package/dist/blocks/link/style.css +1 -221
- package/dist/blocks/link/style.scss +163 -0
- package/dist/blocks/tab/style.css +1 -152
- package/dist/blocks/tab/style.scss +159 -0
- package/dist/blocks/tab-group/style.css +1 -23
- package/dist/blocks/tab-group/style.scss +32 -0
- package/dist/blocks/{flag → tag}/block.json +46 -14
- package/dist/blocks/{flag → tag}/edit.js +9 -20
- package/dist/blocks/{flag → tag}/index.js +2 -2
- package/dist/blocks/{flag → tag}/render.php +24 -19
- package/dist/blocks/tag/save.js +23 -0
- package/dist/blocks/{chip → tag}/style-editor.css +2 -2
- package/dist/blocks/tag/style.css +1 -0
- package/dist/blocks/tag/style.scss +115 -0
- package/dist/blocks/text/style.css +1 -7
- package/dist/blocks/text/style.scss +11 -0
- package/dist/blocks/toast/style.css +1 -68
- package/dist/blocks/toast/style.scss +67 -0
- package/dist/blocks/utils/render-icon.php +72 -5
- package/dist/icon-data.json +1 -1
- package/dist/index.cjs +391 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +391 -54
- package/dist/index.js.map +1 -1
- package/dist/plugin.php +42 -0
- package/dist/utils/render-icon.php +11 -2
- package/package.json +6 -4
- package/plugin.php +42 -0
- package/dist/blocks/flag/save.js +0 -25
- package/dist/blocks/flag/style-editor.css +0 -5
- package/dist/blocks/flag/style.css +0 -72
package/dist/plugin.php
CHANGED
|
@@ -139,6 +139,48 @@ function tds_enqueue_assets() {
|
|
|
139
139
|
|
|
140
140
|
add_action( 'wp_enqueue_scripts', 'tds_enqueue_assets' );
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Enqueue block init scripts.
|
|
144
|
+
* Loads init.js files for blocks that have them (e.g., chip.init.js for onClick handlers).
|
|
145
|
+
*
|
|
146
|
+
* @since 1.1.0
|
|
147
|
+
* @return void
|
|
148
|
+
*/
|
|
149
|
+
function tds_enqueue_block_scripts() {
|
|
150
|
+
$plugin_dir = plugin_dir_url( __FILE__ );
|
|
151
|
+
$blocks_dir = plugin_dir_path( __FILE__ ) . 'blocks/';
|
|
152
|
+
|
|
153
|
+
if ( ! is_dir( $blocks_dir ) ) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
$block_dirs = glob( $blocks_dir . '*', GLOB_ONLYDIR );
|
|
158
|
+
|
|
159
|
+
if ( empty( $block_dirs ) ) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
foreach ( $block_dirs as $block_dir ) {
|
|
164
|
+
$block_name = basename( $block_dir );
|
|
165
|
+
$init_js_path = $block_dir . '/init.js';
|
|
166
|
+
|
|
167
|
+
// Check if block has an init.js file
|
|
168
|
+
if ( file_exists( $init_js_path ) ) {
|
|
169
|
+
$handle = 'tds-' . $block_name . '-init';
|
|
170
|
+
wp_register_script(
|
|
171
|
+
$handle,
|
|
172
|
+
$plugin_dir . 'blocks/' . $block_name . '/init.js',
|
|
173
|
+
array(), // No dependencies
|
|
174
|
+
tds_get_asset_version( 'blocks/' . $block_name . '/init.js' ),
|
|
175
|
+
true // Load in footer
|
|
176
|
+
);
|
|
177
|
+
wp_enqueue_script( $handle );
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
add_action( 'wp_enqueue_scripts', 'tds_enqueue_block_scripts' );
|
|
183
|
+
|
|
142
184
|
/**
|
|
143
185
|
* Register Times Design System admin page in the menu.
|
|
144
186
|
*
|
|
@@ -133,8 +133,17 @@ function tds_render_icon($icon_name, $size_name = 'medium', $class = '') {
|
|
|
133
133
|
* @return string Modified SVG
|
|
134
134
|
*/
|
|
135
135
|
function tds_inject_svg_dimensions($svg, $width, $height, $class = '') {
|
|
136
|
-
//
|
|
137
|
-
|
|
136
|
+
// Remove or replace existing width/height attributes, then add the correct ones
|
|
137
|
+
// Match width="...", width='...' or width=... patterns and replace with new value
|
|
138
|
+
$svg = preg_replace('/width="[^"]*"/', sprintf('width="%d"', $width), $svg);
|
|
139
|
+
$svg = preg_replace('/width=\'[^\']*\'/', sprintf('width="%d"', $width), $svg);
|
|
140
|
+
|
|
141
|
+
// Same for height
|
|
142
|
+
$svg = preg_replace('/height="[^"]*"/', sprintf('height="%d"', $height), $svg);
|
|
143
|
+
$svg = preg_replace('/height=\'[^\']*\'/', sprintf('height="%d"', $height), $svg);
|
|
144
|
+
|
|
145
|
+
// If SVG still doesn't have width/height (fallback for edge cases), inject them
|
|
146
|
+
if (strpos($svg, 'width=') === false || strpos($svg, 'height=') === false) {
|
|
138
147
|
$svg = str_replace('<svg', sprintf('<svg width="%d" height="%d"', $width, $height), $svg);
|
|
139
148
|
}
|
|
140
149
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@times-design-system/components-wordpress",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Times Design System Gutenberg blocks for WordPress Full Site Editing",
|
|
6
6
|
"keywords": [
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
"requiresPhp": "7.4"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "npm run check:css-imports && npm run clean && npm run extract:icons && npm run build:rollup && npm run build:plugin",
|
|
35
|
+
"build": "npm run check:css-imports && npm run clean && npm run extract:icons && npm run build:rollup && npm run compile:scss && npm run build:plugin",
|
|
36
36
|
"check:css-imports": "bash scripts/check-css-imports.sh",
|
|
37
37
|
"build:rollup": "rollup -c",
|
|
38
|
+
"compile:scss": "node scripts/compile-scss.cjs",
|
|
38
39
|
"build:plugin": "node scripts/build-plugin.cjs",
|
|
39
40
|
"clean": "rimraf dist",
|
|
40
41
|
"extract:icons": "node scripts/extract-icons.cjs",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"access": "public"
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
|
-
"@times-design-system/theme-scss": "^2.
|
|
72
|
+
"@times-design-system/theme-scss": "^2.7.0",
|
|
72
73
|
"@wordpress/block-editor": "^12.0.0",
|
|
73
74
|
"@wordpress/blocks": "^12.0.0",
|
|
74
75
|
"@wordpress/components": "^25.0.0",
|
|
@@ -95,8 +96,9 @@
|
|
|
95
96
|
"rollup": "^3.0.0",
|
|
96
97
|
"rollup-plugin-copy": "^3.4.0",
|
|
97
98
|
"rollup-plugin-postcss": "^4.0.2",
|
|
99
|
+
"sass": "^1.69.0",
|
|
98
100
|
"typescript": "^5.0.0",
|
|
99
101
|
"vitest": "^1.0.4"
|
|
100
102
|
},
|
|
101
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "9c307c4ebda60d58d3d03ef7b869554cbb80b88b"
|
|
102
104
|
}
|
package/plugin.php
CHANGED
|
@@ -139,6 +139,48 @@ function tds_enqueue_assets() {
|
|
|
139
139
|
|
|
140
140
|
add_action( 'wp_enqueue_scripts', 'tds_enqueue_assets' );
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Enqueue block init scripts.
|
|
144
|
+
* Loads init.js files for blocks that have them (e.g., chip.init.js for onClick handlers).
|
|
145
|
+
*
|
|
146
|
+
* @since 1.1.0
|
|
147
|
+
* @return void
|
|
148
|
+
*/
|
|
149
|
+
function tds_enqueue_block_scripts() {
|
|
150
|
+
$plugin_dir = plugin_dir_url( __FILE__ );
|
|
151
|
+
$blocks_dir = plugin_dir_path( __FILE__ ) . 'blocks/';
|
|
152
|
+
|
|
153
|
+
if ( ! is_dir( $blocks_dir ) ) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
$block_dirs = glob( $blocks_dir . '*', GLOB_ONLYDIR );
|
|
158
|
+
|
|
159
|
+
if ( empty( $block_dirs ) ) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
foreach ( $block_dirs as $block_dir ) {
|
|
164
|
+
$block_name = basename( $block_dir );
|
|
165
|
+
$init_js_path = $block_dir . '/init.js';
|
|
166
|
+
|
|
167
|
+
// Check if block has an init.js file
|
|
168
|
+
if ( file_exists( $init_js_path ) ) {
|
|
169
|
+
$handle = 'tds-' . $block_name . '-init';
|
|
170
|
+
wp_register_script(
|
|
171
|
+
$handle,
|
|
172
|
+
$plugin_dir . 'blocks/' . $block_name . '/init.js',
|
|
173
|
+
array(), // No dependencies
|
|
174
|
+
tds_get_asset_version( 'blocks/' . $block_name . '/init.js' ),
|
|
175
|
+
true // Load in footer
|
|
176
|
+
);
|
|
177
|
+
wp_enqueue_script( $handle );
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
add_action( 'wp_enqueue_scripts', 'tds_enqueue_block_scripts' );
|
|
183
|
+
|
|
142
184
|
/**
|
|
143
185
|
* Register Times Design System admin page in the menu.
|
|
144
186
|
*
|
package/dist/blocks/flag/save.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useBlockProps, RichText } from '@wordpress/block-editor';
|
|
2
|
-
|
|
3
|
-
const save = ({ attributes }) => {
|
|
4
|
-
const { label, content, intent, size, iconLeft, iconRight, ariaLabel } =
|
|
5
|
-
attributes;
|
|
6
|
-
const blockProps = useBlockProps.save();
|
|
7
|
-
|
|
8
|
-
const buildClass = () => {
|
|
9
|
-
const classes = ['tds-flag'];
|
|
10
|
-
classes.push(`tds-flag--intent-${intent}`);
|
|
11
|
-
classes.push(`tds-flag--size-${size}`);
|
|
12
|
-
return classes.join(' ');
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<div {...blockProps} className={buildClass()} aria-label={ariaLabel}>
|
|
17
|
-
{label && <div className="tds-flag__label">{label}</div>}
|
|
18
|
-
{iconLeft && <span className="tds-flag__icon-left">{iconLeft}</span>}
|
|
19
|
-
<RichText.Content value={content} className="tds-flag__content" />
|
|
20
|
-
{iconRight && <span className="tds-flag__icon-right">{iconRight}</span>}
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default save;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* Flag Block Frontend Styles (Tag Component) */
|
|
2
|
-
/* Using design tokens for self-contained styling */
|
|
3
|
-
|
|
4
|
-
.tds-flag {
|
|
5
|
-
--tds-tag-bg: var(--tag-primary-fill, #000000);
|
|
6
|
-
--tds-tag-fg: var(--tag-primary-text, #f2f2f2);
|
|
7
|
-
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
gap: var(--spacing-03);
|
|
12
|
-
min-height: 19px;
|
|
13
|
-
min-width: 42px;
|
|
14
|
-
padding: var(--spacing-03) var(--spacing-04);
|
|
15
|
-
border-radius: var(--border-radius-50);
|
|
16
|
-
background-color: var(--tds-tag-bg);
|
|
17
|
-
color: var(--tds-tag-fg);
|
|
18
|
-
font-family: var(--fontFamily040, sans-serif);
|
|
19
|
-
font-size: var(--fontSize020, 14px);
|
|
20
|
-
font-weight: var(--fontWeight050, 500);
|
|
21
|
-
line-height: 1.125;
|
|
22
|
-
text-transform: uppercase;
|
|
23
|
-
white-space: nowrap;
|
|
24
|
-
box-sizing: border-box;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.tds-flag--size-small {
|
|
28
|
-
padding: var(--spacing-01) var(--spacing-04);
|
|
29
|
-
font-size: var(--fontSize010, 12px);
|
|
30
|
-
gap: var(--spacing-01);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.tds-flag--intent-secondary {
|
|
34
|
-
--tds-tag-bg: transparent;
|
|
35
|
-
--tds-tag-fg: var(--text-primary, #1a1a1a);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.tds-flag--intent-callout {
|
|
39
|
-
--tds-tag-bg: var(--tag-callout-primary-fill, #b20908);
|
|
40
|
-
--tds-tag-fg: var(--tag-callout-primary-text, #ffffff);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.tds-flag__label {
|
|
44
|
-
display: inline-flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.tds-flag__content {
|
|
49
|
-
display: inline-flex;
|
|
50
|
-
align-items: center;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.tds-flag__icon {
|
|
54
|
-
display: inline-flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
justify-content: center;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.tds-flag--size-small .tds-flag__icon {
|
|
60
|
-
width: 16px;
|
|
61
|
-
height: 16px;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.tds-flag--size-large .tds-flag__icon {
|
|
65
|
-
width: 24px;
|
|
66
|
-
height: 24px;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.tds-flag__icon svg {
|
|
70
|
-
width: 100%;
|
|
71
|
-
height: 100%;
|
|
72
|
-
}
|