@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.
- package/BLOCK_CREATION_CHECKLIST.md +160 -0
- package/BUILD.md +411 -0
- package/CHANGELOG.md +32 -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,36 @@
|
|
|
1
|
+
import { useBlockProps, RichText } from '@wordpress/block-editor';
|
|
2
|
+
|
|
3
|
+
const save = ({ attributes }) => {
|
|
4
|
+
const {
|
|
5
|
+
content,
|
|
6
|
+
intent,
|
|
7
|
+
size,
|
|
8
|
+
state,
|
|
9
|
+
channel,
|
|
10
|
+
toggle,
|
|
11
|
+
iconLeft,
|
|
12
|
+
iconRight,
|
|
13
|
+
ariaLabel
|
|
14
|
+
} = attributes;
|
|
15
|
+
const blockProps = useBlockProps.save();
|
|
16
|
+
|
|
17
|
+
const buildClass = () => {
|
|
18
|
+
const classes = ['tds-chip'];
|
|
19
|
+
classes.push(`tds-chip--intent-${intent}`);
|
|
20
|
+
classes.push(`tds-chip--size-${size}`);
|
|
21
|
+
classes.push(`tds-chip--state-${state}`);
|
|
22
|
+
if (channel) classes.push('tds-chip--channel');
|
|
23
|
+
if (toggle) classes.push('tds-chip--toggle');
|
|
24
|
+
return classes.join(' ');
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<button {...blockProps} className={buildClass()} aria-label={ariaLabel}>
|
|
29
|
+
{iconLeft && <span className="tds-chip__icon-left">{iconLeft}</span>}
|
|
30
|
+
<RichText.Content value={content} className="tds-chip__content" />
|
|
31
|
+
{iconRight && <span className="tds-chip__icon-right">{iconRight}</span>}
|
|
32
|
+
</button>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default save;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* Chip Block Styles */
|
|
2
|
+
.tds-chip {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--spacing-xs);
|
|
6
|
+
padding: var(--spacing-xs) var(--spacing-m);
|
|
7
|
+
border: 1px solid var(--color-border-secondary);
|
|
8
|
+
border-radius: 16px;
|
|
9
|
+
background-color: var(--color-fill-secondary);
|
|
10
|
+
color: var(--color-text-primary);
|
|
11
|
+
font: var(--typography-body-small);
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
transition: all 0.2s ease-in-out;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.tds-chip--intent-primary {
|
|
17
|
+
background-color: var(--color-fill-primary);
|
|
18
|
+
border-color: var(--color-border-primary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tds-chip--intent-negative {
|
|
22
|
+
background-color: var(--color-fill-negative);
|
|
23
|
+
border-color: var(--color-border-negative);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tds-chip--size-small {
|
|
27
|
+
padding: var(--spacing-xs) var(--spacing-s);
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.tds-chip--size-large {
|
|
32
|
+
padding: var(--spacing-s) var(--spacing-m);
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.tds-chip--state-hover {
|
|
37
|
+
opacity: 0.8;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.tds-chip--state-disabled {
|
|
41
|
+
opacity: 0.5;
|
|
42
|
+
cursor: not-allowed;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.tds-chip__icon-left,
|
|
46
|
+
.tds-chip__icon-right {
|
|
47
|
+
font-size: 14px;
|
|
48
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "times/divider",
|
|
5
|
+
"title": "Divider",
|
|
6
|
+
"category": "common",
|
|
7
|
+
"description": "A horizontal line divider component",
|
|
8
|
+
"icon": "minus",
|
|
9
|
+
"supports": {
|
|
10
|
+
"html": false,
|
|
11
|
+
"spacing": {
|
|
12
|
+
"margin": true
|
|
13
|
+
},
|
|
14
|
+
"align": ["wide", "full"]
|
|
15
|
+
},
|
|
16
|
+
"attributes": {
|
|
17
|
+
"isDashed": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"default": false
|
|
20
|
+
},
|
|
21
|
+
"isVertical": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"default": false
|
|
24
|
+
},
|
|
25
|
+
"padding": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"example": {}
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
|
2
|
+
import { PanelBody, ToggleControl } from '@wordpress/components';
|
|
3
|
+
|
|
4
|
+
const edit = ({ attributes, setAttributes }) => {
|
|
5
|
+
const { isDashed, isVertical, padding } = attributes;
|
|
6
|
+
const blockProps = useBlockProps();
|
|
7
|
+
|
|
8
|
+
const buildDividerClass = () => {
|
|
9
|
+
const classes = ['tds-divider'];
|
|
10
|
+
if (isDashed) classes.push('tds-divider--dashed');
|
|
11
|
+
if (isVertical) classes.push('tds-divider--vertical');
|
|
12
|
+
if (padding) classes.push('tds-divider--padding');
|
|
13
|
+
return classes.join(' ');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<InspectorControls>
|
|
19
|
+
<PanelBody title="Divider Settings">
|
|
20
|
+
<ToggleControl
|
|
21
|
+
label="Dashed"
|
|
22
|
+
checked={isDashed}
|
|
23
|
+
onChange={(val) => setAttributes({ isDashed: val })}
|
|
24
|
+
/>
|
|
25
|
+
<ToggleControl
|
|
26
|
+
label="Vertical"
|
|
27
|
+
checked={isVertical}
|
|
28
|
+
onChange={(val) => setAttributes({ isVertical: val })}
|
|
29
|
+
/>
|
|
30
|
+
<ToggleControl
|
|
31
|
+
label="Padding"
|
|
32
|
+
checked={padding}
|
|
33
|
+
onChange={(val) => setAttributes({ padding: val })}
|
|
34
|
+
/>
|
|
35
|
+
</PanelBody>
|
|
36
|
+
</InspectorControls>
|
|
37
|
+
<div {...blockProps} className={buildDividerClass()} />
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default edit;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
2
|
+
|
|
3
|
+
const save = ({ attributes }) => {
|
|
4
|
+
const { isDashed, isVertical, padding } = attributes;
|
|
5
|
+
const blockProps = useBlockProps.save();
|
|
6
|
+
|
|
7
|
+
const buildDividerClass = () => {
|
|
8
|
+
const classes = ['tds-divider'];
|
|
9
|
+
if (isDashed) classes.push('tds-divider--dashed');
|
|
10
|
+
if (isVertical) classes.push('tds-divider--vertical');
|
|
11
|
+
if (padding) classes.push('tds-divider--padding');
|
|
12
|
+
return classes.join(' ');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return <div {...blockProps} className={buildDividerClass()} />;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default save;
|
|
@@ -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,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,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,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,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
|
+
}
|