@times-design-system/components-wordpress 1.3.0 → 1.5.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 +124 -12
- package/CHANGELOG.md +12 -0
- package/README.md +57 -40
- package/TESTING.md +152 -0
- package/dist/blocks/dialog-box/block.json +24 -0
- package/dist/blocks/dialog-box/edit.js +41 -0
- package/dist/blocks/dialog-box/index.js +17 -0
- package/dist/blocks/dialog-box/render.php +24 -0
- package/dist/blocks/dialog-box/save.js +23 -0
- package/dist/blocks/dialog-box/style.css +23 -0
- package/dist/blocks/icon/block.json +24 -0
- package/dist/blocks/icon/edit.js +41 -0
- package/dist/blocks/icon/index.js +17 -0
- package/dist/blocks/icon/render.php +24 -0
- package/dist/blocks/icon/save.js +23 -0
- package/dist/blocks/icon/style.css +23 -0
- package/dist/blocks/input-helper-message/block.json +24 -0
- package/dist/blocks/input-helper-message/edit.js +42 -0
- package/dist/blocks/input-helper-message/index.js +17 -0
- package/dist/blocks/input-helper-message/render.php +24 -0
- package/dist/blocks/input-helper-message/save.js +23 -0
- package/dist/blocks/input-helper-message/style.css +23 -0
- package/dist/blocks/tab/block.json +24 -0
- package/dist/blocks/tab/edit.js +41 -0
- package/dist/blocks/tab/index.js +17 -0
- package/dist/blocks/tab/render.php +24 -0
- package/dist/blocks/tab/save.js +23 -0
- package/dist/blocks/tab/style.css +23 -0
- package/dist/blocks/tab-group/block.json +24 -0
- package/dist/blocks/tab-group/edit.js +41 -0
- package/dist/blocks/tab-group/index.js +17 -0
- package/dist/blocks/tab-group/render.php +24 -0
- package/dist/blocks/tab-group/save.js +23 -0
- package/dist/blocks/tab-group/style.css +23 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.setup.d.ts +1 -0
- package/package.json +21 -5
- package/scripts/create-wordpress-block-tests.cjs +438 -0
- package/scripts/create-wordpress-block.cjs +681 -0
- package/src/blocks/dialog-box/block.json +24 -0
- package/src/blocks/dialog-box/edit.js +41 -0
- package/src/blocks/dialog-box/index.js +17 -0
- package/src/blocks/dialog-box/render.php +24 -0
- package/src/blocks/dialog-box/save.js +23 -0
- package/src/blocks/dialog-box/style.css +23 -0
- package/src/blocks/icon/block.json +24 -0
- package/src/blocks/icon/edit.js +41 -0
- package/src/blocks/icon/index.js +17 -0
- package/src/blocks/icon/render.php +24 -0
- package/src/blocks/icon/save.js +23 -0
- package/src/blocks/icon/style.css +23 -0
- package/src/blocks/input-helper-message/block.json +24 -0
- package/src/blocks/input-helper-message/edit.js +42 -0
- package/src/blocks/input-helper-message/index.js +17 -0
- package/src/blocks/input-helper-message/render.php +24 -0
- package/src/blocks/input-helper-message/save.js +23 -0
- package/src/blocks/input-helper-message/style.css +23 -0
- package/src/blocks/tab/block.json +24 -0
- package/src/blocks/tab/edit.js +41 -0
- package/src/blocks/tab/index.js +17 -0
- package/src/blocks/tab/render.php +24 -0
- package/src/blocks/tab/save.js +23 -0
- package/src/blocks/tab/style.css +23 -0
- package/src/blocks/tab-group/block.json +24 -0
- package/src/blocks/tab-group/edit.js +41 -0
- package/src/blocks/tab-group/index.js +17 -0
- package/src/blocks/tab-group/render.php +24 -0
- package/src/blocks/tab-group/save.js +23 -0
- package/src/blocks/tab-group/style.css +23 -0
- package/vitest.config.js +28 -0
- package/vitest.config.ts +28 -0
- package/vitest.setup.ts +129 -0
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Block Rendering: Icon
|
|
4
|
+
*
|
|
5
|
+
* Server-side rendering for the Icon block.
|
|
6
|
+
* Reference: packages/components-react/src/Icon/
|
|
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 Icon 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 Icon component here -->
|
|
22
|
+
<!-- Use CSS custom properties from packages/tokens/data/resolved-hexes.json -->
|
|
23
|
+
<!-- Apply BEM naming: tds-icon--{modifier} -->
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block Save Component: Icon
|
|
3
|
+
*
|
|
4
|
+
* Renders the static output saved to the database.
|
|
5
|
+
* Reference: packages/components-react/src/Icon/
|
|
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 Icon 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 Icon component */}
|
|
20
|
+
{attributes.content && <p>{attributes.content}</p>}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for Icon Block
|
|
3
|
+
*
|
|
4
|
+
* Reference: packages/components-react/src/Icon/
|
|
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-icon--{modifier}
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
.tds-icon {
|
|
14
|
+
/* TODO: Add component styles here */
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tds-icon--focus {
|
|
18
|
+
/* TODO: Add focus state styles */
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tds-icon--disabled {
|
|
22
|
+
/* TODO: Add disabled state styles */
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "tds/input-helper-message",
|
|
5
|
+
"title": "Times Design System - InputHelperMessage",
|
|
6
|
+
"category": "common",
|
|
7
|
+
"description": "WordPress block for Times Design System InputHelperMessage 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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block Editor Component: InputHelperMessage
|
|
3
|
+
*
|
|
4
|
+
* Renders the editor UI for the InputHelperMessage block in Gutenberg.
|
|
5
|
+
* Reference: packages/components-react/src/InputHelperMessage/
|
|
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="InputHelperMessage 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>📝 InputHelperMessage block editor</p>
|
|
35
|
+
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
36
|
+
TODO: Render the InputHelperMessage component here with current
|
|
37
|
+
attributes
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress Block Loader: InputHelperMessage
|
|
3
|
+
*
|
|
4
|
+
* Reference: packages/components-react/src/InputHelperMessage/
|
|
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
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Block Rendering: InputHelperMessage
|
|
4
|
+
*
|
|
5
|
+
* Server-side rendering for the InputHelperMessage block.
|
|
6
|
+
* Reference: packages/components-react/src/InputHelperMessage/
|
|
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 InputHelperMessage 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 InputHelperMessage component here -->
|
|
22
|
+
<!-- Use CSS custom properties from packages/tokens/data/resolved-hexes.json -->
|
|
23
|
+
<!-- Apply BEM naming: tds-input-helper-message--{modifier} -->
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block Save Component: InputHelperMessage
|
|
3
|
+
*
|
|
4
|
+
* Renders the static output saved to the database.
|
|
5
|
+
* Reference: packages/components-react/src/InputHelperMessage/
|
|
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 InputHelperMessage 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 InputHelperMessage component */}
|
|
20
|
+
{attributes.content && <p>{attributes.content}</p>}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for InputHelperMessage Block
|
|
3
|
+
*
|
|
4
|
+
* Reference: packages/components-react/src/InputHelperMessage/
|
|
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-input-helper-message--{modifier}
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
.tds-input-helper-message {
|
|
14
|
+
/* TODO: Add component styles here */
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tds-input-helper-message--focus {
|
|
18
|
+
/* TODO: Add focus state styles */
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tds-input-helper-message--disabled {
|
|
22
|
+
/* TODO: Add disabled state styles */
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "tds/tab",
|
|
5
|
+
"title": "Times Design System - Tab",
|
|
6
|
+
"category": "common",
|
|
7
|
+
"description": "WordPress block for Times Design System Tab 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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block Editor Component: Tab
|
|
3
|
+
*
|
|
4
|
+
* Renders the editor UI for the Tab block in Gutenberg.
|
|
5
|
+
* Reference: packages/components-react/src/Tab/
|
|
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="Tab 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>📝 Tab block editor</p>
|
|
35
|
+
<p style={{ fontSize: '12px', color: '#666' }}>
|
|
36
|
+
TODO: Render the Tab component here with current attributes
|
|
37
|
+
</p>
|
|
38
|
+
</div>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress Block Loader: Tab
|
|
3
|
+
*
|
|
4
|
+
* Reference: packages/components-react/src/Tab/
|
|
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
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Block Rendering: Tab
|
|
4
|
+
*
|
|
5
|
+
* Server-side rendering for the Tab block.
|
|
6
|
+
* Reference: packages/components-react/src/Tab/
|
|
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 Tab 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 Tab component here -->
|
|
22
|
+
<!-- Use CSS custom properties from packages/tokens/data/resolved-hexes.json -->
|
|
23
|
+
<!-- Apply BEM naming: tds-tab--{modifier} -->
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block Save Component: Tab
|
|
3
|
+
*
|
|
4
|
+
* Renders the static output saved to the database.
|
|
5
|
+
* Reference: packages/components-react/src/Tab/
|
|
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 Tab 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 Tab component */}
|
|
20
|
+
{attributes.content && <p>{attributes.content}</p>}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for Tab Block
|
|
3
|
+
*
|
|
4
|
+
* Reference: packages/components-react/src/Tab/
|
|
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--{modifier}
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
.tds-tab {
|
|
14
|
+
/* TODO: Add component styles here */
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tds-tab--focus {
|
|
18
|
+
/* TODO: Add focus state styles */
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tds-tab--disabled {
|
|
22
|
+
/* TODO: Add disabled state styles */
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
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>
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|