@times-design-system/components-wordpress 1.7.0 → 1.8.1-alpha.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/README.md +3 -0
- package/dist/blocks/button/block.json +2 -2
- package/dist/blocks/button/render.php +20 -10
- package/dist/blocks/chip/block.json +4 -2
- package/dist/blocks/chip/render.php +10 -2
- package/dist/blocks/chip/style.css +21 -0
- package/dist/blocks/flag/block.json +4 -2
- package/dist/blocks/flag/render.php +11 -2
- package/dist/blocks/flag/style.css +21 -0
- package/dist/blocks/icon/block.json +17 -2
- package/dist/blocks/icon/render.php +32 -17
- package/dist/blocks/icon-button/block.json +16 -1
- package/dist/blocks/icon-button/render.php +4 -2
- package/dist/blocks/link/block.json +4 -2
- package/dist/blocks/link/render.php +12 -2
- package/dist/icon-data.json +3932 -0
- package/dist/index.cjs +30 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -9
- package/dist/index.js.map +1 -1
- package/dist/utils/render-icon.php +209 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -846,9 +846,12 @@ Then follow the [BLOCK_CREATION_CHECKLIST.md](./BLOCK_CREATION_CHECKLIST.md) whi
|
|
|
846
846
|
|
|
847
847
|
For detailed context on component patterns, see [TRANSFORMATION_GUIDE.md](./TRANSFORMATION_GUIDE.md).
|
|
848
848
|
|
|
849
|
+
For icon handling in blocks (variants, extraction, color transformation), see [ICON_HANDLING.md](./ICON_HANDLING.md).
|
|
850
|
+
|
|
849
851
|
## Resources
|
|
850
852
|
|
|
851
853
|
- [Complete Transformation Guide](./TRANSFORMATION_GUIDE.md) — Detailed step-by-step process
|
|
854
|
+
- [Icon Handling Guide](./ICON_HANDLING.md) — Icons, variants, color theming
|
|
852
855
|
- [Block Creation Checklist](./BLOCK_CREATION_CHECKLIST.md) — Quality assurance checklist
|
|
853
856
|
- [WordPress Blocks Documentation](https://developer.wordpress.org/block-editor/)
|
|
854
857
|
- [Gutenberg Block API](https://developer.wordpress.org/block-editor/reference-guides/block-api/)
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
},
|
|
78
78
|
"iconLeft": {
|
|
79
79
|
"type": "string",
|
|
80
|
-
"description": "Icon
|
|
80
|
+
"description": "Icon on the left with variant prefix (e.g., 'filled_circle', 'outlined_circle')"
|
|
81
81
|
},
|
|
82
82
|
"iconRight": {
|
|
83
83
|
"type": "string",
|
|
84
|
-
"description": "Icon
|
|
84
|
+
"description": "Icon on the right with variant prefix (e.g., 'filled_circle', 'outlined_circle')"
|
|
85
85
|
},
|
|
86
86
|
"ariaLabel": {
|
|
87
87
|
"type": "string",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
14
15
|
|
|
15
16
|
$label = isset($attributes['label']) ? sanitize_text_field($attributes['label']) : 'Button label';
|
|
16
17
|
$intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : 'primary';
|
|
@@ -25,6 +26,15 @@ $rel = isset($attributes['rel']) ? sanitize_text_field($attributes['rel']) : '';
|
|
|
25
26
|
$type = isset($attributes['type']) ? sanitize_text_field($attributes['type']) : 'button';
|
|
26
27
|
$icon_left = isset($attributes['iconLeft']) ? sanitize_text_field($attributes['iconLeft']) : '';
|
|
27
28
|
$icon_right = isset($attributes['iconRight']) ? sanitize_text_field($attributes['iconRight']) : '';
|
|
29
|
+
|
|
30
|
+
// Derive icon size from button size
|
|
31
|
+
$icon_size_map = [
|
|
32
|
+
'small' => 'small',
|
|
33
|
+
'medium' => 'medium',
|
|
34
|
+
'large' => 'large',
|
|
35
|
+
'xlarge' => 'large'
|
|
36
|
+
];
|
|
37
|
+
$icon_size = $icon_size_map[$size] ?? 'medium';
|
|
28
38
|
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
29
39
|
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
30
40
|
|
|
@@ -73,11 +83,11 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => 'tds-button-wrapper'])
|
|
|
73
83
|
>
|
|
74
84
|
<span class="tds-button__label-container">
|
|
75
85
|
<?php if ($icon_left) : ?>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
<span class="tds-button__icon tds-button__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
87
|
+
<?php endif; ?>
|
|
88
|
+
<span class="tds-button__label"><?php echo wp_kses_post($label); ?></span>
|
|
89
|
+
<?php if ($icon_right) : ?>
|
|
90
|
+
<span class="tds-button__icon tds-button__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
81
91
|
<?php endif; ?>
|
|
82
92
|
</span>
|
|
83
93
|
</a>
|
|
@@ -93,11 +103,11 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => 'tds-button-wrapper'])
|
|
|
93
103
|
>
|
|
94
104
|
<span class="tds-button__label-container">
|
|
95
105
|
<?php if ($icon_left) : ?>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
<span class="tds-button__icon tds-button__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
107
|
+
<?php endif; ?>
|
|
108
|
+
<span class="tds-button__label"><?php echo wp_kses_post($label); ?></span>
|
|
109
|
+
<?php if ($icon_right) : ?>
|
|
110
|
+
<span class="tds-button__icon tds-button__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
101
111
|
<?php endif; ?>
|
|
102
112
|
</span>
|
|
103
113
|
</button>
|
|
@@ -38,11 +38,13 @@
|
|
|
38
38
|
},
|
|
39
39
|
"iconLeft": {
|
|
40
40
|
"type": "string",
|
|
41
|
-
"default": ""
|
|
41
|
+
"default": "",
|
|
42
|
+
"description": "Icon on the left with variant prefix (e.g., 'filled_circle')"
|
|
42
43
|
},
|
|
43
44
|
"iconRight": {
|
|
44
45
|
"type": "string",
|
|
45
|
-
"default": ""
|
|
46
|
+
"default": "",
|
|
47
|
+
"description": "Icon on the right with variant prefix (e.g., 'outlined_circle')"
|
|
46
48
|
},
|
|
47
49
|
"ariaLabel": {
|
|
48
50
|
"type": "string",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
14
15
|
|
|
15
16
|
$content_text = isset($attributes['content']) ? wp_kses_post($attributes['content']) : '';
|
|
16
17
|
$intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent']) : '';
|
|
@@ -19,6 +20,13 @@ $channel = isset($attributes['channel']) ? (bool) $attributes['channel'] : false
|
|
|
19
20
|
$toggle = isset($attributes['toggle']) ? (bool) $attributes['toggle'] : false;
|
|
20
21
|
$icon_left = isset($attributes['iconLeft']) ? sanitize_text_field($attributes['iconLeft']) : '';
|
|
21
22
|
$icon_right = isset($attributes['iconRight']) ? sanitize_text_field($attributes['iconRight']) : '';
|
|
23
|
+
|
|
24
|
+
// Derive icon size from chip size
|
|
25
|
+
$icon_size_map = [
|
|
26
|
+
'small' => 'xsmall',
|
|
27
|
+
'large' => 'small'
|
|
28
|
+
];
|
|
29
|
+
$icon_size = $icon_size_map[$size] ?? 'xsmall';
|
|
22
30
|
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
23
31
|
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
24
32
|
|
|
@@ -52,11 +60,11 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
52
60
|
>
|
|
53
61
|
<span class="tds-chip__content">
|
|
54
62
|
<?php if ($icon_left) : ?>
|
|
55
|
-
<span class="tds-chip__icon tds-chip__icon--left"><?php echo wp_kses_post($icon_left); ?></span>
|
|
63
|
+
<span class="tds-chip__icon tds-chip__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
56
64
|
<?php endif; ?>
|
|
57
65
|
<?php echo wp_kses_post($content_text); ?>
|
|
58
66
|
<?php if ($icon_right) : ?>
|
|
59
|
-
<span class="tds-chip__icon tds-chip__icon--right"><?php echo wp_kses_post($icon_right); ?></span>
|
|
67
|
+
<span class="tds-chip__icon tds-chip__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
60
68
|
<?php endif; ?>
|
|
61
69
|
</span>
|
|
62
70
|
</button>
|
|
@@ -85,3 +85,24 @@
|
|
|
85
85
|
align-items: center;
|
|
86
86
|
justify-content: center;
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
.tds-chip__icon {
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.tds-chip--size-small .tds-chip__icon {
|
|
96
|
+
width: 16px;
|
|
97
|
+
height: 16px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.tds-chip--size-large .tds-chip__icon {
|
|
101
|
+
width: 20px;
|
|
102
|
+
height: 20px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.tds-chip__icon svg {
|
|
106
|
+
width: 100%;
|
|
107
|
+
height: 100%;
|
|
108
|
+
}
|
|
@@ -34,11 +34,13 @@
|
|
|
34
34
|
},
|
|
35
35
|
"iconLeft": {
|
|
36
36
|
"type": "string",
|
|
37
|
-
"default": ""
|
|
37
|
+
"default": "",
|
|
38
|
+
"description": "Icon on the left with variant prefix (e.g., 'filled_check')"
|
|
38
39
|
},
|
|
39
40
|
"iconRight": {
|
|
40
41
|
"type": "string",
|
|
41
|
-
"default": ""
|
|
42
|
+
"default": "",
|
|
43
|
+
"description": "Icon on the right with variant prefix (e.g., 'outlined_check')"
|
|
42
44
|
},
|
|
43
45
|
"ariaLabel": {
|
|
44
46
|
"type": "string",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
14
15
|
|
|
15
16
|
$label = isset($attributes['label']) ? sanitize_text_field($attributes['label']) : '';
|
|
16
17
|
$content_text = isset($attributes['content']) ? wp_kses_post($attributes['content']) : '';
|
|
@@ -18,6 +19,14 @@ $intent = isset($attributes['intent']) ? sanitize_text_field($attributes['intent
|
|
|
18
19
|
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : '';
|
|
19
20
|
$icon_left = isset($attributes['iconLeft']) ? sanitize_text_field($attributes['iconLeft']) : '';
|
|
20
21
|
$icon_right = isset($attributes['iconRight']) ? sanitize_text_field($attributes['iconRight']) : '';
|
|
22
|
+
|
|
23
|
+
// Derive icon size from flag size
|
|
24
|
+
$icon_size_map = [
|
|
25
|
+
'small' => 'xsmall',
|
|
26
|
+
'medium' => 'small',
|
|
27
|
+
'large' => 'medium'
|
|
28
|
+
];
|
|
29
|
+
$icon_size = $icon_size_map[$size] ?? 'small';
|
|
21
30
|
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
22
31
|
$element_class_name = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
23
32
|
|
|
@@ -46,11 +55,11 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
46
55
|
<?php if ($label) : ?>
|
|
47
56
|
<div class="tds-flag__label">
|
|
48
57
|
<?php if ($icon_left) : ?>
|
|
49
|
-
<span class="tds-flag__icon tds-flag__icon--left"><?php echo wp_kses_post($icon_left); ?></span>
|
|
58
|
+
<span class="tds-flag__icon tds-flag__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
50
59
|
<?php endif; ?>
|
|
51
60
|
<?php echo wp_kses_post($label); ?>
|
|
52
61
|
<?php if ($icon_right) : ?>
|
|
53
|
-
<span class="tds-flag__icon tds-flag__icon--right"><?php echo wp_kses_post($icon_right); ?></span>
|
|
62
|
+
<span class="tds-flag__icon tds-flag__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
54
63
|
<?php endif; ?>
|
|
55
64
|
</div>
|
|
56
65
|
<?php endif; ?>
|
|
@@ -52,3 +52,24 @@
|
|
|
52
52
|
display: inline-flex;
|
|
53
53
|
align-items: center;
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
.tds-flag__icon {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.tds-flag--size-small .tds-flag__icon {
|
|
63
|
+
width: 16px;
|
|
64
|
+
height: 16px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.tds-flag--size-large .tds-flag__icon {
|
|
68
|
+
width: 24px;
|
|
69
|
+
height: 24px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.tds-flag__icon svg {
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
75
|
+
}
|
|
@@ -14,9 +14,24 @@
|
|
|
14
14
|
},
|
|
15
15
|
"textdomain": "times-blocks",
|
|
16
16
|
"attributes": {
|
|
17
|
-
"
|
|
17
|
+
"iconName": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"default": ""
|
|
19
|
+
"default": "",
|
|
20
|
+
"description": "The name of the icon to display (e.g., 'filled_circle', 'outlined_check')"
|
|
21
|
+
},
|
|
22
|
+
"size": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": [
|
|
25
|
+
"2xsmall",
|
|
26
|
+
"xsmall",
|
|
27
|
+
"small",
|
|
28
|
+
"medium",
|
|
29
|
+
"large",
|
|
30
|
+
"xlarge",
|
|
31
|
+
"2xlarge"
|
|
32
|
+
],
|
|
33
|
+
"default": "medium",
|
|
34
|
+
"description": "Size of the icon"
|
|
20
35
|
},
|
|
21
36
|
"classes": {
|
|
22
37
|
"type": "string",
|
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
/**
|
|
3
|
-
* Block
|
|
3
|
+
* Icon Block Render Callback
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Renders the Icon block with inline SVG content.
|
|
6
|
+
* Supports sizing parity with components-react Icon component.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
8
|
+
* @package TimesDesignSystem\ComponentsWordPress
|
|
9
|
+
* @var array $attributes Block attributes
|
|
10
|
+
* @var string $content Block content
|
|
11
|
+
* @var WP_Block $block Block instance
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
require_once __DIR__ . '/../../utils/
|
|
14
|
+
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
15
15
|
|
|
16
|
-
$
|
|
17
|
-
$
|
|
16
|
+
$icon_name = isset($attributes['iconName']) ? sanitize_text_field($attributes['iconName']) : '';
|
|
17
|
+
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : 'medium';
|
|
18
|
+
$classes = isset($attributes['classes']) ? sanitize_text_field($attributes['classes']) : '';
|
|
18
19
|
|
|
19
20
|
// Sanitize and prepare data-* attributes
|
|
21
|
+
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
20
22
|
$sanitized_data_attributes = tds_sanitize_data_attributes($attributes['dataAttributes'] ?? [], 'icon', $attributes);
|
|
21
23
|
$data_attrs_html = '';
|
|
22
24
|
foreach ($sanitized_data_attributes as $attr_name => $attr_value) {
|
|
23
25
|
$data_attrs_html .= ' ' . esc_attr($attr_name) . '="' . esc_attr($attr_value) . '"';
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
// Build wrapper classes
|
|
29
|
+
$wrapper_classes = ['tds-icon-wrapper'];
|
|
30
|
+
if ($classes) {
|
|
31
|
+
$wrapper_classes[] = $classes;
|
|
29
32
|
}
|
|
30
|
-
$
|
|
33
|
+
$wrapper_class = implode(' ', $wrapper_classes);
|
|
34
|
+
$wrapper_attrs = get_block_wrapper_attributes(['class' => $wrapper_class]);
|
|
31
35
|
|
|
36
|
+
// Render icon (icon name includes variant: filled_circle, outlined_circle, etc.)
|
|
37
|
+
$svg_content = tds_render_icon($icon_name, $size);
|
|
32
38
|
?>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
|
|
40
|
+
<div <?php echo wp_kses_post($wrapper_attrs); ?><?php echo wp_kses_post($data_attrs_html); ?>>
|
|
41
|
+
<?php if ($svg_content) : ?>
|
|
42
|
+
<div class="tds-icon">
|
|
43
|
+
<?php echo wp_kses_post($svg_content); ?>
|
|
44
|
+
</div>
|
|
45
|
+
<?php else : ?>
|
|
46
|
+
<div class="tds-icon tds-icon--error">
|
|
47
|
+
<span class="tds-icon__placeholder"><?php esc_html_e('Icon not found', 'times-design-system'); ?></span>
|
|
48
|
+
</div>
|
|
49
|
+
<?php endif; ?>
|
|
50
|
+
</div>
|
|
@@ -16,7 +16,22 @@
|
|
|
16
16
|
"attributes": {
|
|
17
17
|
"iconName": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"default": ""
|
|
19
|
+
"default": "",
|
|
20
|
+
"description": "Icon name with variant prefix (e.g., 'filled_accessibility', 'outlined_accessibility')"
|
|
21
|
+
},
|
|
22
|
+
"iconSize": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": [
|
|
25
|
+
"2xsmall",
|
|
26
|
+
"xsmall",
|
|
27
|
+
"small",
|
|
28
|
+
"medium",
|
|
29
|
+
"large",
|
|
30
|
+
"xlarge",
|
|
31
|
+
"2xlarge"
|
|
32
|
+
],
|
|
33
|
+
"default": "medium",
|
|
34
|
+
"description": "Size of the icon"
|
|
20
35
|
},
|
|
21
36
|
"round": {
|
|
22
37
|
"type": "boolean",
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
14
15
|
|
|
15
16
|
$icon_name = isset($attributes['iconName']) ? sanitize_text_field($attributes['iconName']) : '';
|
|
17
|
+
$icon_size = isset($attributes['iconSize']) ? sanitize_text_field($attributes['iconSize']) : 'medium';
|
|
16
18
|
$round = isset($attributes['round']) ? (bool) $attributes['round'] : false;
|
|
17
19
|
$isLoading = isset($attributes['isLoading']) ? (bool) $attributes['isLoading'] : false;
|
|
18
20
|
$href = isset($attributes['href']) ? esc_url($attributes['href']) : '';
|
|
@@ -52,7 +54,7 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
52
54
|
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
53
55
|
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
54
56
|
>
|
|
55
|
-
<span class="tds-icon-button__icon"><?php echo wp_kses_post($icon_name); ?></span>
|
|
57
|
+
<span class="tds-icon-button__icon"><?php echo wp_kses_post(tds_render_icon($icon_name, $icon_size)); ?></span>
|
|
56
58
|
</a>
|
|
57
59
|
<?php else : ?>
|
|
58
60
|
<button
|
|
@@ -60,6 +62,6 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
60
62
|
<?php echo $aria_label ? 'aria-label="' . esc_attr($aria_label) . '"' : ''; ?>
|
|
61
63
|
<?php echo wp_kses_post($data_attrs_html); ?>
|
|
62
64
|
>
|
|
63
|
-
<span class="tds-icon-button__icon"><?php echo wp_kses_post($icon_name); ?></span>
|
|
65
|
+
<span class="tds-icon-button__icon"><?php echo wp_kses_post(tds_render_icon($icon_name, $icon_size)); ?></span>
|
|
64
66
|
</button>
|
|
65
67
|
<?php endif; ?>
|
|
@@ -39,11 +39,13 @@
|
|
|
39
39
|
},
|
|
40
40
|
"iconLeft": {
|
|
41
41
|
"type": "string",
|
|
42
|
-
"default": ""
|
|
42
|
+
"default": "",
|
|
43
|
+
"description": "Icon on the left with variant prefix (e.g., 'filled_external-link')"
|
|
43
44
|
},
|
|
44
45
|
"iconRight": {
|
|
45
46
|
"type": "string",
|
|
46
|
-
"default": ""
|
|
47
|
+
"default": "",
|
|
48
|
+
"description": "Icon on the right with variant prefix (e.g., 'outlined_external-link')"
|
|
47
49
|
},
|
|
48
50
|
"inline": {
|
|
49
51
|
"type": "boolean",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
require_once __DIR__ . '/../../utils/sanitize-data-attributes.php';
|
|
14
|
+
require_once __DIR__ . '/../../utils/render-icon.php';
|
|
14
15
|
|
|
15
16
|
$href = isset($attributes['href']) ? esc_url($attributes['href']) : '';
|
|
16
17
|
$content_text = isset($attributes['content']) ? wp_kses_post($attributes['content']) : '';
|
|
@@ -19,6 +20,15 @@ $sentiment = isset($attributes['sentiment']) ? sanitize_text_field($attributes['
|
|
|
19
20
|
$size = isset($attributes['size']) ? sanitize_text_field($attributes['size']) : '';
|
|
20
21
|
$icon_left = isset($attributes['iconLeft']) ? sanitize_text_field($attributes['iconLeft']) : '';
|
|
21
22
|
$icon_right = isset($attributes['iconRight']) ? sanitize_text_field($attributes['iconRight']) : '';
|
|
23
|
+
|
|
24
|
+
// Derive icon size from link size
|
|
25
|
+
$icon_size_map = [
|
|
26
|
+
'xsmall' => 'xsmall',
|
|
27
|
+
'small' => 'xsmall',
|
|
28
|
+
'medium' => 'small',
|
|
29
|
+
'large' => 'medium'
|
|
30
|
+
];
|
|
31
|
+
$icon_size = $icon_size_map[$size] ?? 'small';
|
|
22
32
|
$inline = isset($attributes['inline']) ? (bool) $attributes['inline'] : true;
|
|
23
33
|
$aria_label = isset($attributes['ariaLabel']) ? sanitize_text_field($attributes['ariaLabel']) : '';
|
|
24
34
|
$target = isset($attributes['target']) ? sanitize_text_field($attributes['target']) : '_self';
|
|
@@ -56,11 +66,11 @@ $wrapper_attrs = get_block_wrapper_attributes(['class' => implode(' ', $classes)
|
|
|
56
66
|
>
|
|
57
67
|
<span class="tds-link__content">
|
|
58
68
|
<?php if ($icon_left) : ?>
|
|
59
|
-
<span class="tds-link__icon tds-link__icon--left"><?php echo wp_kses_post($icon_left); ?></span>
|
|
69
|
+
<span class="tds-link__icon tds-link__icon--left"><?php echo wp_kses_post(tds_render_icon($icon_left, $icon_size)); ?></span>
|
|
60
70
|
<?php endif; ?>
|
|
61
71
|
<?php echo wp_kses_post($content_text); ?>
|
|
62
72
|
<?php if ($icon_right) : ?>
|
|
63
|
-
<span class="tds-link__icon tds-link__icon--right"><?php echo wp_kses_post($icon_right); ?></span>
|
|
73
|
+
<span class="tds-link__icon tds-link__icon--right"><?php echo wp_kses_post(tds_render_icon($icon_right, $icon_size)); ?></span>
|
|
64
74
|
<?php endif; ?>
|
|
65
75
|
</span>
|
|
66
76
|
</a>
|