From cb1bf05bc2b04b25d71f066194545cbfb0e576a3 Mon Sep 17 00:00:00 2001 From: Troy Chaplin Date: Tue, 23 Dec 2025 09:39:01 -0500 Subject: [PATCH 1/7] add: button color options --- build/priority-editor.asset.php | 2 +- build/priority-editor.js | 2 +- build/priority-plus-nav.asset.php | 2 +- build/priority-plus-nav.js | 2 +- classes/class-enqueues.php | 43 ++++++++++++------- src/core/PriorityNav.js | 18 ++++++++ src/styles/editor.scss | 65 ++++++++++++++++------------- src/variation/block.js | 8 ++++ src/variation/controls.js | 69 ++++++++++++++++++++++++++++--- 9 files changed, 158 insertions(+), 53 deletions(-) diff --git a/build/priority-editor.asset.php b/build/priority-editor.asset.php index 2d5aeeb..602c231 100644 --- a/build/priority-editor.asset.php +++ b/build/priority-editor.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-hooks', 'wp-i18n', 'wp-primitives'), 'version' => '3c18caf20bb2d937b841'); + array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-hooks', 'wp-i18n', 'wp-primitives'), 'version' => '3dff20275527da13bfe1'); diff --git a/build/priority-editor.js b/build/priority-editor.js index eb7a3d2..0288ba0 100644 --- a/build/priority-editor.js +++ b/build/priority-editor.js @@ -1 +1 @@ -(()=>{"use strict";const o=window.wp.i18n,e=window.wp.blocks,r=window.wp.primitives,i=window.ReactJSXRuntime;var t=(0,i.jsx)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(r.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M7.404 16.596a6.5 6.5 0 1 0 9.192-9.192 6.5 6.5 0 0 0-9.192 9.192ZM6.344 6.343a8 8 0 1 0 11.313 11.314A8 8 0 0 0 6.343 6.343Zm4.906 9.407v-3h-3v-1.5h3v-3h1.5v3h3v1.5h-3v3h-1.5Z"})});const n=window.wp.hooks;(0,e.registerBlockVariation)("core/navigation",{name:"priority-nav",title:(0,o.__)("Priority Plus Nav","priority-nav"),description:(0,o.__)('A responsive navigation that automatically moves overflow items to a "More" dropdown.',"priority-nav"),icon:t,scope:["inserter","transform"],attributes:{className:"is-style-priority-nav",overlayMenu:"never",priorityNavEnabled:!0,priorityNavMoreLabel:"Browse",priorityNavMoreIcon:"none"},isActive:(o,e)=>o.className?.includes(e.className)}),(0,n.addFilter)("blocks.registerBlockType","priority-nav/extend-core-navigation",(o,e)=>"core/navigation"!==e?o:{...o,attributes:{...o.attributes,priorityNavEnabled:{type:"boolean",default:!1},priorityNavMoreLabel:{type:"string",default:"Browse"},priorityNavMoreIcon:{type:"string",default:"none"}}});const a=window.wp.blockEditor,l=window.wp.components,s=(0,window.wp.compose.createHigherOrderComponent)(e=>r=>{const{name:t,attributes:n,setAttributes:s}=r;if("core/navigation"!==t)return(0,i.jsx)(e,{...r});const{priorityNavEnabled:v,priorityNavMoreLabel:p,priorityNavMoreIcon:c}=n;return(0,i.jsxs)(i.Fragment,{children:[v&&(0,i.jsx)("div",{className:"priority-nav-editor-wrapper",children:(0,i.jsx)(e,{...r})}),!v&&(0,i.jsx)(e,{...r}),(0,i.jsx)(a.InspectorControls,{children:(0,i.jsxs)(l.PanelBody,{title:(0,o.__)("Priority+ Settings","priority-nav"),children:[(0,i.jsx)(l.TextControl,{label:(0,o.__)("More Button Label","priority-nav"),value:p,onChange:o=>s({priorityNavMoreLabel:o}),help:(0,o.__)('Text displayed on the "More" button',"priority-nav")}),(0,i.jsx)(l.SelectControl,{label:(0,o.__)("More Button Icon","priority-nav"),value:c,options:[{label:(0,o.__)("None","priority-nav"),value:"none"},{label:(0,o.__)("Chevron Down (▼)","priority-nav"),value:"chevron"},{label:(0,o.__)("Plus (+)","priority-nav"),value:"plus"},{label:(0,o.__)("Menu (≡)","priority-nav"),value:"menu"}],onChange:o=>s({priorityNavMoreIcon:o})})]})})]})},"withPriorityNavControls");(0,n.addFilter)("editor.BlockEdit","priority-nav/add-priority-nav-controls",s)})(); \ No newline at end of file +(()=>{"use strict";const o=window.wp.i18n,r=window.wp.blocks,e=window.wp.primitives,t=window.ReactJSXRuntime;var i=(0,t.jsx)(e.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,t.jsx)(e.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M7.404 16.596a6.5 6.5 0 1 0 9.192-9.192 6.5 6.5 0 0 0-9.192 9.192ZM6.344 6.343a8 8 0 1 0 11.313 11.314A8 8 0 0 0 6.343 6.343Zm4.906 9.407v-3h-3v-1.5h3v-3h1.5v3h3v1.5h-3v3h-1.5Z"})});const a=window.wp.hooks;(0,r.registerBlockVariation)("core/navigation",{name:"priority-nav",title:(0,o.__)("Priority Plus Nav","priority-nav"),description:(0,o.__)('A responsive navigation that automatically moves overflow items to a "More" dropdown.',"priority-nav"),icon:i,scope:["inserter","transform"],attributes:{className:"is-style-priority-nav",overlayMenu:"never",priorityNavEnabled:!0,priorityNavMoreLabel:"Browse",priorityNavMoreIcon:"none",priorityNavMoreBackgroundColor:void 0,priorityNavMoreTextColor:void 0},isActive:(o,r)=>o.className?.includes(r.className)}),(0,a.addFilter)("blocks.registerBlockType","priority-nav/extend-core-navigation",(o,r)=>"core/navigation"!==r?o:{...o,attributes:{...o.attributes,priorityNavEnabled:{type:"boolean",default:!1},priorityNavMoreLabel:{type:"string",default:"Browse"},priorityNavMoreIcon:{type:"string",default:"none"},priorityNavMoreBackgroundColor:{type:"string"},priorityNavMoreTextColor:{type:"string"}}});const n=window.wp.blockEditor,l=window.wp.components,s=(0,window.wp.compose.createHigherOrderComponent)(r=>e=>{const{name:i,attributes:a,setAttributes:s}=e;if("core/navigation"!==i)return(0,t.jsx)(r,{...e});const{priorityNavEnabled:v,priorityNavMoreLabel:p,priorityNavMoreIcon:c,priorityNavMoreBackgroundColor:d,priorityNavMoreTextColor:y}=a,u=(0,n.useSetting)("color.palette")||[];return(0,t.jsxs)(t.Fragment,{children:[v?(0,t.jsx)("div",{className:"priority-nav-editor-wrapper",children:(0,t.jsx)(r,{...e})}):(0,t.jsx)(r,{...e}),(0,t.jsx)(n.InspectorControls,{group:"styles",children:(0,t.jsxs)(l.PanelBody,{title:(0,o.__)("Priority Plus Nav","priority-nav"),children:[(0,t.jsx)(l.TextControl,{label:(0,o.__)("More Button Label","priority-nav"),value:p,onChange:o=>s({priorityNavMoreLabel:o}),help:(0,o.__)('Text displayed on the "More" button',"priority-nav")}),(0,t.jsx)(l.SelectControl,{label:(0,o.__)("More Button Icon","priority-nav"),value:c,options:[{label:(0,o.__)("None","priority-nav"),value:"none"},{label:(0,o.__)("Chevron Down (▼)","priority-nav"),value:"chevron"},{label:(0,o.__)("Plus (+)","priority-nav"),value:"plus"},{label:(0,o.__)("Menu (≡)","priority-nav"),value:"menu"}],onChange:o=>s({priorityNavMoreIcon:o})}),(0,t.jsx)(l.BaseControl,{id:"priority-nav-background-color",label:(0,o.__)("More Button Background Color","priority-nav"),help:(0,o.__)('Background color for the "More" button',"priority-nav"),children:(0,t.jsx)(l.ColorPalette,{value:d,onChange:o=>s({priorityNavMoreBackgroundColor:o}),colors:u,clearable:!0})}),(0,t.jsx)(l.BaseControl,{id:"priority-nav-text-color",label:(0,o.__)("More Button Text Color","priority-nav"),help:(0,o.__)('Text color for the "More" button',"priority-nav"),children:(0,t.jsx)(l.ColorPalette,{value:y,onChange:o=>s({priorityNavMoreTextColor:o}),colors:u,clearable:!0})})]})})]})},"withPriorityNavControls");(0,a.addFilter)("editor.BlockEdit","priority-nav/add-priority-nav-controls",s)})(); \ No newline at end of file diff --git a/build/priority-plus-nav.asset.php b/build/priority-plus-nav.asset.php index a72523f..e71707e 100644 --- a/build/priority-plus-nav.asset.php +++ b/build/priority-plus-nav.asset.php @@ -1 +1 @@ - array(), 'version' => 'ccab84b63ca39dba3b2d'); + array(), 'version' => '4b2c1096708cce28f3dc'); diff --git a/build/priority-plus-nav.js b/build/priority-plus-nav.js index 4a5cf8a..272fe92 100644 --- a/build/priority-plus-nav.js +++ b/build/priority-plus-nav.js @@ -1 +1 @@ -(()=>{"use strict";var t,e={400(){const t="Browse",e="none";function i(t){if(!t)return!1;const e=window.getComputedStyle(t),i=t.getBoundingClientRect();return"none"!==e.display&&"hidden"!==e.visibility&&i.width>0&&i.height>0}function n(t){return i(t)?t.getBoundingClientRect().width:0}function s(t){return i(t)}function o(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}function r(t){const e={text:"",url:"#",hasSubmenu:!1,children:[]},i=t.querySelector(":scope > .wp-block-navigation__submenu-container");let n=t.querySelector(":scope > a");if(n||(n=t.querySelector(":scope > .wp-block-navigation-item__content a")),!n){if(i){const i=t.cloneNode(!0),n=i.querySelector(".wp-block-navigation__submenu-container");n&&n.remove(),e.text=i.textContent.trim()}else e.text=t.textContent.trim();return i&&(e.hasSubmenu=!0,i.querySelectorAll(":scope > li").forEach(t=>{e.children.push(r(t))})),e}return e.text=function(t){if(!t)return"";const e=t.querySelector(".wp-block-navigation-item__label");if(e)return e.textContent.trim();const i=t.cloneNode(!0);i.querySelectorAll("*").forEach(t=>t.remove());let n=i.textContent.trim();if(!n){const e=Array.from(t.childNodes).filter(t=>t.nodeType===Node.TEXT_NODE);e.length>0&&(n=e.map(t=>t.textContent.trim()).filter(t=>t).join(" "))}return n}(n),i&&e.text&&(e.text=function(t,e){if(!t||!e)return t;const i=[];if(e.querySelectorAll("li a").forEach(e=>{const n=e.textContent.trim();n&&t.includes(n)&&i.push(n)}),i.length>0){let e=t;return i.forEach(t=>{e=e.replace(t,"").trim()}),e}return t}(e.text,i)),e.url=n.getAttribute("href")||"#",i&&(e.hasSubmenu=!0,i.querySelectorAll(":scope > li").forEach(t=>{e.children.push(r(t))})),e}function a(t,e,i,n,s){const r=`${i}-submenu-${n.value++}`;let l="";return t.hasSubmenu?(l=s?`\n\t\t\t\t\n\t\t\t\t