@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,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
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "times/link",
5
+ "title": "Link",
6
+ "category": "common",
7
+ "description": "Styled link component with variants and states",
8
+ "icon": "link",
9
+ "supports": {
10
+ "html": false,
11
+ "spacing": {
12
+ "margin": true
13
+ }
14
+ },
15
+ "attributes": {
16
+ "href": {
17
+ "type": "string",
18
+ "default": ""
19
+ },
20
+ "content": {
21
+ "type": "string",
22
+ "default": ""
23
+ },
24
+ "intent": {
25
+ "type": "string",
26
+ "default": "primary",
27
+ "enum": ["primary", "secondary", "negative"]
28
+ },
29
+ "sentiment": {
30
+ "type": "string",
31
+ "default": "neutral",
32
+ "enum": ["neutral", "positive", "negative"]
33
+ },
34
+ "size": {
35
+ "type": "string",
36
+ "default": "medium",
37
+ "enum": ["small", "medium", "large"]
38
+ },
39
+ "state": {
40
+ "type": "string",
41
+ "default": "base",
42
+ "enum": ["base", "hover", "visited", "focus", "disabled"]
43
+ },
44
+ "iconLeft": {
45
+ "type": "string",
46
+ "default": ""
47
+ },
48
+ "iconRight": {
49
+ "type": "string",
50
+ "default": ""
51
+ },
52
+ "inline": {
53
+ "type": "boolean",
54
+ "default": true
55
+ },
56
+ "ariaLabel": {
57
+ "type": "string",
58
+ "default": ""
59
+ },
60
+ "target": {
61
+ "type": "string",
62
+ "default": "_self",
63
+ "enum": ["_self", "_blank", "_parent", "_top"]
64
+ },
65
+ "rel": {
66
+ "type": "string",
67
+ "default": ""
68
+ }
69
+ },
70
+ "example": {}
71
+ }
@@ -0,0 +1,151 @@
1
+ import {
2
+ useBlockProps,
3
+ RichText,
4
+ InspectorControls
5
+ } from '@wordpress/block-editor';
6
+ import {
7
+ PanelBody,
8
+ TextControl,
9
+ SelectControl,
10
+ ToggleControl
11
+ } from '@wordpress/components';
12
+
13
+ const edit = ({ attributes, setAttributes }) => {
14
+ const {
15
+ href,
16
+ content,
17
+ intent,
18
+ sentiment,
19
+ size,
20
+ state,
21
+ iconLeft,
22
+ iconRight,
23
+ inline,
24
+ ariaLabel,
25
+ target,
26
+ rel
27
+ } = attributes;
28
+ const blockProps = useBlockProps();
29
+
30
+ const buildClass = () => {
31
+ const classes = ['tds-link'];
32
+ classes.push(`tds-link--intent-${intent}`);
33
+ classes.push(`tds-link--sentiment-${sentiment}`);
34
+ classes.push(`tds-link--size-${size}`);
35
+ classes.push(`tds-link--state-${state}`);
36
+ if (!inline) classes.push('tds-link--block');
37
+ return classes.join(' ');
38
+ };
39
+
40
+ return (
41
+ <>
42
+ <InspectorControls>
43
+ <PanelBody title="Link Settings">
44
+ <TextControl
45
+ label="URL"
46
+ value={href}
47
+ onChange={(val) => setAttributes({ href: val })}
48
+ type="url"
49
+ />
50
+ <SelectControl
51
+ label="Intent"
52
+ value={intent}
53
+ options={[
54
+ { label: 'Primary', value: 'primary' },
55
+ { label: 'Secondary', value: 'secondary' },
56
+ { label: 'Negative', value: 'negative' }
57
+ ]}
58
+ onChange={(val) => setAttributes({ intent: val })}
59
+ />
60
+ <SelectControl
61
+ label="Sentiment"
62
+ value={sentiment}
63
+ options={[
64
+ { label: 'Neutral', value: 'neutral' },
65
+ { label: 'Positive', value: 'positive' },
66
+ { label: 'Negative', value: 'negative' }
67
+ ]}
68
+ onChange={(val) => setAttributes({ sentiment: val })}
69
+ />
70
+ <SelectControl
71
+ label="Size"
72
+ value={size}
73
+ options={[
74
+ { label: 'Small', value: 'small' },
75
+ { label: 'Medium', value: 'medium' },
76
+ { label: 'Large', value: 'large' }
77
+ ]}
78
+ onChange={(val) => setAttributes({ size: val })}
79
+ />
80
+ <SelectControl
81
+ label="State"
82
+ value={state}
83
+ options={[
84
+ { label: 'Base', value: 'base' },
85
+ { label: 'Hover', value: 'hover' },
86
+ { label: 'Visited', value: 'visited' },
87
+ { label: 'Focus', value: 'focus' },
88
+ { label: 'Disabled', value: 'disabled' }
89
+ ]}
90
+ onChange={(val) => setAttributes({ state: val })}
91
+ />
92
+ <TextControl
93
+ label="Left Icon"
94
+ value={iconLeft}
95
+ onChange={(val) => setAttributes({ iconLeft: val })}
96
+ />
97
+ <TextControl
98
+ label="Right Icon"
99
+ value={iconRight}
100
+ onChange={(val) => setAttributes({ iconRight: val })}
101
+ />
102
+ <ToggleControl
103
+ label="Inline"
104
+ checked={inline}
105
+ onChange={(val) => setAttributes({ inline: val })}
106
+ />
107
+ <SelectControl
108
+ label="Target"
109
+ value={target}
110
+ options={[
111
+ { label: 'Same window', value: '_self' },
112
+ { label: 'New window', value: '_blank' },
113
+ { label: 'Parent', value: '_parent' },
114
+ { label: 'Top', value: '_top' }
115
+ ]}
116
+ onChange={(val) => setAttributes({ target: val })}
117
+ />
118
+ <TextControl
119
+ label="Rel"
120
+ value={rel}
121
+ onChange={(val) => setAttributes({ rel: val })}
122
+ />
123
+ <TextControl
124
+ label="Aria Label"
125
+ value={ariaLabel}
126
+ onChange={(val) => setAttributes({ ariaLabel: val })}
127
+ />
128
+ </PanelBody>
129
+ </InspectorControls>
130
+ <a
131
+ {...blockProps}
132
+ href={href || '#'}
133
+ className={buildClass()}
134
+ aria-label={ariaLabel}
135
+ target={target}
136
+ rel={rel}
137
+ >
138
+ {iconLeft && <span className="tds-link__icon-left">{iconLeft}</span>}
139
+ <RichText
140
+ value={content}
141
+ onChange={(val) => setAttributes({ content: val })}
142
+ placeholder="Link text"
143
+ className="tds-link__content"
144
+ />
145
+ {iconRight && <span className="tds-link__icon-right">{iconRight}</span>}
146
+ </a>
147
+ </>
148
+ );
149
+ };
150
+
151
+ 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,46 @@
1
+ import { useBlockProps, RichText } from '@wordpress/block-editor';
2
+
3
+ const save = ({ attributes }) => {
4
+ const {
5
+ href,
6
+ content,
7
+ intent,
8
+ sentiment,
9
+ size,
10
+ state,
11
+ iconLeft,
12
+ iconRight,
13
+ inline,
14
+ ariaLabel,
15
+ target,
16
+ rel
17
+ } = attributes;
18
+ const blockProps = useBlockProps.save();
19
+
20
+ const buildClass = () => {
21
+ const classes = ['tds-link'];
22
+ classes.push(`tds-link--intent-${intent}`);
23
+ classes.push(`tds-link--sentiment-${sentiment}`);
24
+ classes.push(`tds-link--size-${size}`);
25
+ classes.push(`tds-link--state-${state}`);
26
+ if (!inline) classes.push('tds-link--block');
27
+ return classes.join(' ');
28
+ };
29
+
30
+ return (
31
+ <a
32
+ {...blockProps}
33
+ href={href}
34
+ className={buildClass()}
35
+ aria-label={ariaLabel}
36
+ target={target !== '_self' ? target : undefined}
37
+ rel={rel || undefined}
38
+ >
39
+ {iconLeft && <span className="tds-link__icon-left">{iconLeft}</span>}
40
+ <RichText.Content value={content} className="tds-link__content" />
41
+ {iconRight && <span className="tds-link__icon-right">{iconRight}</span>}
42
+ </a>
43
+ );
44
+ };
45
+
46
+ export default save;
@@ -0,0 +1,5 @@
1
+ /* Link Editor Styles */
2
+ .wp-block-times-link {
3
+ display: inline-block;
4
+ margin: var(--spacing-s);
5
+ }
@@ -0,0 +1,66 @@
1
+ /* Link Block Styles */
2
+ .tds-link {
3
+ display: inline-flex;
4
+ align-items: center;
5
+ gap: var(--spacing-xs);
6
+ text-decoration: none;
7
+ cursor: pointer;
8
+ transition: all 0.2s ease-in-out;
9
+ }
10
+
11
+ .tds-link--intent-primary {
12
+ color: var(--color-text-link-primary);
13
+ }
14
+
15
+ .tds-link--intent-secondary {
16
+ color: var(--color-text-link-secondary);
17
+ }
18
+
19
+ .tds-link--intent-negative {
20
+ color: var(--color-text-link-negative);
21
+ }
22
+
23
+ .tds-link--sentiment-positive {
24
+ font-weight: 600;
25
+ }
26
+
27
+ .tds-link--sentiment-negative {
28
+ font-weight: 400;
29
+ opacity: 0.8;
30
+ }
31
+
32
+ .tds-link--size-small {
33
+ font-size: 12px;
34
+ }
35
+
36
+ .tds-link--size-large {
37
+ font-size: 18px;
38
+ }
39
+
40
+ .tds-link--state-hover {
41
+ text-decoration: underline;
42
+ }
43
+
44
+ .tds-link--state-visited {
45
+ color: var(--color-text-link-visited);
46
+ }
47
+
48
+ .tds-link--state-focus {
49
+ outline: 2px solid var(--color-border-focus);
50
+ outline-offset: 2px;
51
+ }
52
+
53
+ .tds-link--state-disabled {
54
+ opacity: 0.5;
55
+ cursor: not-allowed;
56
+ }
57
+
58
+ .tds-link--block {
59
+ display: flex;
60
+ width: 100%;
61
+ }
62
+
63
+ .tds-link__icon-left,
64
+ .tds-link__icon-right {
65
+ font-size: 1em;
66
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "times/text",
5
+ "title": "Text",
6
+ "category": "common",
7
+ "description": "Typography component for displaying text with style variants",
8
+ "icon": "editor-paragraph",
9
+ "supports": {
10
+ "html": false,
11
+ "spacing": {
12
+ "margin": true,
13
+ "padding": false
14
+ }
15
+ },
16
+ "attributes": {
17
+ "as": {
18
+ "type": "string",
19
+ "default": "p",
20
+ "enum": ["p", "span", "h1", "h2", "h3", "h4", "h5"]
21
+ },
22
+ "typographyStyle": {
23
+ "type": "string",
24
+ "default": "body-standard"
25
+ },
26
+ "content": {
27
+ "type": "string",
28
+ "default": ""
29
+ }
30
+ },
31
+ "example": {}
32
+ }
@@ -0,0 +1,56 @@
1
+ import {
2
+ useBlockProps,
3
+ RichText,
4
+ InspectorControls
5
+ } from '@wordpress/block-editor';
6
+ import { PanelBody, SelectControl } from '@wordpress/components';
7
+
8
+ const edit = ({ attributes, setAttributes }) => {
9
+ const { as, typographyStyle, content } = attributes;
10
+ const blockProps = useBlockProps();
11
+
12
+ const tagName = as || 'p';
13
+
14
+ return (
15
+ <>
16
+ <InspectorControls>
17
+ <PanelBody title="Text Settings">
18
+ <SelectControl
19
+ label="Tag"
20
+ value={as}
21
+ options={[
22
+ { label: 'Paragraph', value: 'p' },
23
+ { label: 'Span', value: 'span' },
24
+ { label: 'Heading 1', value: 'h1' },
25
+ { label: 'Heading 2', value: 'h2' },
26
+ { label: 'Heading 3', value: 'h3' },
27
+ { label: 'Heading 4', value: 'h4' },
28
+ { label: 'Heading 5', value: 'h5' }
29
+ ]}
30
+ onChange={(val) => setAttributes({ as: val })}
31
+ />
32
+ <SelectControl
33
+ label="Typography Style"
34
+ value={typographyStyle}
35
+ options={[
36
+ { label: 'Body Standard', value: 'body-standard' },
37
+ { label: 'Body Small', value: 'body-small' },
38
+ { label: 'Headline', value: 'headline' }
39
+ ]}
40
+ onChange={(val) => setAttributes({ typographyStyle: val })}
41
+ />
42
+ </PanelBody>
43
+ </InspectorControls>
44
+ <RichText
45
+ {...blockProps}
46
+ tagName={tagName}
47
+ value={content}
48
+ onChange={(val) => setAttributes({ content: val })}
49
+ className={`tds-text tds-text--${typographyStyle}`}
50
+ placeholder="Enter text..."
51
+ />
52
+ </>
53
+ );
54
+ };
55
+
56
+ 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,18 @@
1
+ import { useBlockProps, RichText } from '@wordpress/block-editor';
2
+
3
+ const save = ({ attributes }) => {
4
+ const { as, typographyStyle, content } = attributes;
5
+ const blockProps = useBlockProps.save();
6
+ const tagName = as || 'p';
7
+
8
+ return (
9
+ <RichText.Content
10
+ {...blockProps}
11
+ tagName={tagName}
12
+ value={content}
13
+ className={`tds-text tds-text--${typographyStyle}`}
14
+ />
15
+ );
16
+ };
17
+
18
+ export default save;
@@ -0,0 +1,4 @@
1
+ /* Text Editor Styles */
2
+ .wp-block-times-text {
3
+ margin: var(--spacing-m) 0;
4
+ }