@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.
- package/BLOCK_CREATION_CHECKLIST.md +160 -0
- package/BUILD.md +411 -0
- package/CHANGELOG.md +30 -0
- package/LICENSE +29 -0
- package/README.md +972 -5
- package/TRANSFORMATION_GUIDE.md +635 -0
- package/block.json +10 -0
- package/dist/block.json +10 -0
- package/dist/blocks/ad-container/block.json +28 -0
- package/dist/blocks/ad-container/edit.js +42 -0
- package/dist/blocks/ad-container/index.js +10 -0
- package/dist/blocks/ad-container/save.js +16 -0
- package/dist/blocks/ad-container/style-editor.css +4 -0
- package/dist/blocks/ad-container/style.css +27 -0
- package/dist/blocks/button/block.json +89 -0
- package/dist/blocks/button/edit.js +187 -0
- package/dist/blocks/button/index.js +11 -0
- package/dist/blocks/button/save.js +52 -0
- package/dist/blocks/button/style-editor.css +15 -0
- package/dist/blocks/button/style.css +37 -0
- package/dist/blocks/chip/block.json +57 -0
- package/dist/blocks/chip/edit.js +113 -0
- package/dist/blocks/chip/index.js +10 -0
- package/dist/blocks/chip/save.js +36 -0
- package/dist/blocks/chip/style-editor.css +5 -0
- package/dist/blocks/chip/style.css +48 -0
- package/dist/blocks/divider/block.json +31 -0
- package/dist/blocks/divider/edit.js +42 -0
- package/dist/blocks/divider/index.js +10 -0
- package/dist/blocks/divider/save.js +18 -0
- package/dist/blocks/divider/style-editor.css +4 -0
- package/dist/blocks/divider/style.css +25 -0
- package/dist/blocks/flag/block.json +48 -0
- package/dist/blocks/flag/edit.js +82 -0
- package/dist/blocks/flag/index.js +10 -0
- package/dist/blocks/flag/save.js +25 -0
- package/dist/blocks/flag/style-editor.css +5 -0
- package/dist/blocks/flag/style.css +45 -0
- package/dist/blocks/icon-button/block.json +43 -0
- package/dist/blocks/icon-button/edit.js +82 -0
- package/dist/blocks/icon-button/index.js +10 -0
- package/dist/blocks/icon-button/save.js +29 -0
- package/dist/blocks/icon-button/style-editor.css +5 -0
- package/dist/blocks/icon-button/style.css +32 -0
- package/dist/blocks/input/block.json +47 -0
- package/dist/blocks/input/edit.js +78 -0
- package/dist/blocks/input/index.js +10 -0
- package/dist/blocks/input/save.js +27 -0
- package/dist/blocks/input/style-editor.css +8 -0
- package/dist/blocks/input/style.css +30 -0
- package/dist/blocks/link/block.json +71 -0
- package/dist/blocks/link/edit.js +151 -0
- package/dist/blocks/link/index.js +10 -0
- package/dist/blocks/link/save.js +46 -0
- package/dist/blocks/link/style-editor.css +5 -0
- package/dist/blocks/link/style.css +66 -0
- package/dist/blocks/text/block.json +32 -0
- package/dist/blocks/text/edit.js +56 -0
- package/dist/blocks/text/index.js +10 -0
- package/dist/blocks/text/save.js +18 -0
- package/dist/blocks/text/style-editor.css +4 -0
- package/dist/blocks/text/style.css +20 -0
- package/dist/blocks/toast/block.json +39 -0
- package/dist/blocks/toast/edit.js +85 -0
- package/dist/blocks/toast/index.js +10 -0
- package/dist/blocks/toast/save.js +29 -0
- package/dist/blocks/toast/style-editor.css +4 -0
- package/dist/blocks/toast/style.css +51 -0
- package/dist/index.cjs +2232 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +2196 -255
- package/dist/index.js.map +1 -1
- package/dist/plugin.php +79 -0
- package/dist/utils/classBuilder.js +53 -0
- package/package.json +39 -7
- package/plugin.php +79 -0
- package/rollup.config.js +39 -22
- package/scripts/build-plugin.cjs +121 -0
- package/scripts/create-block.sh +141 -0
- package/src/blocks/ad-container/block.json +28 -0
- package/src/blocks/ad-container/edit.js +42 -0
- package/src/blocks/ad-container/index.js +10 -0
- package/src/blocks/ad-container/save.js +16 -0
- package/src/blocks/ad-container/style-editor.css +4 -0
- package/src/blocks/ad-container/style.css +27 -0
- package/src/blocks/button/block.json +89 -0
- package/src/blocks/button/edit.js +187 -0
- package/src/blocks/button/index.js +11 -0
- package/src/blocks/button/save.js +52 -0
- package/src/blocks/button/style-editor.css +15 -0
- package/src/blocks/button/style.css +37 -0
- package/src/blocks/chip/block.json +57 -0
- package/src/blocks/chip/edit.js +113 -0
- package/src/blocks/chip/index.js +10 -0
- package/src/blocks/chip/save.js +36 -0
- package/src/blocks/chip/style-editor.css +5 -0
- package/src/blocks/chip/style.css +48 -0
- package/src/blocks/divider/block.json +31 -0
- package/src/blocks/divider/edit.js +42 -0
- package/src/blocks/divider/index.js +10 -0
- package/src/blocks/divider/save.js +18 -0
- package/src/blocks/divider/style-editor.css +4 -0
- package/src/blocks/divider/style.css +25 -0
- package/src/blocks/flag/block.json +48 -0
- package/src/blocks/flag/edit.js +82 -0
- package/src/blocks/flag/index.js +10 -0
- package/src/blocks/flag/save.js +25 -0
- package/src/blocks/flag/style-editor.css +5 -0
- package/src/blocks/flag/style.css +45 -0
- package/src/blocks/icon-button/block.json +43 -0
- package/src/blocks/icon-button/edit.js +82 -0
- package/src/blocks/icon-button/index.js +10 -0
- package/src/blocks/icon-button/save.js +29 -0
- package/src/blocks/icon-button/style-editor.css +5 -0
- package/src/blocks/icon-button/style.css +32 -0
- package/src/blocks/input/block.json +47 -0
- package/src/blocks/input/edit.js +78 -0
- package/src/blocks/input/index.js +10 -0
- package/src/blocks/input/save.js +27 -0
- package/src/blocks/input/style-editor.css +8 -0
- package/src/blocks/input/style.css +30 -0
- package/src/blocks/link/block.json +71 -0
- package/src/blocks/link/edit.js +151 -0
- package/src/blocks/link/index.js +10 -0
- package/src/blocks/link/save.js +46 -0
- package/src/blocks/link/style-editor.css +5 -0
- package/src/blocks/link/style.css +66 -0
- package/src/blocks/text/block.json +32 -0
- package/src/blocks/text/edit.js +56 -0
- package/src/blocks/text/index.js +10 -0
- package/src/blocks/text/save.js +18 -0
- package/src/blocks/text/style-editor.css +4 -0
- package/src/blocks/text/style.css +20 -0
- package/src/blocks/toast/block.json +39 -0
- package/src/blocks/toast/edit.js +85 -0
- package/src/blocks/toast/index.js +10 -0
- package/src/blocks/toast/save.js +29 -0
- package/src/blocks/toast/style-editor.css +4 -0
- package/src/blocks/toast/style.css +51 -0
- package/src/index.js +15 -12
- package/src/utils/classBuilder.js +53 -0
- package/tsconfig.json +4 -4
- package/__tests__/wordpress.test.js +0 -0
- package/dist/AdContainer/AdContainer.d.ts +0 -9
- package/dist/Article/ArticleMetaContainer/ArticleMetaContainer.d.ts +0 -8
- package/dist/Article/UpNextArticles/UpNextArticles.d.ts +0 -13
- package/dist/Button/Button.d.ts +0 -15
- package/dist/CommentsDisabled/CommentsDisabled.d.ts +0 -10
- package/dist/CommentsDisabled/CommentsDisabled.stories.d.ts +0 -44
- package/dist/CommentsDisabled/index.d.ts +0 -2
- package/dist/Divider/Divider.d.ts +0 -15
- package/dist/Input/Input.d.ts +0 -25
- package/dist/Link/Link.d.ts +0 -18
- package/dist/Text/Text.d.ts +0 -14
- package/dist/index.cjs.js +0 -299
- package/dist/index.cjs.js.map +0 -1
- package/dist/styles.css +0 -151
- package/dist/typographyStyles.css +0 -30
- package/dist/utils/cn.d.ts +0 -1
- package/dist/utils/hooks.d.ts +0 -8
- package/src/AdContainer/AdContainer.tsx +0 -31
- package/src/AdContainer/styles.css +0 -58
- package/src/Article/ArticleMetaContainer/ArticleMetaContainer.tsx +0 -14
- package/src/Article/ArticleMetaContainer/styles.css +0 -151
- package/src/Article/UpNextArticles/UpNextArticles.tsx +0 -69
- package/src/Article/UpNextArticles/styles.css +0 -151
- package/src/Button/Button.tsx +0 -36
- package/src/Button/styles.css +0 -30
- package/src/CommentsDisabled/CommentsDisabled.stories.tsx +0 -178
- package/src/CommentsDisabled/CommentsDisabled.tsx +0 -63
- package/src/CommentsDisabled/IMPLEMENTATION_SUMMARY.md +0 -305
- package/src/CommentsDisabled/README.md +0 -284
- package/src/CommentsDisabled/TOKEN_MAPPING.md +0 -269
- package/src/CommentsDisabled/index.ts +0 -2
- package/src/CommentsDisabled/styles.css +0 -82
- package/src/Divider/Divider.tsx +0 -41
- package/src/Divider/styles.css +0 -80
- package/src/Input/Input.tsx +0 -62
- package/src/Input/styles.css +0 -69
- package/src/Link/Link.tsx +0 -49
- package/src/Link/styles.css +0 -111
- package/src/Text/Text.tsx +0 -38
- package/src/Text/styles.css +0 -30
- package/src/Text/typographyStyles.css +0 -30
- package/src/utils/cn.js +0 -3
- package/src/utils/cn.tsx +0 -3
- package/src/utils/hooks.ts +0 -34
|
@@ -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,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,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,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,20 @@
|
|
|
1
|
+
/* Text Block Styles */
|
|
2
|
+
.tds-text {
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.tds-text--body-standard {
|
|
8
|
+
font: var(--typography-body-standard);
|
|
9
|
+
color: var(--color-text-primary);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.tds-text--body-small {
|
|
13
|
+
font: var(--typography-body-small);
|
|
14
|
+
color: var(--color-text-secondary);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tds-text--headline {
|
|
18
|
+
font: var(--typography-headline);
|
|
19
|
+
color: var(--color-text-primary);
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "times/toast",
|
|
5
|
+
"title": "Toast",
|
|
6
|
+
"category": "common",
|
|
7
|
+
"description": "Notification toast component",
|
|
8
|
+
"icon": "bell",
|
|
9
|
+
"supports": {
|
|
10
|
+
"html": false,
|
|
11
|
+
"spacing": {
|
|
12
|
+
"margin": true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"attributes": {
|
|
16
|
+
"label": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"default": ""
|
|
19
|
+
},
|
|
20
|
+
"intent": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"default": "info",
|
|
23
|
+
"enum": ["info", "success", "warning", "error"]
|
|
24
|
+
},
|
|
25
|
+
"link": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false
|
|
28
|
+
},
|
|
29
|
+
"linkLabel": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"default": ""
|
|
32
|
+
},
|
|
33
|
+
"timeout": {
|
|
34
|
+
"type": "number",
|
|
35
|
+
"default": 5000
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"example": {}
|
|
39
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useBlockProps,
|
|
3
|
+
RichText,
|
|
4
|
+
InspectorControls
|
|
5
|
+
} from '@wordpress/block-editor';
|
|
6
|
+
import {
|
|
7
|
+
PanelBody,
|
|
8
|
+
SelectControl,
|
|
9
|
+
TextControl,
|
|
10
|
+
ToggleControl,
|
|
11
|
+
NumberControl
|
|
12
|
+
} from '@wordpress/components';
|
|
13
|
+
|
|
14
|
+
const edit = ({ attributes, setAttributes }) => {
|
|
15
|
+
const { label, intent, link, linkLabel, timeout } = attributes;
|
|
16
|
+
const blockProps = useBlockProps();
|
|
17
|
+
|
|
18
|
+
const buildClass = () => {
|
|
19
|
+
const classes = ['tds-toast'];
|
|
20
|
+
classes.push(`tds-toast--intent-${intent}`);
|
|
21
|
+
return classes.join(' ');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<InspectorControls>
|
|
27
|
+
<PanelBody title="Toast Settings">
|
|
28
|
+
<TextControl
|
|
29
|
+
label="Label"
|
|
30
|
+
value={label}
|
|
31
|
+
onChange={(val) => setAttributes({ label: val })}
|
|
32
|
+
/>
|
|
33
|
+
<SelectControl
|
|
34
|
+
label="Intent"
|
|
35
|
+
value={intent}
|
|
36
|
+
options={[
|
|
37
|
+
{ label: 'Info', value: 'info' },
|
|
38
|
+
{ label: 'Success', value: 'success' },
|
|
39
|
+
{ label: 'Warning', value: 'warning' },
|
|
40
|
+
{ label: 'Error', value: 'error' }
|
|
41
|
+
]}
|
|
42
|
+
onChange={(val) => setAttributes({ intent: val })}
|
|
43
|
+
/>
|
|
44
|
+
<ToggleControl
|
|
45
|
+
label="Show Link"
|
|
46
|
+
checked={link}
|
|
47
|
+
onChange={(val) => setAttributes({ link: val })}
|
|
48
|
+
/>
|
|
49
|
+
{link && (
|
|
50
|
+
<TextControl
|
|
51
|
+
label="Link Label"
|
|
52
|
+
value={linkLabel}
|
|
53
|
+
onChange={(val) => setAttributes({ linkLabel: val })}
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
<NumberControl
|
|
57
|
+
label="Timeout (ms)"
|
|
58
|
+
value={timeout}
|
|
59
|
+
onChange={(val) => setAttributes({ timeout: val || 0 })}
|
|
60
|
+
min={0}
|
|
61
|
+
step={1000}
|
|
62
|
+
/>
|
|
63
|
+
</PanelBody>
|
|
64
|
+
</InspectorControls>
|
|
65
|
+
<div
|
|
66
|
+
{...blockProps}
|
|
67
|
+
className={buildClass()}
|
|
68
|
+
role="status"
|
|
69
|
+
aria-live="polite"
|
|
70
|
+
>
|
|
71
|
+
<div className="tds-toast__content">
|
|
72
|
+
<RichText
|
|
73
|
+
value={label}
|
|
74
|
+
onChange={(val) => setAttributes({ label: val })}
|
|
75
|
+
placeholder="Toast message"
|
|
76
|
+
className="tds-toast__label"
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
{link && <button className="tds-toast__link">{linkLabel}</button>}
|
|
80
|
+
</div>
|
|
81
|
+
</>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default edit;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useBlockProps, RichText } from '@wordpress/block-editor';
|
|
2
|
+
|
|
3
|
+
const save = ({ attributes }) => {
|
|
4
|
+
const { label, intent, link, linkLabel, timeout } = attributes;
|
|
5
|
+
const blockProps = useBlockProps.save();
|
|
6
|
+
|
|
7
|
+
const buildClass = () => {
|
|
8
|
+
const classes = ['tds-toast'];
|
|
9
|
+
classes.push(`tds-toast--intent-${intent}`);
|
|
10
|
+
return classes.join(' ');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div
|
|
15
|
+
{...blockProps}
|
|
16
|
+
className={buildClass()}
|
|
17
|
+
role="status"
|
|
18
|
+
aria-live="polite"
|
|
19
|
+
data-timeout={timeout}
|
|
20
|
+
>
|
|
21
|
+
<div className="tds-toast__content">
|
|
22
|
+
<RichText.Content value={label} className="tds-toast__label" />
|
|
23
|
+
</div>
|
|
24
|
+
{link && <button className="tds-toast__link">{linkLabel}</button>}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default save;
|