@times-design-system/components-wordpress 0.1.1-alpha.831 → 0.7.2-alpha.2

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 +30 -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,25 @@
1
+ /* Divider Block Styles */
2
+ .tds-divider {
3
+ height: 1px;
4
+ background-color: var(--color-border-secondary);
5
+ margin: var(--spacing-m) 0;
6
+ }
7
+
8
+ .tds-divider--dashed {
9
+ border-top: 1px dashed var(--color-border-secondary);
10
+ background-color: transparent;
11
+ }
12
+
13
+ .tds-divider--vertical {
14
+ width: 1px;
15
+ height: auto;
16
+ margin: 0 var(--spacing-m);
17
+ }
18
+
19
+ .tds-divider--padding {
20
+ margin: var(--spacing-xl) 0;
21
+ }
22
+
23
+ .tds-divider--vertical.tds-divider--padding {
24
+ margin: 0 var(--spacing-xl);
25
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "times/flag",
5
+ "title": "Flag",
6
+ "category": "common",
7
+ "description": "Badge or status indicator component",
8
+ "icon": "flag",
9
+ "supports": {
10
+ "html": false,
11
+ "spacing": {
12
+ "margin": true
13
+ }
14
+ },
15
+ "attributes": {
16
+ "label": {
17
+ "type": "string",
18
+ "default": ""
19
+ },
20
+ "content": {
21
+ "type": "string",
22
+ "default": ""
23
+ },
24
+ "intent": {
25
+ "type": "string",
26
+ "default": "secondary",
27
+ "enum": ["primary", "secondary", "negative", "positive"]
28
+ },
29
+ "size": {
30
+ "type": "string",
31
+ "default": "medium",
32
+ "enum": ["small", "medium", "large"]
33
+ },
34
+ "iconLeft": {
35
+ "type": "string",
36
+ "default": ""
37
+ },
38
+ "iconRight": {
39
+ "type": "string",
40
+ "default": ""
41
+ },
42
+ "ariaLabel": {
43
+ "type": "string",
44
+ "default": ""
45
+ }
46
+ },
47
+ "example": {}
48
+ }
@@ -0,0 +1,82 @@
1
+ import {
2
+ useBlockProps,
3
+ RichText,
4
+ InspectorControls
5
+ } from '@wordpress/block-editor';
6
+ import { PanelBody, SelectControl, TextControl } from '@wordpress/components';
7
+
8
+ const edit = ({ attributes, setAttributes }) => {
9
+ const { label, content, intent, size, iconLeft, iconRight, ariaLabel } =
10
+ attributes;
11
+ const blockProps = useBlockProps();
12
+
13
+ const buildClass = () => {
14
+ const classes = ['tds-flag'];
15
+ classes.push(`tds-flag--intent-${intent}`);
16
+ classes.push(`tds-flag--size-${size}`);
17
+ return classes.join(' ');
18
+ };
19
+
20
+ return (
21
+ <>
22
+ <InspectorControls>
23
+ <PanelBody title="Flag Settings">
24
+ <TextControl
25
+ label="Label"
26
+ value={label}
27
+ onChange={(val) => setAttributes({ label: val })}
28
+ />
29
+ <SelectControl
30
+ label="Intent"
31
+ value={intent}
32
+ options={[
33
+ { label: 'Primary', value: 'primary' },
34
+ { label: 'Secondary', value: 'secondary' },
35
+ { label: 'Negative', value: 'negative' },
36
+ { label: 'Positive', value: 'positive' }
37
+ ]}
38
+ onChange={(val) => setAttributes({ intent: val })}
39
+ />
40
+ <SelectControl
41
+ label="Size"
42
+ value={size}
43
+ options={[
44
+ { label: 'Small', value: 'small' },
45
+ { label: 'Medium', value: 'medium' },
46
+ { label: 'Large', value: 'large' }
47
+ ]}
48
+ onChange={(val) => setAttributes({ size: val })}
49
+ />
50
+ <TextControl
51
+ label="Left Icon"
52
+ value={iconLeft}
53
+ onChange={(val) => setAttributes({ iconLeft: val })}
54
+ />
55
+ <TextControl
56
+ label="Right Icon"
57
+ value={iconRight}
58
+ onChange={(val) => setAttributes({ iconRight: val })}
59
+ />
60
+ <TextControl
61
+ label="Aria Label"
62
+ value={ariaLabel}
63
+ onChange={(val) => setAttributes({ ariaLabel: val })}
64
+ />
65
+ </PanelBody>
66
+ </InspectorControls>
67
+ <div {...blockProps} className={buildClass()} aria-label={ariaLabel}>
68
+ {label && <div className="tds-flag__label">{label}</div>}
69
+ {iconLeft && <span className="tds-flag__icon-left">{iconLeft}</span>}
70
+ <RichText
71
+ value={content}
72
+ onChange={(val) => setAttributes({ content: val })}
73
+ placeholder="Flag content"
74
+ className="tds-flag__content"
75
+ />
76
+ {iconRight && <span className="tds-flag__icon-right">{iconRight}</span>}
77
+ </div>
78
+ </>
79
+ );
80
+ };
81
+
82
+ 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,25 @@
1
+ import { useBlockProps, RichText } from '@wordpress/block-editor';
2
+
3
+ const save = ({ attributes }) => {
4
+ const { label, content, intent, size, iconLeft, iconRight, ariaLabel } =
5
+ attributes;
6
+ const blockProps = useBlockProps.save();
7
+
8
+ const buildClass = () => {
9
+ const classes = ['tds-flag'];
10
+ classes.push(`tds-flag--intent-${intent}`);
11
+ classes.push(`tds-flag--size-${size}`);
12
+ return classes.join(' ');
13
+ };
14
+
15
+ return (
16
+ <div {...blockProps} className={buildClass()} aria-label={ariaLabel}>
17
+ {label && <div className="tds-flag__label">{label}</div>}
18
+ {iconLeft && <span className="tds-flag__icon-left">{iconLeft}</span>}
19
+ <RichText.Content value={content} className="tds-flag__content" />
20
+ {iconRight && <span className="tds-flag__icon-right">{iconRight}</span>}
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default save;
@@ -0,0 +1,5 @@
1
+ /* Flag Editor Styles */
2
+ .wp-block-times-flag {
3
+ display: inline-block;
4
+ margin: var(--spacing-s);
5
+ }
@@ -0,0 +1,45 @@
1
+ /* Flag Block Styles */
2
+ .tds-flag {
3
+ display: inline-flex;
4
+ align-items: center;
5
+ gap: var(--spacing-s);
6
+ padding: var(--spacing-s) var(--spacing-m);
7
+ border-radius: var(--border-radius-s);
8
+ background-color: var(--color-fill-secondary);
9
+ color: var(--color-text-primary);
10
+ font: var(--typography-body-small);
11
+ }
12
+
13
+ .tds-flag--intent-primary {
14
+ background-color: var(--color-fill-primary);
15
+ color: var(--color-text-on-primary);
16
+ }
17
+
18
+ .tds-flag--intent-negative {
19
+ background-color: var(--color-fill-negative);
20
+ color: var(--color-text-on-negative);
21
+ }
22
+
23
+ .tds-flag--intent-positive {
24
+ background-color: var(--color-fill-positive);
25
+ color: var(--color-text-on-positive);
26
+ }
27
+
28
+ .tds-flag--size-small {
29
+ padding: var(--spacing-xs) var(--spacing-s);
30
+ font-size: 12px;
31
+ }
32
+
33
+ .tds-flag--size-large {
34
+ padding: var(--spacing-m) var(--spacing-l);
35
+ font-size: 16px;
36
+ }
37
+
38
+ .tds-flag__label {
39
+ font-weight: 600;
40
+ }
41
+
42
+ .tds-flag__icon-left,
43
+ .tds-flag__icon-right {
44
+ font-size: 14px;
45
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "times/icon-button",
5
+ "title": "Icon Button",
6
+ "category": "common",
7
+ "description": "Button component displaying only an icon",
8
+ "icon": "button",
9
+ "supports": {
10
+ "html": false,
11
+ "spacing": {
12
+ "margin": true
13
+ }
14
+ },
15
+ "attributes": {
16
+ "iconName": {
17
+ "type": "string",
18
+ "default": ""
19
+ },
20
+ "round": {
21
+ "type": "boolean",
22
+ "default": false
23
+ },
24
+ "href": {
25
+ "type": "string",
26
+ "default": ""
27
+ },
28
+ "target": {
29
+ "type": "string",
30
+ "default": "_self",
31
+ "enum": ["_self", "_blank", "_parent", "_top"]
32
+ },
33
+ "rel": {
34
+ "type": "string",
35
+ "default": ""
36
+ },
37
+ "ariaLabel": {
38
+ "type": "string",
39
+ "default": ""
40
+ }
41
+ },
42
+ "example": {}
43
+ }
@@ -0,0 +1,82 @@
1
+ import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
2
+ import {
3
+ PanelBody,
4
+ TextControl,
5
+ SelectControl,
6
+ ToggleControl
7
+ } from '@wordpress/components';
8
+
9
+ const edit = ({ attributes, setAttributes }) => {
10
+ const { iconName, round, href, target, rel, ariaLabel } = attributes;
11
+ const blockProps = useBlockProps();
12
+
13
+ const buildClass = () => {
14
+ const classes = ['tds-icon-button'];
15
+ if (round) classes.push('tds-icon-button--round');
16
+ return classes.join(' ');
17
+ };
18
+
19
+ const Element = href ? 'a' : 'button';
20
+
21
+ return (
22
+ <>
23
+ <InspectorControls>
24
+ <PanelBody title="Icon Button Settings">
25
+ <TextControl
26
+ label="Icon Name"
27
+ value={iconName}
28
+ onChange={(val) => setAttributes({ iconName: val })}
29
+ placeholder="e.g., arrow-right"
30
+ />
31
+ <ToggleControl
32
+ label="Round"
33
+ checked={round}
34
+ onChange={(val) => setAttributes({ round: val })}
35
+ />
36
+ <TextControl
37
+ label="URL (Leave empty for button)"
38
+ value={href}
39
+ onChange={(val) => setAttributes({ href: val })}
40
+ />
41
+ {href && (
42
+ <>
43
+ <SelectControl
44
+ label="Target"
45
+ value={target}
46
+ options={[
47
+ { label: 'Same window', value: '_self' },
48
+ { label: 'New window', value: '_blank' },
49
+ { label: 'Parent', value: '_parent' },
50
+ { label: 'Top', value: '_top' }
51
+ ]}
52
+ onChange={(val) => setAttributes({ target: val })}
53
+ />
54
+ <TextControl
55
+ label="Rel"
56
+ value={rel}
57
+ onChange={(val) => setAttributes({ rel: val })}
58
+ />
59
+ </>
60
+ )}
61
+ <TextControl
62
+ label="Aria Label"
63
+ value={ariaLabel}
64
+ onChange={(val) => setAttributes({ ariaLabel: val })}
65
+ />
66
+ </PanelBody>
67
+ </InspectorControls>
68
+ <Element
69
+ {...blockProps}
70
+ className={buildClass()}
71
+ href={href || undefined}
72
+ target={href ? target : undefined}
73
+ rel={href && rel ? rel : undefined}
74
+ aria-label={ariaLabel}
75
+ >
76
+ <span className="tds-icon-button__icon">{iconName}</span>
77
+ </Element>
78
+ </>
79
+ );
80
+ };
81
+
82
+ 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,29 @@
1
+ import { useBlockProps } from '@wordpress/block-editor';
2
+
3
+ const save = ({ attributes }) => {
4
+ const { iconName, round, href, target, rel, ariaLabel } = attributes;
5
+ const blockProps = useBlockProps.save();
6
+
7
+ const buildClass = () => {
8
+ const classes = ['tds-icon-button'];
9
+ if (round) classes.push('tds-icon-button--round');
10
+ return classes.join(' ');
11
+ };
12
+
13
+ const Element = href ? 'a' : 'button';
14
+
15
+ return (
16
+ <Element
17
+ {...blockProps}
18
+ className={buildClass()}
19
+ href={href || undefined}
20
+ target={href ? target : undefined}
21
+ rel={href && rel ? rel : undefined}
22
+ aria-label={ariaLabel}
23
+ >
24
+ <span className="tds-icon-button__icon">{iconName}</span>
25
+ </Element>
26
+ );
27
+ };
28
+
29
+ export default save;
@@ -0,0 +1,5 @@
1
+ /* Icon Button Editor Styles */
2
+ .wp-block-times-icon-button {
3
+ display: inline-block;
4
+ margin: var(--spacing-s);
5
+ }
@@ -0,0 +1,32 @@
1
+ /* Icon Button Styles */
2
+ .tds-icon-button {
3
+ display: inline-flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ width: 40px;
7
+ height: 40px;
8
+ border: none;
9
+ border-radius: var(--border-radius-s);
10
+ background-color: var(--color-fill-secondary);
11
+ color: var(--color-text-primary);
12
+ cursor: pointer;
13
+ transition: all 0.2s ease-in-out;
14
+ text-decoration: none;
15
+ }
16
+
17
+ .tds-icon-button:hover {
18
+ background-color: var(--color-fill-hover);
19
+ }
20
+
21
+ .tds-icon-button:focus {
22
+ outline: none;
23
+ box-shadow: 0 0 0 2px var(--color-fill-focus);
24
+ }
25
+
26
+ .tds-icon-button--round {
27
+ border-radius: 50%;
28
+ }
29
+
30
+ .tds-icon-button__icon {
31
+ font-size: 20px;
32
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "times/input",
5
+ "title": "Input",
6
+ "category": "common",
7
+ "description": "Form input field component",
8
+ "icon": "text",
9
+ "supports": {
10
+ "html": false,
11
+ "spacing": {
12
+ "margin": true
13
+ }
14
+ },
15
+ "attributes": {
16
+ "label": {
17
+ "type": "string",
18
+ "default": ""
19
+ },
20
+ "placeholder": {
21
+ "type": "string",
22
+ "default": ""
23
+ },
24
+ "type": {
25
+ "type": "string",
26
+ "default": "text",
27
+ "enum": ["text", "email", "password", "number", "tel", "url"]
28
+ },
29
+ "disabled": {
30
+ "type": "boolean",
31
+ "default": false
32
+ },
33
+ "required": {
34
+ "type": "boolean",
35
+ "default": false
36
+ },
37
+ "name": {
38
+ "type": "string",
39
+ "default": ""
40
+ },
41
+ "id": {
42
+ "type": "string",
43
+ "default": ""
44
+ }
45
+ },
46
+ "example": {}
47
+ }
@@ -0,0 +1,78 @@
1
+ import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
2
+ import {
3
+ PanelBody,
4
+ TextControl,
5
+ SelectControl,
6
+ ToggleControl
7
+ } from '@wordpress/components';
8
+
9
+ const edit = ({ attributes, setAttributes }) => {
10
+ const { label, placeholder, type, disabled, required, name, id } = attributes;
11
+ const blockProps = useBlockProps();
12
+
13
+ return (
14
+ <>
15
+ <InspectorControls>
16
+ <PanelBody title="Input Settings">
17
+ <TextControl
18
+ label="Label"
19
+ value={label}
20
+ onChange={(val) => setAttributes({ label: val })}
21
+ />
22
+ <TextControl
23
+ label="Placeholder"
24
+ value={placeholder}
25
+ onChange={(val) => setAttributes({ placeholder: val })}
26
+ />
27
+ <SelectControl
28
+ label="Type"
29
+ value={type}
30
+ options={[
31
+ { label: 'Text', value: 'text' },
32
+ { label: 'Email', value: 'email' },
33
+ { label: 'Password', value: 'password' },
34
+ { label: 'Number', value: 'number' },
35
+ { label: 'Tel', value: 'tel' },
36
+ { label: 'URL', value: 'url' }
37
+ ]}
38
+ onChange={(val) => setAttributes({ type: val })}
39
+ />
40
+ <TextControl
41
+ label="Name"
42
+ value={name}
43
+ onChange={(val) => setAttributes({ name: val })}
44
+ />
45
+ <TextControl
46
+ label="ID"
47
+ value={id}
48
+ onChange={(val) => setAttributes({ id: val })}
49
+ />
50
+ <ToggleControl
51
+ label="Required"
52
+ checked={required}
53
+ onChange={(val) => setAttributes({ required: val })}
54
+ />
55
+ <ToggleControl
56
+ label="Disabled"
57
+ checked={disabled}
58
+ onChange={(val) => setAttributes({ disabled: val })}
59
+ />
60
+ </PanelBody>
61
+ </InspectorControls>
62
+ <div {...blockProps}>
63
+ {label && <label className="tds-input__label">{label}</label>}
64
+ <input
65
+ type={type}
66
+ placeholder={placeholder}
67
+ disabled={disabled}
68
+ required={required}
69
+ name={name}
70
+ id={id}
71
+ className="tds-input"
72
+ />
73
+ </div>
74
+ </>
75
+ );
76
+ };
77
+
78
+ 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,27 @@
1
+ import { useBlockProps } from '@wordpress/block-editor';
2
+
3
+ const save = ({ attributes }) => {
4
+ const { label, placeholder, type, disabled, required, name, id } = attributes;
5
+ const blockProps = useBlockProps.save();
6
+
7
+ return (
8
+ <div {...blockProps}>
9
+ {label && (
10
+ <label htmlFor={id} className="tds-input__label">
11
+ {label}
12
+ </label>
13
+ )}
14
+ <input
15
+ type={type}
16
+ placeholder={placeholder}
17
+ disabled={disabled}
18
+ required={required}
19
+ name={name}
20
+ id={id}
21
+ className="tds-input"
22
+ />
23
+ </div>
24
+ );
25
+ };
26
+
27
+ export default save;
@@ -0,0 +1,8 @@
1
+ /* Input Editor Styles */
2
+ .wp-block-times-input {
3
+ margin: var(--spacing-m) 0;
4
+ }
5
+
6
+ .wp-block-times-input .tds-input {
7
+ opacity: 0.7;
8
+ }
@@ -0,0 +1,30 @@
1
+ /* Input Block Styles */
2
+ .tds-input {
3
+ display: block;
4
+ width: 100%;
5
+ padding: var(--spacing-s) var(--spacing-m);
6
+ border: 1px solid var(--color-border-primary);
7
+ border-radius: var(--border-radius-s);
8
+ font: var(--typography-body-standard);
9
+ color: var(--color-text-primary);
10
+ background-color: var(--color-fill-primary);
11
+ }
12
+
13
+ .tds-input:focus {
14
+ outline: none;
15
+ border-color: var(--color-border-focus);
16
+ box-shadow: 0 0 0 2px var(--color-fill-focus);
17
+ }
18
+
19
+ .tds-input:disabled {
20
+ background-color: var(--color-fill-disabled);
21
+ color: var(--color-text-disabled);
22
+ cursor: not-allowed;
23
+ }
24
+
25
+ .tds-input__label {
26
+ display: block;
27
+ margin-bottom: var(--spacing-s);
28
+ font-weight: 600;
29
+ color: var(--color-text-primary);
30
+ }