@times-design-system/components-wordpress 1.5.3 → 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.
Files changed (175) hide show
  1. package/dist/blocks/ad-container/block.json +10 -0
  2. package/dist/blocks/ad-container/edit.js +17 -1
  3. package/dist/blocks/ad-container/render.php +14 -0
  4. package/dist/blocks/button/block.json +19 -5
  5. package/dist/blocks/button/edit.js +33 -15
  6. package/dist/blocks/button/render.php +24 -2
  7. package/dist/blocks/button/style.css +63 -0
  8. package/dist/blocks/chip/block.json +12 -7
  9. package/dist/blocks/chip/edit.js +20 -17
  10. package/dist/blocks/chip/render.php +14 -2
  11. package/dist/blocks/dialog-box/block.json +10 -0
  12. package/dist/blocks/dialog-box/edit.js +17 -0
  13. package/dist/blocks/dialog-box/render.php +16 -4
  14. package/dist/blocks/divider/block.json +10 -0
  15. package/dist/blocks/divider/edit.js +18 -2
  16. package/dist/blocks/divider/render.php +14 -1
  17. package/dist/blocks/flag/block.json +10 -0
  18. package/dist/blocks/flag/edit.js +27 -2
  19. package/dist/blocks/flag/render.php +14 -0
  20. package/dist/blocks/icon/block.json +10 -0
  21. package/dist/blocks/icon/edit.js +17 -0
  22. package/dist/blocks/icon/render.php +16 -4
  23. package/dist/blocks/icon-button/block.json +15 -0
  24. package/dist/blocks/icon-button/edit.js +33 -1
  25. package/dist/blocks/icon-button/render.php +19 -0
  26. package/dist/blocks/icon-button/style.css +37 -3
  27. package/dist/blocks/input/block.json +10 -0
  28. package/dist/blocks/input/edit.js +27 -1
  29. package/dist/blocks/input/render.php +17 -1
  30. package/dist/blocks/input-helper-message/block.json +10 -0
  31. package/dist/blocks/input-helper-message/edit.js +17 -0
  32. package/dist/blocks/input-helper-message/render.php +16 -4
  33. package/dist/blocks/link/block.json +12 -7
  34. package/dist/blocks/link/edit.js +21 -18
  35. package/dist/blocks/link/render.php +14 -2
  36. package/dist/blocks/tab/block.json +10 -0
  37. package/dist/blocks/tab/edit.js +17 -0
  38. package/dist/blocks/tab/render.php +16 -4
  39. package/dist/blocks/tab-group/block.json +10 -0
  40. package/dist/blocks/tab-group/edit.js +17 -0
  41. package/dist/blocks/tab-group/render.php +16 -4
  42. package/dist/blocks/text/block.json +10 -0
  43. package/dist/blocks/text/edit.js +18 -2
  44. package/dist/blocks/text/render.php +14 -1
  45. package/dist/blocks/toast/block.json +10 -0
  46. package/dist/blocks/toast/edit.js +18 -1
  47. package/dist/blocks/toast/render.php +14 -0
  48. package/dist/index.cjs +389 -148
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.js +389 -148
  51. package/dist/index.js.map +1 -1
  52. package/dist/utils/DATA_ATTRIBUTES_USAGE.md +377 -0
  53. package/dist/utils/sanitize-data-attributes.php +109 -0
  54. package/package.json +9 -3
  55. package/BLOCK_CREATION_CHECKLIST.md +0 -385
  56. package/BUILD.md +0 -411
  57. package/CHANGELOG.md +0 -85
  58. package/SCSS_VARIABLES_REFERENCE.md +0 -316
  59. package/STYLING_SYNC_GUIDE.md +0 -306
  60. package/TESTING.md +0 -152
  61. package/TRANSFORMATION_GUIDE.md +0 -908
  62. package/dist/blocks/button/style-resolved.css +0 -153
  63. package/lib/wordpress.js +0 -7
  64. package/rollup.config.js +0 -75
  65. package/scripts/build-plugin.cjs +0 -121
  66. package/scripts/create-block.sh +0 -141
  67. package/scripts/create-wordpress-block-tests.cjs +0 -438
  68. package/scripts/create-wordpress-block.cjs +0 -681
  69. package/src/blocks/ad-container/block.json +0 -29
  70. package/src/blocks/ad-container/edit.js +0 -42
  71. package/src/blocks/ad-container/index.js +0 -10
  72. package/src/blocks/ad-container/render.php +0 -27
  73. package/src/blocks/ad-container/save.js +0 -16
  74. package/src/blocks/ad-container/style-editor.css +0 -4
  75. package/src/blocks/ad-container/style.css +0 -30
  76. package/src/blocks/button/block.json +0 -90
  77. package/src/blocks/button/edit.js +0 -187
  78. package/src/blocks/button/index.js +0 -11
  79. package/src/blocks/button/render.php +0 -71
  80. package/src/blocks/button/save.js +0 -52
  81. package/src/blocks/button/style-editor.css +0 -15
  82. package/src/blocks/button/style-resolved.css +0 -153
  83. package/src/blocks/button/style.css +0 -157
  84. package/src/blocks/chip/block.json +0 -58
  85. package/src/blocks/chip/edit.js +0 -113
  86. package/src/blocks/chip/index.js +0 -10
  87. package/src/blocks/chip/render.php +0 -40
  88. package/src/blocks/chip/save.js +0 -36
  89. package/src/blocks/chip/style-editor.css +0 -5
  90. package/src/blocks/chip/style.css +0 -87
  91. package/src/blocks/dialog-box/block.json +0 -24
  92. package/src/blocks/dialog-box/edit.js +0 -41
  93. package/src/blocks/dialog-box/index.js +0 -17
  94. package/src/blocks/dialog-box/render.php +0 -24
  95. package/src/blocks/dialog-box/save.js +0 -23
  96. package/src/blocks/dialog-box/style.css +0 -23
  97. package/src/blocks/divider/block.json +0 -32
  98. package/src/blocks/divider/edit.js +0 -42
  99. package/src/blocks/divider/index.js +0 -10
  100. package/src/blocks/divider/render.php +0 -31
  101. package/src/blocks/divider/save.js +0 -18
  102. package/src/blocks/divider/style-editor.css +0 -4
  103. package/src/blocks/divider/style.css +0 -37
  104. package/src/blocks/flag/block.json +0 -49
  105. package/src/blocks/flag/edit.js +0 -82
  106. package/src/blocks/flag/index.js +0 -10
  107. package/src/blocks/flag/render.php +0 -34
  108. package/src/blocks/flag/save.js +0 -25
  109. package/src/blocks/flag/style-editor.css +0 -5
  110. package/src/blocks/flag/style.css +0 -54
  111. package/src/blocks/icon/block.json +0 -24
  112. package/src/blocks/icon/edit.js +0 -41
  113. package/src/blocks/icon/index.js +0 -17
  114. package/src/blocks/icon/render.php +0 -24
  115. package/src/blocks/icon/save.js +0 -23
  116. package/src/blocks/icon/style.css +0 -23
  117. package/src/blocks/icon-button/block.json +0 -44
  118. package/src/blocks/icon-button/edit.js +0 -82
  119. package/src/blocks/icon-button/index.js +0 -10
  120. package/src/blocks/icon-button/render.php +0 -46
  121. package/src/blocks/icon-button/save.js +0 -29
  122. package/src/blocks/icon-button/style-editor.css +0 -5
  123. package/src/blocks/icon-button/style.css +0 -31
  124. package/src/blocks/input/block.json +0 -48
  125. package/src/blocks/input/edit.js +0 -78
  126. package/src/blocks/input/index.js +0 -10
  127. package/src/blocks/input/render.php +0 -39
  128. package/src/blocks/input/save.js +0 -27
  129. package/src/blocks/input/style-editor.css +0 -8
  130. package/src/blocks/input/style.css +0 -53
  131. package/src/blocks/input-helper-message/block.json +0 -24
  132. package/src/blocks/input-helper-message/edit.js +0 -42
  133. package/src/blocks/input-helper-message/index.js +0 -17
  134. package/src/blocks/input-helper-message/render.php +0 -24
  135. package/src/blocks/input-helper-message/save.js +0 -23
  136. package/src/blocks/input-helper-message/style.css +0 -23
  137. package/src/blocks/link/block.json +0 -72
  138. package/src/blocks/link/edit.js +0 -151
  139. package/src/blocks/link/index.js +0 -10
  140. package/src/blocks/link/render.php +0 -44
  141. package/src/blocks/link/save.js +0 -46
  142. package/src/blocks/link/style-editor.css +0 -5
  143. package/src/blocks/link/style.css +0 -119
  144. package/src/blocks/tab/block.json +0 -24
  145. package/src/blocks/tab/edit.js +0 -41
  146. package/src/blocks/tab/index.js +0 -17
  147. package/src/blocks/tab/render.php +0 -24
  148. package/src/blocks/tab/save.js +0 -23
  149. package/src/blocks/tab/style.css +0 -23
  150. package/src/blocks/tab-group/block.json +0 -24
  151. package/src/blocks/tab-group/edit.js +0 -41
  152. package/src/blocks/tab-group/index.js +0 -17
  153. package/src/blocks/tab-group/render.php +0 -24
  154. package/src/blocks/tab-group/save.js +0 -23
  155. package/src/blocks/tab-group/style.css +0 -23
  156. package/src/blocks/text/block.json +0 -33
  157. package/src/blocks/text/edit.js +0 -56
  158. package/src/blocks/text/index.js +0 -10
  159. package/src/blocks/text/render.php +0 -26
  160. package/src/blocks/text/save.js +0 -18
  161. package/src/blocks/text/style-editor.css +0 -4
  162. package/src/blocks/text/style.css +0 -7
  163. package/src/blocks/toast/block.json +0 -40
  164. package/src/blocks/toast/edit.js +0 -85
  165. package/src/blocks/toast/index.js +0 -10
  166. package/src/blocks/toast/render.php +0 -37
  167. package/src/blocks/toast/save.js +0 -29
  168. package/src/blocks/toast/style-editor.css +0 -4
  169. package/src/blocks/toast/style.css +0 -67
  170. package/src/index.js +0 -16
  171. package/src/utils/classBuilder.js +0 -53
  172. package/tsconfig.json +0 -116
  173. package/vitest.config.js +0 -28
  174. package/vitest.config.ts +0 -28
  175. package/vitest.setup.ts +0 -129
@@ -1,42 +0,0 @@
1
- import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
2
- import { PanelBody, SelectControl, TextControl } from '@wordpress/components';
3
-
4
- const edit = ({ attributes, setAttributes }) => {
5
- const { type, slotID } = attributes;
6
- const blockProps = useBlockProps();
7
-
8
- return (
9
- <>
10
- <InspectorControls>
11
- <PanelBody title="Ad Container Settings">
12
- <SelectControl
13
- label="Type"
14
- value={type}
15
- options={[
16
- { label: 'Header', value: 'header' },
17
- { label: 'Inline', value: 'inline' }
18
- ]}
19
- onChange={(val) => setAttributes({ type: val })}
20
- />
21
- <TextControl
22
- label="Slot ID"
23
- value={slotID}
24
- onChange={(val) => setAttributes({ slotID: val })}
25
- placeholder="e.g., /123456789/section/article-top"
26
- />
27
- </PanelBody>
28
- </InspectorControls>
29
- <div
30
- {...blockProps}
31
- className={`tds-ad-container tds-ad-container--${type}`}
32
- data-slot-id={slotID}
33
- >
34
- <div className="tds-ad-container__placeholder">
35
- <p>Ad Slot: {slotID || '(not configured)'}</p>
36
- </div>
37
- </div>
38
- </>
39
- );
40
- };
41
-
42
- export default edit;
@@ -1,10 +0,0 @@
1
- import { registerBlockType } from '@wordpress/blocks';
2
- import metadata from './block.json';
3
- import edit from './edit';
4
- import save from './save';
5
-
6
- registerBlockType(metadata.name, {
7
- ...metadata,
8
- edit,
9
- save
10
- });
@@ -1,27 +0,0 @@
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,16 +0,0 @@
1
- import { useBlockProps } from '@wordpress/block-editor';
2
-
3
- const save = ({ attributes }) => {
4
- const { type, slotID } = attributes;
5
- const blockProps = useBlockProps.save();
6
-
7
- return (
8
- <div
9
- {...blockProps}
10
- className={`tds-ad-container tds-ad-container--${type}`}
11
- data-slot-id={slotID}
12
- />
13
- );
14
- };
15
-
16
- export default save;
@@ -1,4 +0,0 @@
1
- /* Ad Container Editor Styles */
2
- .wp-block-times-ad-container {
3
- margin: var(--spacing-m) 0;
4
- }
@@ -1,30 +0,0 @@
1
- /* Ad Container Block Frontend Styles */
2
- /* Using resolved design token values for self-contained styling */
3
-
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
- }
13
-
14
- @media (min-width: 768px) and (max-width: 1023px) {
15
- .tds-ad-container {
16
- min-height: 123px;
17
- }
18
- }
19
-
20
- .tds-ad-container--header {
21
- display: flex;
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;
30
- }
@@ -1,90 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 3,
4
- "name": "tds/button",
5
- "title": "Button",
6
- "category": "common",
7
- "description": "A customizable button component for user interactions",
8
- "icon": "admin-generic",
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": "Button label",
24
- "description": "The text label displayed inside the button"
25
- },
26
- "intent": {
27
- "type": "string",
28
- "enum": ["primary", "secondary", "negative"],
29
- "default": "primary",
30
- "description": "Visual style variant"
31
- },
32
- "size": {
33
- "type": "string",
34
- "enum": ["small", "medium", "large"],
35
- "default": "large",
36
- "description": "Controls the overall dimensions of the button"
37
- },
38
- "behaviour": {
39
- "type": "string",
40
- "enum": ["hug", "full"],
41
- "default": "hug",
42
- "description": "Controls the width behaviour"
43
- },
44
- "state": {
45
- "type": "string",
46
- "enum": ["base", "hover", "pressed", "loading", "disabled", "focus"],
47
- "default": "base",
48
- "description": "The interaction state"
49
- },
50
- "disabled": {
51
- "type": "boolean",
52
- "default": false,
53
- "description": "Whether the button is disabled"
54
- },
55
- "href": {
56
- "type": "string",
57
- "description": "Optional href to render as a link"
58
- },
59
- "target": {
60
- "type": "string",
61
- "enum": ["_blank", "_self", "_parent", "_top"],
62
- "description": "Optional target attribute for links"
63
- },
64
- "rel": {
65
- "type": "string",
66
- "description": "Optional rel attribute for links"
67
- },
68
- "type": {
69
- "type": "string",
70
- "enum": ["button", "submit", "reset"],
71
- "default": "button",
72
- "description": "Button type"
73
- },
74
- "iconLeft": {
75
- "type": "string",
76
- "description": "Icon name to display on the left side of the label"
77
- },
78
- "iconRight": {
79
- "type": "string",
80
- "description": "Icon name to display on the right side of the label"
81
- },
82
- "ariaLabel": {
83
- "type": "string",
84
- "description": "Accessible name for icon-only buttons"
85
- }
86
- },
87
- "editorScript": "file:./index.js",
88
- "editorStyle": "file:./style-editor.css",
89
- "style": "file:./style.css"
90
- }
@@ -1,187 +0,0 @@
1
- import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
2
- import {
3
- PanelBody,
4
- SelectControl,
5
- TextControl,
6
- ToggleControl
7
- } from '@wordpress/components';
8
- import { RichText } from '@wordpress/block-editor';
9
- import { buildButtonClass } from '../../utils/classBuilder.js';
10
- import './style-editor.css';
11
-
12
- export default function Edit({ attributes, setAttributes }) {
13
- const {
14
- label,
15
- intent,
16
- size,
17
- behaviour,
18
- state,
19
- disabled,
20
- href,
21
- target,
22
- rel,
23
- type,
24
- iconLeft,
25
- iconRight,
26
- ariaLabel
27
- } = attributes;
28
-
29
- const blockProps = useBlockProps({
30
- className: 'tds-button-wrapper'
31
- });
32
-
33
- const buttonClass = buildButtonClass({
34
- intent,
35
- size,
36
- behaviour,
37
- state,
38
- disabled
39
- });
40
-
41
- const Element = href ? 'a' : 'button';
42
-
43
- return (
44
- <>
45
- <div {...blockProps}>
46
- <Element
47
- className={buttonClass}
48
- disabled={!href && disabled}
49
- href={href}
50
- target={target}
51
- rel={rel}
52
- type={!href ? type : undefined}
53
- aria-label={ariaLabel}
54
- >
55
- <span className="tds-button__label-container">
56
- <span className="tds-button__label">{label}</span>
57
- </span>
58
- </Element>
59
- </div>
60
-
61
- <InspectorControls>
62
- <PanelBody title="Button Settings">
63
- <TextControl
64
- label="Label"
65
- value={label}
66
- onChange={(value) => setAttributes({ label: value })}
67
- help="The text displayed inside the button"
68
- />
69
-
70
- <SelectControl
71
- label="Intent (Style)"
72
- value={intent}
73
- options={[
74
- { label: 'Primary', value: 'primary' },
75
- { label: 'Secondary', value: 'secondary' },
76
- { label: 'Negative', value: 'negative' }
77
- ]}
78
- onChange={(value) => setAttributes({ intent: value })}
79
- />
80
-
81
- <SelectControl
82
- label="Size"
83
- value={size}
84
- options={[
85
- { label: 'Small', value: 'small' },
86
- { label: 'Medium', value: 'medium' },
87
- { label: 'Large', value: 'large' }
88
- ]}
89
- onChange={(value) => setAttributes({ size: value })}
90
- />
91
-
92
- <SelectControl
93
- label="Behaviour"
94
- value={behaviour}
95
- options={[
96
- { label: 'Hug Content', value: 'hug' },
97
- { label: 'Full Width', value: 'full' }
98
- ]}
99
- onChange={(value) => setAttributes({ behaviour: value })}
100
- />
101
-
102
- <SelectControl
103
- label="State"
104
- value={state}
105
- options={[
106
- { label: 'Base', value: 'base' },
107
- { label: 'Hover', value: 'hover' },
108
- { label: 'Pressed', value: 'pressed' },
109
- { label: 'Loading', value: 'loading' },
110
- { label: 'Disabled', value: 'disabled' },
111
- { label: 'Focus', value: 'focus' }
112
- ]}
113
- onChange={(value) => setAttributes({ state: value })}
114
- />
115
-
116
- <ToggleControl
117
- label="Disabled"
118
- checked={disabled}
119
- onChange={(value) => setAttributes({ disabled: value })}
120
- />
121
- </PanelBody>
122
-
123
- <PanelBody title="Link Settings" initialOpen={false}>
124
- <TextControl
125
- label="URL"
126
- value={href}
127
- onChange={(value) => setAttributes({ href: value })}
128
- placeholder="https://example.com"
129
- />
130
-
131
- <SelectControl
132
- label="Link Target"
133
- value={target}
134
- options={[
135
- { label: 'Same Window', value: '_self' },
136
- { label: 'New Window', value: '_blank' },
137
- { label: 'Parent Window', value: '_parent' },
138
- { label: 'Top Window', value: '_top' }
139
- ]}
140
- onChange={(value) => setAttributes({ target: value })}
141
- />
142
-
143
- <TextControl
144
- label="Link Rel"
145
- value={rel}
146
- onChange={(value) => setAttributes({ rel: value })}
147
- placeholder="noopener noreferrer"
148
- />
149
- </PanelBody>
150
-
151
- <PanelBody title="Advanced" initialOpen={false}>
152
- <SelectControl
153
- label="Button Type"
154
- value={type}
155
- options={[
156
- { label: 'Button', value: 'button' },
157
- { label: 'Submit', value: 'submit' },
158
- { label: 'Reset', value: 'reset' }
159
- ]}
160
- onChange={(value) => setAttributes({ type: value })}
161
- />
162
-
163
- <TextControl
164
- label="Aria Label"
165
- value={ariaLabel}
166
- onChange={(value) => setAttributes({ ariaLabel: value })}
167
- help="Accessible name for icon-only buttons"
168
- />
169
-
170
- <TextControl
171
- label="Icon Left"
172
- value={iconLeft}
173
- onChange={(value) => setAttributes({ iconLeft: value })}
174
- placeholder="Icon name"
175
- />
176
-
177
- <TextControl
178
- label="Icon Right"
179
- value={iconRight}
180
- onChange={(value) => setAttributes({ iconRight: value })}
181
- placeholder="Icon name"
182
- />
183
- </PanelBody>
184
- </InspectorControls>
185
- </>
186
- );
187
- }
@@ -1,11 +0,0 @@
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
- });
@@ -1,71 +0,0 @@
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>
@@ -1,52 +0,0 @@
1
- import { useBlockProps } from '@wordpress/block-editor';
2
- import { buildButtonClass } from '../../utils/classBuilder.js';
3
-
4
- export default function Save({ attributes }) {
5
- const {
6
- label,
7
- intent,
8
- size,
9
- behaviour,
10
- state,
11
- disabled,
12
- href,
13
- target,
14
- rel,
15
- type,
16
- iconLeft,
17
- iconRight,
18
- ariaLabel
19
- } = attributes;
20
-
21
- const blockProps = useBlockProps.save({
22
- className: 'tds-button-wrapper'
23
- });
24
-
25
- const buttonClass = buildButtonClass({
26
- intent,
27
- size,
28
- behaviour,
29
- state,
30
- disabled
31
- });
32
-
33
- const Element = href ? 'a' : 'button';
34
-
35
- return (
36
- <div {...blockProps}>
37
- <Element
38
- className={buttonClass}
39
- disabled={!href && disabled}
40
- href={href}
41
- target={target}
42
- rel={rel}
43
- type={!href ? type : undefined}
44
- aria-label={ariaLabel}
45
- >
46
- <span className="tds-button__label-container">
47
- <span className="tds-button__label">{label}</span>
48
- </span>
49
- </Element>
50
- </div>
51
- );
52
- }
@@ -1,15 +0,0 @@
1
- /* Button Block Editor Styles */
2
-
3
- .tds-button-wrapper {
4
- margin-bottom: 1rem;
5
- }
6
-
7
- .tds-button-wrapper .tds-button {
8
- /* Styles inherited from theme-scss package */
9
- /* This file can be extended with editor-specific overrides */
10
- }
11
-
12
- /* Inspector Controls Styling */
13
- .block-editor .components-panel {
14
- /* WordPress will handle component styling */
15
- }