@times-design-system/components-wordpress 0.4.0 → 1.2.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 (189) hide show
  1. package/BLOCK_CREATION_CHECKLIST.md +160 -0
  2. package/BUILD.md +411 -0
  3. package/CHANGELOG.md +32 -0
  4. package/LICENSE +29 -0
  5. package/README.md +972 -5
  6. package/TRANSFORMATION_GUIDE.md +635 -0
  7. package/block.json +10 -0
  8. package/dist/block.json +10 -0
  9. package/dist/blocks/ad-container/block.json +28 -0
  10. package/dist/blocks/ad-container/edit.js +42 -0
  11. package/dist/blocks/ad-container/index.js +10 -0
  12. package/dist/blocks/ad-container/save.js +16 -0
  13. package/dist/blocks/ad-container/style-editor.css +4 -0
  14. package/dist/blocks/ad-container/style.css +27 -0
  15. package/dist/blocks/button/block.json +89 -0
  16. package/dist/blocks/button/edit.js +187 -0
  17. package/dist/blocks/button/index.js +11 -0
  18. package/dist/blocks/button/save.js +52 -0
  19. package/dist/blocks/button/style-editor.css +15 -0
  20. package/dist/blocks/button/style.css +37 -0
  21. package/dist/blocks/chip/block.json +57 -0
  22. package/dist/blocks/chip/edit.js +113 -0
  23. package/dist/blocks/chip/index.js +10 -0
  24. package/dist/blocks/chip/save.js +36 -0
  25. package/dist/blocks/chip/style-editor.css +5 -0
  26. package/dist/blocks/chip/style.css +48 -0
  27. package/dist/blocks/divider/block.json +31 -0
  28. package/dist/blocks/divider/edit.js +42 -0
  29. package/dist/blocks/divider/index.js +10 -0
  30. package/dist/blocks/divider/save.js +18 -0
  31. package/dist/blocks/divider/style-editor.css +4 -0
  32. package/dist/blocks/divider/style.css +25 -0
  33. package/dist/blocks/flag/block.json +48 -0
  34. package/dist/blocks/flag/edit.js +82 -0
  35. package/dist/blocks/flag/index.js +10 -0
  36. package/dist/blocks/flag/save.js +25 -0
  37. package/dist/blocks/flag/style-editor.css +5 -0
  38. package/dist/blocks/flag/style.css +45 -0
  39. package/dist/blocks/icon-button/block.json +43 -0
  40. package/dist/blocks/icon-button/edit.js +82 -0
  41. package/dist/blocks/icon-button/index.js +10 -0
  42. package/dist/blocks/icon-button/save.js +29 -0
  43. package/dist/blocks/icon-button/style-editor.css +5 -0
  44. package/dist/blocks/icon-button/style.css +32 -0
  45. package/dist/blocks/input/block.json +47 -0
  46. package/dist/blocks/input/edit.js +78 -0
  47. package/dist/blocks/input/index.js +10 -0
  48. package/dist/blocks/input/save.js +27 -0
  49. package/dist/blocks/input/style-editor.css +8 -0
  50. package/dist/blocks/input/style.css +30 -0
  51. package/dist/blocks/link/block.json +71 -0
  52. package/dist/blocks/link/edit.js +151 -0
  53. package/dist/blocks/link/index.js +10 -0
  54. package/dist/blocks/link/save.js +46 -0
  55. package/dist/blocks/link/style-editor.css +5 -0
  56. package/dist/blocks/link/style.css +66 -0
  57. package/dist/blocks/text/block.json +32 -0
  58. package/dist/blocks/text/edit.js +56 -0
  59. package/dist/blocks/text/index.js +10 -0
  60. package/dist/blocks/text/save.js +18 -0
  61. package/dist/blocks/text/style-editor.css +4 -0
  62. package/dist/blocks/text/style.css +20 -0
  63. package/dist/blocks/toast/block.json +39 -0
  64. package/dist/blocks/toast/edit.js +85 -0
  65. package/dist/blocks/toast/index.js +10 -0
  66. package/dist/blocks/toast/save.js +29 -0
  67. package/dist/blocks/toast/style-editor.css +4 -0
  68. package/dist/blocks/toast/style.css +51 -0
  69. package/dist/index.cjs +2232 -0
  70. package/dist/index.cjs.map +1 -0
  71. package/dist/index.css +2 -0
  72. package/dist/index.css.map +1 -0
  73. package/dist/index.js +2196 -255
  74. package/dist/index.js.map +1 -1
  75. package/dist/plugin.php +79 -0
  76. package/dist/utils/classBuilder.js +53 -0
  77. package/package.json +39 -7
  78. package/plugin.php +79 -0
  79. package/rollup.config.js +39 -22
  80. package/scripts/build-plugin.cjs +121 -0
  81. package/scripts/create-block.sh +141 -0
  82. package/src/blocks/ad-container/block.json +28 -0
  83. package/src/blocks/ad-container/edit.js +42 -0
  84. package/src/blocks/ad-container/index.js +10 -0
  85. package/src/blocks/ad-container/save.js +16 -0
  86. package/src/blocks/ad-container/style-editor.css +4 -0
  87. package/src/blocks/ad-container/style.css +27 -0
  88. package/src/blocks/button/block.json +89 -0
  89. package/src/blocks/button/edit.js +187 -0
  90. package/src/blocks/button/index.js +11 -0
  91. package/src/blocks/button/save.js +52 -0
  92. package/src/blocks/button/style-editor.css +15 -0
  93. package/src/blocks/button/style.css +37 -0
  94. package/src/blocks/chip/block.json +57 -0
  95. package/src/blocks/chip/edit.js +113 -0
  96. package/src/blocks/chip/index.js +10 -0
  97. package/src/blocks/chip/save.js +36 -0
  98. package/src/blocks/chip/style-editor.css +5 -0
  99. package/src/blocks/chip/style.css +48 -0
  100. package/src/blocks/divider/block.json +31 -0
  101. package/src/blocks/divider/edit.js +42 -0
  102. package/src/blocks/divider/index.js +10 -0
  103. package/src/blocks/divider/save.js +18 -0
  104. package/src/blocks/divider/style-editor.css +4 -0
  105. package/src/blocks/divider/style.css +25 -0
  106. package/src/blocks/flag/block.json +48 -0
  107. package/src/blocks/flag/edit.js +82 -0
  108. package/src/blocks/flag/index.js +10 -0
  109. package/src/blocks/flag/save.js +25 -0
  110. package/src/blocks/flag/style-editor.css +5 -0
  111. package/src/blocks/flag/style.css +45 -0
  112. package/src/blocks/icon-button/block.json +43 -0
  113. package/src/blocks/icon-button/edit.js +82 -0
  114. package/src/blocks/icon-button/index.js +10 -0
  115. package/src/blocks/icon-button/save.js +29 -0
  116. package/src/blocks/icon-button/style-editor.css +5 -0
  117. package/src/blocks/icon-button/style.css +32 -0
  118. package/src/blocks/input/block.json +47 -0
  119. package/src/blocks/input/edit.js +78 -0
  120. package/src/blocks/input/index.js +10 -0
  121. package/src/blocks/input/save.js +27 -0
  122. package/src/blocks/input/style-editor.css +8 -0
  123. package/src/blocks/input/style.css +30 -0
  124. package/src/blocks/link/block.json +71 -0
  125. package/src/blocks/link/edit.js +151 -0
  126. package/src/blocks/link/index.js +10 -0
  127. package/src/blocks/link/save.js +46 -0
  128. package/src/blocks/link/style-editor.css +5 -0
  129. package/src/blocks/link/style.css +66 -0
  130. package/src/blocks/text/block.json +32 -0
  131. package/src/blocks/text/edit.js +56 -0
  132. package/src/blocks/text/index.js +10 -0
  133. package/src/blocks/text/save.js +18 -0
  134. package/src/blocks/text/style-editor.css +4 -0
  135. package/src/blocks/text/style.css +20 -0
  136. package/src/blocks/toast/block.json +39 -0
  137. package/src/blocks/toast/edit.js +85 -0
  138. package/src/blocks/toast/index.js +10 -0
  139. package/src/blocks/toast/save.js +29 -0
  140. package/src/blocks/toast/style-editor.css +4 -0
  141. package/src/blocks/toast/style.css +51 -0
  142. package/src/index.js +15 -12
  143. package/src/utils/classBuilder.js +53 -0
  144. package/tsconfig.json +4 -4
  145. package/__tests__/wordpress.test.js +0 -0
  146. package/dist/AdContainer/AdContainer.d.ts +0 -9
  147. package/dist/Article/ArticleMetaContainer/ArticleMetaContainer.d.ts +0 -8
  148. package/dist/Article/UpNextArticles/UpNextArticles.d.ts +0 -13
  149. package/dist/Button/Button.d.ts +0 -15
  150. package/dist/CommentsDisabled/CommentsDisabled.d.ts +0 -10
  151. package/dist/CommentsDisabled/CommentsDisabled.stories.d.ts +0 -44
  152. package/dist/CommentsDisabled/index.d.ts +0 -2
  153. package/dist/Divider/Divider.d.ts +0 -15
  154. package/dist/Input/Input.d.ts +0 -25
  155. package/dist/Link/Link.d.ts +0 -18
  156. package/dist/Text/Text.d.ts +0 -14
  157. package/dist/index.cjs.js +0 -299
  158. package/dist/index.cjs.js.map +0 -1
  159. package/dist/styles.css +0 -151
  160. package/dist/typographyStyles.css +0 -30
  161. package/dist/utils/cn.d.ts +0 -1
  162. package/dist/utils/hooks.d.ts +0 -8
  163. package/src/AdContainer/AdContainer.tsx +0 -31
  164. package/src/AdContainer/styles.css +0 -58
  165. package/src/Article/ArticleMetaContainer/ArticleMetaContainer.tsx +0 -14
  166. package/src/Article/ArticleMetaContainer/styles.css +0 -151
  167. package/src/Article/UpNextArticles/UpNextArticles.tsx +0 -69
  168. package/src/Article/UpNextArticles/styles.css +0 -151
  169. package/src/Button/Button.tsx +0 -36
  170. package/src/Button/styles.css +0 -30
  171. package/src/CommentsDisabled/CommentsDisabled.stories.tsx +0 -178
  172. package/src/CommentsDisabled/CommentsDisabled.tsx +0 -63
  173. package/src/CommentsDisabled/IMPLEMENTATION_SUMMARY.md +0 -305
  174. package/src/CommentsDisabled/README.md +0 -284
  175. package/src/CommentsDisabled/TOKEN_MAPPING.md +0 -269
  176. package/src/CommentsDisabled/index.ts +0 -2
  177. package/src/CommentsDisabled/styles.css +0 -82
  178. package/src/Divider/Divider.tsx +0 -41
  179. package/src/Divider/styles.css +0 -80
  180. package/src/Input/Input.tsx +0 -62
  181. package/src/Input/styles.css +0 -69
  182. package/src/Link/Link.tsx +0 -49
  183. package/src/Link/styles.css +0 -111
  184. package/src/Text/Text.tsx +0 -38
  185. package/src/Text/styles.css +0 -30
  186. package/src/Text/typographyStyles.css +0 -30
  187. package/src/utils/cn.js +0 -3
  188. package/src/utils/cn.tsx +0 -3
  189. package/src/utils/hooks.ts +0 -34
@@ -0,0 +1,42 @@
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;
@@ -0,0 +1,10 @@
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
+ });
@@ -0,0 +1,16 @@
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;
@@ -0,0 +1,4 @@
1
+ /* Ad Container Editor Styles */
2
+ .wp-block-times-ad-container {
3
+ margin: var(--spacing-m) 0;
4
+ }
@@ -0,0 +1,27 @@
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
+ }
9
+
10
+ .tds-ad-container--header {
11
+ min-height: 90px;
12
+ }
13
+
14
+ .tds-ad-container--inline {
15
+ min-height: 250px;
16
+ }
17
+
18
+ .tds-ad-container__placeholder {
19
+ 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);
27
+ }
@@ -0,0 +1,89 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "times/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
+ "attributes": {
20
+ "label": {
21
+ "type": "string",
22
+ "default": "Button label",
23
+ "description": "The text label displayed inside the button"
24
+ },
25
+ "intent": {
26
+ "type": "string",
27
+ "enum": ["primary", "secondary", "negative"],
28
+ "default": "primary",
29
+ "description": "Visual style variant"
30
+ },
31
+ "size": {
32
+ "type": "string",
33
+ "enum": ["small", "medium", "large"],
34
+ "default": "large",
35
+ "description": "Controls the overall dimensions of the button"
36
+ },
37
+ "behaviour": {
38
+ "type": "string",
39
+ "enum": ["hug", "full"],
40
+ "default": "hug",
41
+ "description": "Controls the width behaviour"
42
+ },
43
+ "state": {
44
+ "type": "string",
45
+ "enum": ["base", "hover", "pressed", "loading", "disabled", "focus"],
46
+ "default": "base",
47
+ "description": "The interaction state"
48
+ },
49
+ "disabled": {
50
+ "type": "boolean",
51
+ "default": false,
52
+ "description": "Whether the button is disabled"
53
+ },
54
+ "href": {
55
+ "type": "string",
56
+ "description": "Optional href to render as a link"
57
+ },
58
+ "target": {
59
+ "type": "string",
60
+ "enum": ["_blank", "_self", "_parent", "_top"],
61
+ "description": "Optional target attribute for links"
62
+ },
63
+ "rel": {
64
+ "type": "string",
65
+ "description": "Optional rel attribute for links"
66
+ },
67
+ "type": {
68
+ "type": "string",
69
+ "enum": ["button", "submit", "reset"],
70
+ "default": "button",
71
+ "description": "Button type"
72
+ },
73
+ "iconLeft": {
74
+ "type": "string",
75
+ "description": "Icon name to display on the left side of the label"
76
+ },
77
+ "iconRight": {
78
+ "type": "string",
79
+ "description": "Icon name to display on the right side of the label"
80
+ },
81
+ "ariaLabel": {
82
+ "type": "string",
83
+ "description": "Accessible name for icon-only buttons"
84
+ }
85
+ },
86
+ "editorScript": "file:./index.js",
87
+ "editorStyle": "file:./style-editor.css",
88
+ "style": "file:./style.css"
89
+ }
@@ -0,0 +1,187 @@
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
+ }
@@ -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,52 @@
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
+ }
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,37 @@
1
+ /* Button Block Frontend Styles */
2
+
3
+ .tds-button-wrapper {
4
+ display: inline-block;
5
+ }
6
+
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;
11
+ align-items: center;
12
+ justify-content: center;
13
+ cursor: pointer;
14
+ 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;
20
+ }
21
+
22
+ .tds-button-wrapper .tds-button--behaviour-full {
23
+ width: 100%;
24
+ }
25
+
26
+ .tds-button-wrapper .tds-button:disabled {
27
+ cursor: not-allowed;
28
+ opacity: 0.5;
29
+ }
30
+
31
+ .tds-button__label-container {
32
+ display: inline;
33
+ }
34
+
35
+ .tds-button__label {
36
+ display: inline;
37
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "times/chip",
5
+ "title": "Chip",
6
+ "category": "common",
7
+ "description": "Small component for displaying labels, tags, or filter options",
8
+ "icon": "tag",
9
+ "supports": {
10
+ "html": false,
11
+ "spacing": {
12
+ "margin": true
13
+ }
14
+ },
15
+ "attributes": {
16
+ "content": {
17
+ "type": "string",
18
+ "default": ""
19
+ },
20
+ "intent": {
21
+ "type": "string",
22
+ "default": "secondary",
23
+ "enum": ["primary", "secondary", "negative"]
24
+ },
25
+ "size": {
26
+ "type": "string",
27
+ "default": "medium",
28
+ "enum": ["small", "medium", "large"]
29
+ },
30
+ "state": {
31
+ "type": "string",
32
+ "default": "base",
33
+ "enum": ["base", "hover", "pressed", "disabled"]
34
+ },
35
+ "channel": {
36
+ "type": "boolean",
37
+ "default": false
38
+ },
39
+ "toggle": {
40
+ "type": "boolean",
41
+ "default": false
42
+ },
43
+ "iconLeft": {
44
+ "type": "string",
45
+ "default": ""
46
+ },
47
+ "iconRight": {
48
+ "type": "string",
49
+ "default": ""
50
+ },
51
+ "ariaLabel": {
52
+ "type": "string",
53
+ "default": ""
54
+ }
55
+ },
56
+ "example": {}
57
+ }
@@ -0,0 +1,113 @@
1
+ import {
2
+ useBlockProps,
3
+ RichText,
4
+ InspectorControls
5
+ } from '@wordpress/block-editor';
6
+ import {
7
+ PanelBody,
8
+ SelectControl,
9
+ TextControl,
10
+ ToggleControl
11
+ } from '@wordpress/components';
12
+
13
+ const edit = ({ attributes, setAttributes }) => {
14
+ const {
15
+ content,
16
+ intent,
17
+ size,
18
+ state,
19
+ channel,
20
+ toggle,
21
+ iconLeft,
22
+ iconRight,
23
+ ariaLabel
24
+ } = attributes;
25
+ const blockProps = useBlockProps();
26
+
27
+ const buildClass = () => {
28
+ const classes = ['tds-chip'];
29
+ classes.push(`tds-chip--intent-${intent}`);
30
+ classes.push(`tds-chip--size-${size}`);
31
+ classes.push(`tds-chip--state-${state}`);
32
+ if (channel) classes.push('tds-chip--channel');
33
+ if (toggle) classes.push('tds-chip--toggle');
34
+ return classes.join(' ');
35
+ };
36
+
37
+ return (
38
+ <>
39
+ <InspectorControls>
40
+ <PanelBody title="Chip Settings">
41
+ <SelectControl
42
+ label="Intent"
43
+ value={intent}
44
+ options={[
45
+ { label: 'Primary', value: 'primary' },
46
+ { label: 'Secondary', value: 'secondary' },
47
+ { label: 'Negative', value: 'negative' }
48
+ ]}
49
+ onChange={(val) => setAttributes({ intent: val })}
50
+ />
51
+ <SelectControl
52
+ label="Size"
53
+ value={size}
54
+ options={[
55
+ { label: 'Small', value: 'small' },
56
+ { label: 'Medium', value: 'medium' },
57
+ { label: 'Large', value: 'large' }
58
+ ]}
59
+ onChange={(val) => setAttributes({ size: val })}
60
+ />
61
+ <SelectControl
62
+ label="State"
63
+ value={state}
64
+ options={[
65
+ { label: 'Base', value: 'base' },
66
+ { label: 'Hover', value: 'hover' },
67
+ { label: 'Pressed', value: 'pressed' },
68
+ { label: 'Disabled', value: 'disabled' }
69
+ ]}
70
+ onChange={(val) => setAttributes({ state: val })}
71
+ />
72
+ <ToggleControl
73
+ label="Channel"
74
+ checked={channel}
75
+ onChange={(val) => setAttributes({ channel: val })}
76
+ />
77
+ <ToggleControl
78
+ label="Toggle"
79
+ checked={toggle}
80
+ onChange={(val) => setAttributes({ toggle: val })}
81
+ />
82
+ <TextControl
83
+ label="Left Icon"
84
+ value={iconLeft}
85
+ onChange={(val) => setAttributes({ iconLeft: val })}
86
+ />
87
+ <TextControl
88
+ label="Right Icon"
89
+ value={iconRight}
90
+ onChange={(val) => setAttributes({ iconRight: val })}
91
+ />
92
+ <TextControl
93
+ label="Aria Label"
94
+ value={ariaLabel}
95
+ onChange={(val) => setAttributes({ ariaLabel: val })}
96
+ />
97
+ </PanelBody>
98
+ </InspectorControls>
99
+ <button {...blockProps} className={buildClass()} aria-label={ariaLabel}>
100
+ {iconLeft && <span className="tds-chip__icon-left">{iconLeft}</span>}
101
+ <RichText
102
+ value={content}
103
+ onChange={(val) => setAttributes({ content: val })}
104
+ placeholder="Chip text"
105
+ className="tds-chip__content"
106
+ />
107
+ {iconRight && <span className="tds-chip__icon-right">{iconRight}</span>}
108
+ </button>
109
+ </>
110
+ );
111
+ };
112
+
113
+ export default edit;
@@ -0,0 +1,10 @@
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
+ });