FEATURE Refactoring block to best handle urls, innerlink and passing svg arrow for better reusability
This commit is contained in:
parent
19dcaeb338
commit
c41db977d6
|
|
@ -1,18 +1,15 @@
|
||||||
/*!*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
|
/*!*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
|
||||||
!*** css ./node_modules/.pnpm/css-loader@6.11.0_webpack@5.103.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.103.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/.pnpm/sass-loader@16.0.6_sass@1.94.1_webpack@5.103.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/cta/editor.scss ***!
|
!*** css ./node_modules/.pnpm/css-loader@6.11.0_webpack@5.103.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.103.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/.pnpm/sass-loader@16.0.6_sass@1.94.1_webpack@5.103.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/cta/editor.scss ***!
|
||||||
\*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
|
\*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
|
||||||
.wp-block-carhop-blocks-cta {
|
|
||||||
color: var(--cta-current-color);
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta a {
|
.wp-block-carhop-blocks-cta a {
|
||||||
color: var(--cta-current-color) !important;
|
padding-bottom: 0 !important;
|
||||||
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
.wp-block-carhop-blocks-cta {
|
.wp-block-carhop-blocks-cta {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
display: block;
|
|
||||||
width: -moz-fit-content;
|
width: -moz-fit-content;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
display: flex;
|
display: flex !important;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
|
|
@ -23,7 +20,7 @@
|
||||||
}
|
}
|
||||||
.wp-block-carhop-blocks-cta .icon svg path,
|
.wp-block-carhop-blocks-cta .icon svg path,
|
||||||
.wp-block-carhop-blocks-cta .icon svg circle {
|
.wp-block-carhop-blocks-cta .icon svg circle {
|
||||||
stroke: var(--cta-current-color);
|
stroke: currentColor;
|
||||||
}
|
}
|
||||||
.wp-block-carhop-blocks-cta.align--left {
|
.wp-block-carhop-blocks-cta.align--left {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '1a1c96d4851a5a9d92ea');
|
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => 'b611b7ff4b53bdf52fa8');
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
/*!*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
|
/*!*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
|
||||||
!*** css ./node_modules/.pnpm/css-loader@6.11.0_webpack@5.103.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.103.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/.pnpm/sass-loader@16.0.6_sass@1.94.1_webpack@5.103.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/cta/editor.scss ***!
|
!*** css ./node_modules/.pnpm/css-loader@6.11.0_webpack@5.103.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.103.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/.pnpm/sass-loader@16.0.6_sass@1.94.1_webpack@5.103.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/cta/editor.scss ***!
|
||||||
\*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
|
\*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
|
||||||
.wp-block-carhop-blocks-cta {
|
|
||||||
color: var(--cta-current-color);
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta a {
|
.wp-block-carhop-blocks-cta a {
|
||||||
color: var(--cta-current-color) !important;
|
padding-bottom: 0 !important;
|
||||||
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
.wp-block-carhop-blocks-cta {
|
.wp-block-carhop-blocks-cta {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
display: block;
|
|
||||||
width: -moz-fit-content;
|
width: -moz-fit-content;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
display: flex;
|
display: flex !important;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
|
|
@ -23,7 +20,7 @@
|
||||||
}
|
}
|
||||||
.wp-block-carhop-blocks-cta .icon svg path,
|
.wp-block-carhop-blocks-cta .icon svg path,
|
||||||
.wp-block-carhop-blocks-cta .icon svg circle {
|
.wp-block-carhop-blocks-cta .icon svg circle {
|
||||||
stroke: var(--cta-current-color);
|
stroke: currentColor;
|
||||||
}
|
}
|
||||||
.wp-block-carhop-blocks-cta.align--left {
|
.wp-block-carhop-blocks-cta.align--left {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"cta/index.css","mappings":";;;AAAA;EACC;AACD;AAAC;EACC;AAEF;AALA;EAOC;EACA;EACA;EAAA;EACA;EACA;EACA;EACA;AACD;AAEE;EACC;EACA;AAAH;AAEE;;EAEC;AAAH;AAIC;EACC;AAFF;AAIC;EACC;EACA;AAFF;AAIC;EACC;AAFF,C","sources":["webpack://carhop-blocks/./src/cta/editor.scss"],"sourcesContent":[".wp-block-carhop-blocks-cta {\n\tcolor: var(--cta-current-color);\n\ta {\n\t\tcolor: var(--cta-current-color) !important;\n\n\t\t&:after{}\n\t}\n\tpadding: 2px;\n\tdisplay: block;\n\twidth: fit-content;\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 10px;\n\tline-height: normal;\n\n\t.icon {\n\t\tsvg {\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t}\n\t\tsvg path,\n\t\tsvg circle {\n\t\t\tstroke: var(--cta-current-color);\n\t\t}\n\t}\n\n\t&.align--left {\n\t\tmargin-left: 0;\n\t}\n\t&.align--right {\n\t\tmargin-right: 0;\n\t\tmargin-left: auto;\n\t}\n\t&.align--center {\n\t\tmargin: 0 auto;\n\t}\n}\n"],"names":[],"ignoreList":[],"sourceRoot":""}
|
{"version":3,"file":"cta/index.css","mappings":";;;AAEC;EAGC;EACA;AAHF;AAHA;EAQC;EAEA;EAAA;EACA;EACA;EACA;EACA;AAHD;AAME;EACC;EACA;AAJH;AAME;;EAEC;AAJH;AASC;EACC;AAPF;AASC;EACC;EACA;AAPF;AASC;EACC;AAPF,C","sources":["webpack://carhop-blocks/./src/cta/editor.scss"],"sourcesContent":[".wp-block-carhop-blocks-cta {\n\t// color: var(--cta-current-color);\n\ta {\n\t\t// color: var(--cta-current-color) !important;\n\n\t\tpadding-bottom: 0 !important;\n\t\tmargin-bottom: 0 !important;\n\t}\n\tpadding: 2px;\n\n\twidth: fit-content;\n\tdisplay: flex !important;\n\talign-items: center;\n\tgap: 10px;\n\tline-height: normal;\n\n\t.icon {\n\t\tsvg {\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t}\n\t\tsvg path,\n\t\tsvg circle {\n\t\t\tstroke: currentColor;\n\t\t\t// stroke: var(--cta-current-color);\n\t\t}\n\t}\n\n\t&.align--left {\n\t\tmargin-left: 0;\n\t}\n\t&.align--right {\n\t\tmargin-right: 0;\n\t\tmargin-left: auto;\n\t}\n\t&.align--center {\n\t\tmargin: 0 auto;\n\t}\n}\n"],"names":[],"ignoreList":[],"sourceRoot":""}
|
||||||
|
|
@ -30,8 +30,10 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__);
|
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__);
|
||||||
/* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./editor.scss */ "./src/cta/editor.scss");
|
/* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./editor.scss */ "./src/cta/editor.scss");
|
||||||
/* harmony import */ var _img_carhop_fleche_lien_externe_full_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./img/carhop-fleche-lien-externe-full.svg */ "./src/cta/img/carhop-fleche-lien-externe-full.svg");
|
/* harmony import */ var _img_carhop_fleche_lien_externe_full_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./img/carhop-fleche-lien-externe-full.svg */ "./src/cta/img/carhop-fleche-lien-externe-full.svg");
|
||||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime");
|
/* harmony import */ var _img_carhop_fleche_ancre_page_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./img/carhop-fleche-ancre-page.svg */ "./src/cta/img/carhop-fleche-ancre-page.svg");
|
||||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__);
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime");
|
||||||
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,37 +52,58 @@ function Edit({
|
||||||
link
|
link
|
||||||
} = attributes;
|
} = attributes;
|
||||||
const colors = (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useSetting)("color.palette.theme");
|
const colors = (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useSetting)("color.palette.theme");
|
||||||
|
const isHashLink = typeof link?.url === "string" && link.url.startsWith("#");
|
||||||
function handleColorChange(value) {
|
function handleColorChange(value) {
|
||||||
setAttributes({
|
setAttributes({
|
||||||
color: value
|
color: value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.Fragment, {
|
console.log(attributes);
|
||||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.BlockControls, {
|
console.log(link);
|
||||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.AlignmentToolbar, {
|
function handleLinkChange(newLink) {
|
||||||
|
if (!newLink) {
|
||||||
|
setAttributes({
|
||||||
|
link: undefined
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (newLink.url) {
|
||||||
|
newLink.title = newLink.url;
|
||||||
|
}
|
||||||
|
console.log(newLink);
|
||||||
|
setAttributes({
|
||||||
|
link: newLink
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.Fragment, {
|
||||||
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.BlockControls, {
|
||||||
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.AlignmentToolbar, {
|
||||||
value: attributes.align,
|
value: attributes.align,
|
||||||
onChange: value => setAttributes({
|
onChange: value => setAttributes({
|
||||||
align: value
|
align: value
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InspectorControls, {
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InspectorControls, {
|
||||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
|
||||||
title: "Lien",
|
title: "Lien",
|
||||||
initialOpen: true,
|
initialOpen: true,
|
||||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
||||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.__experimentalLinkControl, {
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.__experimentalLinkControl, {
|
||||||
value: attributes.link,
|
value: attributes.link,
|
||||||
onChange: value => {
|
label: "Lien",
|
||||||
setAttributes({
|
onSelect: value => {
|
||||||
link: value
|
console.log("onSelect");
|
||||||
});
|
console.log(value);
|
||||||
|
},
|
||||||
|
onChange: newlink => {
|
||||||
|
handleLinkChange(newlink);
|
||||||
}
|
}
|
||||||
})
|
}, "link-control")
|
||||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
|
||||||
title: "Couleur",
|
title: "Couleur",
|
||||||
initialOpen: true,
|
initialOpen: true,
|
||||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelRow, {
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelRow, {
|
||||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ColorPalette, {
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ColorPalette, {
|
||||||
value: color,
|
value: color,
|
||||||
onChange: value => {
|
onChange: value => {
|
||||||
handleColorChange(value);
|
handleColorChange(value);
|
||||||
|
|
@ -91,14 +114,14 @@ function Edit({
|
||||||
})
|
})
|
||||||
})]
|
})]
|
||||||
})
|
})
|
||||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", {
|
||||||
...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps)({
|
...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps)({
|
||||||
className: `cta align--${attributes.align}`,
|
className: `cta align--${attributes.align}${isHashLink ? " cta--hash-link" : ""}`,
|
||||||
style: {
|
style: {
|
||||||
"--cta-current-color": color
|
"--cta-current-color": color
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.RichText, {
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.RichText, {
|
||||||
tagName: "a",
|
tagName: "a",
|
||||||
placeholder: "Ajouter un lien",
|
placeholder: "Ajouter un lien",
|
||||||
value: attributes.text,
|
value: attributes.text,
|
||||||
|
|
@ -106,7 +129,15 @@ function Edit({
|
||||||
text
|
text
|
||||||
}),
|
}),
|
||||||
allowedFormats: []
|
allowedFormats: []
|
||||||
})
|
}), isHashLink ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_img_carhop_fleche_ancre_page_svg__WEBPACK_IMPORTED_MODULE_5__.ReactComponent, {
|
||||||
|
style: {
|
||||||
|
color
|
||||||
|
}
|
||||||
|
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_img_carhop_fleche_lien_externe_full_svg__WEBPACK_IMPORTED_MODULE_4__.ReactComponent, {
|
||||||
|
style: {
|
||||||
|
color
|
||||||
|
}
|
||||||
|
})]
|
||||||
})]
|
})]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -123,6 +154,48 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
// extracted by mini-css-extract-plugin
|
// extracted by mini-css-extract-plugin
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ "./src/cta/img/carhop-fleche-ancre-page.svg":
|
||||||
|
/*!**************************************************!*\
|
||||||
|
!*** ./src/cta/img/carhop-fleche-ancre-page.svg ***!
|
||||||
|
\**************************************************/
|
||||||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ ReactComponent: () => (/* binding */ SvgCarhopFlecheAncrePage),
|
||||||
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||||
|
/* harmony export */ });
|
||||||
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
||||||
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
|
var _circle, _path;
|
||||||
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
||||||
|
|
||||||
|
var SvgCarhopFlecheAncrePage = function SvgCarhopFlecheAncrePage(props) {
|
||||||
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
|
||||||
|
xmlns: "http://www.w3.org/2000/svg",
|
||||||
|
"aria-hidden": "true",
|
||||||
|
viewBox: "0 0 32 32"
|
||||||
|
}, props), _circle || (_circle = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", {
|
||||||
|
cx: 16,
|
||||||
|
cy: 16,
|
||||||
|
r: 15,
|
||||||
|
fill: "none",
|
||||||
|
stroke: "currentColor",
|
||||||
|
strokeWidth: 2
|
||||||
|
})), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||||
|
fill: "none",
|
||||||
|
stroke: "currentColor",
|
||||||
|
strokeLinecap: "round",
|
||||||
|
strokeLinejoin: "round",
|
||||||
|
strokeWidth: 2,
|
||||||
|
d: "M16 9v11m-5-3 5 6 5-6"
|
||||||
|
})));
|
||||||
|
};
|
||||||
|
|
||||||
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIgZm9jdXNhYmxlPSJmYWxzZSIgYXJpYS1oaWRkZW49InRydWUiPg0KCTxjaXJjbGUgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiIgY3g9IjE2IiBjeT0iMTYiIHI9IjE1Ii8+DQoJPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJNMTYgOXYxMU0xMSAxN2w1IDYgNS02Ii8+DQo8L3N2Zz4NCg==");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ "./src/cta/img/carhop-fleche-lien-externe-full.svg":
|
/***/ "./src/cta/img/carhop-fleche-lien-externe-full.svg":
|
||||||
|
|
@ -138,26 +211,31 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
||||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
var _defs, _path, _circle;
|
var _g, _circle;
|
||||||
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
||||||
|
|
||||||
var SvgCarhopFlecheLienExterneFull = function SvgCarhopFlecheLienExterneFull(props) {
|
var SvgCarhopFlecheLienExterneFull = function SvgCarhopFlecheLienExterneFull(props) {
|
||||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
|
||||||
xmlns: "http://www.w3.org/2000/svg",
|
xmlns: "http://www.w3.org/2000/svg",
|
||||||
id: "carhop-fleche-lien-externe-full_svg__fleche-lien-externe-full",
|
"aria-hidden": "true",
|
||||||
viewBox: "0 0 32 32"
|
viewBox: "0 0 32 32"
|
||||||
}, props), _defs || (_defs = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("defs", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("style", null, ".carhop-fleche-lien-externe-full_svg__cls-1{fill:none;stroke:#000;stroke-width:2px}"))), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
}, props), _g || (_g = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", {
|
||||||
d: "m21.15 10.59-9.38 10.02M21.15 21.4V10.59H10.83",
|
fill: "none",
|
||||||
className: "carhop-fleche-lien-externe-full_svg__cls-1"
|
stroke: "currentColor",
|
||||||
})), _circle || (_circle = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", {
|
strokeWidth: 2
|
||||||
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
|
||||||
|
d: "m21.15 10.59-9.38 10.02M21.15 21.4V10.59H10.83"
|
||||||
|
}))), _circle || (_circle = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", {
|
||||||
cx: 16,
|
cx: 16,
|
||||||
cy: 16,
|
cy: 16,
|
||||||
r: 15,
|
r: 15,
|
||||||
className: "carhop-fleche-lien-externe-full_svg__cls-1"
|
fill: "none",
|
||||||
|
stroke: "currentColor",
|
||||||
|
strokeWidth: 2
|
||||||
})));
|
})));
|
||||||
};
|
};
|
||||||
|
|
||||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBpZD0iZmxlY2hlLWxpZW4tZXh0ZXJuZS1mdWxsIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+CiAgPGRlZnM+CiAgICA8c3R5bGU+CiAgICAgIC5jbHMtMSB7CiAgICAgICAgZmlsbDogbm9uZTsKICAgICAgICBzdHJva2U6ICMwMDA7CiAgICAgICAgc3Ryb2tlLXdpZHRoOiAycHg7CiAgICAgIH0KICAgIDwvc3R5bGU+CiAgPC9kZWZzPgogIDxnPgogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMjEuMTUsMTAuNTlsLTkuMzgsMTAuMDIiLz4KICAgIDxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTIxLjE1LDIxLjR2LTEwLjgxaC0xMC4zMiIvPgogIDwvZz4KICA8Y2lyY2xlIGNsYXNzPSJjbHMtMSIgY3g9IjE2IiBjeT0iMTYiIHI9IjE1Ii8+Cjwvc3ZnPg==");
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIgZm9jdXNhYmxlPSJmYWxzZSIgYXJpYS1oaWRkZW49InRydWUiPgoJPGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiI+CgkJPHBhdGggZD0iTTIxLjE1LDEwLjU5bC05LjM4LDEwLjAyIi8+CgkJPHBhdGggZD0iTTIxLjE1LDIxLjR2LTEwLjgxaC0xMC4zMiIvPgoJPC9nPgoJPGNpcmNsZSBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBjeD0iMTYiIGN5PSIxNiIgcj0iMTUiLz4KPC9zdmc+Cg==");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
|
@ -229,37 +307,12 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor");
|
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor");
|
||||||
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__);
|
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
/* harmony import */ var _img_carhop_fleche_lien_externe_full_svg__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./img/carhop-fleche-lien-externe-full.svg */ "./src/cta/img/carhop-fleche-lien-externe-full.svg");
|
/* harmony import */ var _img_carhop_fleche_lien_externe_full_svg__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./img/carhop-fleche-lien-externe-full.svg */ "./src/cta/img/carhop-fleche-lien-externe-full.svg");
|
||||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime");
|
|
||||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function save({
|
function save({
|
||||||
attributes
|
attributes
|
||||||
}) {
|
}) {
|
||||||
const {
|
return;
|
||||||
align,
|
|
||||||
link,
|
|
||||||
text,
|
|
||||||
color
|
|
||||||
} = attributes;
|
|
||||||
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.Fragment, {})
|
|
||||||
// <a
|
|
||||||
// href={link?.url}
|
|
||||||
// {...useBlockProps.save({
|
|
||||||
// className: `align--${align}`,
|
|
||||||
// style: {
|
|
||||||
// color: color,
|
|
||||||
// "--cta-current-color": color,
|
|
||||||
// },
|
|
||||||
// })}
|
|
||||||
// >
|
|
||||||
// {text}
|
|
||||||
// <div className="icon">
|
|
||||||
// <ArrowIcon style={{ "--cta-current-color": color }} />
|
|
||||||
// </div>
|
|
||||||
// </a>
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -5,6 +5,10 @@ $text = isset($attributes['text']) ? $attributes['text'] : '';
|
||||||
$color = isset($attributes['color']) ? $attributes['color'] : '';
|
$color = isset($attributes['color']) ? $attributes['color'] : '';
|
||||||
$target = isset($link) && $link['opensInNewTab'] ? '_blank' : '_self';
|
$target = isset($link) && $link['opensInNewTab'] ? '_blank' : '_self';
|
||||||
|
|
||||||
|
$raw_url = isset($link['url']) ? $link['url'] : '';
|
||||||
|
$is_inner_page_link = is_string($raw_url) && strpos($raw_url, '#') === 0;
|
||||||
|
|
||||||
|
|
||||||
$styles = [];
|
$styles = [];
|
||||||
if ($color) {
|
if ($color) {
|
||||||
$styles[] = 'color: ' . esc_attr($color);
|
$styles[] = 'color: ' . esc_attr($color);
|
||||||
|
|
@ -12,7 +16,7 @@ if ($color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$wrapper_attributes = get_block_wrapper_attributes([
|
$wrapper_attributes = get_block_wrapper_attributes([
|
||||||
'class' => 'align--' . esc_attr($align),
|
'class' => 'align--' . esc_attr($align) . ($is_inner_page_link ? ' cta--inner-page-link' : ' cta--external-page-link'),
|
||||||
'style' => implode('; ', $styles)
|
'style' => implode('; ', $styles)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -21,4 +25,38 @@ $link_url = isset($link['url']) ? esc_url($link['url']) : '#';
|
||||||
|
|
||||||
<a href="<?php echo $link_url; ?>" <?php echo $wrapper_attributes; ?> target="<?php echo $target; ?>">
|
<a href="<?php echo $link_url; ?>" <?php echo $wrapper_attributes; ?> target="<?php echo $target; ?>">
|
||||||
<?php echo esc_html($text); ?>
|
<?php echo esc_html($text); ?>
|
||||||
|
<?php if ($is_inner_page_link) : ?>
|
||||||
|
<svg id="arrow-internal-link" class="cta-icon" width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_2159_20039)">
|
||||||
|
<path d="M14.5469 20.4253L14.5469 10.5" stroke="#136F63" stroke-width="2" />
|
||||||
|
<path d="M8.53276 14.1263L14.5536 20.4253L20.5684 14.1263" stroke="#136F63" stroke-width="2" />
|
||||||
|
</g>
|
||||||
|
<circle cx="15" cy="15" r="14" transform="rotate(90 15 15)" stroke="#136F63" stroke-width="2" />
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_2159_20039">
|
||||||
|
<rect width="10.8" height="12.9" fill="white" transform="translate(21 10.5) rotate(90)" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
|
||||||
|
<?php else : ?>
|
||||||
|
<svg id="arrow-external-link" class="cta-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
||||||
|
<defs>
|
||||||
|
<style>
|
||||||
|
.cls-1 {
|
||||||
|
fill: none;
|
||||||
|
stroke: <?php echo esc_attr($color); ?>;
|
||||||
|
stroke-width: 2px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<circle class="cls-1" cx="16" cy="16" r="15" />
|
||||||
|
<g>
|
||||||
|
<path class="cls-1" d="M21.15,10.59l-9.38,10.02" />
|
||||||
|
<path class="cls-1" d="M21.15,21.4v-10.81h-10.32" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -1,41 +1 @@
|
||||||
/*!****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
|
.wp-block-carhop-blocks-cta{align-items:center;color:var(--cta-current-color,currentColor);display:block;display:flex;font-weight:600;gap:10px;line-height:normal;margin-top:20px;padding:2px;width:-moz-fit-content;width:fit-content}.wp-block-carhop-blocks-cta a{text-decoration:none}.wp-block-carhop-blocks-cta .icon svg{height:30px;width:30px}.wp-block-carhop-blocks-cta .icon svg circle,.wp-block-carhop-blocks-cta .icon svg path{fill:transparent;stroke:var(--cta-current-color);stroke-width:2}.wp-block-carhop-blocks-cta.align--left{margin-left:0}.wp-block-carhop-blocks-cta.align--right{margin-left:auto;margin-right:0}.wp-block-carhop-blocks-cta.align--center{margin:0 auto}
|
||||||
!*** css ./node_modules/.pnpm/css-loader@6.11.0_webpack@5.103.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.103.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/.pnpm/sass-loader@16.0.6_sass@1.94.1_webpack@5.103.0/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/cta/style.scss ***!
|
|
||||||
\****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
|
|
||||||
.wp-block-carhop-blocks-cta {
|
|
||||||
margin-top: 20px;
|
|
||||||
color: var(--cta-current-color, currentColor);
|
|
||||||
padding: 2px;
|
|
||||||
display: block;
|
|
||||||
width: -moz-fit-content;
|
|
||||||
width: fit-content;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
line-height: normal;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta .icon svg {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta .icon svg path,
|
|
||||||
.wp-block-carhop-blocks-cta .icon svg circle {
|
|
||||||
fill: transparent;
|
|
||||||
stroke: var(--cta-current-color);
|
|
||||||
stroke-width: 2;
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta.align--left {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta.align--right {
|
|
||||||
margin-right: 0;
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
.wp-block-carhop-blocks-cta.align--center {
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*# sourceMappingURL=style-index.css.map*/
|
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"cta/style-index.css","mappings":";;;AAAA;EACC;EACA;EAEA;EACA;EACA;EAAA;EACA;EACA;EACA;EACA;EAEA;AADD;AAGC;EACC;AADF;AAIE;EACC;EACA;AAFH;AAIE;;EAEC;EACA;EACA;AAFH;AAMC;EACC;AAJF;AAMC;EACC;EACA;AAJF;AAMC;EACC;AAJF,C","sources":["webpack://carhop-blocks/./src/cta/style.scss"],"sourcesContent":[".wp-block-carhop-blocks-cta {\n\tmargin-top: 20px;\n\tcolor: var(--cta-current-color, currentColor);\n\n\tpadding: 2px;\n\tdisplay: block;\n\twidth: fit-content;\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 10px;\n\tline-height: normal;\n\n\tfont-weight: 600;\n\n\ta {\n\t\ttext-decoration: none;\n\t}\n\t.icon {\n\t\tsvg {\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t}\n\t\tsvg path,\n\t\tsvg circle {\n\t\t\tfill: transparent;\n\t\t\tstroke: var(--cta-current-color);\n\t\t\tstroke-width: 2;\n\t\t}\n\t}\n\n\t&.align--left {\n\t\tmargin-left: 0;\n\t}\n\t&.align--right {\n\t\tmargin-right: 0;\n\t\tmargin-left: auto;\n\t}\n\t&.align--center {\n\t\tmargin: 0 auto;\n\t}\n}\n"],"names":[],"ignoreList":[],"sourceRoot":""}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
/******/ (() => { // webpackBootstrap
|
|
||||||
/*!*************************!*\
|
|
||||||
!*** ./src/cta/view.js ***!
|
|
||||||
\*************************/
|
|
||||||
|
|
||||||
/******/ })()
|
|
||||||
;
|
|
||||||
|
|
@ -12,15 +12,33 @@ import { BlockControls, AlignmentToolbar } from "@wordpress/block-editor";
|
||||||
import { ColorPalette, PanelRow } from "@wordpress/components";
|
import { ColorPalette, PanelRow } from "@wordpress/components";
|
||||||
import { Tip } from "@wordpress/components";
|
import { Tip } from "@wordpress/components";
|
||||||
import { ReactComponent as ArrowIcon } from "./img/carhop-fleche-lien-externe-full.svg";
|
import { ReactComponent as ArrowIcon } from "./img/carhop-fleche-lien-externe-full.svg";
|
||||||
|
import { ReactComponent as AnchorIcon } from "./img/carhop-fleche-ancre-page.svg";
|
||||||
|
|
||||||
export default function Edit({ attributes, setAttributes }) {
|
export default function Edit({ attributes, setAttributes }) {
|
||||||
const { color, link } = attributes;
|
const { color, link } = attributes;
|
||||||
const colors = useSetting("color.palette.theme");
|
const colors = useSetting("color.palette.theme");
|
||||||
|
const isHashLink = typeof link?.url === "string" && link.url.startsWith("#");
|
||||||
|
|
||||||
function handleColorChange(value) {
|
function handleColorChange(value) {
|
||||||
setAttributes({ color: value });
|
setAttributes({ color: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(attributes);
|
||||||
|
console.log(link);
|
||||||
|
|
||||||
|
function handleLinkChange(newLink) {
|
||||||
|
if (!newLink) {
|
||||||
|
setAttributes({ link: undefined });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newLink.url) {
|
||||||
|
newLink.title = newLink.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(newLink);
|
||||||
|
setAttributes({ link: newLink });
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BlockControls>
|
<BlockControls>
|
||||||
|
|
@ -33,9 +51,15 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
<PanelBody title="Lien" initialOpen={true}>
|
<PanelBody title="Lien" initialOpen={true}>
|
||||||
<div>
|
<div>
|
||||||
<LinkControl
|
<LinkControl
|
||||||
|
key="link-control"
|
||||||
value={attributes.link}
|
value={attributes.link}
|
||||||
onChange={(value) => {
|
label="Lien"
|
||||||
setAttributes({ link: value });
|
onSelect={(value) => {
|
||||||
|
console.log("onSelect");
|
||||||
|
console.log(value);
|
||||||
|
}}
|
||||||
|
onChange={(newlink) => {
|
||||||
|
handleLinkChange(newlink);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -56,7 +80,9 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
<div
|
<div
|
||||||
{...useBlockProps({
|
{...useBlockProps({
|
||||||
className: `cta align--${attributes.align}`,
|
className: `cta align--${attributes.align}${
|
||||||
|
isHashLink ? " cta--hash-link" : ""
|
||||||
|
}`,
|
||||||
style: {
|
style: {
|
||||||
"--cta-current-color": color,
|
"--cta-current-color": color,
|
||||||
},
|
},
|
||||||
|
|
@ -69,9 +95,12 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
onChange={(text) => setAttributes({ text })}
|
onChange={(text) => setAttributes({ text })}
|
||||||
allowedFormats={[]}
|
allowedFormats={[]}
|
||||||
/>
|
/>
|
||||||
{/* <div className="icon">
|
|
||||||
<ArrowIcon style={{ "--cta-current-color": color }} />
|
{isHashLink ? (
|
||||||
</div> */}
|
<AnchorIcon style={{ color }} />
|
||||||
|
) : (
|
||||||
|
<ArrowIcon style={{ color }} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
.wp-block-carhop-blocks-cta {
|
.wp-block-carhop-blocks-cta {
|
||||||
color: var(--cta-current-color);
|
// color: var(--cta-current-color);
|
||||||
a {
|
a {
|
||||||
color: var(--cta-current-color) !important;
|
// color: var(--cta-current-color) !important;
|
||||||
|
|
||||||
&:after{}
|
padding-bottom: 0 !important;
|
||||||
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
display: block;
|
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
display: flex;
|
display: flex !important;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
|
|
@ -20,7 +21,8 @@
|
||||||
}
|
}
|
||||||
svg path,
|
svg path,
|
||||||
svg circle {
|
svg circle {
|
||||||
stroke: var(--cta-current-color);
|
stroke: currentColor;
|
||||||
|
// stroke: var(--cta-current-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" focusable="false" aria-hidden="true">
|
||||||
|
<circle fill="none" stroke="currentColor" stroke-width="2" cx="16" cy="16" r="15"/>
|
||||||
|
<path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M16 9v11M11 17l5 6 5-6"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 328 B |
|
|
@ -1,17 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" focusable="false" aria-hidden="true">
|
||||||
<svg id="fleche-lien-externe-full" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
<g fill="none" stroke="currentColor" stroke-width="2">
|
||||||
<defs>
|
<path d="M21.15,10.59l-9.38,10.02"/>
|
||||||
<style>
|
<path d="M21.15,21.4v-10.81h-10.32"/>
|
||||||
.cls-1 {
|
</g>
|
||||||
fill: none;
|
<circle fill="none" stroke="currentColor" stroke-width="2" cx="16" cy="16" r="15"/>
|
||||||
stroke: #000;
|
</svg>
|
||||||
stroke-width: 2px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</defs>
|
|
||||||
<g>
|
|
||||||
<path class="cls-1" d="M21.15,10.59l-9.38,10.02"/>
|
|
||||||
<path class="cls-1" d="M21.15,21.4v-10.81h-10.32"/>
|
|
||||||
</g>
|
|
||||||
<circle class="cls-1" cx="16" cy="16" r="15"/>
|
|
||||||
</svg>
|
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 331 B |
|
|
@ -5,6 +5,10 @@ $text = isset($attributes['text']) ? $attributes['text'] : '';
|
||||||
$color = isset($attributes['color']) ? $attributes['color'] : '';
|
$color = isset($attributes['color']) ? $attributes['color'] : '';
|
||||||
$target = isset($link) && $link['opensInNewTab'] ? '_blank' : '_self';
|
$target = isset($link) && $link['opensInNewTab'] ? '_blank' : '_self';
|
||||||
|
|
||||||
|
$raw_url = isset($link['url']) ? $link['url'] : '';
|
||||||
|
$is_inner_page_link = is_string($raw_url) && strpos($raw_url, '#') === 0;
|
||||||
|
|
||||||
|
|
||||||
$styles = [];
|
$styles = [];
|
||||||
if ($color) {
|
if ($color) {
|
||||||
$styles[] = 'color: ' . esc_attr($color);
|
$styles[] = 'color: ' . esc_attr($color);
|
||||||
|
|
@ -12,7 +16,7 @@ if ($color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$wrapper_attributes = get_block_wrapper_attributes([
|
$wrapper_attributes = get_block_wrapper_attributes([
|
||||||
'class' => 'align--' . esc_attr($align),
|
'class' => 'align--' . esc_attr($align) . ($is_inner_page_link ? ' cta--inner-page-link' : ' cta--external-page-link'),
|
||||||
'style' => implode('; ', $styles)
|
'style' => implode('; ', $styles)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -21,4 +25,38 @@ $link_url = isset($link['url']) ? esc_url($link['url']) : '#';
|
||||||
|
|
||||||
<a href="<?php echo $link_url; ?>" <?php echo $wrapper_attributes; ?> target="<?php echo $target; ?>">
|
<a href="<?php echo $link_url; ?>" <?php echo $wrapper_attributes; ?> target="<?php echo $target; ?>">
|
||||||
<?php echo esc_html($text); ?>
|
<?php echo esc_html($text); ?>
|
||||||
|
<?php if ($is_inner_page_link) : ?>
|
||||||
|
<svg id="arrow-internal-link" class="cta-icon" width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_2159_20039)">
|
||||||
|
<path d="M14.5469 20.4253L14.5469 10.5" stroke="#136F63" stroke-width="2" />
|
||||||
|
<path d="M8.53276 14.1263L14.5536 20.4253L20.5684 14.1263" stroke="#136F63" stroke-width="2" />
|
||||||
|
</g>
|
||||||
|
<circle cx="15" cy="15" r="14" transform="rotate(90 15 15)" stroke="#136F63" stroke-width="2" />
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_2159_20039">
|
||||||
|
<rect width="10.8" height="12.9" fill="white" transform="translate(21 10.5) rotate(90)" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
|
||||||
|
<?php else : ?>
|
||||||
|
<svg id="arrow-external-link" class="cta-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
||||||
|
<defs>
|
||||||
|
<style>
|
||||||
|
.cls-1 {
|
||||||
|
fill: none;
|
||||||
|
stroke: <?php echo esc_attr($color); ?>;
|
||||||
|
stroke-width: 2px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<circle class="cls-1" cx="16" cy="16" r="15" />
|
||||||
|
<g>
|
||||||
|
<path class="cls-1" d="M21.15,10.59l-9.38,10.02" />
|
||||||
|
<path class="cls-1" d="M21.15,21.4v-10.81h-10.32" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -2,23 +2,5 @@ import { useBlockProps } from "@wordpress/block-editor";
|
||||||
import { ReactComponent as ArrowIcon } from "./img/carhop-fleche-lien-externe-full.svg";
|
import { ReactComponent as ArrowIcon } from "./img/carhop-fleche-lien-externe-full.svg";
|
||||||
|
|
||||||
export default function save({ attributes }) {
|
export default function save({ attributes }) {
|
||||||
const { align, link, text, color } = attributes;
|
return;
|
||||||
return (
|
|
||||||
<></>
|
|
||||||
// <a
|
|
||||||
// href={link?.url}
|
|
||||||
// {...useBlockProps.save({
|
|
||||||
// className: `align--${align}`,
|
|
||||||
// style: {
|
|
||||||
// color: color,
|
|
||||||
// "--cta-current-color": color,
|
|
||||||
// },
|
|
||||||
// })}
|
|
||||||
// >
|
|
||||||
// {text}
|
|
||||||
// <div className="icon">
|
|
||||||
// <ArrowIcon style={{ "--cta-current-color": color }} />
|
|
||||||
// </div>
|
|
||||||
// </a>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user