@times-design-system/components-wordpress 1.8.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 +10 -10
- package/dist/blocks/chip/block.json +4 -2
- package/dist/blocks/flag/block.json +4 -2
- package/dist/blocks/icon/block.json +1 -1
- package/dist/blocks/icon/render.php +1 -1
- package/dist/blocks/icon-button/block.json +2 -1
- package/dist/blocks/link/block.json +4 -2
- package/dist/icon-data.json +3895 -1952
- package/dist/index.cjs +16 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -9
- package/dist/index.js.map +1 -1
- package/dist/utils/render-icon.php +32 -6
- package/package.json +4 -4
|
@@ -55,9 +55,14 @@ function tds_load_icon_data() {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Get icon SVG by name
|
|
58
|
+
* Get icon SVG by name and optional variant
|
|
59
59
|
*
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Get icon SVG content from icon data store
|
|
62
|
+
*
|
|
63
|
+
* Icon names include variant prefix: 'filled_arrow_left', 'outlined_check'
|
|
64
|
+
*
|
|
65
|
+
* @param string $icon_name Icon name with variant (e.g., 'filled_arrow_left', 'outlined_check')
|
|
61
66
|
* @return string|false SVG content or false if not found
|
|
62
67
|
*/
|
|
63
68
|
function tds_get_icon_svg($icon_name) {
|
|
@@ -70,14 +75,23 @@ function tds_get_icon_svg($icon_name) {
|
|
|
70
75
|
return false;
|
|
71
76
|
}
|
|
72
77
|
|
|
78
|
+
// Sanitize the icon name (includes variant prefix)
|
|
73
79
|
$icon_name = sanitize_key($icon_name);
|
|
74
|
-
|
|
80
|
+
|
|
81
|
+
// Look up icon directly (icon name already includes variant)
|
|
82
|
+
if (isset($icon_data['icons'][$icon_name])) {
|
|
83
|
+
return $icon_data['icons'][$icon_name];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return false;
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
/**
|
|
78
90
|
* Render an inline SVG icon with optional sizing
|
|
79
91
|
*
|
|
80
|
-
*
|
|
92
|
+
* Icon names include variant prefix (e.g., 'filled_accessibility', 'outlined_check')
|
|
93
|
+
*
|
|
94
|
+
* @param string $icon_name Icon name with variant (e.g., 'filled_circle', 'outlined_circle')
|
|
81
95
|
* @param string $size_name Size name (e.g., 'medium', 'large')
|
|
82
96
|
* @param string $class Optional CSS class to add to the SVG
|
|
83
97
|
* @return string HTML SVG string or empty string if icon not found
|
|
@@ -91,7 +105,7 @@ function tds_render_icon($icon_name, $size_name = 'medium', $class = '') {
|
|
|
91
105
|
if (!$svg_content) {
|
|
92
106
|
// Icon not found - log debug info if WP_DEBUG is enabled
|
|
93
107
|
if (defined('WP_DEBUG') && WP_DEBUG) {
|
|
94
|
-
error_log("Icon not found: {$icon_name}");
|
|
108
|
+
error_log("Icon not found: {$variant}-{$icon_name}");
|
|
95
109
|
}
|
|
96
110
|
return '';
|
|
97
111
|
}
|
|
@@ -110,7 +124,7 @@ function tds_render_icon($icon_name, $size_name = 'medium', $class = '') {
|
|
|
110
124
|
* Inject width/height attributes into SVG string
|
|
111
125
|
*
|
|
112
126
|
* Handles both existing SVG elements and injects sizing.
|
|
113
|
-
* Also adds optional CSS class.
|
|
127
|
+
* Also adds optional CSS class and replaces color attributes with currentcolor.
|
|
114
128
|
*
|
|
115
129
|
* @param string $svg SVG content
|
|
116
130
|
* @param int $width Width in pixels
|
|
@@ -124,6 +138,18 @@ function tds_inject_svg_dimensions($svg, $width, $height, $class = '') {
|
|
|
124
138
|
$svg = str_replace('<svg', sprintf('<svg width="%d" height="%d"', $width, $height), $svg);
|
|
125
139
|
}
|
|
126
140
|
|
|
141
|
+
// Replace fill attributes with currentcolor
|
|
142
|
+
$svg = preg_replace('/fill="[^"]*"/i', 'fill="currentcolor"', $svg);
|
|
143
|
+
|
|
144
|
+
// Replace stroke attributes with currentcolor
|
|
145
|
+
$svg = preg_replace('/stroke="[^"]*"/i', 'stroke="currentcolor"', $svg);
|
|
146
|
+
|
|
147
|
+
// Handle fill in style attributes: style="fill: #xxx" or style="...fill: #xxx..."
|
|
148
|
+
$svg = preg_replace('/style="([^"]*)fill:\s*[^;}"]+/i', 'style="$1fill: currentcolor', $svg);
|
|
149
|
+
|
|
150
|
+
// Handle stroke in style attributes: style="stroke: #xxx" or style="...stroke: #xxx..."
|
|
151
|
+
$svg = preg_replace('/style="([^"]*)stroke:\s*[^;}"]+/i', 'style="$1stroke: currentcolor', $svg);
|
|
152
|
+
|
|
127
153
|
// Add class if provided
|
|
128
154
|
if (!empty($class)) {
|
|
129
155
|
$class_attr = sanitize_html_class($class);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@times-design-system/components-wordpress",
|
|
3
|
-
"version": "1.8.0",
|
|
3
|
+
"version": "1.8.1-alpha.0+66ac66b0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Times Design System Gutenberg blocks for WordPress Full Site Editing",
|
|
6
6
|
"keywords": [
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@times-design-system/theme-scss": "^2.6.
|
|
68
|
+
"@times-design-system/theme-scss": "^2.6.1-alpha.2+66ac66b0",
|
|
69
69
|
"@wordpress/block-editor": "^12.0.0",
|
|
70
70
|
"@wordpress/blocks": "^12.0.0",
|
|
71
71
|
"@wordpress/components": "^25.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@testing-library/jest-dom": "^6.1.5",
|
|
84
84
|
"@testing-library/react": "^14.1.2",
|
|
85
85
|
"@testing-library/user-event": "^14.5.1",
|
|
86
|
-
"@times-design-system/icons": "^1.2.
|
|
86
|
+
"@times-design-system/icons": "^1.2.1-alpha.77+66ac66b0",
|
|
87
87
|
"@types/react": "19.2.5",
|
|
88
88
|
"@vitest/ui": "^1.0.4",
|
|
89
89
|
"jsdom": "^23.0.0",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"typescript": "^5.0.0",
|
|
96
96
|
"vitest": "^1.0.4"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "66ac66b0ffc921ff609182674bb573de41fe7e36"
|
|
99
99
|
}
|