@times-design-system/components-wordpress 1.14.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.
Files changed (81) hide show
  1. package/dist/STYLE_HANDLES.md +3 -1
  2. package/dist/blocks/ad-container/block.json +5 -0
  3. package/dist/blocks/ad-container/render.php +10 -1
  4. package/dist/blocks/ad-container/style.css +1 -1
  5. package/dist/blocks/ad-container/style.scss +3 -2
  6. package/dist/blocks/button/block.json +5 -0
  7. package/dist/blocks/button/render.php +12 -2
  8. package/dist/blocks/button/style.css +1 -1
  9. package/dist/blocks/button/style.scss +33 -33
  10. package/dist/blocks/chip/block.json +15 -0
  11. package/dist/blocks/chip/render.php +54 -21
  12. package/dist/blocks/chip/style.css +1 -1
  13. package/dist/blocks/chip/style.scss +136 -76
  14. package/dist/blocks/dialog-box/block.json +5 -0
  15. package/dist/blocks/dialog-box/render.php +9 -1
  16. package/dist/blocks/dialog-box/style.css +1 -1
  17. package/dist/blocks/dialog-box/style.scss +6 -5
  18. package/dist/blocks/divider/block.json +21 -1
  19. package/dist/blocks/divider/render.php +9 -1
  20. package/dist/blocks/divider/style.css +1 -1
  21. package/dist/blocks/divider/style.scss +4 -3
  22. package/dist/blocks/icon/block.json +5 -0
  23. package/dist/blocks/icon/render.php +10 -12
  24. package/dist/blocks/icon/style.css +1 -1
  25. package/dist/blocks/icon/style.scss +4 -0
  26. package/dist/blocks/icon-button/block.json +5 -0
  27. package/dist/blocks/icon-button/render.php +14 -4
  28. package/dist/blocks/icon-button/style.css +1 -1
  29. package/dist/blocks/icon-button/style.scss +33 -32
  30. package/dist/blocks/input/block.json +5 -0
  31. package/dist/blocks/input/render.php +10 -1
  32. package/dist/blocks/input/style.css +1 -1
  33. package/dist/blocks/input/style.scss +14 -13
  34. package/dist/blocks/input-helper-message/block.json +5 -0
  35. package/dist/blocks/input-helper-message/render.php +9 -1
  36. package/dist/blocks/input-helper-message/style.css +1 -1
  37. package/dist/blocks/input-helper-message/style.scss +6 -5
  38. package/dist/blocks/label/block.json +68 -0
  39. package/dist/blocks/label/edit.js +79 -0
  40. package/dist/blocks/label/index.js +11 -0
  41. package/dist/blocks/label/render.php +56 -0
  42. package/dist/blocks/label/save.js +21 -0
  43. package/dist/blocks/label/style.css +1 -0
  44. package/dist/blocks/label/style.scss +39 -0
  45. package/dist/blocks/link/block.json +5 -0
  46. package/dist/blocks/link/render.php +3 -1
  47. package/dist/blocks/link/style.css +1 -1
  48. package/dist/blocks/link/style.scss +19 -18
  49. package/dist/blocks/tab/block.json +5 -0
  50. package/dist/blocks/tab/render.php +9 -1
  51. package/dist/blocks/tab/style.css +1 -1
  52. package/dist/blocks/tab/style.scss +16 -15
  53. package/dist/blocks/tab-group/block.json +5 -0
  54. package/dist/blocks/tab-group/render.php +9 -1
  55. package/dist/blocks/tab-group/style.css +1 -1
  56. package/dist/blocks/tab-group/style.scss +2 -1
  57. package/dist/blocks/tag/block.json +5 -0
  58. package/dist/blocks/tag/render.php +10 -1
  59. package/dist/blocks/tag/style.css +1 -1
  60. package/dist/blocks/tag/style.scss +23 -25
  61. package/dist/blocks/text/block.json +5 -0
  62. package/dist/blocks/text/render.php +9 -1
  63. package/dist/blocks/toast/block.json +5 -0
  64. package/dist/blocks/toast/render.php +10 -1
  65. package/dist/blocks/toast/style.css +1 -1
  66. package/dist/blocks/toast/style.scss +13 -12
  67. package/dist/icon-data.json +1 -1
  68. package/dist/index.cjs +485 -177
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.css +1 -1
  71. package/dist/index.css.map +1 -1
  72. package/dist/index.js +485 -177
  73. package/dist/index.js.map +1 -1
  74. package/dist/plugin.php +1 -0
  75. package/dist/style-handles.json +5 -0
  76. package/dist/utils/render-icon.php +3 -0
  77. package/dist/utils/sanitize-aria-attributes.php +109 -0
  78. package/package.json +4 -4
  79. package/plugin.php +1 -0
  80. package/dist/blocks/utils/render-icon.php +0 -106
  81. 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/theme-apply.scss';
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
- @include theme-value('--tds-button-bg', 'interactive-primary-fill-default');
11
- @include theme-value('--tds-button-fg', 'interactive-primary-text-default');
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
- @include theme-value('--tds-button-bg-hover', 'interactive-primary-fill-hover');
14
- @include theme-value('--tds-button-fg-hover', 'interactive-primary-text-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
- @include theme-value('--tds-button-bg-pressed', 'interactive-primary-fill-pressed');
17
- @include theme-value('--tds-button-fg-pressed', 'interactive-primary-text-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
- @include theme-value('--tds-button-focus-ring', 'text-tertiary');
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
- @include theme-value('--tds-button-bg', 'interactive-primary-fill-default');
76
- @include theme-value('--tds-button-fg', 'interactive-primary-text-default');
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
- @include theme-value('--tds-button-bg-hover', 'interactive-primary-fill-hover');
79
- @include theme-value('--tds-button-fg-hover', 'interactive-primary-text-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
- @include theme-value('--tds-button-bg-pressed', 'interactive-primary-fill-pressed');
82
- @include theme-value('--tds-button-fg-pressed', 'interactive-primary-text-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
- @include theme-value('--tds-button-bg', 'interactive-secondary-fill-default');
88
- @include theme-value('--tds-button-fg', 'interactive-secondary-text-default');
89
- @include theme-value('--tds-button-border', 'interactive-secondary-border-default');
90
- @include theme-value('--tds-button-bg-hover', 'interactive-secondary-fill-hover');
91
- @include theme-value('--tds-button-fg-hover', 'interactive-secondary-text-hover');
92
- @include theme-value('--tds-button-border-hover', 'interactive-secondary-border-hover');
93
- @include theme-value('--tds-button-bg-pressed', 'interactive-secondary-fill-pressed');
94
- @include theme-value('--tds-button-fg-pressed', 'interactive-secondary-text-pressed');
95
- @include theme-value('--tds-button-border-pressed', 'interactive-secondary-border-pressed');
96
- @include theme-value('--tds-button-border-focus', 'interactive-secondary-border-default');
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
- @include theme-value('--tds-button-bg', 'interactive-negative-fill-default');
101
- @include theme-value('--tds-button-fg', 'interactive-negative-text-default');
102
- @include theme-value('--tds-button-border', 'interactive-negative-border-default');
103
- @include theme-value('--tds-button-bg-hover', 'interactive-negative-fill-hover');
104
- @include theme-value('--tds-button-fg-hover', 'interactive-negative-text-hover');
105
- @include theme-value('--tds-button-border-hover', 'interactive-negative-border-hover');
106
- @include theme-value('--tds-button-bg-pressed', 'interactive-negative-fill-pressed');
107
- @include theme-value('--tds-button-fg-pressed', 'interactive-negative-text-pressed');
108
- @include theme-value('--tds-button-border-pressed', 'interactive-negative-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
- if ($toggle) {
48
- $toggleStatus = 'on';
49
- } else {
50
- $toggleStatus = 'off';
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
- <button
61
- <?php echo wp_kses_post($wrapper_attrs); ?>
62
- <?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
63
- <?php echo $on_click ? 'data-onclick="' . esc_attr($on_click) . '"' : ''; ?>
64
- <?php echo wp_kses_post($data_attrs_html); ?>
65
- >
66
- <span class="tds-chip__content">
67
- <?php if ($icon_left) : ?>
68
- <span class="tds-chip__icon tds-chip__icon--left"><?php echo tds_kses_svg(tds_render_icon($icon_left, $icon_size)); ?></span>
69
- <?php endif; ?>
70
- <span class="tds-chip__label"><?php echo wp_kses_post($content_text); ?></span>
71
- <?php if ($icon_right) : ?>
72
- <span class="tds-chip__icon tds-chip__icon--right"><?php echo tds_kses_svg(tds_render_icon($icon_right, $icon_size)); ?></span>
73
- <?php endif; ?>
74
- </span>
75
- </button>
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; ?>