@times-design-system/components-wordpress 1.14.0 → 1.16.1-alpha.1
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/STYLE_HANDLES.md +3 -1
- package/dist/blocks/ad-container/block.json +5 -0
- package/dist/blocks/ad-container/render.php +10 -1
- package/dist/blocks/ad-container/style.css +1 -1
- package/dist/blocks/ad-container/style.scss +3 -2
- package/dist/blocks/button/block.json +5 -0
- package/dist/blocks/button/render.php +12 -2
- package/dist/blocks/button/style.css +1 -1
- package/dist/blocks/button/style.scss +33 -33
- package/dist/blocks/chip/block.json +15 -0
- package/dist/blocks/chip/render.php +54 -21
- package/dist/blocks/chip/style.css +1 -1
- package/dist/blocks/chip/style.scss +136 -76
- package/dist/blocks/dialog-box/block.json +5 -0
- package/dist/blocks/dialog-box/render.php +9 -1
- package/dist/blocks/dialog-box/style.css +1 -1
- package/dist/blocks/dialog-box/style.scss +6 -5
- package/dist/blocks/divider/block.json +21 -1
- package/dist/blocks/divider/render.php +9 -1
- package/dist/blocks/divider/style.css +1 -1
- package/dist/blocks/divider/style.scss +4 -3
- package/dist/blocks/icon/block.json +5 -0
- package/dist/blocks/icon/render.php +10 -12
- package/dist/blocks/icon/style.css +1 -1
- package/dist/blocks/icon/style.scss +4 -0
- package/dist/blocks/icon-button/block.json +5 -0
- package/dist/blocks/icon-button/render.php +14 -4
- package/dist/blocks/icon-button/style.css +1 -1
- package/dist/blocks/icon-button/style.scss +33 -32
- package/dist/blocks/input/block.json +5 -0
- package/dist/blocks/input/render.php +10 -1
- package/dist/blocks/input/style.css +1 -1
- package/dist/blocks/input/style.scss +14 -13
- package/dist/blocks/input-helper-message/block.json +5 -0
- package/dist/blocks/input-helper-message/render.php +9 -1
- package/dist/blocks/input-helper-message/style.css +1 -1
- package/dist/blocks/input-helper-message/style.scss +6 -5
- package/dist/blocks/label/block.json +68 -0
- package/dist/blocks/label/edit.js +79 -0
- package/dist/blocks/label/index.js +11 -0
- package/dist/blocks/label/render.php +56 -0
- package/dist/blocks/label/save.js +21 -0
- package/dist/blocks/label/style.css +1 -0
- package/dist/blocks/label/style.scss +39 -0
- package/dist/blocks/link/block.json +5 -0
- package/dist/blocks/link/render.php +3 -1
- package/dist/blocks/link/style.css +1 -1
- package/dist/blocks/link/style.scss +19 -18
- package/dist/blocks/tab/block.json +5 -0
- package/dist/blocks/tab/render.php +9 -1
- package/dist/blocks/tab/style.css +1 -1
- package/dist/blocks/tab/style.scss +16 -15
- package/dist/blocks/tab-group/block.json +5 -0
- package/dist/blocks/tab-group/render.php +9 -1
- package/dist/blocks/tab-group/style.css +1 -1
- package/dist/blocks/tab-group/style.scss +2 -1
- package/dist/blocks/tag/block.json +5 -0
- package/dist/blocks/tag/render.php +10 -1
- package/dist/blocks/tag/style.css +1 -1
- package/dist/blocks/tag/style.scss +23 -25
- package/dist/blocks/text/block.json +5 -0
- package/dist/blocks/text/render.php +9 -1
- package/dist/blocks/toast/block.json +5 -0
- package/dist/blocks/toast/render.php +10 -1
- package/dist/blocks/toast/style.css +1 -1
- package/dist/blocks/toast/style.scss +13 -12
- package/dist/icon-data.json +1 -1
- package/dist/index.cjs +485 -177
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +485 -177
- package/dist/index.js.map +1 -1
- package/dist/plugin.php +1 -0
- package/dist/style-handles.json +5 -0
- package/dist/utils/render-icon.php +3 -0
- package/dist/utils/sanitize-aria-attributes.php +109 -0
- package/package.json +4 -4
- package/plugin.php +1 -0
- package/dist/blocks/utils/render-icon.php +0 -106
- package/dist/blocks/utils/sanitize-data-attributes.php +0 -37
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Reference: packages/components-react/src/InputHelperMessage/
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
@import '@times-design-system/theme-scss/src/theme-classes.scss';
|
|
8
9
|
@import '@times-design-system/theme-scss/src/theme-apply.scss';
|
|
9
10
|
@import '@times-design-system/theme-scss/src/tds-layout.scss';
|
|
10
11
|
@import '@times-design-system/theme-scss/src/tds-typography.scss';
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
display: inline-flex;
|
|
14
15
|
align-items: center;
|
|
15
16
|
gap: $spacing-05;
|
|
16
|
-
|
|
17
|
+
color: var(--text-primary);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
.tds-input-helper-message__icon {
|
|
@@ -29,17 +30,17 @@
|
|
|
29
30
|
|
|
30
31
|
/* Intent icon colours */
|
|
31
32
|
.tds-input-helper-message--error .tds-input-helper-message__icon {
|
|
32
|
-
|
|
33
|
+
color: var(--messaging-icon-error);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
.tds-input-helper-message--success .tds-input-helper-message__icon {
|
|
36
|
-
|
|
37
|
+
color: var(--messaging-icon-success);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
.tds-input-helper-message--info .tds-input-helper-message__icon {
|
|
40
|
-
|
|
41
|
+
color: var(--messaging-icon-info);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
.tds-input-helper-message--warning .tds-input-helper-message__icon {
|
|
44
|
-
|
|
45
|
+
color: var(--messaging-icon-warning);
|
|
45
46
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "tds/label",
|
|
5
|
+
"title": "Label",
|
|
6
|
+
"category": "common",
|
|
7
|
+
"description": "A label component used to denote article category, channel, or content type near metadata",
|
|
8
|
+
"icon": "tag",
|
|
9
|
+
"supports": {
|
|
10
|
+
"html": false,
|
|
11
|
+
"spacing": {
|
|
12
|
+
"margin": true,
|
|
13
|
+
"padding": false
|
|
14
|
+
},
|
|
15
|
+
"align": true,
|
|
16
|
+
"customClassName": true
|
|
17
|
+
},
|
|
18
|
+
"textdomain": "times-design-system",
|
|
19
|
+
"render": "file:./render.php",
|
|
20
|
+
"attributes": {
|
|
21
|
+
"label": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"default": "LABEL",
|
|
24
|
+
"description": "The text content displayed in the label"
|
|
25
|
+
},
|
|
26
|
+
"intent": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": [
|
|
29
|
+
"primary",
|
|
30
|
+
"secondary",
|
|
31
|
+
"channel",
|
|
32
|
+
"callout"
|
|
33
|
+
],
|
|
34
|
+
"default": "primary",
|
|
35
|
+
"description": "Visual treatment variant"
|
|
36
|
+
},
|
|
37
|
+
"size": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": [
|
|
40
|
+
"small",
|
|
41
|
+
"medium",
|
|
42
|
+
"large"
|
|
43
|
+
],
|
|
44
|
+
"default": "medium",
|
|
45
|
+
"description": "Typography size variant"
|
|
46
|
+
},
|
|
47
|
+
"ariaLabel": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Optional accessible name for the label"
|
|
50
|
+
},
|
|
51
|
+
"classes": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"default": "",
|
|
54
|
+
"description": "Additional CSS classes applied to the rendered label element"
|
|
55
|
+
},
|
|
56
|
+
"dataAttributes": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"default": {},
|
|
59
|
+
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
60
|
+
},
|
|
61
|
+
"ariaAttributes": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"default": {},
|
|
64
|
+
"description": "Custom aria-* attributes for extensibility (allowlisted server-side)"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"style": "tds-label-style"
|
|
68
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
|
2
|
+
import { PanelBody, SelectControl, TextControl } from '@wordpress/components';
|
|
3
|
+
import { RichText } from '@wordpress/block-editor';
|
|
4
|
+
|
|
5
|
+
export default function Edit({ attributes, setAttributes }) {
|
|
6
|
+
const { label, intent, size, ariaLabel, classes, dataAttributes } =
|
|
7
|
+
attributes;
|
|
8
|
+
|
|
9
|
+
const blockProps = useBlockProps({
|
|
10
|
+
className: [
|
|
11
|
+
'tds-label',
|
|
12
|
+
`tds-label--intent-${intent}`,
|
|
13
|
+
`utility-label-${size}`,
|
|
14
|
+
classes
|
|
15
|
+
]
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.join(' ')
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<span {...blockProps}>{label}</span>
|
|
23
|
+
|
|
24
|
+
<InspectorControls>
|
|
25
|
+
<PanelBody title="Label Settings">
|
|
26
|
+
<TextControl
|
|
27
|
+
label="Label Text"
|
|
28
|
+
value={label}
|
|
29
|
+
onChange={(value) => setAttributes({ label: value })}
|
|
30
|
+
help="The text content displayed in the label"
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
<SelectControl
|
|
34
|
+
label="Intent (Visual Treatment)"
|
|
35
|
+
value={intent}
|
|
36
|
+
options={[
|
|
37
|
+
{ label: 'Primary', value: 'primary' },
|
|
38
|
+
{ label: 'Secondary', value: 'secondary' },
|
|
39
|
+
{ label: 'Channel', value: 'channel' },
|
|
40
|
+
{ label: 'Callout', value: 'callout' }
|
|
41
|
+
]}
|
|
42
|
+
onChange={(value) => setAttributes({ intent: value })}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
<SelectControl
|
|
46
|
+
label="Size"
|
|
47
|
+
value={size}
|
|
48
|
+
options={[
|
|
49
|
+
{ label: 'Small', value: 'small' },
|
|
50
|
+
{ label: 'Medium', value: 'medium' },
|
|
51
|
+
{ label: 'Large', value: 'large' }
|
|
52
|
+
]}
|
|
53
|
+
onChange={(value) => setAttributes({ size: value })}
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
<TextControl
|
|
57
|
+
label="Aria Label"
|
|
58
|
+
value={ariaLabel}
|
|
59
|
+
onChange={(value) => setAttributes({ ariaLabel: value })}
|
|
60
|
+
help="Optional accessible name for the label"
|
|
61
|
+
/>
|
|
62
|
+
</PanelBody>
|
|
63
|
+
|
|
64
|
+
<PanelBody title="Extensibility">
|
|
65
|
+
<TextControl
|
|
66
|
+
label="Custom CSS Classes"
|
|
67
|
+
value={classes}
|
|
68
|
+
onChange={(value) => setAttributes({ classes: value })}
|
|
69
|
+
help="Additional CSS classes to apply to the element"
|
|
70
|
+
/>
|
|
71
|
+
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
72
|
+
Data attributes are typically set programmatically and should not be
|
|
73
|
+
edited here.
|
|
74
|
+
</p>
|
|
75
|
+
</PanelBody>
|
|
76
|
+
</InspectorControls>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerBlockType } from '@wordpress/blocks';
|
|
2
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
3
|
+
import Edit from './edit.js';
|
|
4
|
+
import Save from './save.js';
|
|
5
|
+
import metadata from './block.json';
|
|
6
|
+
|
|
7
|
+
registerBlockType(metadata.name, {
|
|
8
|
+
...metadata,
|
|
9
|
+
edit: Edit,
|
|
10
|
+
save: Save
|
|
11
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Label Block Render Callback
|
|
4
|
+
*
|
|
5
|
+
* Renders the Label block on the frontend.
|
|
6
|
+
*
|
|
7
|
+
* @package TimesDesignSystem\ComponentsWordPress
|
|
8
|
+
* @var array $attributes Block attributes
|
|
9
|
+
* @var string $contetds-nt Block content
|
|
10
|
+
* @var WP_Block $block Block instance
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
require_once __DIR__ . '/../../utils/sanitize-aria-attributes.php';
|
|
15
|
+
|
|
16
|
+
$label = isset($attributes['label']) ? sanitize_text_field($attributes['label']) : 'LABEL';
|
|
17
|
+
$intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : 'primary';
|
|
18
|
+
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : 'medium';
|
|
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'] ?? [], 'label', $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
|
+
}
|
|
28
|
+
|
|
29
|
+
// Sanitize and prepare aria-* attributes
|
|
30
|
+
$sanitized_aria_attributes = tds_sanitize_aria_attributes($attributes['ariaAttributes'] ?? [], 'label', $attributes);
|
|
31
|
+
$aria_attrs_html = '';
|
|
32
|
+
foreach ($sanitized_aria_attributes as $attr_name => $attr_value) {
|
|
33
|
+
$aria_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Build label classes
|
|
37
|
+
$classes = ['tds-label'];
|
|
38
|
+
$classes[] = 'tds-label--' . $intent;
|
|
39
|
+
$classes[] = 'tds-label--' . $size;
|
|
40
|
+
|
|
41
|
+
// Add custom classes
|
|
42
|
+
if ($element_class_name) {
|
|
43
|
+
$classes[] = $element_class_name;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
$label_class = implode(' ', $classes);
|
|
47
|
+
?>
|
|
48
|
+
|
|
49
|
+
<span
|
|
50
|
+
class="<?php echo esc_attr($label_class); ?>"
|
|
51
|
+
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
52
|
+
<?php echo $aria_attrs_html; ?>
|
|
53
|
+
<?php echo $data_attrs_html; ?>
|
|
54
|
+
>
|
|
55
|
+
<?php echo wp_kses_post($label); ?>
|
|
56
|
+
</span>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
2
|
+
|
|
3
|
+
export default function Save({ attributes }) {
|
|
4
|
+
const { label, intent, size, ariaLabel } = attributes;
|
|
5
|
+
|
|
6
|
+
const blockProps = useBlockProps.save({
|
|
7
|
+
className: [
|
|
8
|
+
'tds-label',
|
|
9
|
+
`tds-label--intent-${intent}`,
|
|
10
|
+
`utility-label-${size}`
|
|
11
|
+
]
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join(' ')
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<span {...blockProps} aria-label={ariaLabel}>
|
|
18
|
+
{label}
|
|
19
|
+
</span>
|
|
20
|
+
);
|
|
21
|
+
}
|