@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.
Files changed (175) hide show
  1. package/dist/blocks/ad-container/block.json +10 -0
  2. package/dist/blocks/ad-container/edit.js +17 -1
  3. package/dist/blocks/ad-container/render.php +14 -0
  4. package/dist/blocks/button/block.json +19 -5
  5. package/dist/blocks/button/edit.js +33 -15
  6. package/dist/blocks/button/render.php +24 -2
  7. package/dist/blocks/button/style.css +63 -0
  8. package/dist/blocks/chip/block.json +12 -7
  9. package/dist/blocks/chip/edit.js +20 -17
  10. package/dist/blocks/chip/render.php +14 -2
  11. package/dist/blocks/dialog-box/block.json +10 -0
  12. package/dist/blocks/dialog-box/edit.js +17 -0
  13. package/dist/blocks/dialog-box/render.php +16 -4
  14. package/dist/blocks/divider/block.json +10 -0
  15. package/dist/blocks/divider/edit.js +18 -2
  16. package/dist/blocks/divider/render.php +14 -1
  17. package/dist/blocks/flag/block.json +10 -0
  18. package/dist/blocks/flag/edit.js +27 -2
  19. package/dist/blocks/flag/render.php +14 -0
  20. package/dist/blocks/icon/block.json +10 -0
  21. package/dist/blocks/icon/edit.js +17 -0
  22. package/dist/blocks/icon/render.php +16 -4
  23. package/dist/blocks/icon-button/block.json +15 -0
  24. package/dist/blocks/icon-button/edit.js +33 -1
  25. package/dist/blocks/icon-button/render.php +19 -0
  26. package/dist/blocks/icon-button/style.css +37 -3
  27. package/dist/blocks/input/block.json +10 -0
  28. package/dist/blocks/input/edit.js +27 -1
  29. package/dist/blocks/input/render.php +17 -1
  30. package/dist/blocks/input-helper-message/block.json +10 -0
  31. package/dist/blocks/input-helper-message/edit.js +17 -0
  32. package/dist/blocks/input-helper-message/render.php +16 -4
  33. package/dist/blocks/link/block.json +12 -7
  34. package/dist/blocks/link/edit.js +21 -18
  35. package/dist/blocks/link/render.php +14 -2
  36. package/dist/blocks/tab/block.json +10 -0
  37. package/dist/blocks/tab/edit.js +17 -0
  38. package/dist/blocks/tab/render.php +16 -4
  39. package/dist/blocks/tab-group/block.json +10 -0
  40. package/dist/blocks/tab-group/edit.js +17 -0
  41. package/dist/blocks/tab-group/render.php +16 -4
  42. package/dist/blocks/text/block.json +10 -0
  43. package/dist/blocks/text/edit.js +18 -2
  44. package/dist/blocks/text/render.php +14 -1
  45. package/dist/blocks/toast/block.json +10 -0
  46. package/dist/blocks/toast/edit.js +18 -1
  47. package/dist/blocks/toast/render.php +14 -0
  48. package/dist/index.cjs +389 -148
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.js +389 -148
  51. package/dist/index.js.map +1 -1
  52. package/dist/utils/DATA_ATTRIBUTES_USAGE.md +377 -0
  53. package/dist/utils/sanitize-data-attributes.php +109 -0
  54. package/package.json +9 -3
  55. package/BLOCK_CREATION_CHECKLIST.md +0 -385
  56. package/BUILD.md +0 -411
  57. package/CHANGELOG.md +0 -85
  58. package/SCSS_VARIABLES_REFERENCE.md +0 -316
  59. package/STYLING_SYNC_GUIDE.md +0 -306
  60. package/TESTING.md +0 -152
  61. package/TRANSFORMATION_GUIDE.md +0 -908
  62. package/dist/blocks/button/style-resolved.css +0 -153
  63. package/lib/wordpress.js +0 -7
  64. package/rollup.config.js +0 -75
  65. package/scripts/build-plugin.cjs +0 -121
  66. package/scripts/create-block.sh +0 -141
  67. package/scripts/create-wordpress-block-tests.cjs +0 -438
  68. package/scripts/create-wordpress-block.cjs +0 -681
  69. package/src/blocks/ad-container/block.json +0 -29
  70. package/src/blocks/ad-container/edit.js +0 -42
  71. package/src/blocks/ad-container/index.js +0 -10
  72. package/src/blocks/ad-container/render.php +0 -27
  73. package/src/blocks/ad-container/save.js +0 -16
  74. package/src/blocks/ad-container/style-editor.css +0 -4
  75. package/src/blocks/ad-container/style.css +0 -30
  76. package/src/blocks/button/block.json +0 -90
  77. package/src/blocks/button/edit.js +0 -187
  78. package/src/blocks/button/index.js +0 -11
  79. package/src/blocks/button/render.php +0 -71
  80. package/src/blocks/button/save.js +0 -52
  81. package/src/blocks/button/style-editor.css +0 -15
  82. package/src/blocks/button/style-resolved.css +0 -153
  83. package/src/blocks/button/style.css +0 -157
  84. package/src/blocks/chip/block.json +0 -58
  85. package/src/blocks/chip/edit.js +0 -113
  86. package/src/blocks/chip/index.js +0 -10
  87. package/src/blocks/chip/render.php +0 -40
  88. package/src/blocks/chip/save.js +0 -36
  89. package/src/blocks/chip/style-editor.css +0 -5
  90. package/src/blocks/chip/style.css +0 -87
  91. package/src/blocks/dialog-box/block.json +0 -24
  92. package/src/blocks/dialog-box/edit.js +0 -41
  93. package/src/blocks/dialog-box/index.js +0 -17
  94. package/src/blocks/dialog-box/render.php +0 -24
  95. package/src/blocks/dialog-box/save.js +0 -23
  96. package/src/blocks/dialog-box/style.css +0 -23
  97. package/src/blocks/divider/block.json +0 -32
  98. package/src/blocks/divider/edit.js +0 -42
  99. package/src/blocks/divider/index.js +0 -10
  100. package/src/blocks/divider/render.php +0 -31
  101. package/src/blocks/divider/save.js +0 -18
  102. package/src/blocks/divider/style-editor.css +0 -4
  103. package/src/blocks/divider/style.css +0 -37
  104. package/src/blocks/flag/block.json +0 -49
  105. package/src/blocks/flag/edit.js +0 -82
  106. package/src/blocks/flag/index.js +0 -10
  107. package/src/blocks/flag/render.php +0 -34
  108. package/src/blocks/flag/save.js +0 -25
  109. package/src/blocks/flag/style-editor.css +0 -5
  110. package/src/blocks/flag/style.css +0 -54
  111. package/src/blocks/icon/block.json +0 -24
  112. package/src/blocks/icon/edit.js +0 -41
  113. package/src/blocks/icon/index.js +0 -17
  114. package/src/blocks/icon/render.php +0 -24
  115. package/src/blocks/icon/save.js +0 -23
  116. package/src/blocks/icon/style.css +0 -23
  117. package/src/blocks/icon-button/block.json +0 -44
  118. package/src/blocks/icon-button/edit.js +0 -82
  119. package/src/blocks/icon-button/index.js +0 -10
  120. package/src/blocks/icon-button/render.php +0 -46
  121. package/src/blocks/icon-button/save.js +0 -29
  122. package/src/blocks/icon-button/style-editor.css +0 -5
  123. package/src/blocks/icon-button/style.css +0 -31
  124. package/src/blocks/input/block.json +0 -48
  125. package/src/blocks/input/edit.js +0 -78
  126. package/src/blocks/input/index.js +0 -10
  127. package/src/blocks/input/render.php +0 -39
  128. package/src/blocks/input/save.js +0 -27
  129. package/src/blocks/input/style-editor.css +0 -8
  130. package/src/blocks/input/style.css +0 -53
  131. package/src/blocks/input-helper-message/block.json +0 -24
  132. package/src/blocks/input-helper-message/edit.js +0 -42
  133. package/src/blocks/input-helper-message/index.js +0 -17
  134. package/src/blocks/input-helper-message/render.php +0 -24
  135. package/src/blocks/input-helper-message/save.js +0 -23
  136. package/src/blocks/input-helper-message/style.css +0 -23
  137. package/src/blocks/link/block.json +0 -72
  138. package/src/blocks/link/edit.js +0 -151
  139. package/src/blocks/link/index.js +0 -10
  140. package/src/blocks/link/render.php +0 -44
  141. package/src/blocks/link/save.js +0 -46
  142. package/src/blocks/link/style-editor.css +0 -5
  143. package/src/blocks/link/style.css +0 -119
  144. package/src/blocks/tab/block.json +0 -24
  145. package/src/blocks/tab/edit.js +0 -41
  146. package/src/blocks/tab/index.js +0 -17
  147. package/src/blocks/tab/render.php +0 -24
  148. package/src/blocks/tab/save.js +0 -23
  149. package/src/blocks/tab/style.css +0 -23
  150. package/src/blocks/tab-group/block.json +0 -24
  151. package/src/blocks/tab-group/edit.js +0 -41
  152. package/src/blocks/tab-group/index.js +0 -17
  153. package/src/blocks/tab-group/render.php +0 -24
  154. package/src/blocks/tab-group/save.js +0 -23
  155. package/src/blocks/tab-group/style.css +0 -23
  156. package/src/blocks/text/block.json +0 -33
  157. package/src/blocks/text/edit.js +0 -56
  158. package/src/blocks/text/index.js +0 -10
  159. package/src/blocks/text/render.php +0 -26
  160. package/src/blocks/text/save.js +0 -18
  161. package/src/blocks/text/style-editor.css +0 -4
  162. package/src/blocks/text/style.css +0 -7
  163. package/src/blocks/toast/block.json +0 -40
  164. package/src/blocks/toast/edit.js +0 -85
  165. package/src/blocks/toast/index.js +0 -10
  166. package/src/blocks/toast/render.php +0 -37
  167. package/src/blocks/toast/save.js +0 -29
  168. package/src/blocks/toast/style-editor.css +0 -4
  169. package/src/blocks/toast/style.css +0 -67
  170. package/src/index.js +0 -16
  171. package/src/utils/classBuilder.js +0 -53
  172. package/tsconfig.json +0 -116
  173. package/vitest.config.js +0 -28
  174. package/vitest.config.ts +0 -28
  175. 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
- }
@@ -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;
@@ -1,10 +0,0 @@
1
- import { registerBlockType } from '@wordpress/blocks';
2
- import metadata from './block.json';
3
- import edit from './edit';
4
- import save from './save';
5
-
6
- registerBlockType(metadata.name, {
7
- ...metadata,
8
- edit,
9
- save
10
- });
@@ -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); ?>
@@ -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,4 +0,0 @@
1
- /* Text Editor Styles */
2
- .wp-block-times-text {
3
- margin: var(--spacing-m) 0;
4
- }
@@ -1,7 +0,0 @@
1
- /* Text Block Frontend Styles */
2
- /* Using resolved design token values for self-contained styling */
3
- /* Text component is typography-based, minimal CSS needed */
4
-
5
- .tds-text {
6
- /* Base typography handled by design tokens and parent context */
7
- }
@@ -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
- }
@@ -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,10 +0,0 @@
1
- import { registerBlockType } from '@wordpress/blocks';
2
- import metadata from './block.json';
3
- import edit from './edit';
4
- import save from './save';
5
-
6
- registerBlockType(metadata.name, {
7
- ...metadata,
8
- edit,
9
- save
10
- });
@@ -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>
@@ -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,4 +0,0 @@
1
- /* Toast Editor Styles */
2
- .wp-block-times-toast {
3
- margin: var(--spacing-m) 0;
4
- }
@@ -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
- }