@times-design-system/components-wordpress 1.13.0 → 1.16.1-alpha.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/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 +4 -3
- package/dist/blocks/button/block.json +5 -0
- package/dist/blocks/button/init.js +1 -1
- 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 +137 -77
- 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 +8 -6
- 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 +5 -4
- 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 +5 -1
- package/dist/blocks/icon-button/block.json +5 -0
- package/dist/blocks/icon-button/render.php +16 -6
- package/dist/blocks/icon-button/style.css +1 -1
- package/dist/blocks/icon-button/style.scss +34 -33
- 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 +16 -14
- 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 +7 -6
- 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 +20 -19
- 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 +17 -16
- 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 +4 -2
- 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 +24 -26
- package/dist/blocks/text/block.json +5 -0
- package/dist/blocks/text/render.php +9 -1
- package/dist/blocks/text/style.scss +1 -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 +14 -13
- 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 +129 -117
- 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
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
/* These styles use SCSS variables from @times-design-system/theme-scss */
|
|
3
3
|
/* Maintains styling parity with React Button component */
|
|
4
4
|
|
|
5
|
-
@import '@times-design-system/theme-scss/src/
|
|
5
|
+
@import '@times-design-system/theme-scss/src/theme-classes.scss';
|
|
6
6
|
@import '@times-design-system/theme-scss/src/tds-layout.scss';
|
|
7
7
|
@import '@times-design-system/theme-scss/src/tds-typography.scss';
|
|
8
8
|
|
|
9
9
|
.tds-button {
|
|
10
|
-
--tds-button-bg:
|
|
11
|
-
--tds-button-fg:
|
|
10
|
+
--tds-button-bg: var(--interactive-primary-fill-default);
|
|
11
|
+
--tds-button-fg: var(--interactive-primary-text-default);
|
|
12
12
|
--tds-button-border: transparent;
|
|
13
|
-
--tds-button-bg-hover:
|
|
14
|
-
--tds-button-fg-hover:
|
|
13
|
+
--tds-button-bg-hover: var(--interactive-primary-fill-hover);
|
|
14
|
+
--tds-button-fg-hover: var(--interactive-primary-text-hover);
|
|
15
15
|
--tds-button-border-hover: transparent;
|
|
16
|
-
--tds-button-bg-pressed:
|
|
17
|
-
--tds-button-fg-pressed:
|
|
16
|
+
--tds-button-bg-pressed: var(--interactive-primary-fill-pressed);
|
|
17
|
+
--tds-button-fg-pressed: var(--interactive-primary-text-pressed);
|
|
18
18
|
--tds-button-border-pressed: transparent;
|
|
19
19
|
--tds-button-border-focus: transparent;
|
|
20
|
-
--tds-button-focus-ring:
|
|
20
|
+
--tds-button-focus-ring: var(--text-tertiary);
|
|
21
21
|
--tds-button-label-inline-padding: #{$spacing-05};
|
|
22
22
|
|
|
23
23
|
position: relative;
|
|
@@ -72,40 +72,40 @@
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
.tds-button--intent-primary {
|
|
75
|
-
--tds-button-bg:
|
|
76
|
-
--tds-button-fg:
|
|
75
|
+
--tds-button-bg: var(--interactive-primary-fill-default);
|
|
76
|
+
--tds-button-fg: var(--interactive-primary-text-default);
|
|
77
77
|
--tds-button-border: transparent;
|
|
78
|
-
--tds-button-bg-hover:
|
|
79
|
-
--tds-button-fg-hover:
|
|
78
|
+
--tds-button-bg-hover: var(--interactive-primary-fill-hover);
|
|
79
|
+
--tds-button-fg-hover: var(--interactive-primary-text-hover);
|
|
80
80
|
--tds-button-border-hover: transparent;
|
|
81
|
-
--tds-button-bg-pressed:
|
|
82
|
-
--tds-button-fg-pressed:
|
|
81
|
+
--tds-button-bg-pressed: var(--interactive-primary-fill-pressed);
|
|
82
|
+
--tds-button-fg-pressed: var(--interactive-primary-text-pressed);
|
|
83
83
|
--tds-button-border-pressed: transparent;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
.tds-button--intent-secondary {
|
|
87
|
-
--tds-button-bg:
|
|
88
|
-
--tds-button-fg:
|
|
89
|
-
--tds-button-border:
|
|
90
|
-
--tds-button-bg-hover:
|
|
91
|
-
--tds-button-fg-hover:
|
|
92
|
-
--tds-button-border-hover:
|
|
93
|
-
--tds-button-bg-pressed:
|
|
94
|
-
--tds-button-fg-pressed:
|
|
95
|
-
--tds-button-border-pressed:
|
|
96
|
-
--tds-button-border-focus:
|
|
87
|
+
--tds-button-bg: var(--interactive-secondary-fill-default);
|
|
88
|
+
--tds-button-fg: var(--interactive-secondary-text-default);
|
|
89
|
+
--tds-button-border: var(--interactive-secondary-border-default);
|
|
90
|
+
--tds-button-bg-hover: var(--interactive-secondary-fill-hover);
|
|
91
|
+
--tds-button-fg-hover: var(--interactive-secondary-text-hover);
|
|
92
|
+
--tds-button-border-hover: var(--interactive-secondary-border-hover);
|
|
93
|
+
--tds-button-bg-pressed: var(--interactive-secondary-fill-pressed);
|
|
94
|
+
--tds-button-fg-pressed: var(--interactive-secondary-text-pressed);
|
|
95
|
+
--tds-button-border-pressed: var(--interactive-secondary-border-pressed);
|
|
96
|
+
--tds-button-border-focus: var(--interactive-secondary-border-default);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
.tds-button--intent-negative {
|
|
100
|
-
--tds-button-bg:
|
|
101
|
-
--tds-button-fg:
|
|
102
|
-
--tds-button-border:
|
|
103
|
-
--tds-button-bg-hover:
|
|
104
|
-
--tds-button-fg-hover:
|
|
105
|
-
--tds-button-border-hover:
|
|
106
|
-
--tds-button-bg-pressed:
|
|
107
|
-
--tds-button-fg-pressed:
|
|
108
|
-
--tds-button-border-pressed:
|
|
100
|
+
--tds-button-bg: var(--interactive-negative-fill-default);
|
|
101
|
+
--tds-button-fg: var(--interactive-negative-text-default);
|
|
102
|
+
--tds-button-border: var(--interactive-negative-border-default);
|
|
103
|
+
--tds-button-bg-hover: var(--interactive-negative-fill-hover);
|
|
104
|
+
--tds-button-fg-hover: var(--interactive-negative-text-hover);
|
|
105
|
+
--tds-button-border-hover: var(--interactive-negative-border-hover);
|
|
106
|
+
--tds-button-bg-pressed: var(--interactive-negative-fill-pressed);
|
|
107
|
+
--tds-button-fg-pressed: var(--interactive-negative-text-pressed);
|
|
108
|
+
--tds-button-border-pressed: var(--interactive-negative-border-pressed);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
.tds-button--size-small {
|
|
@@ -56,6 +56,11 @@
|
|
|
56
56
|
"type": "string",
|
|
57
57
|
"default": ""
|
|
58
58
|
},
|
|
59
|
+
"href": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"default": "",
|
|
62
|
+
"description": "Link target URL. When provided, renders as an anchor element instead of button."
|
|
63
|
+
},
|
|
59
64
|
"onClick": {
|
|
60
65
|
"type": "string",
|
|
61
66
|
"default": "",
|
|
@@ -70,6 +75,11 @@
|
|
|
70
75
|
"type": "object",
|
|
71
76
|
"default": {},
|
|
72
77
|
"description": "Custom data-* attributes for extensibility (allowlisted server-side)"
|
|
78
|
+
},
|
|
79
|
+
"ariaAttributes": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"default": {},
|
|
82
|
+
"description": "Custom aria-* attributes for extensibility (allowlisted server-side)"
|
|
73
83
|
}
|
|
74
84
|
},
|
|
75
85
|
"example": {},
|
|
@@ -103,6 +113,11 @@
|
|
|
103
113
|
"intent": "primary",
|
|
104
114
|
"toggle": true,
|
|
105
115
|
"size": "small"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"content": "Link",
|
|
119
|
+
"href": "#",
|
|
120
|
+
"size": "small"
|
|
106
121
|
}
|
|
107
122
|
]
|
|
108
123
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
require_once __DIR__ . '/../../utils/sanitize-aria-attributes.php';
|
|
14
15
|
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
15
16
|
|
|
16
17
|
$content_text = isset($attributes['content']) ? wp_kses_post($attributes['content']) : 'Chip content';
|
|
@@ -20,6 +21,7 @@ $channel = isset($attributes['channel']) ? (bool) $attributes['channel'] : false
|
|
|
20
21
|
$toggle = isset($attributes['toggle']) ? (bool) $attributes['toggle'] : false;
|
|
21
22
|
$icon_left = isset($attributes['iconLeft']) ? sanitize_text_field($attributes['iconLeft']) : '';
|
|
22
23
|
$icon_right = isset($attributes['iconRight']) ? sanitize_text_field($attributes['iconRight']) : '';
|
|
24
|
+
$href = isset($attributes['href']) ? esc_url($attributes['href']) : '';
|
|
23
25
|
$on_click = isset($attributes['onClick']) ? sanitize_text_field($attributes['onClick']) : '';
|
|
24
26
|
|
|
25
27
|
// Derive icon size from chip size
|
|
@@ -38,18 +40,28 @@ foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
|
38
40
|
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
// Sanitize and prepare aria-* attributes
|
|
44
|
+
$sanitized_aria_attributes = tds_sanitize_aria_attributes($attributes['ariaAttributes'] ?? [], 'chip', $attributes);
|
|
45
|
+
$aria_attrs_html = '';
|
|
46
|
+
foreach ($sanitized_aria_attributes as $attr_name => $attr_value) {
|
|
47
|
+
$aria_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
$classes = ['tds-chip'];
|
|
42
51
|
$classes[] = 'tds-chip--intent-' . $intent;
|
|
43
52
|
$classes[] = 'tds-chip--size-' . $size;
|
|
44
53
|
if ($channel) {
|
|
45
54
|
$classes[] = 'tds-chip--channel';
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
// Only apply toggle classes when rendering as button (no href)
|
|
57
|
+
if (!$href) {
|
|
58
|
+
if ($toggle) {
|
|
59
|
+
$toggleStatus = 'on';
|
|
60
|
+
} else {
|
|
61
|
+
$toggleStatus = 'off';
|
|
62
|
+
}
|
|
63
|
+
$classes[] = 'tds-chip--toggle-' . $toggleStatus;
|
|
51
64
|
}
|
|
52
|
-
$classes[] = 'tds-chip--toggle-' . $toggleStatus;
|
|
53
65
|
if ($element_class_name) {
|
|
54
66
|
$classes[] = $element_class_name;
|
|
55
67
|
}
|
|
@@ -57,19 +69,40 @@ if ($element_class_name) {
|
|
|
57
69
|
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
58
70
|
?>
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<span class="tds-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
<?php if ($href) : ?>
|
|
73
|
+
<a
|
|
74
|
+
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
75
|
+
href="<?php echo esc_attr($href); ?>"
|
|
76
|
+
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
77
|
+
<?php echo $aria_attrs_html; ?>
|
|
78
|
+
<?php echo $data_attrs_html; ?>
|
|
79
|
+
>
|
|
80
|
+
<span class="tds-chip__content">
|
|
81
|
+
<?php if ($icon_left) : ?>
|
|
82
|
+
<span class="tds-chip__icon tds-chip__icon--left"><?php echo tds_kses_svg(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
83
|
+
<?php endif; ?>
|
|
84
|
+
<span class="tds-chip__label"><?php echo wp_kses_post($content_text); ?></span>
|
|
85
|
+
<?php if ($icon_right) : ?>
|
|
86
|
+
<span class="tds-chip__icon tds-chip__icon--right"><?php echo tds_kses_svg(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
87
|
+
<?php endif; ?>
|
|
88
|
+
</span>
|
|
89
|
+
</a>
|
|
90
|
+
<?php else : ?>
|
|
91
|
+
<button
|
|
92
|
+
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
93
|
+
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
94
|
+
<?php echo $aria_attrs_html; ?>
|
|
95
|
+
<?php echo $on_click ? 'data-onclick="' . esc_attr($on_click) . '"' : ''; ?>
|
|
96
|
+
<?php echo $data_attrs_html; ?>
|
|
97
|
+
>
|
|
98
|
+
<span class="tds-chip__content">
|
|
99
|
+
<?php if ($icon_left) : ?>
|
|
100
|
+
<span class="tds-chip__icon tds-chip__icon--left"><?php echo tds_kses_svg(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
101
|
+
<?php endif; ?>
|
|
102
|
+
<span class="tds-chip__label"><?php echo wp_kses_post($content_text); ?></span>
|
|
103
|
+
<?php if ($icon_right) : ?>
|
|
104
|
+
<span class="tds-chip__icon tds-chip__icon--right"><?php echo tds_kses_svg(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
105
|
+
<?php endif; ?>
|
|
106
|
+
</span>
|
|
107
|
+
</button>
|
|
108
|
+
<?php endif; ?>
|