@times-design-system/components-wordpress 1.5.2 → 1.6.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/block.json +10 -0
- package/dist/blocks/ad-container/edit.js +17 -1
- package/dist/blocks/ad-container/render.php +14 -0
- package/dist/blocks/button/block.json +19 -5
- package/dist/blocks/button/edit.js +33 -15
- package/dist/blocks/button/render.php +24 -2
- package/dist/blocks/button/style.css +63 -0
- package/dist/blocks/chip/block.json +12 -7
- package/dist/blocks/chip/edit.js +20 -17
- package/dist/blocks/chip/render.php +14 -2
- package/dist/blocks/dialog-box/block.json +10 -0
- package/dist/blocks/dialog-box/edit.js +17 -0
- package/dist/blocks/dialog-box/render.php +16 -4
- package/dist/blocks/divider/block.json +10 -0
- package/dist/blocks/divider/edit.js +18 -2
- package/dist/blocks/divider/render.php +14 -1
- package/dist/blocks/flag/block.json +10 -0
- package/dist/blocks/flag/edit.js +27 -2
- package/dist/blocks/flag/render.php +14 -0
- package/dist/blocks/icon/block.json +10 -0
- package/dist/blocks/icon/edit.js +17 -0
- package/dist/blocks/icon/render.php +16 -4
- package/dist/blocks/icon-button/block.json +15 -0
- package/dist/blocks/icon-button/edit.js +33 -1
- package/dist/blocks/icon-button/render.php +19 -0
- package/dist/blocks/icon-button/style.css +37 -3
- package/dist/blocks/input/block.json +10 -0
- package/dist/blocks/input/edit.js +27 -1
- package/dist/blocks/input/render.php +17 -1
- package/dist/blocks/input-helper-message/block.json +10 -0
- package/dist/blocks/input-helper-message/edit.js +17 -0
- package/dist/blocks/input-helper-message/render.php +16 -4
- package/dist/blocks/link/block.json +12 -7
- package/dist/blocks/link/edit.js +21 -18
- package/dist/blocks/link/render.php +14 -2
- package/dist/blocks/tab/block.json +10 -0
- package/dist/blocks/tab/edit.js +17 -0
- package/dist/blocks/tab/render.php +16 -4
- package/dist/blocks/tab-group/block.json +10 -0
- package/dist/blocks/tab-group/edit.js +17 -0
- package/dist/blocks/tab-group/render.php +16 -4
- package/dist/blocks/text/block.json +10 -0
- package/dist/blocks/text/edit.js +18 -2
- package/dist/blocks/text/render.php +14 -1
- package/dist/blocks/toast/block.json +10 -0
- package/dist/blocks/toast/edit.js +18 -1
- package/dist/blocks/toast/render.php +14 -0
- package/dist/index.cjs +389 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +389 -148
- package/dist/index.js.map +1 -1
- package/dist/utils/DATA_ATTRIBUTES_USAGE.md +377 -0
- package/dist/utils/sanitize-data-attributes.php +109 -0
- package/package.json +9 -3
- package/BLOCK_CREATION_CHECKLIST.md +0 -385
- package/BUILD.md +0 -411
- package/CHANGELOG.md +0 -81
- package/SCSS_VARIABLES_REFERENCE.md +0 -316
- package/STYLING_SYNC_GUIDE.md +0 -306
- package/TESTING.md +0 -152
- package/TRANSFORMATION_GUIDE.md +0 -908
- package/dist/blocks/button/style-resolved.css +0 -153
- package/lib/wordpress.js +0 -7
- package/rollup.config.js +0 -75
- package/scripts/build-plugin.cjs +0 -121
- package/scripts/create-block.sh +0 -141
- package/scripts/create-wordpress-block-tests.cjs +0 -438
- package/scripts/create-wordpress-block.cjs +0 -681
- package/src/blocks/ad-container/block.json +0 -29
- package/src/blocks/ad-container/edit.js +0 -42
- package/src/blocks/ad-container/index.js +0 -10
- package/src/blocks/ad-container/render.php +0 -27
- package/src/blocks/ad-container/save.js +0 -16
- package/src/blocks/ad-container/style-editor.css +0 -4
- package/src/blocks/ad-container/style.css +0 -30
- package/src/blocks/button/block.json +0 -90
- package/src/blocks/button/edit.js +0 -187
- package/src/blocks/button/index.js +0 -11
- package/src/blocks/button/render.php +0 -71
- package/src/blocks/button/save.js +0 -52
- package/src/blocks/button/style-editor.css +0 -15
- package/src/blocks/button/style-resolved.css +0 -153
- package/src/blocks/button/style.css +0 -157
- package/src/blocks/chip/block.json +0 -58
- package/src/blocks/chip/edit.js +0 -113
- package/src/blocks/chip/index.js +0 -10
- package/src/blocks/chip/render.php +0 -40
- package/src/blocks/chip/save.js +0 -36
- package/src/blocks/chip/style-editor.css +0 -5
- package/src/blocks/chip/style.css +0 -87
- package/src/blocks/dialog-box/block.json +0 -24
- package/src/blocks/dialog-box/edit.js +0 -41
- package/src/blocks/dialog-box/index.js +0 -17
- package/src/blocks/dialog-box/render.php +0 -24
- package/src/blocks/dialog-box/save.js +0 -23
- package/src/blocks/dialog-box/style.css +0 -23
- package/src/blocks/divider/block.json +0 -32
- package/src/blocks/divider/edit.js +0 -42
- package/src/blocks/divider/index.js +0 -10
- package/src/blocks/divider/render.php +0 -31
- package/src/blocks/divider/save.js +0 -18
- package/src/blocks/divider/style-editor.css +0 -4
- package/src/blocks/divider/style.css +0 -37
- package/src/blocks/flag/block.json +0 -49
- package/src/blocks/flag/edit.js +0 -82
- package/src/blocks/flag/index.js +0 -10
- package/src/blocks/flag/render.php +0 -34
- package/src/blocks/flag/save.js +0 -25
- package/src/blocks/flag/style-editor.css +0 -5
- package/src/blocks/flag/style.css +0 -54
- package/src/blocks/icon/block.json +0 -24
- package/src/blocks/icon/edit.js +0 -41
- package/src/blocks/icon/index.js +0 -17
- package/src/blocks/icon/render.php +0 -24
- package/src/blocks/icon/save.js +0 -23
- package/src/blocks/icon/style.css +0 -23
- package/src/blocks/icon-button/block.json +0 -44
- package/src/blocks/icon-button/edit.js +0 -82
- package/src/blocks/icon-button/index.js +0 -10
- package/src/blocks/icon-button/render.php +0 -46
- package/src/blocks/icon-button/save.js +0 -29
- package/src/blocks/icon-button/style-editor.css +0 -5
- package/src/blocks/icon-button/style.css +0 -31
- package/src/blocks/input/block.json +0 -48
- package/src/blocks/input/edit.js +0 -78
- package/src/blocks/input/index.js +0 -10
- package/src/blocks/input/render.php +0 -39
- package/src/blocks/input/save.js +0 -27
- package/src/blocks/input/style-editor.css +0 -8
- package/src/blocks/input/style.css +0 -53
- package/src/blocks/input-helper-message/block.json +0 -24
- package/src/blocks/input-helper-message/edit.js +0 -42
- package/src/blocks/input-helper-message/index.js +0 -17
- package/src/blocks/input-helper-message/render.php +0 -24
- package/src/blocks/input-helper-message/save.js +0 -23
- package/src/blocks/input-helper-message/style.css +0 -23
- package/src/blocks/link/block.json +0 -72
- package/src/blocks/link/edit.js +0 -151
- package/src/blocks/link/index.js +0 -10
- package/src/blocks/link/render.php +0 -44
- package/src/blocks/link/save.js +0 -46
- package/src/blocks/link/style-editor.css +0 -5
- package/src/blocks/link/style.css +0 -119
- package/src/blocks/tab/block.json +0 -24
- package/src/blocks/tab/edit.js +0 -41
- package/src/blocks/tab/index.js +0 -17
- package/src/blocks/tab/render.php +0 -24
- package/src/blocks/tab/save.js +0 -23
- package/src/blocks/tab/style.css +0 -23
- package/src/blocks/tab-group/block.json +0 -24
- package/src/blocks/tab-group/edit.js +0 -41
- package/src/blocks/tab-group/index.js +0 -17
- package/src/blocks/tab-group/render.php +0 -24
- package/src/blocks/tab-group/save.js +0 -23
- package/src/blocks/tab-group/style.css +0 -23
- package/src/blocks/text/block.json +0 -33
- package/src/blocks/text/edit.js +0 -56
- package/src/blocks/text/index.js +0 -10
- package/src/blocks/text/render.php +0 -26
- package/src/blocks/text/save.js +0 -18
- package/src/blocks/text/style-editor.css +0 -4
- package/src/blocks/text/style.css +0 -7
- package/src/blocks/toast/block.json +0 -40
- package/src/blocks/toast/edit.js +0 -85
- package/src/blocks/toast/index.js +0 -10
- package/src/blocks/toast/render.php +0 -37
- package/src/blocks/toast/save.js +0 -29
- package/src/blocks/toast/style-editor.css +0 -4
- package/src/blocks/toast/style.css +0 -67
- package/src/index.js +0 -16
- package/src/utils/classBuilder.js +0 -53
- package/tsconfig.json +0 -116
- package/vitest.config.js +0 -28
- package/vitest.config.ts +0 -28
- package/vitest.setup.ts +0 -129
|
@@ -10,9 +10,19 @@
|
|
|
10
10
|
* @var WP_Block $block Block instance
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
|
|
13
15
|
$is_dashed = isset($attributes['isDashed']) ? (bool) $attributes['isDashed'] : false;
|
|
14
16
|
$is_vertical = isset($attributes['isVertical']) ? (bool) $attributes['isVertical'] : false;
|
|
15
17
|
$padding = isset($attributes['padding']) ? (bool) $attributes['padding'] : false;
|
|
18
|
+
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
19
|
+
|
|
20
|
+
// Sanitize and prepare data-* attributes
|
|
21
|
+
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'divider', $attributes);
|
|
22
|
+
$data_attrs_html = '';
|
|
23
|
+
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
24
|
+
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
25
|
+
}
|
|
16
26
|
|
|
17
27
|
$classes = ['tds-divider'];
|
|
18
28
|
if ($is_dashed) {
|
|
@@ -24,8 +34,11 @@ if ($is_vertical) {
|
|
|
24
34
|
if ($padding) {
|
|
25
35
|
$classes[] = 'tds-divider--padding';
|
|
26
36
|
}
|
|
37
|
+
if ($element_class_name) {
|
|
38
|
+
$classes[] = $element_class_name;
|
|
39
|
+
}
|
|
27
40
|
|
|
28
41
|
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
29
42
|
?>
|
|
30
43
|
|
|
31
|
-
<div <?php echo wp_kses_post($wrapper_attrs); ?>></div>
|
|
44
|
+
<div <?php echo wp_kses_post($wrapper_attrs); ?><?php echo wp_kses_post($data_attrs_html); ?>></div>
|
|
@@ -43,6 +43,16 @@
|
|
|
43
43
|
"ariaLabel": {
|
|
44
44
|
"type": "string",
|
|
45
45
|
"default": ""
|
|
46
|
+
},
|
|
47
|
+
"classes": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"default": "",
|
|
50
|
+
"description": "Additional CSS classes applied to the rendered flag element"
|
|
51
|
+
},
|
|
52
|
+
"dataAttributes": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"default": {},
|
|
55
|
+
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
46
56
|
}
|
|
47
57
|
},
|
|
48
58
|
"example": {}
|
package/dist/blocks/flag/edit.js
CHANGED
|
@@ -6,8 +6,17 @@ import {
|
|
|
6
6
|
import { PanelBody, SelectControl, TextControl } from '@wordpress/components';
|
|
7
7
|
|
|
8
8
|
const edit = ({ attributes, setAttributes }) => {
|
|
9
|
-
const {
|
|
10
|
-
|
|
9
|
+
const {
|
|
10
|
+
label,
|
|
11
|
+
content,
|
|
12
|
+
intent,
|
|
13
|
+
size,
|
|
14
|
+
iconLeft,
|
|
15
|
+
iconRight,
|
|
16
|
+
ariaLabel,
|
|
17
|
+
classes,
|
|
18
|
+
dataAttributes
|
|
19
|
+
} = attributes;
|
|
11
20
|
const blockProps = useBlockProps();
|
|
12
21
|
|
|
13
22
|
const buildClass = () => {
|
|
@@ -63,6 +72,22 @@ const edit = ({ attributes, setAttributes }) => {
|
|
|
63
72
|
onChange={(val) => setAttributes({ ariaLabel: val })}
|
|
64
73
|
/>
|
|
65
74
|
</PanelBody>
|
|
75
|
+
|
|
76
|
+
<PanelBody title="Extensibility" initialOpen={false}>
|
|
77
|
+
<TextControl
|
|
78
|
+
label="Custom Classes"
|
|
79
|
+
value={classes}
|
|
80
|
+
onChange={(val) => setAttributes({ classes: val })}
|
|
81
|
+
placeholder="class-name-1 class-name-2"
|
|
82
|
+
help="Space-separated CSS classes added to the flag element"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<p style={{ fontSize: '12px', color: '#666', marginTop: '8px' }}>
|
|
86
|
+
<strong>Data Attributes:</strong> Custom data-* attributes are
|
|
87
|
+
typically set via block templates or PHP filters for analytics,
|
|
88
|
+
testing, and custom hooks. See the block documentation for examples.
|
|
89
|
+
</p>
|
|
90
|
+
</PanelBody>
|
|
66
91
|
</InspectorControls>
|
|
67
92
|
<div {...blockProps} className={buildClass()} aria-label={ariaLabel}>
|
|
68
93
|
{label && <div className="tds-flag__label">{label}</div>}
|
|
@@ -10,15 +10,28 @@
|
|
|
10
10
|
* @var WP_Block $block Block instance
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
|
|
13
15
|
$label = isset($attributes['label']) ? sanitize_text_field($attributes['label']) : '';
|
|
14
16
|
$content_text = isset($attributes['content']) ? wp_kses_post($attributes['content']) : '';
|
|
15
17
|
$intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : '';
|
|
16
18
|
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : '';
|
|
17
19
|
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
20
|
+
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
21
|
+
|
|
22
|
+
// Sanitize and prepare data-* attributes
|
|
23
|
+
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'flag', $attributes);
|
|
24
|
+
$data_attrs_html = '';
|
|
25
|
+
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
26
|
+
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
$classes = ['tds-flag'];
|
|
20
30
|
$classes[] = 'tds-flag--intent-' . $intent;
|
|
21
31
|
$classes[] = 'tds-flag--size-' . $size;
|
|
32
|
+
if ($element_class_name) {
|
|
33
|
+
$classes[] = $element_class_name;
|
|
34
|
+
}
|
|
22
35
|
|
|
23
36
|
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
24
37
|
?>
|
|
@@ -26,6 +39,7 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
26
39
|
<div
|
|
27
40
|
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
28
41
|
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
42
|
+
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
29
43
|
>
|
|
30
44
|
<?php if ($label) : ?>
|
|
31
45
|
<div class="tds-flag__label"><?php echo wp_kses_post($label); ?></div>
|
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
"content": {
|
|
18
18
|
"type": "string",
|
|
19
19
|
"default": ""
|
|
20
|
+
},
|
|
21
|
+
"classes": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"default": "",
|
|
24
|
+
"description": "Additional CSS classes applied to the rendered icon element"
|
|
25
|
+
},
|
|
26
|
+
"dataAttributes": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"default": {},
|
|
29
|
+
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
20
30
|
}
|
|
21
31
|
},
|
|
22
32
|
"render": "file:./render.php",
|
package/dist/blocks/icon/edit.js
CHANGED
|
@@ -10,6 +10,7 @@ import { PanelBody, TextControl } from '@wordpress/components';
|
|
|
10
10
|
|
|
11
11
|
export function edit(props) {
|
|
12
12
|
const { attributes, setAttributes } = props;
|
|
13
|
+
const { content, classes, dataAttributes } = attributes;
|
|
13
14
|
const blockProps = useBlockProps();
|
|
14
15
|
|
|
15
16
|
// TODO: Implement editor UI based on component props
|
|
@@ -29,6 +30,22 @@ export function edit(props) {
|
|
|
29
30
|
/>
|
|
30
31
|
{/* TODO: Add more controls based on component variants */}
|
|
31
32
|
</PanelBody>
|
|
33
|
+
|
|
34
|
+
<PanelBody title="Extensibility" initialOpen={false}>
|
|
35
|
+
<TextControl
|
|
36
|
+
label="Custom Classes"
|
|
37
|
+
value={classes || ''}
|
|
38
|
+
onChange={(val) => setAttributes({ classes: val })}
|
|
39
|
+
placeholder="class-name-1 class-name-2"
|
|
40
|
+
help="Space-separated CSS classes added to the icon element"
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<p style={{ fontSize: '12px', color: '#666', marginTop: '8px' }}>
|
|
44
|
+
<strong>Data Attributes:</strong> Custom data-* attributes are
|
|
45
|
+
typically set via block templates or PHP filters for analytics,
|
|
46
|
+
testing, and custom hooks. See the block documentation for examples.
|
|
47
|
+
</p>
|
|
48
|
+
</PanelBody>
|
|
32
49
|
</InspectorControls>
|
|
33
50
|
<div {...blockProps}>
|
|
34
51
|
<p>📝 Icon block editor</p>
|
|
@@ -11,13 +11,25 @@
|
|
|
11
11
|
* @return string Rendered HTML
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
17
|
+
|
|
18
|
+
// Sanitize and prepare data-* attributes
|
|
19
|
+
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'icon', $attributes);
|
|
20
|
+
$data_attrs_html = '';
|
|
21
|
+
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
22
|
+
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
$wrapper_classes = [];
|
|
26
|
+
if ($element_class_name) {
|
|
27
|
+
$wrapper_classes[] = $element_class_name;
|
|
28
|
+
}
|
|
29
|
+
$wrapper_attributes = get_block_wrapper_attributes(['class' => implode(' ', $wrapper_classes)]);
|
|
18
30
|
|
|
19
31
|
?>
|
|
20
|
-
<div <?php echo wp_kses_post(
|
|
32
|
+
<div <?php echo wp_kses_post($wrapper_attributes); ?><?php echo wp_kses_post($data_attrs_html); ?>>
|
|
21
33
|
<!-- TODO: Render Icon component here -->
|
|
22
34
|
<!-- Use CSS custom properties from packages/tokens/data/resolved-hexes.json -->
|
|
23
35
|
<!-- Apply BEM naming: tds-icon--{modifier} -->
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"type": "boolean",
|
|
23
23
|
"default": false
|
|
24
24
|
},
|
|
25
|
+
"isLoading": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false,
|
|
28
|
+
"description": "Show loading state with spinner and disable interaction"
|
|
29
|
+
},
|
|
25
30
|
"href": {
|
|
26
31
|
"type": "string",
|
|
27
32
|
"default": ""
|
|
@@ -38,6 +43,16 @@
|
|
|
38
43
|
"ariaLabel": {
|
|
39
44
|
"type": "string",
|
|
40
45
|
"default": ""
|
|
46
|
+
},
|
|
47
|
+
"classes": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"default": "",
|
|
50
|
+
"description": "Additional CSS classes applied to the rendered button/link element"
|
|
51
|
+
},
|
|
52
|
+
"dataAttributes": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"default": {},
|
|
55
|
+
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
41
56
|
}
|
|
42
57
|
},
|
|
43
58
|
"example": {}
|
|
@@ -7,7 +7,17 @@ import {
|
|
|
7
7
|
} from '@wordpress/components';
|
|
8
8
|
|
|
9
9
|
const edit = ({ attributes, setAttributes }) => {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
iconName,
|
|
12
|
+
round,
|
|
13
|
+
isLoading,
|
|
14
|
+
href,
|
|
15
|
+
target,
|
|
16
|
+
rel,
|
|
17
|
+
ariaLabel,
|
|
18
|
+
classes,
|
|
19
|
+
dataAttributes
|
|
20
|
+
} = attributes;
|
|
11
21
|
const blockProps = useBlockProps();
|
|
12
22
|
|
|
13
23
|
const buildClass = () => {
|
|
@@ -33,6 +43,12 @@ const edit = ({ attributes, setAttributes }) => {
|
|
|
33
43
|
checked={round}
|
|
34
44
|
onChange={(val) => setAttributes({ round: val })}
|
|
35
45
|
/>
|
|
46
|
+
<ToggleControl
|
|
47
|
+
label="Loading"
|
|
48
|
+
checked={isLoading}
|
|
49
|
+
onChange={(val) => setAttributes({ isLoading: val })}
|
|
50
|
+
help="Show loading state with spinner"
|
|
51
|
+
/>
|
|
36
52
|
<TextControl
|
|
37
53
|
label="URL (Leave empty for button)"
|
|
38
54
|
value={href}
|
|
@@ -64,6 +80,22 @@ const edit = ({ attributes, setAttributes }) => {
|
|
|
64
80
|
onChange={(val) => setAttributes({ ariaLabel: val })}
|
|
65
81
|
/>
|
|
66
82
|
</PanelBody>
|
|
83
|
+
|
|
84
|
+
<PanelBody title="Extensibility" initialOpen={false}>
|
|
85
|
+
<TextControl
|
|
86
|
+
label="Custom Classes"
|
|
87
|
+
value={classes}
|
|
88
|
+
onChange={(val) => setAttributes({ classes: val })}
|
|
89
|
+
placeholder="class-name-1 class-name-2"
|
|
90
|
+
help="Space-separated CSS classes added to the button/link element"
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
<p style={{ fontSize: '12px', color: '#666', marginTop: '8px' }}>
|
|
94
|
+
<strong>Data Attributes:</strong> Custom data-* attributes are
|
|
95
|
+
typically set via block templates or PHP filters for analytics,
|
|
96
|
+
testing, and custom hooks. See the block documentation for examples.
|
|
97
|
+
</p>
|
|
98
|
+
</PanelBody>
|
|
67
99
|
</InspectorControls>
|
|
68
100
|
<Element
|
|
69
101
|
{...blockProps}
|
|
@@ -10,17 +10,34 @@
|
|
|
10
10
|
* @var WP_Block $block Block instance
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
|
|
13
15
|
$icon_name = isset($attributes['iconName']) ? sanitize_text_field($attributes['iconName']) : '';
|
|
14
16
|
$round = isset($attributes['round']) ? (bool) $attributes['round'] : false;
|
|
17
|
+
$isLoading = isset($attributes['isLoading']) ? (bool) $attributes['isLoading'] : false;
|
|
15
18
|
$href = isset($attributes['href']) ? esc_url($attributes['href']) : '';
|
|
16
19
|
$target = isset($attributes['target']) ? sanitize_text_field($attributes['target']) : '';
|
|
17
20
|
$rel = isset($attributes['rel']) ? sanitize_text_field($attributes['rel']) : '';
|
|
18
21
|
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
22
|
+
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
23
|
+
|
|
24
|
+
// Sanitize and prepare data-* attributes
|
|
25
|
+
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'icon-button', $attributes);
|
|
26
|
+
$data_attrs_html = '';
|
|
27
|
+
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
28
|
+
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
29
|
+
}
|
|
19
30
|
|
|
20
31
|
$classes = ['tds-icon-button'];
|
|
21
32
|
if ($round) {
|
|
22
33
|
$classes[] = 'tds-icon-button--round';
|
|
23
34
|
}
|
|
35
|
+
if ($isLoading) {
|
|
36
|
+
$classes[] = 'tds-icon-button--loading';
|
|
37
|
+
}
|
|
38
|
+
if ($element_class_name) {
|
|
39
|
+
$classes[] = $element_class_name;
|
|
40
|
+
}
|
|
24
41
|
|
|
25
42
|
$element_tag = $href ? 'a' : 'button';
|
|
26
43
|
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
@@ -33,6 +50,7 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
33
50
|
<?php echo $target ? 'target="' . esc_attr($target) . '"' : ''; ?>
|
|
34
51
|
<?php echo $rel ? 'rel="' . esc_attr($rel) . '"' : ''; ?>
|
|
35
52
|
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
53
|
+
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
36
54
|
>
|
|
37
55
|
<span class="tds-icon-button__icon"><?php echo wp_kses_post($icon_name); ?></span>
|
|
38
56
|
</a>
|
|
@@ -40,6 +58,7 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
40
58
|
<button
|
|
41
59
|
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
42
60
|
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
61
|
+
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
43
62
|
>
|
|
44
63
|
<span class="tds-icon-button__icon"><?php echo wp_kses_post($icon_name); ?></span>
|
|
45
64
|
</button>
|
|
@@ -2,30 +2,64 @@
|
|
|
2
2
|
/* Using resolved design token values for self-contained styling */
|
|
3
3
|
/* Icon buttons inherit base button styles for colors, intents, etc. */
|
|
4
4
|
|
|
5
|
+
.tds-icon-button--size-small,
|
|
6
|
+
.tds-icon-button--size-medium,
|
|
7
|
+
.tds-icon-button--size-large {
|
|
8
|
+
padding: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
.tds-icon-button--size-small {
|
|
6
12
|
width: 32px;
|
|
7
13
|
height: 32px;
|
|
8
|
-
padding: 6px;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
.tds-icon-button--size-medium {
|
|
12
17
|
width: 48px;
|
|
13
18
|
height: 48px;
|
|
14
|
-
padding: 12px;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
.tds-icon-button--size-large {
|
|
18
22
|
width: 64px;
|
|
19
23
|
height: 64px;
|
|
20
|
-
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tds-icon-button--size-xlarge {
|
|
27
|
+
width: 80px;
|
|
28
|
+
height: 80px;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
.tds-icon-button--round.tds-button {
|
|
24
32
|
border-radius: 9999px;
|
|
25
33
|
}
|
|
26
34
|
|
|
35
|
+
.tds-icon-button--loading {
|
|
36
|
+
cursor: wait;
|
|
37
|
+
gap: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
.tds-icon-button__icon {
|
|
28
41
|
display: inline-flex;
|
|
29
42
|
align-items: center;
|
|
30
43
|
justify-content: center;
|
|
31
44
|
}
|
|
45
|
+
|
|
46
|
+
.tds-icon-button__spinner {
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.tds-icon-button__spinner svg {
|
|
53
|
+
animation: tds-icon-button-spin 1.8s linear infinite;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@keyframes tds-icon-button-spin {
|
|
57
|
+
0% {
|
|
58
|
+
transform: rotate(0deg);
|
|
59
|
+
transform-origin: center;
|
|
60
|
+
}
|
|
61
|
+
100% {
|
|
62
|
+
transform: rotate(360deg);
|
|
63
|
+
transform-origin: center;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -42,6 +42,16 @@
|
|
|
42
42
|
"id": {
|
|
43
43
|
"type": "string",
|
|
44
44
|
"default": ""
|
|
45
|
+
},
|
|
46
|
+
"classes": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"default": "",
|
|
49
|
+
"description": "Additional CSS classes applied to the rendered input element"
|
|
50
|
+
},
|
|
51
|
+
"dataAttributes": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"default": {},
|
|
54
|
+
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
45
55
|
}
|
|
46
56
|
},
|
|
47
57
|
"example": {}
|
|
@@ -7,7 +7,17 @@ import {
|
|
|
7
7
|
} from '@wordpress/components';
|
|
8
8
|
|
|
9
9
|
const edit = ({ attributes, setAttributes }) => {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
label,
|
|
12
|
+
placeholder,
|
|
13
|
+
type,
|
|
14
|
+
disabled,
|
|
15
|
+
required,
|
|
16
|
+
name,
|
|
17
|
+
id,
|
|
18
|
+
classes,
|
|
19
|
+
dataAttributes
|
|
20
|
+
} = attributes;
|
|
11
21
|
const blockProps = useBlockProps();
|
|
12
22
|
|
|
13
23
|
return (
|
|
@@ -58,6 +68,22 @@ const edit = ({ attributes, setAttributes }) => {
|
|
|
58
68
|
onChange={(val) => setAttributes({ disabled: val })}
|
|
59
69
|
/>
|
|
60
70
|
</PanelBody>
|
|
71
|
+
|
|
72
|
+
<PanelBody title="Extensibility" initialOpen={false}>
|
|
73
|
+
<TextControl
|
|
74
|
+
label="Custom Classes"
|
|
75
|
+
value={classes}
|
|
76
|
+
onChange={(val) => setAttributes({ classes: val })}
|
|
77
|
+
placeholder="class-name-1 class-name-2"
|
|
78
|
+
help="Space-separated CSS classes added to the input element"
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<p style={{ fontSize: '12px', color: '#666', marginTop: '8px' }}>
|
|
82
|
+
<strong>Data Attributes:</strong> Custom data-* attributes are
|
|
83
|
+
typically set via block templates or PHP filters for analytics,
|
|
84
|
+
testing, and custom hooks. See the block documentation for examples.
|
|
85
|
+
</p>
|
|
86
|
+
</PanelBody>
|
|
61
87
|
</InspectorControls>
|
|
62
88
|
<div {...blockProps}>
|
|
63
89
|
{label && <label className="tds-input__label">{label}</label>}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* @var WP_Block $block Block instance
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
|
|
13
15
|
$label = isset($attributes['label']) ? sanitize_text_field($attributes['label']) : '';
|
|
14
16
|
$placeholder = isset($attributes['placeholder']) ? sanitize_text_field($attributes['placeholder']) : '';
|
|
15
17
|
$type = isset($attributes['type']) ? sanitize_text_field($attributes['type']) : 'text';
|
|
@@ -17,6 +19,19 @@ $disabled = isset($attributes['disabled']) ? (bool) $attributes['disabled'] : fa
|
|
|
17
19
|
$required = isset($attributes['required']) ? (bool) $attributes['required'] : false;
|
|
18
20
|
$name = isset($attributes['name']) ? sanitize_text_field($attributes['name']) : '';
|
|
19
21
|
$id = isset($attributes['id']) ? sanitize_text_field($attributes['id']) : '';
|
|
22
|
+
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
23
|
+
|
|
24
|
+
// Sanitize and prepare data-* attributes
|
|
25
|
+
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'input', $attributes);
|
|
26
|
+
$data_attrs_html = '';
|
|
27
|
+
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
28
|
+
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
$input_classes = ['tds-input'];
|
|
32
|
+
if ($element_class_name) {
|
|
33
|
+
$input_classes[] = $element_class_name;
|
|
34
|
+
}
|
|
20
35
|
|
|
21
36
|
$wrapper_attrs = get_block_wrapper_attributes();
|
|
22
37
|
?>
|
|
@@ -34,6 +49,7 @@ $wrapper_attrs = get_block_wrapper_attributes();
|
|
|
34
49
|
<?php echo $required ? 'required' : ''; ?>
|
|
35
50
|
<?php echo $name ? 'name="' . esc_attr($name) . '"' : ''; ?>
|
|
36
51
|
<?php echo $id ? 'id="' . esc_attr($id) . '"' : ''; ?>
|
|
37
|
-
class="
|
|
52
|
+
class="<?php echo esc_attr(implode(' ', $input_classes)); ?>"
|
|
53
|
+
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
38
54
|
/>
|
|
39
55
|
</div>
|
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
"content": {
|
|
18
18
|
"type": "string",
|
|
19
19
|
"default": ""
|
|
20
|
+
},
|
|
21
|
+
"classes": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"default": "",
|
|
24
|
+
"description": "Additional CSS classes applied to the rendered message element"
|
|
25
|
+
},
|
|
26
|
+
"dataAttributes": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"default": {},
|
|
29
|
+
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
20
30
|
}
|
|
21
31
|
},
|
|
22
32
|
"render": "file:./render.php",
|
|
@@ -10,6 +10,7 @@ import { PanelBody, TextControl } from '@wordpress/components';
|
|
|
10
10
|
|
|
11
11
|
export function edit(props) {
|
|
12
12
|
const { attributes, setAttributes } = props;
|
|
13
|
+
const { content, classes, dataAttributes } = attributes;
|
|
13
14
|
const blockProps = useBlockProps();
|
|
14
15
|
|
|
15
16
|
// TODO: Implement editor UI based on component props
|
|
@@ -29,6 +30,22 @@ export function edit(props) {
|
|
|
29
30
|
/>
|
|
30
31
|
{/* TODO: Add more controls based on component variants */}
|
|
31
32
|
</PanelBody>
|
|
33
|
+
|
|
34
|
+
<PanelBody title="Extensibility" initialOpen={false}>
|
|
35
|
+
<TextControl
|
|
36
|
+
label="Custom Classes"
|
|
37
|
+
value={classes || ''}
|
|
38
|
+
onChange={(val) => setAttributes({ classes: val })}
|
|
39
|
+
placeholder="class-name-1 class-name-2"
|
|
40
|
+
help="Space-separated CSS classes added to the input-helper-message element"
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<p style={{ fontSize: '12px', color: '#666', marginTop: '8px' }}>
|
|
44
|
+
<strong>Data Attributes:</strong> Custom data-* attributes are
|
|
45
|
+
typically set via block templates or PHP filters for analytics,
|
|
46
|
+
testing, and custom hooks. See the block documentation for examples.
|
|
47
|
+
</p>
|
|
48
|
+
</PanelBody>
|
|
32
49
|
</InspectorControls>
|
|
33
50
|
<div {...blockProps}>
|
|
34
51
|
<p>📝 InputHelperMessage block editor</p>
|
|
@@ -11,13 +11,25 @@
|
|
|
11
11
|
* @return string Rendered HTML
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
17
|
+
|
|
18
|
+
// Sanitize and prepare data-* attributes
|
|
19
|
+
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'input-helper-message', $attributes);
|
|
20
|
+
$data_attrs_html = '';
|
|
21
|
+
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
22
|
+
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
$wrapper_classes = [];
|
|
26
|
+
if ($element_class_name) {
|
|
27
|
+
$wrapper_classes[] = $element_class_name;
|
|
28
|
+
}
|
|
29
|
+
$wrapper_attributes = get_block_wrapper_attributes(['class' => implode(' ', $wrapper_classes)]);
|
|
18
30
|
|
|
19
31
|
?>
|
|
20
|
-
<div <?php echo wp_kses_post(
|
|
32
|
+
<div <?php echo wp_kses_post($wrapper_attributes); ?><?php echo wp_kses_post($data_attrs_html); ?>>
|
|
21
33
|
<!-- TODO: Render InputHelperMessage component here -->
|
|
22
34
|
<!-- Use CSS custom properties from packages/tokens/data/resolved-hexes.json -->
|
|
23
35
|
<!-- Apply BEM naming: tds-input-helper-message--{modifier} -->
|
|
@@ -29,19 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"sentiment": {
|
|
31
31
|
"type": "string",
|
|
32
|
-
"default": "
|
|
33
|
-
"enum": ["
|
|
32
|
+
"default": "brand",
|
|
33
|
+
"enum": ["brand", "utility"]
|
|
34
34
|
},
|
|
35
35
|
"size": {
|
|
36
36
|
"type": "string",
|
|
37
37
|
"default": "medium",
|
|
38
38
|
"enum": ["small", "medium", "large"]
|
|
39
39
|
},
|
|
40
|
-
"state": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"default": "base",
|
|
43
|
-
"enum": ["base", "hover", "visited", "focus", "disabled"]
|
|
44
|
-
},
|
|
45
40
|
"iconLeft": {
|
|
46
41
|
"type": "string",
|
|
47
42
|
"default": ""
|
|
@@ -66,6 +61,16 @@
|
|
|
66
61
|
"rel": {
|
|
67
62
|
"type": "string",
|
|
68
63
|
"default": ""
|
|
64
|
+
},
|
|
65
|
+
"classes": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"default": "",
|
|
68
|
+
"description": "Additional CSS classes applied to the rendered link element"
|
|
69
|
+
},
|
|
70
|
+
"dataAttributes": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"default": {},
|
|
73
|
+
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
"example": {}
|