@eightshift/frontend-libs-tailwind 1.4.5 → 1.4.7
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/.husky/pre-commit +0 -0
- package/CHANGELOG.md +19 -0
- package/blocks/init/src/Blocks/components/button/button.php +5 -0
- package/blocks/init/src/Blocks/components/button/manifest.json +3 -0
- package/blocks/init/src/Blocks/components/icon/icon.php +18 -1
- package/blocks/init/src/Blocks/components/icon/manifest.json +4 -0
- package/blocks/init/src/Blocks/components/image/image.php +9 -4
- package/blocks/init/src/Blocks/wrapper/manifest.json +7 -1
- package/bun.lockb +0 -0
- package/package.json +91 -90
- package/scripts/editor/fetch.js +71 -0
- package/webpack/base.mjs +9 -1
package/.husky/pre-commit
CHANGED
|
File without changes
|
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,23 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [1.4.7]
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Fixed Image component "image" part tailwind class output if not set.
|
|
13
|
+
- Fix Image component responsive output Co-authored-by: goran.alkovic@infinum.com
|
|
14
|
+
- Add "Auto" width to wrapperContent and set is as defaults
|
|
15
|
+
- Add a buttonType attribute to Button component
|
|
16
|
+
- Implement a11y for Icon component either by setting aria-hidden to true (default) or using the existing iconName label from manifest options key
|
|
17
|
+
- Updated dependencies.
|
|
18
|
+
|
|
19
|
+
## [1.4.6]
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Tweaked webpack config to properly include font files from `@eightshfit` packages from `node_modules`.
|
|
23
|
+
- Added a new `buildWpRestUrl` helper for easily fetching WP REST URLs. (Similar to `fetchFromWpRest`, but allows you control over how you fetch).
|
|
24
|
+
- Updated dependencies.
|
|
25
|
+
|
|
9
26
|
## [1.4.5]
|
|
10
27
|
|
|
11
28
|
### Changed
|
|
@@ -152,6 +169,8 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
|
|
|
152
169
|
- Initial release.
|
|
153
170
|
|
|
154
171
|
[Unreleased]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/master...HEAD
|
|
172
|
+
[1.4.7]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.6...1.4.7
|
|
173
|
+
[1.4.6]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.5...1.4.6
|
|
155
174
|
[1.4.5]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.4...1.4.5
|
|
156
175
|
[1.4.4]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.3...1.4.4
|
|
157
176
|
[1.4.3]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.2...1.4.3
|
|
@@ -19,6 +19,7 @@ if (!$buttonUse) {
|
|
|
19
19
|
$additionalClass = $attributes['additionalClass'] ?? '';
|
|
20
20
|
$additionalAttributes = $attributes['additionalAttributes'] ?? [];
|
|
21
21
|
$buttonId = Helpers::checkAttr('buttonId', $attributes, $manifest);
|
|
22
|
+
$buttonType = Helpers::checkAttr('buttonType', $attributes, $manifest);
|
|
22
23
|
|
|
23
24
|
$buttonUrl = Helpers::checkAttr('buttonUrl', $attributes, $manifest);
|
|
24
25
|
$buttonIsNewTab = Helpers::checkAttr('buttonIsNewTab', $attributes, $manifest);
|
|
@@ -59,6 +60,10 @@ if (!empty($buttonAriaLabel)) {
|
|
|
59
60
|
$buttonAttrs['class'] = Helpers::tailwindClasses('base', $attributes, $manifest, 'button', $additionalClass);
|
|
60
61
|
|
|
61
62
|
$buttonTag = !empty($buttonUrl) ? 'a' : 'button';
|
|
63
|
+
|
|
64
|
+
if (empty($buttonUrl) && !empty($buttonType)) {
|
|
65
|
+
$buttonAttrs['type'] = $buttonType;
|
|
66
|
+
}
|
|
62
67
|
?>
|
|
63
68
|
|
|
64
69
|
<<?php echo $buttonTag; // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped ?>
|
|
@@ -19,6 +19,7 @@ if (!$iconUse) {
|
|
|
19
19
|
$additionalClass = $attributes['additionalClass'] ?? '';
|
|
20
20
|
|
|
21
21
|
$iconName = Helpers::checkAttr('iconName', $attributes, $manifest);
|
|
22
|
+
$iconAriaHidden = Helpers::checkAttr('iconAriaHidden', $attributes, $manifest);
|
|
22
23
|
|
|
23
24
|
if (!isset($manifest['icons'][$iconName])) {
|
|
24
25
|
return;
|
|
@@ -29,7 +30,23 @@ $icon = $manifest['icons'][$iconName];
|
|
|
29
30
|
$className = Helpers::tailwindClasses('base', $attributes, $manifest, $additionalClass);
|
|
30
31
|
|
|
31
32
|
if (!empty($className)) {
|
|
32
|
-
$icon = str_replace('<svg ', '<svg class="' .
|
|
33
|
+
$icon = str_replace('<svg ', '<svg class="' . esc_attr($className) . '" ', $icon);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ($iconAriaHidden) {
|
|
37
|
+
$icon = str_replace('<svg ', '<svg aria-hidden="true" ', $icon);
|
|
38
|
+
} else {
|
|
39
|
+
$iconTitle = '';
|
|
40
|
+
$iconOption = array_filter($manifest['options']['iconName'], fn($option) => $option['value'] === $iconName);
|
|
41
|
+
|
|
42
|
+
if (!empty($iconOption)) {
|
|
43
|
+
$iconTitle = reset($iconOption)['label'];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!empty($iconTitle)) {
|
|
47
|
+
$titleTag = '<title>' . esc_html($iconTitle) . '</title>';
|
|
48
|
+
$icon = str_replace('</svg>', $titleTag . '</svg>', $icon);
|
|
49
|
+
}
|
|
33
50
|
}
|
|
34
51
|
|
|
35
52
|
// phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
|
|
@@ -25,7 +25,11 @@ $imageAlt = get_post_meta($imageData['_default']['id'], '_wp_attachment_image_al
|
|
|
25
25
|
$isDesktopFirst = $imageData['_desktopFirst'] ?? false;
|
|
26
26
|
|
|
27
27
|
$breakpointData = Helpers::getSettingsGlobalVariablesBreakpoints();
|
|
28
|
-
$breakpoints = Helpers::getTwBreakpoints();
|
|
28
|
+
$breakpoints = Helpers::getTwBreakpoints($isDesktopFirst);
|
|
29
|
+
|
|
30
|
+
if (!$isDesktopFirst) {
|
|
31
|
+
$breakpoints = array_reverse($breakpoints);
|
|
32
|
+
}
|
|
29
33
|
?>
|
|
30
34
|
|
|
31
35
|
<picture
|
|
@@ -33,7 +37,8 @@ $breakpoints = Helpers::getTwBreakpoints();
|
|
|
33
37
|
class="<?php echo esc_attr($additionalClass['picture']); ?>"
|
|
34
38
|
<?php } ?>
|
|
35
39
|
>
|
|
36
|
-
<?php
|
|
40
|
+
<?php
|
|
41
|
+
foreach ($breakpoints as $breakpoint) { ?>
|
|
37
42
|
<?php
|
|
38
43
|
if (!isset($imageData[$breakpoint])) {
|
|
39
44
|
continue;
|
|
@@ -45,7 +50,7 @@ $breakpoints = Helpers::getTwBreakpoints();
|
|
|
45
50
|
continue;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
$breakpointWidth = $breakpointData[$breakpoint];
|
|
53
|
+
$breakpointWidth = $breakpointData[str_replace('max-', '', $breakpoint)];
|
|
49
54
|
|
|
50
55
|
$widthMode = $isDesktopFirst ? 'max-width' : 'min-width';
|
|
51
56
|
|
|
@@ -57,7 +62,7 @@ $breakpoints = Helpers::getTwBreakpoints();
|
|
|
57
62
|
<img
|
|
58
63
|
src="<?php echo esc_url($imageData['_default']['url'] ?? ''); ?>"
|
|
59
64
|
alt="<?php echo esc_attr($imageAlt); ?>"
|
|
60
|
-
class="<?php echo esc_attr(Helpers::tailwindClasses('base', $attributes, $manifest, $additionalClass['image'] ??
|
|
65
|
+
class="<?php echo esc_attr(Helpers::tailwindClasses('base', $attributes, $manifest, $additionalClass['image'] ?? '')); ?>"
|
|
61
66
|
/>
|
|
62
67
|
</picture>
|
|
63
68
|
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"wrapperContentWidth": {
|
|
91
91
|
"type": "object",
|
|
92
92
|
"default": {
|
|
93
|
-
"_default": "
|
|
93
|
+
"_default": "auto",
|
|
94
94
|
"_desktopFirst": true
|
|
95
95
|
}
|
|
96
96
|
},
|
|
@@ -289,6 +289,11 @@
|
|
|
289
289
|
}
|
|
290
290
|
],
|
|
291
291
|
"wrapperContentWidth": [
|
|
292
|
+
{
|
|
293
|
+
"label": "Auto",
|
|
294
|
+
"value": "auto",
|
|
295
|
+
"separator": "below"
|
|
296
|
+
},
|
|
292
297
|
{
|
|
293
298
|
"label": "Full",
|
|
294
299
|
"value": "full",
|
|
@@ -439,6 +444,7 @@
|
|
|
439
444
|
"wrapperContentWidth": {
|
|
440
445
|
"responsive": true,
|
|
441
446
|
"twClasses": {
|
|
447
|
+
"auto": "w-auto",
|
|
442
448
|
"full": "w-full",
|
|
443
449
|
"half": "w-1/2",
|
|
444
450
|
"one-third": "w-1/3",
|
package/bun.lockb
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,91 +1,92 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
2
|
+
"name": "@eightshift/frontend-libs-tailwind",
|
|
3
|
+
"version": "1.4.7",
|
|
4
|
+
"description": "A framework for creating modern Gutenberg themes with styling provided by Tailwind CSS.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Eightshift team",
|
|
7
|
+
"email": "team@eightshift.com",
|
|
8
|
+
"url": "https://eightshift.com/"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/infinum/eightshift-frontend-libs-tailwind.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"frontend",
|
|
16
|
+
"css",
|
|
17
|
+
"mixin",
|
|
18
|
+
"js",
|
|
19
|
+
"utility",
|
|
20
|
+
"module",
|
|
21
|
+
"WordPress",
|
|
22
|
+
"tailwind",
|
|
23
|
+
"TailwindCSS"
|
|
24
|
+
],
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/infinum/eightshift-frontend-libs-tailwind/issues"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"lintStyle": "stylelint **/*.css",
|
|
30
|
+
"lintJs": "npx eslint",
|
|
31
|
+
"lint": "npm run lintJs && npm run lintStyle",
|
|
32
|
+
"prepare": "husky"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/infinum/eightshift-frontend-libs-tailwind#readme",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@eightshift/ui-components": "^1.9.1",
|
|
38
|
+
"@stylistic/eslint-plugin-js": "^2.12.1",
|
|
39
|
+
"@stylistic/stylelint-plugin": "^3.1.1",
|
|
40
|
+
"@swc/core": "^1.10.1",
|
|
41
|
+
"@wordpress/api-fetch": "^7.14.0",
|
|
42
|
+
"@wordpress/block-editor": "^14.9.0",
|
|
43
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^5.9.0",
|
|
44
|
+
"@wordpress/dom-ready": "^4.14.0",
|
|
45
|
+
"@wordpress/server-side-render": "^5.14.0",
|
|
46
|
+
"browserslist": "^4.24.3",
|
|
47
|
+
"css-loader": "^7.1.2",
|
|
48
|
+
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
49
|
+
"eslint": "^9.17.0",
|
|
50
|
+
"eslint-config-prettier": "^9.1.0",
|
|
51
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
52
|
+
"globals": "^15.13.0",
|
|
53
|
+
"husky": "^9.1.7",
|
|
54
|
+
"lightningcss": "^1.28.2",
|
|
55
|
+
"mini-css-extract-plugin": "^2.9.2",
|
|
56
|
+
"postcss": "^8.4.49",
|
|
57
|
+
"postcss-loader": "^8.1.1",
|
|
58
|
+
"prettier": "^3.4.2",
|
|
59
|
+
"prettier-plugin-tailwindcss": "^0.6.9",
|
|
60
|
+
"sonner": "^1.7.1",
|
|
61
|
+
"stylelint": "^16.12.0",
|
|
62
|
+
"stylelint-config-standard": "^36.0.1",
|
|
63
|
+
"swc-loader": "^0.2.6",
|
|
64
|
+
"terser-webpack-plugin": "^5.3.11",
|
|
65
|
+
"webpack": "^5.97.1",
|
|
66
|
+
"webpack-cli": "^5.1.4",
|
|
67
|
+
"webpack-manifest-plugin": "^5.0.0",
|
|
68
|
+
"webpack-merge": "^6.0.1"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"embla-carousel": "^8.5.1",
|
|
72
|
+
"fluid-tailwind": "^1.0.4",
|
|
73
|
+
"lint-staged": "^15.2.11",
|
|
74
|
+
"micromodal": "^0.4.10",
|
|
75
|
+
"ol": "^10.3.1",
|
|
76
|
+
"ol-mapbox-style": "^12.4.0",
|
|
77
|
+
"tailwindcss": "^3.4.17",
|
|
78
|
+
"tailwindcss-animate": "^1.0.7"
|
|
79
|
+
},
|
|
80
|
+
"sideEffects": false,
|
|
81
|
+
"lint-staged": {
|
|
82
|
+
"*.css": [
|
|
83
|
+
"npm run lintStyle"
|
|
84
|
+
],
|
|
85
|
+
"*.js": [
|
|
86
|
+
"npm run lintJs"
|
|
87
|
+
],
|
|
88
|
+
"*.php": [
|
|
89
|
+
"composer test"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
package/scripts/editor/fetch.js
CHANGED
|
@@ -108,3 +108,74 @@ export const wpSearchRoute = fetchFromWpRest('search', {
|
|
|
108
108
|
searchColumns: 'post_title',
|
|
109
109
|
fields: 'id,title,type,subtype,url',
|
|
110
110
|
});
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns a function that fetches data from WordPress REST API.
|
|
114
|
+
*
|
|
115
|
+
* @param {string} endpoint - Endpoint to fetch from.
|
|
116
|
+
* @param {Object} options - Additional options.
|
|
117
|
+
* @param {number} [options.perPage=30] - Number of items to fetch per page.
|
|
118
|
+
* @param {string} [options.routePrefix='wp/v2'] - Route prefix for the API.
|
|
119
|
+
* @param {string} [options.fields='id,title'] - A comma-separated list of field names to fetch from the API. Good to include as it makes the query faster and the output terser.
|
|
120
|
+
* @param {string} [options.noSearch=false] - If `true`, only the URL will be returned, without the search query support.
|
|
121
|
+
* @param {SearchColumnsConfig} [options.searchColumns] - Allows narrowing the search scope.
|
|
122
|
+
*
|
|
123
|
+
* @returns {Function} The `(searchText) => url: string` function, or URL as `string` if `noSearch` is set.
|
|
124
|
+
*
|
|
125
|
+
* @typedef {'post_title' | 'post_excerpt' | 'post_content'} SearchColumnsConfig
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* const data = await fetch(buildWpRestUrl('pages'));
|
|
129
|
+
* const json = await data.json();
|
|
130
|
+
*
|
|
131
|
+
* console.log(json);
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* <AsyncSelect
|
|
135
|
+
* value={loremIpsum}
|
|
136
|
+
* onChange={(value) => setAttributes({ [getAttrKey('loremIpsum', attributes, manifest)]: value })}
|
|
137
|
+
* fetchUrl={buildWpRestUrl('pages')}
|
|
138
|
+
* />
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
export function buildWpRestUrl(endpoint, options = {}) {
|
|
142
|
+
const {
|
|
143
|
+
perPage = 30,
|
|
144
|
+
routePrefix = 'wp/v2',
|
|
145
|
+
fields = 'id,title',
|
|
146
|
+
searchColumns,
|
|
147
|
+
noSearch,
|
|
148
|
+
...additionalParams
|
|
149
|
+
} = options;
|
|
150
|
+
|
|
151
|
+
let params = {
|
|
152
|
+
per_page: perPage,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if (fields?.length > 0) {
|
|
156
|
+
params['_fields'] = fields;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (searchColumns?.length > 0) {
|
|
160
|
+
params.search_columns = Array.isArray(searchColumns) ? searchColumns.join(',') : searchColumns;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (Object.keys(params).length > 0) {
|
|
164
|
+
params = {
|
|
165
|
+
...params,
|
|
166
|
+
...additionalParams,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (noSearch) {
|
|
171
|
+
return addQueryArgs(`${routePrefix}/${endpoint}/`, params);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return (searchText) => {
|
|
175
|
+
if (searchText?.length > 0) {
|
|
176
|
+
params.search = searchText;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return addQueryArgs(`${routePrefix}/${endpoint}/`, params);
|
|
180
|
+
};
|
|
181
|
+
}
|
package/webpack/base.mjs
CHANGED
|
@@ -34,7 +34,7 @@ export default (options) => {
|
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// Output
|
|
37
|
+
// Output CSS from JS.
|
|
38
38
|
if (!options.overrides.includes('miniCssExtractPlugin')) {
|
|
39
39
|
plugins.push(
|
|
40
40
|
new MiniCssExtractPlugin({
|
|
@@ -94,6 +94,7 @@ export default (options) => {
|
|
|
94
94
|
],
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
// Node modules - CSS.
|
|
97
98
|
module.rules.push({
|
|
98
99
|
test: /\.css$/,
|
|
99
100
|
include: /node_modules/,
|
|
@@ -103,6 +104,13 @@ export default (options) => {
|
|
|
103
104
|
},
|
|
104
105
|
],
|
|
105
106
|
});
|
|
107
|
+
|
|
108
|
+
// Node modules - Eightshift package fonts.
|
|
109
|
+
module.rules.push({
|
|
110
|
+
test: /\.(woff2|ttf|otf)$/i,
|
|
111
|
+
type: 'asset/resource',
|
|
112
|
+
include: /node_modules\/@eightshift/,
|
|
113
|
+
});
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
// Module for Images.
|