@times-design-system/components-wordpress 1.5.3 → 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 -85
- 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,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Block Editor Component: DialogBox
|
|
3
|
-
*
|
|
4
|
-
* Renders the editor UI for the DialogBox block in Gutenberg.
|
|
5
|
-
* Reference: packages/components-react/src/DialogBox/
|
|
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="DialogBox 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>📝 DialogBox block editor</p>
|
|
35
|
-
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
36
|
-
TODO: Render the DialogBox component here with current attributes
|
|
37
|
-
</p>
|
|
38
|
-
</div>
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress Block Loader: DialogBox
|
|
3
|
-
*
|
|
4
|
-
* Reference: packages/components-react/src/DialogBox/
|
|
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: DialogBox
|
|
4
|
-
*
|
|
5
|
-
* Server-side rendering for the DialogBox block.
|
|
6
|
-
* Reference: packages/components-react/src/DialogBox/
|
|
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 DialogBox 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 DialogBox component here -->
|
|
22
|
-
<!-- Use CSS custom properties from packages/tokens/data/resolved-hexes.json -->
|
|
23
|
-
<!-- Apply BEM naming: tds-dialog-box--{modifier} -->
|
|
24
|
-
</div>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Block Save Component: DialogBox
|
|
3
|
-
*
|
|
4
|
-
* Renders the static output saved to the database.
|
|
5
|
-
* Reference: packages/components-react/src/DialogBox/
|
|
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 DialogBox 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 DialogBox component */}
|
|
20
|
-
{attributes.content && <p>{attributes.content}</p>}
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Styles for DialogBox Block
|
|
3
|
-
*
|
|
4
|
-
* Reference: packages/components-react/src/DialogBox/
|
|
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-dialog-box--{modifier}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
.tds-dialog-box {
|
|
14
|
-
/* TODO: Add component styles here */
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.tds-dialog-box--focus {
|
|
18
|
-
/* TODO: Add focus state styles */
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.tds-dialog-box--disabled {
|
|
22
|
-
/* TODO: Add disabled state styles */
|
|
23
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/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
|
-
"render": "file:./render.php",
|
|
17
|
-
"attributes": {
|
|
18
|
-
"isDashed": {
|
|
19
|
-
"type": "boolean",
|
|
20
|
-
"default": false
|
|
21
|
-
},
|
|
22
|
-
"isVertical": {
|
|
23
|
-
"type": "boolean",
|
|
24
|
-
"default": false
|
|
25
|
-
},
|
|
26
|
-
"padding": {
|
|
27
|
-
"type": "boolean",
|
|
28
|
-
"default": false
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"example": {}
|
|
32
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
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;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Divider Block Render Callback
|
|
4
|
-
*
|
|
5
|
-
* Renders the Divider 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
|
-
$is_dashed = isset($attributes['isDashed']) ? (bool) $attributes['isDashed'] : false;
|
|
14
|
-
$is_vertical = isset($attributes['isVertical']) ? (bool) $attributes['isVertical'] : false;
|
|
15
|
-
$padding = isset($attributes['padding']) ? (bool) $attributes['padding'] : false;
|
|
16
|
-
|
|
17
|
-
$classes = ['tds-divider'];
|
|
18
|
-
if ($is_dashed) {
|
|
19
|
-
$classes[] = 'tds-divider--dashed';
|
|
20
|
-
}
|
|
21
|
-
if ($is_vertical) {
|
|
22
|
-
$classes[] = 'tds-divider--vertical';
|
|
23
|
-
}
|
|
24
|
-
if ($padding) {
|
|
25
|
-
$classes[] = 'tds-divider--padding';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
29
|
-
?>
|
|
30
|
-
|
|
31
|
-
<div <?php echo wp_kses_post($wrapper_attrs); ?>></div>
|
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* Divider Block Frontend Styles */
|
|
2
|
-
/* Using resolved design token values for self-contained styling */
|
|
3
|
-
|
|
4
|
-
.tds-divider {
|
|
5
|
-
box-sizing: content-box;
|
|
6
|
-
border: 0;
|
|
7
|
-
border-top: 1px;
|
|
8
|
-
border-style: solid;
|
|
9
|
-
border-color: #999999;
|
|
10
|
-
flex-shrink: 0;
|
|
11
|
-
height: 0;
|
|
12
|
-
width: 100%;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.tds-divider.tds-divider--dashed {
|
|
16
|
-
border-style: dashed;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/* Vertical */
|
|
20
|
-
.tds-divider--vertical {
|
|
21
|
-
width: 0;
|
|
22
|
-
height: 100%;
|
|
23
|
-
align-self: stretch;
|
|
24
|
-
border-top: none;
|
|
25
|
-
border-left: 1px;
|
|
26
|
-
border-style: solid;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Padding — gutter spacing around the line */
|
|
30
|
-
.tds-divider--horizontal.tds-divider--padding {
|
|
31
|
-
margin-block: 24px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.tds-divider--vertical.tds-divider--padding {
|
|
35
|
-
margin-inline: 24px;
|
|
36
|
-
margin-block: 0;
|
|
37
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/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
|
-
"render": "file:./render.php",
|
|
16
|
-
"attributes": {
|
|
17
|
-
"label": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"default": ""
|
|
20
|
-
},
|
|
21
|
-
"content": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"default": ""
|
|
24
|
-
},
|
|
25
|
-
"intent": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"default": "secondary",
|
|
28
|
-
"enum": ["primary", "secondary", "negative", "positive"]
|
|
29
|
-
},
|
|
30
|
-
"size": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"default": "medium",
|
|
33
|
-
"enum": ["small", "medium", "large"]
|
|
34
|
-
},
|
|
35
|
-
"iconLeft": {
|
|
36
|
-
"type": "string",
|
|
37
|
-
"default": ""
|
|
38
|
-
},
|
|
39
|
-
"iconRight": {
|
|
40
|
-
"type": "string",
|
|
41
|
-
"default": ""
|
|
42
|
-
},
|
|
43
|
-
"ariaLabel": {
|
|
44
|
-
"type": "string",
|
|
45
|
-
"default": ""
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"example": {}
|
|
49
|
-
}
|
package/src/blocks/flag/edit.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
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;
|
package/src/blocks/flag/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Flag Block Render Callback
|
|
4
|
-
*
|
|
5
|
-
* Renders the Flag 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']) ? sanitize_text_field($attributes['label']) : '';
|
|
14
|
-
$content_text = isset($attributes['content']) ? wp_kses_post($attributes['content']) : '';
|
|
15
|
-
$intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : '';
|
|
16
|
-
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : '';
|
|
17
|
-
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
18
|
-
|
|
19
|
-
$classes = ['tds-flag'];
|
|
20
|
-
$classes[] = 'tds-flag--intent-' . $intent;
|
|
21
|
-
$classes[] = 'tds-flag--size-' . $size;
|
|
22
|
-
|
|
23
|
-
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
24
|
-
?>
|
|
25
|
-
|
|
26
|
-
<div
|
|
27
|
-
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
28
|
-
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
29
|
-
>
|
|
30
|
-
<?php if ($label) : ?>
|
|
31
|
-
<div class="tds-flag__label"><?php echo wp_kses_post($label); ?></div>
|
|
32
|
-
<?php endif; ?>
|
|
33
|
-
<div class="tds-flag__content"><?php echo wp_kses_post($content_text); ?></div>
|
|
34
|
-
</div>
|
package/src/blocks/flag/save.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* Flag Block Frontend Styles */
|
|
2
|
-
/* Using resolved design token values for self-contained styling */
|
|
3
|
-
|
|
4
|
-
.tds-flag {
|
|
5
|
-
--tds-flag-bg: #000000;
|
|
6
|
-
--tds-flag-fg: #f2f2f2;
|
|
7
|
-
--tds-flag-icon: var(--flag-fg);
|
|
8
|
-
--tds-flag-border: transparent;
|
|
9
|
-
|
|
10
|
-
display: inline-flex;
|
|
11
|
-
align-items: center;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
gap: 4px;
|
|
14
|
-
min-height: 19px;
|
|
15
|
-
min-width: 42px;
|
|
16
|
-
padding: 0 2px;
|
|
17
|
-
border-radius: 2px;
|
|
18
|
-
border: 1px solid var(--tds-flag-border);
|
|
19
|
-
background-color: var(--tds-flag-bg);
|
|
20
|
-
color: var(--tds-flag-fg);
|
|
21
|
-
font-family: Roboto;
|
|
22
|
-
font-size: 1.4rem;
|
|
23
|
-
font-weight: 500;
|
|
24
|
-
line-height: 1.125;
|
|
25
|
-
text-transform: uppercase;
|
|
26
|
-
white-space: nowrap;
|
|
27
|
-
box-sizing: border-box;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.tds-flag--size-small {
|
|
31
|
-
font-size: 1.2rem;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.tds-flag--intent-secondary {
|
|
35
|
-
--tds-flag-bg: transparent;
|
|
36
|
-
--tds-flag-fg: #1a1a1a;
|
|
37
|
-
--tds-flag-icon: var(--tds-flag-fg);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.tds-flag--intent-callout {
|
|
41
|
-
--tds-flag-bg: #b20908;
|
|
42
|
-
--tds-flag-fg: #ffffff;
|
|
43
|
-
--tds-flag-icon: var(--tds-flag-fg);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.tds-flag__label {
|
|
47
|
-
display: inline-flex;
|
|
48
|
-
align-items: center;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.tds-flag__content {
|
|
52
|
-
display: inline-flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/icon",
|
|
5
|
-
"title": "Times Design System - Icon",
|
|
6
|
-
"category": "common",
|
|
7
|
-
"description": "WordPress block for Times Design System Icon 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
|
-
}
|
package/src/blocks/icon/edit.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Block Editor Component: Icon
|
|
3
|
-
*
|
|
4
|
-
* Renders the editor UI for the Icon block in Gutenberg.
|
|
5
|
-
* Reference: packages/components-react/src/Icon/
|
|
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="Icon 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>📝 Icon block editor</p>
|
|
35
|
-
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
36
|
-
TODO: Render the Icon component here with current attributes
|
|
37
|
-
</p>
|
|
38
|
-
</div>
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
}
|
package/src/blocks/icon/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress Block Loader: Icon
|
|
3
|
-
*
|
|
4
|
-
* Reference: packages/components-react/src/Icon/
|
|
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
|
-
});
|