@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
|
-
<?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>
|
package/src/blocks/icon/save.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/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
|
-
"render": "file:./render.php",
|
|
16
|
-
"attributes": {
|
|
17
|
-
"iconName": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"default": ""
|
|
20
|
-
},
|
|
21
|
-
"round": {
|
|
22
|
-
"type": "boolean",
|
|
23
|
-
"default": false
|
|
24
|
-
},
|
|
25
|
-
"href": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"default": ""
|
|
28
|
-
},
|
|
29
|
-
"target": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"default": "_self",
|
|
32
|
-
"enum": ["_self", "_blank", "_parent", "_top"]
|
|
33
|
-
},
|
|
34
|
-
"rel": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"default": ""
|
|
37
|
-
},
|
|
38
|
-
"ariaLabel": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"default": ""
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"example": {}
|
|
44
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
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;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Icon Button Block Render Callback
|
|
4
|
-
*
|
|
5
|
-
* Renders the Icon Button 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
|
-
$icon_name = isset($attributes['iconName']) ? sanitize_text_field($attributes['iconName']) : '';
|
|
14
|
-
$round = isset($attributes['round']) ? (bool) $attributes['round'] : false;
|
|
15
|
-
$href = isset($attributes['href']) ? esc_url($attributes['href']) : '';
|
|
16
|
-
$target = isset($attributes['target']) ? sanitize_text_field($attributes['target']) : '';
|
|
17
|
-
$rel = isset($attributes['rel']) ? sanitize_text_field($attributes['rel']) : '';
|
|
18
|
-
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
19
|
-
|
|
20
|
-
$classes = ['tds-icon-button'];
|
|
21
|
-
if ($round) {
|
|
22
|
-
$classes[] = 'tds-icon-button--round';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
$element_tag = $href ? 'a' : 'button';
|
|
26
|
-
$wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)]);
|
|
27
|
-
?>
|
|
28
|
-
|
|
29
|
-
<?php if ($element_tag === 'a') : ?>
|
|
30
|
-
<a
|
|
31
|
-
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
32
|
-
href="<?php echo esc_attr($href); ?>"
|
|
33
|
-
<?php echo $target ? 'target="' . esc_attr($target) . '"' : ''; ?>
|
|
34
|
-
<?php echo $rel ? 'rel="' . esc_attr($rel) . '"' : ''; ?>
|
|
35
|
-
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
36
|
-
>
|
|
37
|
-
<span class="tds-icon-button__icon"><?php echo wp_kses_post($icon_name); ?></span>
|
|
38
|
-
</a>
|
|
39
|
-
<?php else : ?>
|
|
40
|
-
<button
|
|
41
|
-
<?php echo wp_kses_post($wrapper_attrs); ?>
|
|
42
|
-
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
43
|
-
>
|
|
44
|
-
<span class="tds-icon-button__icon"><?php echo wp_kses_post($icon_name); ?></span>
|
|
45
|
-
</button>
|
|
46
|
-
<?php endif; ?>
|
|
@@ -1,29 +0,0 @@
|
|
|
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;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* Icon Button Block Frontend Styles */
|
|
2
|
-
/* Using resolved design token values for self-contained styling */
|
|
3
|
-
/* Icon buttons inherit base button styles for colors, intents, etc. */
|
|
4
|
-
|
|
5
|
-
.tds-icon-button--size-small {
|
|
6
|
-
width: 32px;
|
|
7
|
-
height: 32px;
|
|
8
|
-
padding: 6px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.tds-icon-button--size-medium {
|
|
12
|
-
width: 48px;
|
|
13
|
-
height: 48px;
|
|
14
|
-
padding: 12px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.tds-icon-button--size-large {
|
|
18
|
-
width: 64px;
|
|
19
|
-
height: 64px;
|
|
20
|
-
padding: 16px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.tds-icon-button--round.tds-button {
|
|
24
|
-
border-radius: 9999px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.tds-icon-button__icon {
|
|
28
|
-
display: inline-flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"apiVersion": 3,
|
|
4
|
-
"name": "tds/input",
|
|
5
|
-
"title": "Input",
|
|
6
|
-
"category": "common",
|
|
7
|
-
"description": "Form input field component",
|
|
8
|
-
"icon": "text",
|
|
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
|
-
"placeholder": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"default": ""
|
|
24
|
-
},
|
|
25
|
-
"type": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"default": "text",
|
|
28
|
-
"enum": ["text", "email", "password", "number", "tel", "url"]
|
|
29
|
-
},
|
|
30
|
-
"disabled": {
|
|
31
|
-
"type": "boolean",
|
|
32
|
-
"default": false
|
|
33
|
-
},
|
|
34
|
-
"required": {
|
|
35
|
-
"type": "boolean",
|
|
36
|
-
"default": false
|
|
37
|
-
},
|
|
38
|
-
"name": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"default": ""
|
|
41
|
-
},
|
|
42
|
-
"id": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"default": ""
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"example": {}
|
|
48
|
-
}
|
package/src/blocks/input/edit.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
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 { label, placeholder, type, disabled, required, name, id } = attributes;
|
|
11
|
-
const blockProps = useBlockProps();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<InspectorControls>
|
|
16
|
-
<PanelBody title="Input Settings">
|
|
17
|
-
<TextControl
|
|
18
|
-
label="Label"
|
|
19
|
-
value={label}
|
|
20
|
-
onChange={(val) => setAttributes({ label: val })}
|
|
21
|
-
/>
|
|
22
|
-
<TextControl
|
|
23
|
-
label="Placeholder"
|
|
24
|
-
value={placeholder}
|
|
25
|
-
onChange={(val) => setAttributes({ placeholder: val })}
|
|
26
|
-
/>
|
|
27
|
-
<SelectControl
|
|
28
|
-
label="Type"
|
|
29
|
-
value={type}
|
|
30
|
-
options={[
|
|
31
|
-
{ label: 'Text', value: 'text' },
|
|
32
|
-
{ label: 'Email', value: 'email' },
|
|
33
|
-
{ label: 'Password', value: 'password' },
|
|
34
|
-
{ label: 'Number', value: 'number' },
|
|
35
|
-
{ label: 'Tel', value: 'tel' },
|
|
36
|
-
{ label: 'URL', value: 'url' }
|
|
37
|
-
]}
|
|
38
|
-
onChange={(val) => setAttributes({ type: val })}
|
|
39
|
-
/>
|
|
40
|
-
<TextControl
|
|
41
|
-
label="Name"
|
|
42
|
-
value={name}
|
|
43
|
-
onChange={(val) => setAttributes({ name: val })}
|
|
44
|
-
/>
|
|
45
|
-
<TextControl
|
|
46
|
-
label="ID"
|
|
47
|
-
value={id}
|
|
48
|
-
onChange={(val) => setAttributes({ id: val })}
|
|
49
|
-
/>
|
|
50
|
-
<ToggleControl
|
|
51
|
-
label="Required"
|
|
52
|
-
checked={required}
|
|
53
|
-
onChange={(val) => setAttributes({ required: val })}
|
|
54
|
-
/>
|
|
55
|
-
<ToggleControl
|
|
56
|
-
label="Disabled"
|
|
57
|
-
checked={disabled}
|
|
58
|
-
onChange={(val) => setAttributes({ disabled: val })}
|
|
59
|
-
/>
|
|
60
|
-
</PanelBody>
|
|
61
|
-
</InspectorControls>
|
|
62
|
-
<div {...blockProps}>
|
|
63
|
-
{label && <label className="tds-input__label">{label}</label>}
|
|
64
|
-
<input
|
|
65
|
-
type={type}
|
|
66
|
-
placeholder={placeholder}
|
|
67
|
-
disabled={disabled}
|
|
68
|
-
required={required}
|
|
69
|
-
name={name}
|
|
70
|
-
id={id}
|
|
71
|
-
className="tds-input"
|
|
72
|
-
/>
|
|
73
|
-
</div>
|
|
74
|
-
</>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export default edit;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Input Block Render Callback
|
|
4
|
-
*
|
|
5
|
-
* Renders the Input 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
|
-
$placeholder = isset($attributes['placeholder']) ? sanitize_text_field($attributes['placeholder']) : '';
|
|
15
|
-
$type = isset($attributes['type']) ? sanitize_text_field($attributes['type']) : 'text';
|
|
16
|
-
$disabled = isset($attributes['disabled']) ? (bool) $attributes['disabled'] : false;
|
|
17
|
-
$required = isset($attributes['required']) ? (bool) $attributes['required'] : false;
|
|
18
|
-
$name = isset($attributes['name']) ? sanitize_text_field($attributes['name']) : '';
|
|
19
|
-
$id = isset($attributes['id']) ? sanitize_text_field($attributes['id']) : '';
|
|
20
|
-
|
|
21
|
-
$wrapper_attrs = get_block_wrapper_attributes();
|
|
22
|
-
?>
|
|
23
|
-
|
|
24
|
-
<div <?php echo wp_kses_post($wrapper_attrs); ?>>
|
|
25
|
-
<?php if ($label) : ?>
|
|
26
|
-
<label for="<?php echo esc_attr($id); ?>" class="tds-input__label">
|
|
27
|
-
<?php echo wp_kses_post($label); ?>
|
|
28
|
-
</label>
|
|
29
|
-
<?php endif; ?>
|
|
30
|
-
<input
|
|
31
|
-
type="<?php echo esc_attr($type); ?>"
|
|
32
|
-
<?php echo $placeholder ? 'placeholder="' . esc_attr($placeholder) . '"' : ''; ?>
|
|
33
|
-
<?php echo $disabled ? 'disabled' : ''; ?>
|
|
34
|
-
<?php echo $required ? 'required' : ''; ?>
|
|
35
|
-
<?php echo $name ? 'name="' . esc_attr($name) . '"' : ''; ?>
|
|
36
|
-
<?php echo $id ? 'id="' . esc_attr($id) . '"' : ''; ?>
|
|
37
|
-
class="tds-input"
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
package/src/blocks/input/save.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useBlockProps } from '@wordpress/block-editor';
|
|
2
|
-
|
|
3
|
-
const save = ({ attributes }) => {
|
|
4
|
-
const { label, placeholder, type, disabled, required, name, id } = attributes;
|
|
5
|
-
const blockProps = useBlockProps.save();
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<div {...blockProps}>
|
|
9
|
-
{label && (
|
|
10
|
-
<label htmlFor={id} className="tds-input__label">
|
|
11
|
-
{label}
|
|
12
|
-
</label>
|
|
13
|
-
)}
|
|
14
|
-
<input
|
|
15
|
-
type={type}
|
|
16
|
-
placeholder={placeholder}
|
|
17
|
-
disabled={disabled}
|
|
18
|
-
required={required}
|
|
19
|
-
name={name}
|
|
20
|
-
id={id}
|
|
21
|
-
className="tds-input"
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default save;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* Input Block Frontend Styles */
|
|
2
|
-
/* Using resolved design token values for self-contained styling */
|
|
3
|
-
|
|
4
|
-
.tds-input-wrapper {
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
gap: 8px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/* Label styles */
|
|
11
|
-
.tds-input__label {
|
|
12
|
-
color: #1a1a1a;
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
gap: 4px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Input field styles */
|
|
19
|
-
.tds-input {
|
|
20
|
-
width: 100%;
|
|
21
|
-
padding: 8px 12px;
|
|
22
|
-
color: #1a1a1a;
|
|
23
|
-
background-color: #ffffff;
|
|
24
|
-
border: 1px solid #999999;
|
|
25
|
-
border-radius: 0;
|
|
26
|
-
transition: all 0.2s ease-in-out;
|
|
27
|
-
box-sizing: border-box;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* Input focus state */
|
|
31
|
-
.tds-input:focus {
|
|
32
|
-
outline: none;
|
|
33
|
-
border-color: #0f4aa2;
|
|
34
|
-
box-shadow: 0 0 0 2px rgba(15, 74, 162, 0.1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Input hover state */
|
|
38
|
-
.tds-input:hover:not(:disabled) {
|
|
39
|
-
border-color: #0f4aa2;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/* Input disabled state */
|
|
43
|
-
.tds-input:disabled {
|
|
44
|
-
background-color: #f2f2f2;
|
|
45
|
-
color: #999999;
|
|
46
|
-
border-color: #cccccc;
|
|
47
|
-
cursor: not-allowed;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* Input placeholder */
|
|
51
|
-
.tds-input::placeholder {
|
|
52
|
-
color: #666666;
|
|
53
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
});
|