@times-design-system/components-wordpress 1.5.2 → 1.6.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/dist/blocks/ad-container/block.json +10 -0
- package/dist/blocks/ad-container/edit.js +17 -1
- package/dist/blocks/ad-container/render.php +14 -0
- package/dist/blocks/button/block.json +19 -5
- package/dist/blocks/button/edit.js +33 -15
- package/dist/blocks/button/render.php +24 -2
- package/dist/blocks/button/style.css +63 -0
- package/dist/blocks/chip/block.json +12 -7
- package/dist/blocks/chip/edit.js +20 -17
- package/dist/blocks/chip/render.php +14 -2
- package/dist/blocks/dialog-box/block.json +10 -0
- package/dist/blocks/dialog-box/edit.js +17 -0
- package/dist/blocks/dialog-box/render.php +16 -4
- package/dist/blocks/divider/block.json +10 -0
- package/dist/blocks/divider/edit.js +18 -2
- package/dist/blocks/divider/render.php +14 -1
- package/dist/blocks/flag/block.json +10 -0
- package/dist/blocks/flag/edit.js +27 -2
- package/dist/blocks/flag/render.php +14 -0
- package/dist/blocks/icon/block.json +10 -0
- package/dist/blocks/icon/edit.js +17 -0
- package/dist/blocks/icon/render.php +16 -4
- package/dist/blocks/icon-button/block.json +15 -0
- package/dist/blocks/icon-button/edit.js +33 -1
- package/dist/blocks/icon-button/render.php +19 -0
- package/dist/blocks/icon-button/style.css +37 -3
- package/dist/blocks/input/block.json +10 -0
- package/dist/blocks/input/edit.js +27 -1
- package/dist/blocks/input/render.php +17 -1
- package/dist/blocks/input-helper-message/block.json +10 -0
- package/dist/blocks/input-helper-message/edit.js +17 -0
- package/dist/blocks/input-helper-message/render.php +16 -4
- package/dist/blocks/link/block.json +12 -7
- package/dist/blocks/link/edit.js +21 -18
- package/dist/blocks/link/render.php +14 -2
- package/dist/blocks/tab/block.json +10 -0
- package/dist/blocks/tab/edit.js +17 -0
- package/dist/blocks/tab/render.php +16 -4
- package/dist/blocks/tab-group/block.json +10 -0
- package/dist/blocks/tab-group/edit.js +17 -0
- package/dist/blocks/tab-group/render.php +16 -4
- package/dist/blocks/text/block.json +10 -0
- package/dist/blocks/text/edit.js +18 -2
- package/dist/blocks/text/render.php +14 -1
- package/dist/blocks/toast/block.json +10 -0
- package/dist/blocks/toast/edit.js +18 -1
- package/dist/blocks/toast/render.php +14 -0
- package/dist/index.cjs +389 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +389 -148
- package/dist/index.js.map +1 -1
- package/dist/utils/DATA_ATTRIBUTES_USAGE.md +377 -0
- package/dist/utils/sanitize-data-attributes.php +109 -0
- package/package.json +9 -3
- package/BLOCK_CREATION_CHECKLIST.md +0 -385
- package/BUILD.md +0 -411
- package/CHANGELOG.md +0 -81
- package/SCSS_VARIABLES_REFERENCE.md +0 -316
- package/STYLING_SYNC_GUIDE.md +0 -306
- package/TESTING.md +0 -152
- package/TRANSFORMATION_GUIDE.md +0 -908
- package/dist/blocks/button/style-resolved.css +0 -153
- package/lib/wordpress.js +0 -7
- package/rollup.config.js +0 -75
- package/scripts/build-plugin.cjs +0 -121
- package/scripts/create-block.sh +0 -141
- package/scripts/create-wordpress-block-tests.cjs +0 -438
- package/scripts/create-wordpress-block.cjs +0 -681
- package/src/blocks/ad-container/block.json +0 -29
- package/src/blocks/ad-container/edit.js +0 -42
- package/src/blocks/ad-container/index.js +0 -10
- package/src/blocks/ad-container/render.php +0 -27
- package/src/blocks/ad-container/save.js +0 -16
- package/src/blocks/ad-container/style-editor.css +0 -4
- package/src/blocks/ad-container/style.css +0 -30
- package/src/blocks/button/block.json +0 -90
- package/src/blocks/button/edit.js +0 -187
- package/src/blocks/button/index.js +0 -11
- package/src/blocks/button/render.php +0 -71
- package/src/blocks/button/save.js +0 -52
- package/src/blocks/button/style-editor.css +0 -15
- package/src/blocks/button/style-resolved.css +0 -153
- package/src/blocks/button/style.css +0 -157
- package/src/blocks/chip/block.json +0 -58
- package/src/blocks/chip/edit.js +0 -113
- package/src/blocks/chip/index.js +0 -10
- package/src/blocks/chip/render.php +0 -40
- package/src/blocks/chip/save.js +0 -36
- package/src/blocks/chip/style-editor.css +0 -5
- package/src/blocks/chip/style.css +0 -87
- package/src/blocks/dialog-box/block.json +0 -24
- package/src/blocks/dialog-box/edit.js +0 -41
- package/src/blocks/dialog-box/index.js +0 -17
- package/src/blocks/dialog-box/render.php +0 -24
- package/src/blocks/dialog-box/save.js +0 -23
- package/src/blocks/dialog-box/style.css +0 -23
- package/src/blocks/divider/block.json +0 -32
- package/src/blocks/divider/edit.js +0 -42
- package/src/blocks/divider/index.js +0 -10
- package/src/blocks/divider/render.php +0 -31
- package/src/blocks/divider/save.js +0 -18
- package/src/blocks/divider/style-editor.css +0 -4
- package/src/blocks/divider/style.css +0 -37
- package/src/blocks/flag/block.json +0 -49
- package/src/blocks/flag/edit.js +0 -82
- package/src/blocks/flag/index.js +0 -10
- package/src/blocks/flag/render.php +0 -34
- package/src/blocks/flag/save.js +0 -25
- package/src/blocks/flag/style-editor.css +0 -5
- package/src/blocks/flag/style.css +0 -54
- package/src/blocks/icon/block.json +0 -24
- package/src/blocks/icon/edit.js +0 -41
- package/src/blocks/icon/index.js +0 -17
- package/src/blocks/icon/render.php +0 -24
- package/src/blocks/icon/save.js +0 -23
- package/src/blocks/icon/style.css +0 -23
- package/src/blocks/icon-button/block.json +0 -44
- package/src/blocks/icon-button/edit.js +0 -82
- package/src/blocks/icon-button/index.js +0 -10
- package/src/blocks/icon-button/render.php +0 -46
- package/src/blocks/icon-button/save.js +0 -29
- package/src/blocks/icon-button/style-editor.css +0 -5
- package/src/blocks/icon-button/style.css +0 -31
- package/src/blocks/input/block.json +0 -48
- package/src/blocks/input/edit.js +0 -78
- package/src/blocks/input/index.js +0 -10
- package/src/blocks/input/render.php +0 -39
- package/src/blocks/input/save.js +0 -27
- package/src/blocks/input/style-editor.css +0 -8
- package/src/blocks/input/style.css +0 -53
- package/src/blocks/input-helper-message/block.json +0 -24
- package/src/blocks/input-helper-message/edit.js +0 -42
- package/src/blocks/input-helper-message/index.js +0 -17
- package/src/blocks/input-helper-message/render.php +0 -24
- package/src/blocks/input-helper-message/save.js +0 -23
- package/src/blocks/input-helper-message/style.css +0 -23
- package/src/blocks/link/block.json +0 -72
- package/src/blocks/link/edit.js +0 -151
- package/src/blocks/link/index.js +0 -10
- package/src/blocks/link/render.php +0 -44
- package/src/blocks/link/save.js +0 -46
- package/src/blocks/link/style-editor.css +0 -5
- package/src/blocks/link/style.css +0 -119
- package/src/blocks/tab/block.json +0 -24
- package/src/blocks/tab/edit.js +0 -41
- package/src/blocks/tab/index.js +0 -17
- package/src/blocks/tab/render.php +0 -24
- package/src/blocks/tab/save.js +0 -23
- package/src/blocks/tab/style.css +0 -23
- package/src/blocks/tab-group/block.json +0 -24
- package/src/blocks/tab-group/edit.js +0 -41
- package/src/blocks/tab-group/index.js +0 -17
- package/src/blocks/tab-group/render.php +0 -24
- package/src/blocks/tab-group/save.js +0 -23
- package/src/blocks/tab-group/style.css +0 -23
- package/src/blocks/text/block.json +0 -33
- package/src/blocks/text/edit.js +0 -56
- package/src/blocks/text/index.js +0 -10
- package/src/blocks/text/render.php +0 -26
- package/src/blocks/text/save.js +0 -18
- package/src/blocks/text/style-editor.css +0 -4
- package/src/blocks/text/style.css +0 -7
- package/src/blocks/toast/block.json +0 -40
- package/src/blocks/toast/edit.js +0 -85
- package/src/blocks/toast/index.js +0 -10
- package/src/blocks/toast/render.php +0 -37
- package/src/blocks/toast/save.js +0 -29
- package/src/blocks/toast/style-editor.css +0 -4
- package/src/blocks/toast/style.css +0 -67
- package/src/index.js +0 -16
- package/src/utils/classBuilder.js +0 -53
- package/tsconfig.json +0 -116
- package/vitest.config.js +0 -28
- package/vitest.config.ts +0 -28
- package/vitest.setup.ts +0 -129
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/tab-group",
|
|
5
|
-
"title": "Times Design System - TabGroup",
|
|
6
|
-
"category": "common",
|
|
7
|
-
"description": "WordPress block for Times Design System TabGroup component",
|
|
8
|
-
"icon": "block-default",
|
|
9
|
-
"supports": {
|
|
10
|
-
"html": false,
|
|
11
|
-
"multiple": true,
|
|
12
|
-
"reusable": true,
|
|
13
|
-
"customClassName": true
|
|
14
|
-
},
|
|
15
|
-
"textdomain": "times-blocks",
|
|
16
|
-
"attributes": {
|
|
17
|
-
"content": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"default": ""
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"render": "file:./render.php",
|
|
23
|
-
"editorScript": "file:./index.js"
|
|
24
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Block Editor Component: TabGroup
|
|
3
|
-
*
|
|
4
|
-
* Renders the editor UI for the TabGroup block in Gutenberg.
|
|
5
|
-
* Reference: packages/components-react/src/TabGroup/
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
|
9
|
-
import { PanelBody, TextControl } from '@wordpress/components';
|
|
10
|
-
|
|
11
|
-
export function edit(props) {
|
|
12
|
-
const { attributes, setAttributes } = props;
|
|
13
|
-
const blockProps = useBlockProps();
|
|
14
|
-
|
|
15
|
-
// TODO: Implement editor UI based on component props
|
|
16
|
-
// - Add inspector controls for attributes
|
|
17
|
-
// - Render preview of component in editor
|
|
18
|
-
// - Handle attribute changes via setAttributes()
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
<InspectorControls>
|
|
23
|
-
<PanelBody title="TabGroup Settings" initialOpen={true}>
|
|
24
|
-
<TextControl
|
|
25
|
-
label="Content"
|
|
26
|
-
value={attributes.content || ''}
|
|
27
|
-
onChange={(content) => setAttributes({ content })}
|
|
28
|
-
placeholder="Enter content..."
|
|
29
|
-
/>
|
|
30
|
-
{/* TODO: Add more controls based on component variants */}
|
|
31
|
-
</PanelBody>
|
|
32
|
-
</InspectorControls>
|
|
33
|
-
<div {...blockProps}>
|
|
34
|
-
<p>📝 TabGroup block editor</p>
|
|
35
|
-
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
36
|
-
TODO: Render the TabGroup component here with current attributes
|
|
37
|
-
</p>
|
|
38
|
-
</div>
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress Block Loader: TabGroup
|
|
3
|
-
*
|
|
4
|
-
* Reference: packages/components-react/src/TabGroup/
|
|
5
|
-
* TODO: Update attributes in block.json based on component props
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { registerBlockType } from '@wordpress/blocks';
|
|
9
|
-
import { edit as Edit } from './edit';
|
|
10
|
-
import { save as Save } from './save';
|
|
11
|
-
import blockConfig from './block.json';
|
|
12
|
-
|
|
13
|
-
registerBlockType(blockConfig.name, {
|
|
14
|
-
...blockConfig,
|
|
15
|
-
edit: Edit,
|
|
16
|
-
save: Save
|
|
17
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Block Rendering: TabGroup
|
|
4
|
-
*
|
|
5
|
-
* Server-side rendering for the TabGroup block.
|
|
6
|
-
* Reference: packages/components-react/src/TabGroup/
|
|
7
|
-
*
|
|
8
|
-
* @param array $attributes Block attributes
|
|
9
|
-
* @param string $content Saved block content
|
|
10
|
-
* @param WP_Block $block The block instance
|
|
11
|
-
* @return string Rendered HTML
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
$wrapper_attributes = get_block_wrapper_attributes();
|
|
15
|
-
|
|
16
|
-
// TODO: Render the TabGroup component
|
|
17
|
-
// Extract attributes and render appropriate HTML with BEM classes
|
|
18
|
-
|
|
19
|
-
?>
|
|
20
|
-
<div <?php echo wp_kses_post( $wrapper_attributes ); ?>>
|
|
21
|
-
<!-- TODO: Render TabGroup component here -->
|
|
22
|
-
<!-- Use CSS custom properties from packages/tokens/data/resolved-hexes.json -->
|
|
23
|
-
<!-- Apply BEM naming: tds-tab-group--{modifier} -->
|
|
24
|
-
</div>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Block Save Component: TabGroup
|
|
3
|
-
*
|
|
4
|
-
* Renders the static output saved to the database.
|
|
5
|
-
* Reference: packages/components-react/src/TabGroup/
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { useBlockProps } from '@wordpress/block-editor';
|
|
9
|
-
|
|
10
|
-
export function save(props) {
|
|
11
|
-
const { attributes } = props;
|
|
12
|
-
const blockProps = useBlockProps.save();
|
|
13
|
-
|
|
14
|
-
// TODO: Render the actual TabGroup component with attributes
|
|
15
|
-
// This output is saved to the database and displayed on the frontend
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<div {...blockProps}>
|
|
19
|
-
{/* TODO: Render TabGroup component */}
|
|
20
|
-
{attributes.content && <p>{attributes.content}</p>}
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Styles for TabGroup Block
|
|
3
|
-
*
|
|
4
|
-
* Reference: packages/components-react/src/TabGroup/
|
|
5
|
-
* Token Reference: packages/tokens/data/resolved-hexes.json
|
|
6
|
-
*
|
|
7
|
-
* TODO: Adapt styles from React component
|
|
8
|
-
* - Copy relevant CSS from React component
|
|
9
|
-
* - Map CSS custom properties to resolved hex values
|
|
10
|
-
* - Use BEM naming: .tds-tab-group--{modifier}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
.tds-tab-group {
|
|
14
|
-
/* TODO: Add component styles here */
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.tds-tab-group--focus {
|
|
18
|
-
/* TODO: Add focus state styles */
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.tds-tab-group--disabled {
|
|
22
|
-
/* TODO: Add disabled state styles */
|
|
23
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/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
|
-
"render": "file:./render.php",
|
|
17
|
-
"attributes": {
|
|
18
|
-
"as": {
|
|
19
|
-
"type": "string",
|
|
20
|
-
"default": "p",
|
|
21
|
-
"enum": ["p", "span", "h1", "h2", "h3", "h4", "h5"]
|
|
22
|
-
},
|
|
23
|
-
"typographyStyle": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"default": "body-standard"
|
|
26
|
-
},
|
|
27
|
-
"content": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"default": ""
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"example": {}
|
|
33
|
-
}
|
package/src/blocks/text/edit.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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;
|
package/src/blocks/text/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Text Block Render Callback
|
|
4
|
-
*
|
|
5
|
-
* Renders the Text typography block on the frontend.
|
|
6
|
-
*
|
|
7
|
-
* @package TimesDesignSystem\ComponentsWordPress
|
|
8
|
-
* @var array $attributes Block attributes
|
|
9
|
-
* @var string $content Block content
|
|
10
|
-
* @var WP_Block $block Block instance
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
$as = isset($attributes['as']) ? sanitize_text_field($attributes['as']) : 'p';
|
|
14
|
-
$typography_style = isset($attributes['typographyStyle']) ? sanitize_text_field($attributes['typographyStyle']) : '';
|
|
15
|
-
$text_content = isset($attributes['content']) ? wp_kses_post($attributes['content']) : '';
|
|
16
|
-
|
|
17
|
-
$tag_name = in_array($as, ['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5'], true) ? $as : 'p';
|
|
18
|
-
$class_name = 'tds-text';
|
|
19
|
-
if ($typography_style) {
|
|
20
|
-
$class_name .= ' tds-text--' . sanitize_html_class($typography_style);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
$wrapper_attrs = get_block_wrapper_attributes(['class' => $class_name]);
|
|
24
|
-
?>
|
|
25
|
-
|
|
26
|
-
<?php echo wp_sprintf('<%s %s>%s</%s>', $tag_name, wp_kses_post($wrapper_attrs), wp_kses_post($text_content), $tag_name); ?>
|
package/src/blocks/text/save.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/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
|
-
"render": "file:./render.php",
|
|
16
|
-
"attributes": {
|
|
17
|
-
"label": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"default": ""
|
|
20
|
-
},
|
|
21
|
-
"intent": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"default": "info",
|
|
24
|
-
"enum": ["info", "success", "warning", "error"]
|
|
25
|
-
},
|
|
26
|
-
"link": {
|
|
27
|
-
"type": "boolean",
|
|
28
|
-
"default": false
|
|
29
|
-
},
|
|
30
|
-
"linkLabel": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"default": ""
|
|
33
|
-
},
|
|
34
|
-
"timeout": {
|
|
35
|
-
"type": "number",
|
|
36
|
-
"default": 5000
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"example": {}
|
|
40
|
-
}
|
package/src/blocks/toast/edit.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
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;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Toast Block Render Callback
|
|
4
|
-
*
|
|
5
|
-
* Renders the Toast notification block on the frontend.
|
|
6
|
-
*
|
|
7
|
-
* @package TimesDesignSystem\ComponentsWordPress
|
|
8
|
-
* @var array $attributes Block attributes
|
|
9
|
-
* @var string $content Block content
|
|
10
|
-
* @var WP_Block $block Block instance
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
$label = isset($attributes['label']) ? wp_kses_post($attributes['label']) : '';
|
|
14
|
-
$intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : '';
|
|
15
|
-
$link = isset($attributes['link']) ? esc_url($attributes['link']) : '';
|
|
16
|
-
$link_label = isset($attributes['linkLabel']) ? sanitize_text_field($attributes['linkLabel']) : '';
|
|
17
|
-
$timeout = isset($attributes['timeout']) ? intval($attributes['timeout']) : 0;
|
|
18
|
-
|
|
19
|
-
$classes = ['tds-toast'];
|
|
20
|
-
$classes[] = 'tds-toast--intent-' . $intent;
|
|
21
|
-
|
|
22
|
-
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
23
|
-
?>
|
|
24
|
-
|
|
25
|
-
<div
|
|
26
|
-
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
27
|
-
role="status"
|
|
28
|
-
aria-live="polite"
|
|
29
|
-
<?php echo $timeout ? 'data-timeout="' . esc_attr($timeout) . '"' : ''; ?>
|
|
30
|
-
>
|
|
31
|
-
<div class="tds-toast__content">
|
|
32
|
-
<div class="tds-toast__label"><?php echo wp_kses_post($label); ?></div>
|
|
33
|
-
</div>
|
|
34
|
-
<?php if ($link && $link_label) : ?>
|
|
35
|
-
<a href="<?php echo esc_attr($link); ?>" class="tds-toast__link"><?php echo wp_kses_post($link_label); ?></a>
|
|
36
|
-
<?php endif; ?>
|
|
37
|
-
</div>
|
package/src/blocks/toast/save.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/* Toast Block Frontend Styles */
|
|
2
|
-
/* Using resolved design token values for self-contained styling */
|
|
3
|
-
|
|
4
|
-
.tds-toast {
|
|
5
|
-
--tds-toast-fill: #22724f;
|
|
6
|
-
--tds-toast-text: #ffffff;
|
|
7
|
-
--tds-toast-link: #ffffff;
|
|
8
|
-
|
|
9
|
-
display: inline-flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
gap: 12px;
|
|
12
|
-
width: 373px;
|
|
13
|
-
min-height: 48px;
|
|
14
|
-
padding: 12px 16px;
|
|
15
|
-
border-radius: 4px;
|
|
16
|
-
background: var(--tds-toast-fill);
|
|
17
|
-
color: var(--tds-toast-text);
|
|
18
|
-
box-shadow: 0 16px 24px 0 rgb(0 0 0 / 8%);
|
|
19
|
-
box-sizing: border-box;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.tds-toast__content {
|
|
23
|
-
flex: 1 1 auto;
|
|
24
|
-
min-width: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.tds-toast__label {
|
|
28
|
-
font-family: Roboto;
|
|
29
|
-
font-size: 1.6rem;
|
|
30
|
-
line-height: 1.5;
|
|
31
|
-
font-weight: 400;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.tds-toast__link {
|
|
35
|
-
flex: 0 0 auto;
|
|
36
|
-
font-family: Roboto;
|
|
37
|
-
font-size: 1.6rem;
|
|
38
|
-
line-height: 1.5;
|
|
39
|
-
font-weight: 700;
|
|
40
|
-
text-decoration: underline;
|
|
41
|
-
color: var(--tds-toast-link);
|
|
42
|
-
cursor: pointer;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.tds-toast--intent-success {
|
|
46
|
-
--tds-toast-fill: #22724f;
|
|
47
|
-
--tds-toast-text: #ffffff;
|
|
48
|
-
--tds-toast-link: #ffffff;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.tds-toast--intent-info {
|
|
52
|
-
--tds-toast-fill: #0a3472;
|
|
53
|
-
--tds-toast-text: #ffffff;
|
|
54
|
-
--tds-toast-link: #ffffff;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.tds-toast--intent-warning {
|
|
58
|
-
--tds-toast-fill: #e49307;
|
|
59
|
-
--tds-toast-text: #000000;
|
|
60
|
-
--tds-toast-link: #000000;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.tds-toast--intent-error {
|
|
64
|
-
--tds-toast-fill: #cb0705;
|
|
65
|
-
--tds-toast-text: #ffffff;
|
|
66
|
-
--tds-toast-link: #ffffff;
|
|
67
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress Blocks Entry Point
|
|
3
|
-
* Registers all Times Design System blocks with Gutenberg
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Register blocks
|
|
7
|
-
import './blocks/button/index.js';
|
|
8
|
-
import './blocks/divider/index.js';
|
|
9
|
-
import './blocks/text/index.js';
|
|
10
|
-
import './blocks/input/index.js';
|
|
11
|
-
import './blocks/icon-button/index.js';
|
|
12
|
-
import './blocks/chip/index.js';
|
|
13
|
-
import './blocks/flag/index.js';
|
|
14
|
-
import './blocks/toast/index.js';
|
|
15
|
-
import './blocks/link/index.js';
|
|
16
|
-
import './blocks/ad-container/index.js';
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build className string for Button component based on attributes.
|
|
3
|
-
* Maps component properties to TDS (Times Design System) SCSS classes.
|
|
4
|
-
*
|
|
5
|
-
* @param {Object} options - Button configuration options
|
|
6
|
-
* @param {string} options.intent - Visual style variant (primary, secondary, negative)
|
|
7
|
-
* @param {string} options.size - Button size (small, medium, large)
|
|
8
|
-
* @param {string} options.behaviour - Width behaviour (hug, full)
|
|
9
|
-
* @param {string} options.state - Interaction state (base, hover, pressed, loading, disabled, focus)
|
|
10
|
-
* @param {boolean} options.disabled - Whether button is disabled
|
|
11
|
-
* @returns {string} Complete className string
|
|
12
|
-
*/
|
|
13
|
-
export function buildButtonClass({
|
|
14
|
-
intent = 'primary',
|
|
15
|
-
size = 'large',
|
|
16
|
-
behaviour = 'hug',
|
|
17
|
-
state = 'base',
|
|
18
|
-
disabled = false
|
|
19
|
-
}) {
|
|
20
|
-
const classes = [
|
|
21
|
-
'tds-button',
|
|
22
|
-
`tds-button--intent-${intent}`,
|
|
23
|
-
`tds-button--size-${size}`,
|
|
24
|
-
`tds-button--behaviour-${behaviour}`,
|
|
25
|
-
`tds-button--state-${state}`
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
if (disabled) {
|
|
29
|
-
classes.push('tds-button--disabled');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return classes.join(' ');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Generic class builder utility for consistent naming conventions.
|
|
37
|
-
* Creates BEM-style className strings.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} blockName - Base block name (e.g., 'tds-button')
|
|
40
|
-
* @param {Object} modifiers - Object with modifier names as keys
|
|
41
|
-
* @returns {string} Complete className string
|
|
42
|
-
*/
|
|
43
|
-
export function buildClassName(blockName, modifiers = {}) {
|
|
44
|
-
const classes = [blockName];
|
|
45
|
-
|
|
46
|
-
Object.entries(modifiers).forEach(([key, value]) => {
|
|
47
|
-
if (value && value !== '') {
|
|
48
|
-
classes.push(`${blockName}--${key}-${value}`);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return classes.join(' ');
|
|
53
|
-
}
|