FIX REfining behaviour
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nonimart 2025-12-04 10:47:19 +01:00
parent 7c73d5079f
commit 4da8e85464
7 changed files with 13 additions and 80 deletions

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '3da4dd74b01a483d6218');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '2b98bbfc592b1bc1d2e2');

View File

@ -1173,7 +1173,6 @@ function save({
const {
title,
iconUrl,
iconName,
hasTitle,
hasIcon,
variant,
@ -1182,31 +1181,6 @@ function save({
logoUrl,
iconPosition
} = attributes;
const ICON_FILES = {
key: 'icon_key.svg',
chain: 'icon_chain.svg',
house: 'icon_house.svg',
bulb: 'icon_bulb.svg',
warning: 'icon_warning.svg',
acoustic: 'icon_acoustic.svg',
documentation: 'icon_documentation.svg',
notification: 'icon_notification.svg',
search: 'icon_search.svg',
info: 'icon_info.svg',
tip: 'icon_tip.svg',
euro: 'icon_euro.svg'
};
const buildIconUrlFromName = () => {
const filename = ICON_FILES[iconName];
if (!filename) return '';
try {
return new URL(`./img/${filename}`, "file:///Users/martoni_sato/Local%20Sites/homegrade-network/app/public/wp-content/plugins/homegrade-blocks/blocks/highlight/src/save.js").toString();
} catch (e) {
return '';
}
};
const isLikelyIconName = value => typeof value === 'string' && Object.keys(ICON_FILES).includes(value);
const resolvedIconUrl = !iconUrl || isLikelyIconName(iconUrl) ? buildIconUrlFromName() : iconUrl;
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("section", {
..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps.save({
className: `homegrade-blocks-highlight ${variant ? `homegrade-blocks-highlight--${variant}` : ''}`
@ -1217,7 +1191,7 @@ function save({
className: "icon"
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
className: "icon__image",
src: resolvedIconUrl,
src: iconUrl,
alt: ""
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.RichText.Content, {
tagName: "h3",
@ -1229,7 +1203,7 @@ function save({
className: "icon"
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
className: "icon__image",
src: resolvedIconUrl,
src: iconUrl,
alt: ""
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
className: "homegrade-blocks-highlight__content__innerblocks"

File diff suppressed because one or more lines are too long

View File

@ -22,10 +22,8 @@
align-items: center;
}
.homegrade-blocks-highlight .icon img {
width: 30px;
max-width: 80%;
max-height: 100%;
height: auto;
width: 100%;
height: 100%;
}
.homegrade-blocks-highlight__titling h3 {
padding-left: 10px;

View File

@ -1 +1 @@
{"version":3,"file":"./style-index.css","mappings":";;;AAAA;;;;;EAAA;AAQC;EACC;AADF;AAGC;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AADF;AAGE;EACC;EACA;EACA;EACA;AADH;AAKE;EACC;AAHH;AAaC;EACC;AAXF;AAaC;EACC;AAXF,C","sources":["webpack://multiblocks/./src/style.scss"],"sourcesContent":["/**\n * The following styles get applied both on the front of your site\n * and in the editor.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.homegrade-blocks-highlight {\n\t&__block-title {\n\t\tmargin: 0 !important;\n\t}\n\t.icon {\n\t\tbackground-color: black;\n\t\tborder-radius: 50%;\n\t\taspect-ratio: 1/1;\n\t\twidth: 40px;\n\t\theight: 40px;\n\t\tpadding: 10px;\n\t\tdisplay: flex;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\n\t\timg {\n\t\t\twidth: 30px;\n\t\t\tmax-width: 80%;\n\t\t\tmax-height: 100%;\n\t\t\theight: auto;\n\t\t}\n\t}\n\t&__titling {\n\t\th3 {\n\t\t\tpadding-left: 10px;\n\t\t}\n\t}\n\n\t// ul li {\n\t// \tlist-style-type: disc;\n\t// \tlist-style-position: inside;\n\t// \tmargin-left: 1.5em;\n\t// }\n\n\tp + ul {\n\t\tpadding-top: 16px;\n\t}\n\tul + p {\n\t\tpadding-top: 16px;\n\t}\n}\n"],"names":[],"sourceRoot":""}
{"version":3,"file":"./style-index.css","mappings":";;;AAAA;;;;;EAAA;AAQC;EACC;AADF;AAGC;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AADF;AAGE;EACC;EACA;AADH;AAKE;EACC;AAHH;AAaC;EACC;AAXF;AAaC;EACC;AAXF,C","sources":["webpack://multiblocks/./src/style.scss"],"sourcesContent":["/**\n * The following styles get applied both on the front of your site\n * and in the editor.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.homegrade-blocks-highlight {\n\t&__block-title {\n\t\tmargin: 0 !important;\n\t}\n\t.icon {\n\t\tbackground-color: black;\n\t\tborder-radius: 50%;\n\t\taspect-ratio: 1/1;\n\t\twidth: 40px;\n\t\theight: 40px;\n\t\tpadding: 10px;\n\t\tdisplay: flex;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\n\t\timg {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t}\n\t&__titling {\n\t\th3 {\n\t\t\tpadding-left: 10px;\n\t\t}\n\t}\n\n\t// ul li {\n\t// \tlist-style-type: disc;\n\t// \tlist-style-position: inside;\n\t// \tmargin-left: 1.5em;\n\t// }\n\n\tp + ul {\n\t\tpadding-top: 16px;\n\t}\n\tul + p {\n\t\tpadding-top: 16px;\n\t}\n}\n"],"names":[],"sourceRoot":""}

View File

@ -3,45 +3,8 @@ import { __ } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data'; // pour les querry
export default function save({ attributes }) {
const {
title,
iconUrl,
iconName,
hasTitle,
hasIcon,
variant,
hasLogo,
logoAlt,
logoUrl,
iconPosition,
} = attributes;
const ICON_FILES = {
key: 'icon_key.svg',
chain: 'icon_chain.svg',
house: 'icon_house.svg',
bulb: 'icon_bulb.svg',
warning: 'icon_warning.svg',
acoustic: 'icon_acoustic.svg',
documentation: 'icon_documentation.svg',
notification: 'icon_notification.svg',
search: 'icon_search.svg',
info: 'icon_info.svg',
tip: 'icon_tip.svg',
euro: 'icon_euro.svg',
};
const buildIconUrlFromName = () => {
const filename = ICON_FILES[iconName];
if (!filename) return '';
try {
return new URL(`./img/${filename}`, import.meta.url).toString();
} catch (e) {
return '';
}
};
const isLikelyIconName = (value) =>
typeof value === 'string' && Object.keys(ICON_FILES).includes(value);
const resolvedIconUrl = !iconUrl || isLikelyIconName(iconUrl) ? buildIconUrlFromName() : iconUrl;
const { title, iconUrl, hasTitle, hasIcon, variant, hasLogo, logoAlt, logoUrl, iconPosition } =
attributes;
return (
<section
@ -59,7 +22,7 @@ export default function save({ attributes }) {
>
{hasIcon && iconPosition === 'top' && (
<div className="icon">
<img className="icon__image" src={resolvedIconUrl} alt="" />
<img className="icon__image" src={iconUrl} alt="" />
</div>
)}
@ -73,7 +36,7 @@ export default function save({ attributes }) {
<div className="homegrade-blocks-highlight__content">
{hasIcon && iconPosition === 'side' && !hasTitle && (
<div className="icon">
<img className="icon__image" src={resolvedIconUrl} alt="" />
<img className="icon__image" src={iconUrl} alt="" />
</div>
)}

View File

@ -21,10 +21,8 @@
align-items: center;
img {
width: 30px;
max-width: 80%;
max-height: 100%;
height: auto;
width: 100%;
height: 100%;
}
}
&__titling {