@times-design-system/components-wordpress 1.2.2-alpha.0 → 1.2.2-alpha.10

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 (72) hide show
  1. package/BLOCK_CREATION_CHECKLIST.md +132 -19
  2. package/README.md +10 -4
  3. package/SCSS_VARIABLES_REFERENCE.md +316 -0
  4. package/STYLING_SYNC_GUIDE.md +306 -0
  5. package/TRANSFORMATION_GUIDE.md +286 -13
  6. package/dist/blocks/ad-container/block.json +1 -0
  7. package/dist/blocks/ad-container/render.php +27 -0
  8. package/dist/blocks/ad-container/style.css +23 -20
  9. package/dist/blocks/button/block.json +1 -0
  10. package/dist/blocks/button/render.php +71 -0
  11. package/dist/blocks/button/style-resolved.css +153 -0
  12. package/dist/blocks/button/style.css +138 -18
  13. package/dist/blocks/chip/block.json +1 -0
  14. package/dist/blocks/chip/render.php +40 -0
  15. package/dist/blocks/chip/style.css +68 -29
  16. package/dist/blocks/divider/block.json +1 -0
  17. package/dist/blocks/divider/render.php +31 -0
  18. package/dist/blocks/divider/style.css +25 -13
  19. package/dist/blocks/flag/block.json +1 -0
  20. package/dist/blocks/flag/render.php +34 -0
  21. package/dist/blocks/flag/style.css +39 -30
  22. package/dist/blocks/icon-button/block.json +1 -0
  23. package/dist/blocks/icon-button/render.php +46 -0
  24. package/dist/blocks/icon-button/style.css +21 -22
  25. package/dist/blocks/input/block.json +1 -0
  26. package/dist/blocks/input/render.php +39 -0
  27. package/dist/blocks/input/style.css +40 -17
  28. package/dist/blocks/link/block.json +1 -0
  29. package/dist/blocks/link/render.php +44 -0
  30. package/dist/blocks/link/style.css +87 -34
  31. package/dist/blocks/text/block.json +1 -0
  32. package/dist/blocks/text/render.php +26 -0
  33. package/dist/blocks/text/style.css +5 -18
  34. package/dist/blocks/toast/block.json +1 -0
  35. package/dist/blocks/toast/render.php +37 -0
  36. package/dist/blocks/toast/style.css +50 -34
  37. package/dist/index.cjs +20 -0
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.js +20 -0
  40. package/dist/index.js.map +1 -1
  41. package/package.json +3 -3
  42. package/src/blocks/ad-container/block.json +1 -0
  43. package/src/blocks/ad-container/render.php +27 -0
  44. package/src/blocks/ad-container/style.css +23 -20
  45. package/src/blocks/button/block.json +1 -0
  46. package/src/blocks/button/render.php +71 -0
  47. package/src/blocks/button/style-resolved.css +153 -0
  48. package/src/blocks/button/style.css +138 -18
  49. package/src/blocks/chip/block.json +1 -0
  50. package/src/blocks/chip/render.php +40 -0
  51. package/src/blocks/chip/style.css +68 -29
  52. package/src/blocks/divider/block.json +1 -0
  53. package/src/blocks/divider/render.php +31 -0
  54. package/src/blocks/divider/style.css +25 -13
  55. package/src/blocks/flag/block.json +1 -0
  56. package/src/blocks/flag/render.php +34 -0
  57. package/src/blocks/flag/style.css +39 -30
  58. package/src/blocks/icon-button/block.json +1 -0
  59. package/src/blocks/icon-button/render.php +46 -0
  60. package/src/blocks/icon-button/style.css +21 -22
  61. package/src/blocks/input/block.json +1 -0
  62. package/src/blocks/input/render.php +39 -0
  63. package/src/blocks/input/style.css +40 -17
  64. package/src/blocks/link/block.json +1 -0
  65. package/src/blocks/link/render.php +44 -0
  66. package/src/blocks/link/style.css +87 -34
  67. package/src/blocks/text/block.json +1 -0
  68. package/src/blocks/text/render.php +26 -0
  69. package/src/blocks/text/style.css +5 -18
  70. package/src/blocks/toast/block.json +1 -0
  71. package/src/blocks/toast/render.php +37 -0
  72. package/src/blocks/toast/style.css +50 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@times-design-system/components-wordpress",
3
- "version": "1.2.2-alpha.0+21580795",
3
+ "version": "1.2.2-alpha.10+051fb6da",
4
4
  "type": "module",
5
5
  "description": "Times Design System Gutenberg blocks for WordPress Full Site Editing",
6
6
  "keywords": [
@@ -48,7 +48,7 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@times-design-system/theme-scss": "^2.0.2-alpha.0+21580795",
51
+ "@times-design-system/theme-scss": "^2.0.2-alpha.10+051fb6da",
52
52
  "@wordpress/block-editor": "^12.0.0",
53
53
  "@wordpress/blocks": "^12.0.0",
54
54
  "@wordpress/components": "^25.0.0",
@@ -71,5 +71,5 @@
71
71
  "rollup-plugin-postcss": "^4.0.2",
72
72
  "typescript": "^5.0.0"
73
73
  },
74
- "gitHead": "21580795555c759c56388a9aadd9d21562a9a0d6"
74
+ "gitHead": "051fb6da3c0fa60170996d2351347833827fb9d0"
75
75
  }
@@ -13,6 +13,7 @@
13
13
  "padding": true
14
14
  }
15
15
  },
16
+ "render": "file:./render.php",
16
17
  "attributes": {
17
18
  "type": {
18
19
  "type": "string",
@@ -0,0 +1,27 @@
1
+ <?php
2
+ /**
3
+ * Ad Container Block Render Callback
4
+ *
5
+ * Renders the Ad Container block on the frontend.
6
+ *
7
+ * @package TimesDesignSystem\ComponentsWordPress
8
+ * @var array $attributes Block attributes
9
+ * @var string $content Block content
10
+ * @var WP_Block $block Block instance
11
+ */
12
+
13
+ $type = isset($attributes['type']) ? sanitize_text_field($attributes['type']) : '';
14
+ $slot_id = isset($attributes['slotID']) ? sanitize_text_field($attributes['slotID']) : '';
15
+
16
+ $class_name = 'tds-ad-container';
17
+ if ($type) {
18
+ $class_name .= ' tds-ad-container--' . sanitize_html_class($type);
19
+ }
20
+
21
+ $wrapper_attrs = get_block_wrapper_attributes(['class' => $class_name]);
22
+ ?>
23
+
24
+ <div
25
+ <?php echo wp_kses_post($wrapper_attrs); ?>
26
+ <?php echo $slot_id ? 'data-slot-id="' . esc_attr($slot_id) . '"' : ''; ?>
27
+ ></div>
@@ -1,27 +1,30 @@
1
- /* Ad Container Styles */
2
- .tds-ad-container {
3
- display: block;
4
- min-height: 250px;
5
- background-color: var(--color-fill-secondary);
6
- border: 1px dashed var(--color-border-secondary);
7
- border-radius: var(--border-radius-s);
8
- }
1
+ /* Ad Container Block Frontend Styles */
2
+ /* Using resolved design token values for self-contained styling */
9
3
 
10
- .tds-ad-container--header {
11
- min-height: 90px;
4
+ .tds-ad-container {
5
+ clear: both;
6
+ width: 100%;
7
+ min-height: 283px;
8
+ margin: 18px 0;
9
+ box-sizing: content-box;
10
+ padding: 0 0 8px;
11
+ border-bottom: 2px solid rgb(78, 78, 78);
12
12
  }
13
13
 
14
- .tds-ad-container--inline {
15
- min-height: 250px;
14
+ @media (min-width: 768px) and (max-width: 1023px) {
15
+ .tds-ad-container {
16
+ min-height: 123px;
17
+ }
16
18
  }
17
19
 
18
- .tds-ad-container__placeholder {
20
+ .tds-ad-container--header {
19
21
  display: flex;
20
- align-items: center;
21
- justify-content: center;
22
- width: 100%;
23
- height: 100%;
24
- text-align: center;
25
- color: var(--color-text-secondary);
26
- font: var(--typography-body-small);
22
+ padding-block: 8px 8px;
23
+ margin-left: 0 !important;
24
+ margin-right: 0 !important;
25
+ max-width: 100%;
26
+ border-width: 0 0 2px;
27
+ border-style: solid;
28
+ border-color: #dbdbdb;
29
+ flex-direction: column;
27
30
  }
@@ -16,6 +16,7 @@
16
16
  "customClassName": true
17
17
  },
18
18
  "textdomain": "times-design-system",
19
+ "render": "file:./render.php",
19
20
  "attributes": {
20
21
  "label": {
21
22
  "type": "string",
@@ -0,0 +1,71 @@
1
+ <?php
2
+ /**
3
+ * Button Block Render Callback
4
+ *
5
+ * Renders the Button block on the frontend.
6
+ *
7
+ * @package TimesDesignSystem\ComponentsWordPress
8
+ * @var array $attributes Block attributes
9
+ * @var string $content Block content
10
+ * @var WP_Block $block Block instance
11
+ */
12
+
13
+ $label = isset($attributes['label']) ? sanitize_text_field($attributes['label']) : 'Button label';
14
+ $intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : 'primary';
15
+ $size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : 'large';
16
+ $behaviour = isset($attributes['behaviour']) ? sanitize_text_field($attributes['behaviour']) : 'hug';
17
+ $state = isset($attributes['state']) ? sanitize_text_field($attributes['state']) : 'base';
18
+ $disabled = isset($attributes['disabled']) ? (bool) $attributes['disabled'] : false;
19
+ $href = isset($attributes['href']) ? esc_url($attributes['href']) : '';
20
+ $target = isset($attributes['target']) ? sanitize_text_field($attributes['target']) : '';
21
+ $rel = isset($attributes['rel']) ? sanitize_text_field($attributes['rel']) : '';
22
+ $type = isset($attributes['type']) ? sanitize_text_field($attributes['type']) : 'button';
23
+ $aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
24
+
25
+ // Build button classes
26
+ $classes = ['tds-button'];
27
+ $classes[] = 'tds-button--intent-' . $intent;
28
+ $classes[] = 'tds-button--size-' . $size;
29
+ $classes[] = 'tds-button--behaviour-' . $behaviour;
30
+ $classes[] = 'tds-button--state-' . $state;
31
+ if ($disabled) {
32
+ $classes[] = 'tds-button--disabled';
33
+ }
34
+
35
+ $button_class = implode(' ', $classes);
36
+ $element_tag = $href ? 'a' : 'button';
37
+ $wrapper_attrs = get_block_wrapper_attributes(['class' => 'tds-button-wrapper']);
38
+ ?>
39
+
40
+ <div <?php echo wp_kses_post($wrapper_attrs); ?>>
41
+ <?php
42
+ if ($element_tag === 'a') {
43
+ ?>
44
+ <a
45
+ class="<?php echo esc_attr($button_class); ?>"
46
+ href="<?php echo esc_attr($href); ?>"
47
+ <?php echo $target ? 'target="' . esc_attr($target) . '"' : ''; ?>
48
+ <?php echo $rel ? 'rel="' . esc_attr($rel) . '"' : ''; ?>
49
+ <?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
50
+ >
51
+ <span class="tds-button__label-container">
52
+ <span class="tds-button__label"><?php echo wp_kses_post($label); ?></span>
53
+ </span>
54
+ </a>
55
+ <?php
56
+ } else {
57
+ ?>
58
+ <button
59
+ class="<?php echo esc_attr($button_class); ?>"
60
+ <?php echo $disabled ? 'disabled' : ''; ?>
61
+ type="<?php echo esc_attr($type); ?>"
62
+ <?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
63
+ >
64
+ <span class="tds-button__label-container">
65
+ <span class="tds-button__label"><?php echo wp_kses_post($label); ?></span>
66
+ </span>
67
+ </button>
68
+ <?php
69
+ }
70
+ ?>
71
+ </div>
@@ -0,0 +1,153 @@
1
+ /* Button Block Frontend Styles */
2
+ /* These styles mirror the React Button component styles */
3
+ /* Using resolved design token values for self-contained styling */
4
+
5
+ .tds-button {
6
+ --tds-button-bg: #005c8a;
7
+ --tds-button-fg: #ffffff;
8
+ --tds-button-border: transparent;
9
+ --tds-button-bg-hover: #004e75;
10
+ --tds-button-fg-hover: #ffffff;
11
+ --tds-button-border-hover: transparent;
12
+ --tds-button-bg-pressed: #00496e;
13
+ --tds-button-fg-pressed: #ffffff;
14
+ --tds-button-border-pressed: transparent;
15
+ --tds-button-border-focus: transparent;
16
+ --tds-button-focus-ring: #737373;
17
+ --tds-button-label-inline-padding: 8px;
18
+
19
+ position: relative;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ gap: 4px;
24
+ border-radius: 0;
25
+ border: 1px solid var(--tds-button-border);
26
+ background-color: var(--tds-button-bg);
27
+ color: var(--tds-button-fg);
28
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
29
+ font-weight: 500;
30
+ line-height: 1;
31
+ cursor: pointer;
32
+ text-decoration: none;
33
+ white-space: nowrap;
34
+ transition: 0.15s ease;
35
+ }
36
+
37
+ .tds-button:hover:not(:disabled) {
38
+ background-color: var(--tds-button-bg-hover);
39
+ border-color: var(--tds-button-border-hover);
40
+ color: var(--tds-button-fg-hover);
41
+ }
42
+
43
+ .tds-button:active:not(:disabled) {
44
+ background-color: var(--tds-button-bg-pressed);
45
+ border-color: var(--tds-button-border-pressed);
46
+ color: var(--tds-button-fg-pressed);
47
+ }
48
+
49
+ .tds-button:focus-visible {
50
+ outline: none;
51
+ background-color: var(--tds-button-bg-hover);
52
+ border-color: var(--tds-button-border-focus);
53
+ color: var(--tds-button-fg-hover);
54
+ }
55
+
56
+ .tds-button:focus-visible::after {
57
+ content: '';
58
+ position: absolute;
59
+ inset: -4px;
60
+ border: 2px solid #737373;
61
+ pointer-events: none;
62
+ }
63
+
64
+ .tds-button--loading {
65
+ cursor: wait;
66
+ gap: 0;
67
+ }
68
+
69
+ .tds-button--intent-primary {
70
+ --tds-button-bg: #005c8a;
71
+ --tds-button-fg: #ffffff;
72
+ --tds-button-border: transparent;
73
+ --tds-button-bg-hover: #004e75;
74
+ --tds-button-fg-hover: #ffffff;
75
+ --tds-button-border-hover: transparent;
76
+ --tds-button-bg-pressed: #00496e;
77
+ --tds-button-fg-pressed: #ffffff;
78
+ --tds-button-border-pressed: transparent;
79
+ }
80
+
81
+ .tds-button--intent-secondary {
82
+ --tds-button-bg: #ffffff;
83
+ --tds-button-fg: #1a1a1a;
84
+ --tds-button-border: #8c8c8c;
85
+ --tds-button-bg-hover: #d9d9d9;
86
+ --tds-button-fg-hover: #161616;
87
+ --tds-button-border-hover: #777777;
88
+ --tds-button-bg-pressed: #cccccc;
89
+ --tds-button-fg-pressed: #151515;
90
+ --tds-button-border-pressed: #707070;
91
+ --tds-button-border-focus: #8c8c8c;
92
+ }
93
+
94
+ .tds-button--intent-negative {
95
+ --tds-button-bg: #ffffff;
96
+ --tds-button-fg: #cb0705;
97
+ --tds-button-border: #cb0705;
98
+ --tds-button-bg-hover: #d9d9d9;
99
+ --tds-button-fg-hover: #ad0604;
100
+ --tds-button-border-hover: #ad0604;
101
+ --tds-button-bg-pressed: #cccccc;
102
+ --tds-button-fg-pressed: #a20604;
103
+ --tds-button-border-pressed: #a20604;
104
+ }
105
+
106
+ .tds-button--size-small {
107
+ min-height: 32px;
108
+ padding: 0 12px;
109
+ min-width: 80px;
110
+ font-size: 0.875rem;
111
+ --tds-button-label-inline-padding: 4px;
112
+ }
113
+
114
+ .tds-button--size-medium {
115
+ min-height: 48px;
116
+ min-width: 100px;
117
+ padding: 0 16px;
118
+ font-size: 1rem;
119
+ --tds-button-label-inline-padding: 8px;
120
+ }
121
+
122
+ .tds-button--size-large {
123
+ min-height: 64px;
124
+ min-width: 130px;
125
+ padding: 0 24px;
126
+ font-size: 1.125rem;
127
+ --tds-button-label-inline-padding: 8px;
128
+ }
129
+
130
+ .tds-button--behaviour-hug {
131
+ width: fit-content;
132
+ }
133
+
134
+ .tds-button--behaviour-full {
135
+ width: 100%;
136
+ }
137
+
138
+ .tds-button__label-container {
139
+ display: inline-flex;
140
+ align-items: center;
141
+ justify-content: center;
142
+ flex: 0 0 auto;
143
+ width: fit-content;
144
+ padding: 0 var(--tds-button-label-inline-padding);
145
+ }
146
+
147
+ .tds-button__label {
148
+ display: inline-flex;
149
+ align-items: center;
150
+ justify-content: center;
151
+ flex: 0 0 auto;
152
+ width: fit-content;
153
+ }
@@ -1,37 +1,157 @@
1
1
  /* Button Block Frontend Styles */
2
+ /* These styles mirror the React Button component styles */
3
+ /* Using resolved design token values for self-contained styling */
2
4
 
3
- .tds-button-wrapper {
4
- display: inline-block;
5
- }
5
+ .tds-button {
6
+ --tds-button-bg: #005c8a;
7
+ --tds-button-fg: #ffffff;
8
+ --tds-button-border: transparent;
9
+ --tds-button-bg-hover: #004e75;
10
+ --tds-button-fg-hover: #ffffff;
11
+ --tds-button-border-hover: transparent;
12
+ --tds-button-bg-pressed: #00496e;
13
+ --tds-button-fg-pressed: #ffffff;
14
+ --tds-button-border-pressed: transparent;
15
+ --tds-button-border-focus: transparent;
16
+ --tds-button-focus-ring: #737373;
17
+ --tds-button-label-inline-padding: 8px;
6
18
 
7
- .tds-button-wrapper .tds-button {
8
- /* Styles inherited from @times-design-system/theme-scss package */
9
- /* Import SCSS tokens and component styles as needed */
10
- display: inline-flex;
19
+ position: relative;
20
+ display: flex;
11
21
  align-items: center;
12
22
  justify-content: center;
23
+ gap: 4px;
24
+ border-radius: 0;
25
+ border: 1px solid var(--tds-button-border);
26
+ background-color: var(--tds-button-bg);
27
+ color: var(--tds-button-fg);
28
+ font-family: Roboto;
29
+ font-weight: 500;
30
+ line-height: 1;
13
31
  cursor: pointer;
14
32
  text-decoration: none;
15
- border: none;
16
- border-radius: 0;
17
- font-family: inherit;
18
- font-size: inherit;
19
- transition: all 0.2s ease-in-out;
33
+ white-space: nowrap;
34
+ transition: 0.15s ease;
35
+ }
36
+
37
+ .tds-button:hover:not(:disabled) {
38
+ background-color: var(--tds-button-bg-hover);
39
+ border-color: var(--tds-button-border-hover);
40
+ color: var(--tds-button-fg-hover);
41
+ }
42
+
43
+ .tds-button:active:not(:disabled) {
44
+ background-color: var(--tds-button-bg-pressed);
45
+ border-color: var(--tds-button-border-pressed);
46
+ color: var(--tds-button-fg-pressed);
47
+ }
48
+
49
+ .tds-button:focus-visible {
50
+ outline: none;
51
+ background-color: var(--tds-button-bg-hover);
52
+ border-color: var(--tds-button-border-focus);
53
+ color: var(--tds-button-fg-hover);
54
+ }
55
+
56
+ .tds-button:focus-visible::after {
57
+ content: '';
58
+ position: absolute;
59
+ inset: -4px;
60
+ border: 2px solid #737373;
61
+ pointer-events: none;
62
+ }
63
+
64
+ .tds-button--loading {
65
+ cursor: wait;
66
+ gap: 0;
67
+ }
68
+
69
+ .tds-button--intent-primary {
70
+ --tds-button-bg: #005c8a;
71
+ --tds-button-fg: #ffffff;
72
+ --tds-button-border: transparent;
73
+ --tds-button-bg-hover: #004e75;
74
+ --tds-button-fg-hover: #ffffff;
75
+ --tds-button-border-hover: transparent;
76
+ --tds-button-bg-pressed: #00496e;
77
+ --tds-button-fg-pressed: #ffffff;
78
+ --tds-button-border-pressed: transparent;
79
+ }
80
+
81
+ .tds-button--intent-secondary {
82
+ --tds-button-bg: #ffffff;
83
+ --tds-button-fg: #1a1a1a;
84
+ --tds-button-border: #8c8c8c;
85
+ --tds-button-bg-hover: #d9d9d9;
86
+ --tds-button-fg-hover: #161616;
87
+ --tds-button-border-hover: #777777;
88
+ --tds-button-bg-pressed: #cccccc;
89
+ --tds-button-fg-pressed: #151515;
90
+ --tds-button-border-pressed: #707070;
91
+ --tds-button-border-focus: #8c8c8c;
92
+ }
93
+
94
+ .tds-button--intent-negative {
95
+ --tds-button-bg: #ffffff;
96
+ --tds-button-fg: #cb0705;
97
+ --tds-button-border: #cb0705;
98
+ --tds-button-bg-hover: #d9d9d9;
99
+ --tds-button-fg-hover: #ad0604;
100
+ --tds-button-border-hover: #ad0604;
101
+ --tds-button-bg-pressed: #cccccc;
102
+ --tds-button-fg-pressed: #a20604;
103
+ --tds-button-border-pressed: #a20604;
104
+ }
105
+
106
+ .tds-button--size-small {
107
+ min-height: 32px;
108
+ padding: 0 12px;
109
+ min-width: 80px;
110
+ font-size: 1.4rem;
111
+ --tds-button-label-inline-padding: 4px;
20
112
  }
21
113
 
22
- .tds-button-wrapper .tds-button--behaviour-full {
114
+ .tds-button--size-medium {
115
+ min-height: 48px;
116
+ min-width: 100px;
117
+ padding: 0 16px;
118
+ font-size: 1.6rem;
119
+ --tds-button-label-inline-padding: 8px;
120
+ }
121
+
122
+ .tds-button--size-large {
123
+ min-height: 64px;
124
+ min-width: 130px;
125
+ padding: 0 24px;
126
+ font-size: 1.8rem;
127
+ --tds-button-label-inline-padding: 8px;
128
+ }
129
+
130
+ .tds-button--behaviour-hug {
131
+ width: fit-content;
132
+ }
133
+
134
+ .tds-button--behaviour-full {
23
135
  width: 100%;
24
136
  }
25
137
 
26
- .tds-button-wrapper .tds-button:disabled {
27
- cursor: not-allowed;
28
- opacity: 0.5;
138
+ .tds-button-wrapper {
139
+ display: inline-block;
29
140
  }
30
141
 
31
142
  .tds-button__label-container {
32
- display: inline;
143
+ display: inline-flex;
144
+ align-items: center;
145
+ justify-content: center;
146
+ flex: 0 0 auto;
147
+ width: fit-content;
148
+ padding: 0 var(--tds-button-label-inline-padding);
33
149
  }
34
150
 
35
151
  .tds-button__label {
36
- display: inline;
152
+ display: inline-flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ flex: 0 0 auto;
156
+ width: fit-content;
37
157
  }
@@ -12,6 +12,7 @@
12
12
  "margin": true
13
13
  }
14
14
  },
15
+ "render": "file:./render.php",
15
16
  "attributes": {
16
17
  "content": {
17
18
  "type": "string",
@@ -0,0 +1,40 @@
1
+ <?php
2
+ /**
3
+ * Chip Block Render Callback
4
+ *
5
+ * Renders the Chip block on the frontend.
6
+ *
7
+ * @package TimesDesignSystem\ComponentsWordPress
8
+ * @var array $attributes Block attributes
9
+ * @var string $content Block content
10
+ * @var WP_Block $block Block instance
11
+ */
12
+
13
+ $content_text = isset($attributes['content']) ? wp_kses_post($attributes['content']) : '';
14
+ $intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : '';
15
+ $size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : '';
16
+ $state = isset($attributes['state']) ? sanitize_text_field($attributes['state']) : '';
17
+ $channel = isset($attributes['channel']) ? (bool) $attributes['channel'] : false;
18
+ $toggle = isset($attributes['toggle']) ? (bool) $attributes['toggle'] : false;
19
+ $aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
20
+
21
+ $classes = ['tds-chip'];
22
+ $classes[] = 'tds-chip--intent-' . $intent;
23
+ $classes[] = 'tds-chip--size-' . $size;
24
+ $classes[] = 'tds-chip--state-' . $state;
25
+ if ($channel) {
26
+ $classes[] = 'tds-chip--channel';
27
+ }
28
+ if ($toggle) {
29
+ $classes[] = 'tds-chip--toggle';
30
+ }
31
+
32
+ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
33
+ ?>
34
+
35
+ <button
36
+ <?php echo wp_kses_post($wrapper_attrs); ?>
37
+ <?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
38
+ >
39
+ <span class="tds-chip__content"><?php echo wp_kses_post($content_text); ?></span>
40
+ </button>
@@ -1,48 +1,87 @@
1
- /* Chip Block Styles */
1
+ /* Chip Block Frontend Styles */
2
+ /* Using resolved design token values for self-contained styling */
3
+
2
4
  .tds-chip {
5
+ --tds-chip-bg: #005c8a;
6
+ --tds-chip-bg-hover: #004e75;
7
+ --tds-chip-bg-pressed: #00496e;
8
+ --tds-chip-fg: #ffffff;
9
+ --tds-chip-fg-hover: #d9d9d9;
10
+ --tds-chip-fg-pressed: #cccccc;
11
+ --tds-chip-icon: #ffffff;
12
+ --tds-chip-icon-hover: #d9d9d9;
13
+ --tds-chip-icon-pressed: #cccccc;
14
+ --tds-chip-border: transparent;
15
+ --tds-chip-border-hover: transparent;
16
+ --tds-chip-border-pressed: transparent;
17
+ --tds-chip-focus-ring: #737373;
18
+
19
+ position: relative;
3
20
  display: inline-flex;
4
21
  align-items: center;
5
- gap: var(--spacing-xs);
6
- padding: var(--spacing-xs) var(--spacing-m);
7
- border: 1px solid var(--color-border-secondary);
8
- border-radius: 16px;
9
- background-color: var(--color-fill-secondary);
10
- color: var(--color-text-primary);
11
- font: var(--typography-body-small);
22
+ justify-content: center;
23
+ gap: 4px;
24
+ border: 1px solid var(--tds-chip-border);
25
+ border-radius: 9999px;
26
+ background-color: var(--tds-chip-bg);
27
+ color: var(--tds-chip-fg);
28
+ font-family: Roboto;
29
+ font-weight: 500;
30
+ line-height: 1;
31
+ white-space: nowrap;
12
32
  cursor: pointer;
13
- transition: all 0.2s ease-in-out;
33
+ transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
14
34
  }
15
35
 
16
- .tds-chip--intent-primary {
17
- background-color: var(--color-fill-primary);
18
- border-color: var(--color-border-primary);
36
+ .tds-chip:hover:not(:disabled) {
37
+ background-color: var(--tds-chip-bg-hover);
38
+ border-color: var(--tds-chip-border-hover);
39
+ color: var(--tds-chip-fg-hover);
19
40
  }
20
41
 
21
- .tds-chip--intent-negative {
22
- background-color: var(--color-fill-negative);
23
- border-color: var(--color-border-negative);
42
+ .tds-chip:active:not(:disabled) {
43
+ background-color: var(--tds-chip-bg-pressed);
44
+ border-color: var(--tds-chip-border-pressed);
45
+ color: var(--tds-chip-fg-pressed);
24
46
  }
25
47
 
26
- .tds-chip--size-small {
27
- padding: var(--spacing-xs) var(--spacing-s);
28
- font-size: 12px;
48
+ .tds-chip:focus-visible {
49
+ outline: none;
50
+ background-color: var(--tds-chip-bg-hover);
51
+ border-color: var(--tds-chip-border-hover);
52
+ color: var(--tds-chip-fg-hover);
29
53
  }
30
54
 
31
- .tds-chip--size-large {
32
- padding: var(--spacing-s) var(--spacing-m);
33
- font-size: 16px;
55
+ .tds-chip:focus-visible::after {
56
+ content: '';
57
+ position: absolute;
58
+ inset: -4px;
59
+ border: 2px solid #737373;
60
+ border-radius: inherit;
61
+ pointer-events: none;
34
62
  }
35
63
 
36
- .tds-chip--state-hover {
37
- opacity: 0.8;
64
+ .tds-chip:disabled {
65
+ background-color: #bfbfbf;
66
+ border-color: transparent;
67
+ color: #d9d9d9;
68
+ cursor: not-allowed;
38
69
  }
39
70
 
40
- .tds-chip--state-disabled {
41
- opacity: 0.5;
42
- cursor: not-allowed;
71
+ .tds-chip--size-small {
72
+ min-height: 32px;
73
+ padding: 0 12px;
74
+ font-size: 1.4rem;
75
+ }
76
+
77
+ .tds-chip--size-large {
78
+ min-height: 48px;
79
+ padding: 0 16px;
80
+ font-size: 1.6rem;
43
81
  }
44
82
 
45
- .tds-chip__icon-left,
46
- .tds-chip__icon-right {
47
- font-size: 14px;
83
+ .tds-chip__content {
84
+ display: inline-flex;
85
+ align-items: center;
86
+ justify-content: center;
48
87
  }