diff --git a/assets/js/lcp-ui.js b/assets/js/lcp-ui.js index 0bd7fef..5f5ce53 100644 --- a/assets/js/lcp-ui.js +++ b/assets/js/lcp-ui.js @@ -1,3 +1,5 @@ + +/* ACCORDION */ document.addEventListener('DOMContentLoaded', function () { // Find all elements with the class "lcp-accordion" var accordions = document.querySelectorAll('.lcp-accordion'); @@ -31,31 +33,64 @@ document.addEventListener('DOMContentLoaded', function () { }); +/* TABS */ document.addEventListener('DOMContentLoaded', function () { const tabs = document.querySelectorAll('.tab-link'); const panes = document.querySelectorAll('.tab-pane'); + const tabContainer = document.querySelector('.lcp-tab-container'); // The parent container - tabs.forEach(tab => { - tab.addEventListener('click', function (event) { - event.preventDefault(); + // Only enable the hash functionality if the container has the class '.lcp-support-hash' + if (tabContainer && tabContainer.classList.contains('lcp-support-hash')) { + + // Function to set the active tab based on the hash in the URL + function setActiveTabFromHash() { + const hash = window.location.hash; // Get the current URL hash + if (hash) { + const targetTab = document.querySelector(`.tab-link[data-tab="${hash.substring(1)}"]`); // Remove '#' from hash + const targetPane = document.getElementById(hash.substring(1)); - // Remove active class from all tabs and panes - tabs.forEach(link => link.classList.remove('active')); - panes.forEach(pane => pane.classList.remove('active')); + // If both tab and pane exist, make them active + if (targetTab && targetPane) { + tabs.forEach(link => link.classList.remove('active')); + panes.forEach(pane => pane.classList.remove('active')); - // Add active class to the clicked tab - tab.classList.add('active'); - - // Get the target pane - const targetPaneId = tab.dataset.tab; - const targetPane = document.getElementById(targetPaneId); - - // Check if targetPane exists before trying to manipulate it - if (targetPane) { - targetPane.classList.add('active'); - } else { - console.error(`Tab pane with ID '${targetPaneId}' not found.`); + targetTab.classList.add('active'); + targetPane.classList.add('active'); + } else { + console.error(`Tab or pane with ID '${hash}' not found.`); + } } + } + + // Set the active tab from the hash when the page loads + setActiveTabFromHash(); + } + // Handle tab clicks + tabs.forEach(tab => { + tab.addEventListener('click', function (event) { + event.preventDefault(); + + // Remove active class from all tabs and panes + tabs.forEach(link => link.classList.remove('active')); + panes.forEach(pane => pane.classList.remove('active')); + + // Add active class to the clicked tab + tab.classList.add('active'); + + // Get the target pane and update URL hash + const targetPaneId = tab.dataset.tab; + const targetPane = document.getElementById(targetPaneId); + + // Check if targetPane exists before trying to manipulate it + if (targetPane) { + targetPane.classList.add('active'); + if (tabContainer && tabContainer.classList.contains('lcp-support-hash')){ + window.location.hash = targetPaneId; // Update the URL hash + } + } else { + console.error(`Tab pane with ID '${targetPaneId}' not found.`); + } + }); }); - }); + }); diff --git a/assets/js/lcp.js b/assets/js/lcp.js index efc49a6..ba85d12 100644 --- a/assets/js/lcp.js +++ b/assets/js/lcp.js @@ -89,7 +89,7 @@ document.addEventListener('DOMContentLoaded', function () { } // Add debounced scroll event listener -window.addEventListener('scroll', debounce(handleScroll, 20)); // 200ms debounce +window.addEventListener('scroll', debounce(handleScroll, 0)); // 200ms debounce }); diff --git a/functions.php b/functions.php index 460e9dd..4b6216e 100644 --- a/functions.php +++ b/functions.php @@ -170,32 +170,6 @@ function drop_lcp_icons_table() { -/* BACKEND ICON ADDER */ -// Register the dashboard page in the admin menu -function lcp_register_dashboard_page() { - add_menu_page( - 'Icon Management', // Page Title - 'Icon Management', // Menu Title - 'manage_options', // Capability - 'icon-management', // Menu Slug - 'lcp_dashboard_page', // Callback function - 'dashicons-images-alt2', // Icon for the menu item - 60 // Position - ); -} -add_action('admin_menu', 'lcp_register_dashboard_page'); - -// Callback function to display the dashboard page content -function lcp_dashboard_page() { - ?> -
-

-
- -
-
- array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '00e12da1bdf9e61c448a'); + array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'eca736ee702435b6a2ff'); diff --git a/includes/blocks/lcp-button/build/index.js b/includes/blocks/lcp-button/build/index.js index f93a933..66416ca 100644 --- a/includes/blocks/lcp-button/build/index.js +++ b/includes/blocks/lcp-button/build/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,n={216:()=>{const e=window.wp.blocks,n=window.wp.i18n,t=window.wp.blockEditor,o=window.wp.components,l=(window.wp.element,window.React),a=window.ReactJSXRuntime;function s(e){const{iconSvgId:t,onIconChange:s}=e,[c,i]=(0,l.useState)([]);if((0,l.useEffect)((()=>{(async()=>{try{const e=await fetch("/wp-json/lcp/v1/icons"),n=await e.json();Array.isArray(n)&&n.length>0&&i(n)}catch(e){console.error("Error fetching icons:",e)}})()}),[]),0===c.length)return(0,a.jsx)("p",{children:(0,n.__)("Loading icons...","lcp")});const r=c.map((e=>({value:e.iconSvgId,label:e.name})));return(0,a.jsx)(o.SelectControl,{label:(0,n.__)("Select Icon","lcp"),value:t,options:r,onChange:e=>{const n=c.find((n=>n.iconSvgId===e));n&&s&&(s({iconSvgId:n.iconSvgId,iconSvgPath:n.iconSvgPaths,viewbox:n.selectedIconViewbox}),console.log("Selected Icon ID:",n.iconSvgId),console.log("Selected Icon Path:",n.iconSvgPaths),console.log("Selected Icon Viewbox:",n.selectedIconViewbox))}})}function c({value:e="10px",onChange:t,includeAuto:s=!1,autoReturnsNull:c=!1}){const i=[{label:(0,n.__)("px"),value:"px"},{label:(0,n.__)("%"),value:"%"},{label:(0,n.__)("em"),value:"em"},{label:(0,n.__)("rem"),value:"rem"},{label:(0,n.__)("vw"),value:"vw"},{label:(0,n.__)("vh"),value:"vh"},...s?[{label:(0,n.__)("auto"),value:"auto"}]:[]],r=e=>{const n=e.match(/([0-9]+)([a-zA-Z%]+)?/);return n?{numberValue:parseInt(n[1],10),unitValue:n[2]||"px"}:{numberValue:0,unitValue:"px"}},{numberValue:h,unitValue:u}=r(e),[d,v]=(0,l.useState)(h),[x,g]=(0,l.useState)(u);return(0,l.useEffect)((()=>{const{numberValue:n,unitValue:t}=r(e);v(n),g(t)}),[e]),(0,a.jsx)(o.BaseControl,{className:"lcp-dimension-value-control",children:(0,a.jsxs)(o.__experimentalHStack,{children:[(0,a.jsx)(o.__experimentalNumberControl,{className:"lcp-number-control",value:d||"",onChange:e=>{v(e),t&&"auto"!==x&&t(`${e}${x}`)},min:0,step:.1,spinControls:"none",disabled:"auto"===x}),(0,a.jsx)(o.SelectControl,{className:"lcp-select-control",value:x,options:i,onChange:e=>{"auto"===e&&v(null),g(e),t&&t("auto"===e?c?null:"auto":`${d}${e}`)}})]})})}function i(){return(0,a.jsxs)(o.BaseControl,{className:"lcp-padding-control",children:[(0,a.jsxs)(o.__experimentalHStack,{children:[(0,a.jsx)("span",{children:(0,n.__)("Padding")}),(0,a.jsx)(o.Button,{variant:"secondary","aria-label":(0,n.__)("Unlink sides"),onClick:()=>{},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})})})]}),(0,a.jsxs)(o.__experimentalHStack,{style:{flex:1},children:[(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",className:"spacing-sizes-control__icon","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z",style:{opacity:.25}}),(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9z"}),(0,a.jsx)("path",{d:"m7.5 19.5h9v-1.5h-9z"})]}),(0,a.jsxs)(o.__experimentalHStack,{style:{flex:1},children:[(0,a.jsx)(c,{}),(0,a.jsx)(o.RangeControl,{withInputField:!1,value:10,onChange:()=>{},min:0,max:50})]}),(0,a.jsx)(o.Button,{style:{padding:0,background:"none",color:"var(--wp-components-color-foreground)"},variant:"primary",onClick:()=>{},children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,a.jsx)("path",{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"})]})})]}),(0,a.jsxs)(o.__experimentalHStack,{style:{flex:1},children:[(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",className:"spacing-sizes-control__icon","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z",style:{opacity:.25}}),(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9z"}),(0,a.jsx)("path",{d:"m4.5 7.5v9h1.5v-9z"}),(0,a.jsx)("path",{d:"m18 7.5v9h1.5v-9z"})]}),(0,a.jsx)(o.RangeControl,{withInputField:!1,value:10,onChange:()=>{},min:0,max:50}),(0,a.jsx)(o.Button,{variant:"primary",onClick:()=>{},children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,a.jsx)("path",{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"})]})})]}),(0,a.jsx)(o.__experimentalVStack,{})]})}(0,e.registerBlockType)("lcp/button",{edit:function(e){const{attributes:l,setAttributes:r}=e,{buttonAction:h,iconHeight:u,buttonText:d,iconSvgId:v,iconSvgPath:x,iconSvgViewbox:g,displayIcon:p,iconSource:m,customUrl:w,buttonPadding:b}=l;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.InspectorControls,{children:(0,a.jsxs)(o.PanelBody,{title:(0,n.__)("Button Settings"),children:[(0,a.jsx)(i,{onChange:e=>{"number"==typeof e&&(e=`${e}px`),r({buttonPadding:e})}}),(0,a.jsx)(o.SelectControl,{label:(0,n.__)("Button Action"),value:h,options:[{value:"customUrl",label:"Custom URL"},{value:"showLoginForm",label:"Show Login Form"},{value:"logOut",label:"Open Popup"},{value:"shareCurrentPost",label:"Share Current Post"},{value:"displaySidecontent",label:"Display Sidecontent"}],onChange:e=>r({buttonAction:e})}),"customUrl"===h&&(0,a.jsx)(o.TextControl,{label:(0,n.__)("Custom URL"),value:w,onChange:e=>{r({customUrl:e})}}),(0,a.jsx)(o.TextControl,{label:(0,n.__)("Button Text"),value:d,onChange:e=>r({buttonText:e})}),(0,a.jsx)(o.ToggleControl,{label:"Display Icon",checked:p,onChange:e=>{r({displayIcon:e})}}),(0,a.jsx)(c,{value:u,onChange:e=>r({iconHeight:e}),includeAuto:!0,autoReturnsNull:!0}),p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.SelectControl,{label:(0,n.__)("Icon Source"),value:m,options:[{value:"manualSvgPath",label:"SVG Path"},{value:"iconSelector",label:"Icon Library"}],onChange:e=>r({iconSource:e})}),"manualSvgPath"===m&&(0,a.jsx)(o.TextareaControl,{label:"Icon SVG Path",value:x,onChange:e=>r({iconSvgPath:e})}),"iconSelector"===m&&(0,a.jsx)(s,{iconSvgId:v,onIconChange:e=>{console.log("Icon changed:",e),e&&e.iconSvgPath&&r({iconSvgPath:e.iconSvgPath,iconSvgId:e.iconSvgId,iconSvgViewbox:e.viewbox})}})]})]})}),(0,a.jsx)("div",{...(0,t.useBlockProps)(),children:"customUrl"===h?(0,a.jsxs)("a",{href:w,className:"lcp-button",style:{padding:b||"10px"},children:[p&&x&&(0,a.jsx)("svg",{style:{height:u},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:g||"0 0 576 576",dangerouslySetInnerHTML:{__html:x}}),(0,a.jsx)("span",{className:"lcp-button-text",children:d||"Button"})]}):(0,a.jsxs)("button",{className:"lcp-button",style:{padding:b||"10px"},children:[p&&x&&(0,a.jsx)("svg",{style:{height:u},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:g||"0 0 576 576",dangerouslySetInnerHTML:{__html:x}}),(0,a.jsx)("span",{className:"lcp-button-text",children:d||"Button"})]})})]})},save:function(e){const{attributes:n}=e,{displayIcon:o,buttonText:l,buttonPadding:s,iconHeight:c,iconSvgPath:i,iconSvgViewbox:r,buttonAction:h,customUrl:u}=n,d=t.useBlockProps.save();return(0,a.jsx)("div",{...d,children:"customUrl"===h?(0,a.jsxs)("a",{href:u,className:"lcp-button",style:{padding:s||"10px"},children:[o&&i&&(0,a.jsx)("svg",{style:{height:c},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:r||"0 0 576 576",dangerouslySetInnerHTML:{__html:i}}),(0,a.jsx)("span",{className:"lcp-button-text",children:l||"Button"})]}):(0,a.jsxs)("button",{className:"lcp-button",style:{padding:s||"10px"},children:[o&&i&&(0,a.jsx)("svg",{style:{height:c},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:r||"0 0 576 576",dangerouslySetInnerHTML:{__html:i}}),(0,a.jsx)("span",{className:"lcp-button-text",children:l||"Button"})]})})}})}},t={};function o(e){var l=t[e];if(void 0!==l)return l.exports;var a=t[e]={exports:{}};return n[e](a,a.exports,o),a.exports}o.m=n,e=[],o.O=(n,t,l,a)=>{if(!t){var s=1/0;for(h=0;h=a)&&Object.keys(o.O).every((e=>o.O[e](t[i])))?t.splice(i--,1):(c=!1,a0&&e[h-1][2]>a;h--)e[h]=e[h-1];e[h]=[t,l,a]},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={57:0,350:0};o.O.j=n=>0===e[n];var n=(n,t)=>{var l,a,[s,c,i]=t,r=0;if(s.some((n=>0!==e[n]))){for(l in c)o.o(c,l)&&(o.m[l]=c[l]);if(i)var h=i(o)}for(n&&n(t);ro(216)));l=o.O(l)})(); \ No newline at end of file +(()=>{"use strict";var e,n={216:()=>{const e=window.wp.blocks,n=window.wp.i18n,t=window.wp.blockEditor,o=window.wp.components,l=(window.wp.element,window.React),a=window.ReactJSXRuntime;function s(e){const{iconSvgId:t,onIconChange:s}=e,[c,i]=(0,l.useState)([]);if((0,l.useEffect)((()=>{(async()=>{try{const e=await fetch("/wp-json/lcp/v1/icons"),n=await e.json();Array.isArray(n)&&n.length>0&&i(n)}catch(e){console.error("Error fetching icons:",e)}})()}),[]),0===c.length)return(0,a.jsx)("p",{children:(0,n.__)("Loading icons...","lcp")});const r=c.map((e=>({value:e.iconSvgId,label:e.name})));return(0,a.jsx)(o.SelectControl,{label:(0,n.__)("Select Icon","lcp"),value:t,options:r,onChange:e=>{const n=c.find((n=>n.iconSvgId===e));n&&s&&(s({iconSvgId:n.iconSvgId,iconSvgPath:n.iconSvgPaths,viewbox:n.selectedIconViewbox}),console.log("Selected Icon ID:",n.iconSvgId),console.log("Selected Icon Path:",n.iconSvgPaths),console.log("Selected Icon Viewbox:",n.selectedIconViewbox))}})}function c({value:e="10px",onChange:t,includeAuto:s=!1,autoReturnsNull:c=!1}){const i=[{label:(0,n.__)("px"),value:"px"},{label:(0,n.__)("%"),value:"%"},{label:(0,n.__)("em"),value:"em"},{label:(0,n.__)("rem"),value:"rem"},{label:(0,n.__)("vw"),value:"vw"},{label:(0,n.__)("vh"),value:"vh"},...s?[{label:(0,n.__)("auto"),value:"auto"}]:[]],r=e=>{const n=e.match(/([0-9]+)([a-zA-Z%]+)?/);return n?{numberValue:parseInt(n[1],10),unitValue:n[2]||"px"}:{numberValue:0,unitValue:"px"}},{numberValue:h,unitValue:u}=r(e),[d,v]=(0,l.useState)(h),[x,g]=(0,l.useState)(u);return(0,l.useEffect)((()=>{const{numberValue:n,unitValue:t}=r(e);v(n),g(t)}),[e]),(0,a.jsx)(o.BaseControl,{className:"lcp-dimension-value-control",children:(0,a.jsxs)(o.__experimentalHStack,{children:[(0,a.jsx)(o.__experimentalNumberControl,{className:"lcp-number-control",value:d||"",onChange:e=>{v(e),t&&"auto"!==x&&t(`${e}${x}`)},min:0,step:.1,spinControls:"none",disabled:"auto"===x}),(0,a.jsx)(o.SelectControl,{className:"lcp-select-control",value:x,options:i,onChange:e=>{"auto"===e&&v(null),g(e),t&&t("auto"===e?c?null:"auto":`${d}${e}`)}})]})})}function i(){return(0,a.jsxs)(o.BaseControl,{className:"lcp-padding-control",children:[(0,a.jsxs)(o.__experimentalHStack,{children:[(0,a.jsx)("span",{children:(0,n.__)("Padding")}),(0,a.jsx)(o.Button,{variant:"secondary","aria-label":(0,n.__)("Unlink sides"),onClick:()=>{},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})})})]}),(0,a.jsxs)(o.__experimentalHStack,{style:{flex:1},children:[(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",className:"spacing-sizes-control__icon","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z",style:{opacity:.25}}),(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9z"}),(0,a.jsx)("path",{d:"m7.5 19.5h9v-1.5h-9z"})]}),(0,a.jsxs)(o.__experimentalHStack,{style:{flex:1},children:[(0,a.jsx)(c,{}),(0,a.jsx)(o.RangeControl,{withInputField:!1,value:10,onChange:()=>{},min:0,max:50})]}),(0,a.jsx)(o.Button,{style:{padding:0,background:"none",color:"var(--wp-components-color-foreground)"},variant:"primary",onClick:()=>{},children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,a.jsx)("path",{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"})]})})]}),(0,a.jsxs)(o.__experimentalHStack,{style:{flex:1},children:[(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",className:"spacing-sizes-control__icon","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z",style:{opacity:.25}}),(0,a.jsx)("path",{d:"m7.5 6h9v-1.5h-9z"}),(0,a.jsx)("path",{d:"m4.5 7.5v9h1.5v-9z"}),(0,a.jsx)("path",{d:"m18 7.5v9h1.5v-9z"})]}),(0,a.jsx)(o.RangeControl,{withInputField:!1,value:10,onChange:()=>{},min:0,max:50}),(0,a.jsx)(o.Button,{variant:"primary",onClick:()=>{},children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:[(0,a.jsx)("path",{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,a.jsx)("path",{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"})]})})]}),(0,a.jsx)(o.__experimentalVStack,{})]})}(0,e.registerBlockType)("lcp/button",{edit:function(e){const{attributes:l,setAttributes:r}=e,{buttonAction:h,iconHeight:u,buttonText:d,iconSvgId:v,iconSvgPath:x,iconSvgViewbox:g,displayIcon:p,iconSource:m,customUrl:w,buttonPadding:b}=l;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.InspectorControls,{children:(0,a.jsxs)(o.PanelBody,{title:(0,n.__)("Button Settings"),children:[(0,a.jsx)(i,{onChange:e=>{"number"==typeof e&&(e=`${e}px`),r({buttonPadding:e})}}),(0,a.jsx)(o.SelectControl,{label:(0,n.__)("Button Action"),value:h,options:[{value:"customUrl",label:"Custom URL"},{value:"showLoginForm",label:"Show Login Form"},{value:"logOut",label:"Open Popup"},{value:"shareCurrentPost",label:"Share Current Post"},{value:"displaySidecontent",label:"Display Sidecontent"}],onChange:e=>r({buttonAction:e})}),"customUrl"===h&&(0,a.jsx)(o.TextControl,{label:(0,n.__)("Custom URL"),value:w,onChange:e=>{r({customUrl:e})}}),(0,a.jsx)(o.TextControl,{label:(0,n.__)("Button Text"),value:d,onChange:e=>r({buttonText:e})}),(0,a.jsx)(o.ToggleControl,{label:"Display Icon",checked:p,onChange:e=>{r({displayIcon:e})}}),(0,a.jsx)(c,{value:u,onChange:e=>r({iconHeight:e}),includeAuto:!0,autoReturnsNull:!0}),p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.SelectControl,{label:(0,n.__)("Icon Source"),value:m,options:[{value:"manualSvgPath",label:"SVG Path"},{value:"iconSelector",label:"Icon Library"}],onChange:e=>r({iconSource:e})}),"manualSvgPath"===m&&(0,a.jsx)(o.TextareaControl,{label:"Icon SVG Path",value:x,onChange:e=>r({iconSvgPath:e})}),"iconSelector"===m&&(0,a.jsx)(s,{iconSvgId:v,onIconChange:e=>{console.log("Icon changed:",e),e&&e.iconSvgPath&&r({iconSvgPath:e.iconSvgPath,iconSvgId:e.iconSvgId,iconSvgViewbox:e.viewbox})}})]})]})}),(0,a.jsx)("div",{...(0,t.useBlockProps)(),children:"customUrl"===h?(0,a.jsxs)("a",{href:w,className:"lcp-button",style:{padding:b||"10px"},children:[p&&x&&(0,a.jsx)("svg",{style:{height:u},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:g||"0 0 576 576",dangerouslySetInnerHTML:{__html:x}}),(0,a.jsx)("span",{className:"lcp-button-text",children:d||"Button"})]}):(0,a.jsxs)("button",{className:"lcp-button",style:{padding:b||"10px"},children:[p&&x&&(0,a.jsx)("svg",{style:{height:u},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:g||"0 0 576 576",dangerouslySetInnerHTML:{__html:x}}),(0,a.jsx)("span",{className:"lcp-button-text",children:d||"Button"})]})})]})},save:function(e){const{attributes:n}=e,{displayIcon:o,buttonText:l,buttonPadding:s,iconHeight:c,iconSvgPath:i,iconSvgViewbox:r,buttonAction:h,customUrl:u}=n;return t.useBlockProps.save(),(0,a.jsx)(a.Fragment,{children:"customUrl"===h?(0,a.jsxs)("a",{href:u,className:"lcp-button",style:{padding:s||"10px"},children:[o&&i&&(0,a.jsx)("svg",{style:{height:c},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:r||"0 0 576 576",dangerouslySetInnerHTML:{__html:i}}),(0,a.jsx)("span",{className:"lcp-button-text",children:l||"Button"})]}):(0,a.jsxs)("button",{className:"lcp-button",style:{padding:s||"10px"},children:[o&&i&&(0,a.jsx)("svg",{style:{height:c},className:"lcp-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:r||"0 0 576 576",dangerouslySetInnerHTML:{__html:i}}),(0,a.jsx)("span",{className:"lcp-button-text",children:l||"Button"})]})})}})}},t={};function o(e){var l=t[e];if(void 0!==l)return l.exports;var a=t[e]={exports:{}};return n[e](a,a.exports,o),a.exports}o.m=n,e=[],o.O=(n,t,l,a)=>{if(!t){var s=1/0;for(h=0;h=a)&&Object.keys(o.O).every((e=>o.O[e](t[i])))?t.splice(i--,1):(c=!1,a0&&e[h-1][2]>a;h--)e[h]=e[h-1];e[h]=[t,l,a]},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={57:0,350:0};o.O.j=n=>0===e[n];var n=(n,t)=>{var l,a,[s,c,i]=t,r=0;if(s.some((n=>0!==e[n]))){for(l in c)o.o(c,l)&&(o.m[l]=c[l]);if(i)var h=i(o)}for(n&&n(t);ro(216)));l=o.O(l)})(); \ No newline at end of file diff --git a/includes/blocks/lcp-button/src/save.js b/includes/blocks/lcp-button/src/save.js index 1652fcf..baf8307 100644 --- a/includes/blocks/lcp-button/src/save.js +++ b/includes/blocks/lcp-button/src/save.js @@ -10,26 +10,26 @@ export default function save(props) { // Conditionally render the link or button based on buttonAction return ( -
- {buttonAction === 'customUrl' ? ( - - {displayIcon && iconSvgPath && ( - - )} - - {buttonText || 'Button'} - - - ) : ( - - )} -
+ <> + {buttonAction === 'customUrl' ? ( + + {displayIcon && iconSvgPath && ( + + )} + + {buttonText || 'Button'} + + + ) : ( + + )} + ); } diff --git a/includes/blocks/lcp-main-area/build/index.asset.php b/includes/blocks/lcp-main-area/build/index.asset.php index e6712a7..040da59 100644 --- a/includes/blocks/lcp-main-area/build/index.asset.php +++ b/includes/blocks/lcp-main-area/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => 'e74f7d37dca7635e59f9'); + array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '7b19c7f88a697fc64c09'); diff --git a/includes/blocks/lcp-main-area/build/index.js b/includes/blocks/lcp-main-area/build/index.js index 02926a3..6dee730 100644 --- a/includes/blocks/lcp-main-area/build/index.js +++ b/includes/blocks/lcp-main-area/build/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,n={998:()=>{const e=window.wp.blocks,n=window.wp.i18n,t=window.wp.blockEditor,r=window.wp.components,i=window.ReactJSXRuntime,s=JSON.parse('{"UU":"lcp/main-area"}');(0,e.registerBlockType)(s.UU,{edit:function(e){const{attributes:s,setAttributes:a}=e,{maxWidth:o="100%",expandVertical:l=!0}=s,c=(0,t.useBlockProps)(),p=(0,t.useInnerBlocksProps)(c);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.InspectorControls,{children:(0,i.jsx)(r.PanelBody,{title:(0,n.__)("Max Width Settings","lcp"),initialOpen:!0,children:(0,i.jsxs)("div",{className:"max-width-settings",children:[(0,i.jsx)(r.__experimentalUnitControl,{onChange:e=>{a({maxWidth:e})},value:o,defaultUnit:"px"}),(0,i.jsx)(r.ToggleControl,{label:(0,n.__)("Enable Vertical Expansion","lcp"),checked:l,onChange:e=>{a({expandVertical:e})}})]})})}),(0,i.jsx)("div",{...p,id:"lcp-main-container",style:{minHeight:"200px"},children:(0,i.jsx)(t.InnerBlocks,{...p})})]})},save:function({attributes:e}){const{maxWidth:n="100%",expandVertical:r}=e,s=t.useBlockProps.save(),a=r?`${s.className} lcp-grow-vertical`:s.className,o={maxWidth:n};return(0,i.jsx)("div",{...s,id:"lcp-main-container",className:a,style:o,children:(0,i.jsx)(t.InnerBlocks.Content,{})})}})}},t={};function r(e){var i=t[e];if(void 0!==i)return i.exports;var s=t[e]={exports:{}};return n[e](s,s.exports,r),s.exports}r.m=n,e=[],r.O=(n,t,i,s)=>{if(!t){var a=1/0;for(p=0;p=s)&&Object.keys(r.O).every((e=>r.O[e](t[l])))?t.splice(l--,1):(o=!1,s0&&e[p-1][2]>s;p--)e[p]=e[p-1];e[p]=[t,i,s]},r.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={57:0,350:0};r.O.j=n=>0===e[n];var n=(n,t)=>{var i,s,a=t[0],o=t[1],l=t[2],c=0;if(a.some((n=>0!==e[n]))){for(i in o)r.o(o,i)&&(r.m[i]=o[i]);if(l)var p=l(r)}for(n&&n(t);cr(998)));i=r.O(i)})(); \ No newline at end of file +(()=>{"use strict";var e,n={998:()=>{const e=window.wp.blocks,n=window.wp.i18n,t=window.wp.blockEditor,i=window.wp.components,r=window.ReactJSXRuntime,s=JSON.parse('{"UU":"lcp/main-area"}');(0,e.registerBlockType)(s.UU,{edit:function(e){const{attributes:s,setAttributes:a}=e,{maxWidth:o="100%",expandVertical:l=!0}=s,c=(0,t.useBlockProps)(),p=(0,t.useInnerBlocksProps)(c);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.InspectorControls,{children:(0,r.jsx)(i.PanelBody,{title:(0,n.__)("Max Width Settings","lcp"),initialOpen:!0,children:(0,r.jsxs)("div",{className:"max-width-settings",children:[(0,r.jsx)(i.__experimentalUnitControl,{onChange:e=>{a({maxWidth:e})},value:o,defaultUnit:"px"}),(0,r.jsx)(i.ToggleControl,{label:(0,n.__)("Enable Vertical Expansion","lcp"),checked:l,onChange:e=>{a({expandVertical:e})}})]})})}),(0,r.jsx)("div",{...p,id:"lcp-main-container",style:{minHeight:"200px"},children:(0,r.jsx)(t.InnerBlocks,{...p})})]})},save:function({attributes:e}){const{maxWidth:n="100%",expandVertical:i}=e,s=t.useBlockProps.save(),a=i?`${s.className} lcp-grow-vertical`:s.className,o={maxWidth:n};return(0,r.jsx)("div",{...s,id:"lcp-main-container",className:a,style:o,children:(0,r.jsx)("div",{id:"lcp-main-container-inner",children:(0,r.jsx)(t.InnerBlocks.Content,{})})})}})}},t={};function i(e){var r=t[e];if(void 0!==r)return r.exports;var s=t[e]={exports:{}};return n[e](s,s.exports,i),s.exports}i.m=n,e=[],i.O=(n,t,r,s)=>{if(!t){var a=1/0;for(p=0;p=s)&&Object.keys(i.O).every((e=>i.O[e](t[l])))?t.splice(l--,1):(o=!1,s0&&e[p-1][2]>s;p--)e[p]=e[p-1];e[p]=[t,r,s]},i.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={57:0,350:0};i.O.j=n=>0===e[n];var n=(n,t)=>{var r,s,a=t[0],o=t[1],l=t[2],c=0;if(a.some((n=>0!==e[n]))){for(r in o)i.o(o,r)&&(i.m[r]=o[r]);if(l)var p=l(i)}for(n&&n(t);ci(998)));r=i.O(r)})(); \ No newline at end of file diff --git a/includes/blocks/lcp-main-area/src/save.js b/includes/blocks/lcp-main-area/src/save.js index 5637f8b..2793cfb 100644 --- a/includes/blocks/lcp-main-area/src/save.js +++ b/includes/blocks/lcp-main-area/src/save.js @@ -16,7 +16,9 @@ export default function Save( { attributes } ) { return (
- +
+ +
); } diff --git a/includes/blocks/lcp-sidecontent/build/index.asset.php b/includes/blocks/lcp-sidecontent/build/index.asset.php index 934b827..391c3d9 100644 --- a/includes/blocks/lcp-sidecontent/build/index.asset.php +++ b/includes/blocks/lcp-sidecontent/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => '9fbf94ac3507c2365b0a'); + array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'e510dd9214b81b305e13'); diff --git a/includes/blocks/lcp-sidecontent/build/index.js b/includes/blocks/lcp-sidecontent/build/index.js index 8d7b519..d655914 100644 --- a/includes/blocks/lcp-sidecontent/build/index.js +++ b/includes/blocks/lcp-sidecontent/build/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,n={650:()=>{const e=window.wp.blocks,n=(window.wp.i18n,window.wp.blockEditor),r=window.ReactJSXRuntime,o=JSON.parse('{"UU":"lcp/sidecontent"}');(0,e.registerBlockType)(o.UU,{edit:function(){return(0,n.useBlockProps)(),(0,r.jsx)("div",{...n.useBlockProps,children:(0,r.jsx)("div",{id:"lcp-sidecontent",children:(0,r.jsx)(n.InnerBlocks,{renderAppender:()=>(0,r.jsx)(n.InnerBlocks.ButtonBlockAppender,{})})})})},save:function(){const e=n.useBlockProps.save();return(0,r.jsx)("div",{...e,id:"lcp-sidecontent",children:(0,r.jsx)(n.InnerBlocks.Content,{})})}})}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var s=r[e]={exports:{}};return n[e](s,s.exports,o),s.exports}o.m=n,e=[],o.O=(n,r,t,s)=>{if(!r){var i=1/0;for(d=0;d=s)&&Object.keys(o.O).every((e=>o.O[e](r[l])))?r.splice(l--,1):(c=!1,s0&&e[d-1][2]>s;d--)e[d]=e[d-1];e[d]=[r,t,s]},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={57:0,350:0};o.O.j=n=>0===e[n];var n=(n,r)=>{var t,s,i=r[0],c=r[1],l=r[2],p=0;if(i.some((n=>0!==e[n]))){for(t in c)o.o(c,t)&&(o.m[t]=c[t]);if(l)var d=l(o)}for(n&&n(r);po(650)));t=o.O(t)})(); \ No newline at end of file +(()=>{"use strict";var e,n={650:()=>{const e=window.wp.blocks,n=(window.wp.i18n,window.wp.blockEditor),r=window.ReactJSXRuntime,o=JSON.parse('{"UU":"lcp/sidecontent"}');(0,e.registerBlockType)(o.UU,{edit:function(){return(0,n.useBlockProps)(),(0,r.jsx)("div",{...n.useBlockProps,children:(0,r.jsx)("div",{id:"lcp-sidecontent",children:(0,r.jsx)(n.InnerBlocks,{renderAppender:()=>(0,r.jsx)(n.InnerBlocks.ButtonBlockAppender,{})})})})},save:function(){const e=n.useBlockProps.save();return(0,r.jsx)("div",{...e,id:"lcp-sidecontent",children:(0,r.jsx)("div",{id:"lcp-sidecontent-inner",children:(0,r.jsx)(n.InnerBlocks.Content,{})})})}})}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.m=n,e=[],o.O=(n,r,t,i)=>{if(!r){var s=1/0;for(p=0;p=i)&&Object.keys(o.O).every((e=>o.O[e](r[l])))?r.splice(l--,1):(c=!1,i0&&e[p-1][2]>i;p--)e[p]=e[p-1];e[p]=[r,t,i]},o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={57:0,350:0};o.O.j=n=>0===e[n];var n=(n,r)=>{var t,i,s=r[0],c=r[1],l=r[2],d=0;if(s.some((n=>0!==e[n]))){for(t in c)o.o(c,t)&&(o.m[t]=c[t]);if(l)var p=l(o)}for(n&&n(r);do(650)));t=o.O(t)})(); \ No newline at end of file diff --git a/includes/blocks/lcp-sidecontent/src/save.js b/includes/blocks/lcp-sidecontent/src/save.js index a3a1078..ce0456e 100644 --- a/includes/blocks/lcp-sidecontent/src/save.js +++ b/includes/blocks/lcp-sidecontent/src/save.js @@ -20,11 +20,12 @@ export default function Save() { return (
+
- +
diff --git a/includes/classes/backend.php b/includes/classes/backend.php index ac9fd92..7082783 100644 --- a/includes/classes/backend.php +++ b/includes/classes/backend.php @@ -241,7 +241,7 @@ function render_lcp_theme_settings_page() {

Theme Settings

-
+
    diff --git a/style.css b/style.css index 7dc92b4..10c68f3 100644 --- a/style.css +++ b/style.css @@ -41,7 +41,7 @@ Version: 0.0.1 /* Main Content */ -.lcp-has-sidecontent #lcp-main-container > * > *{ padding:20px +.lcp-has-sidecontent #lcp-main-container > *{ padding-left:40px } @@ -53,15 +53,23 @@ Version: 0.0.1 overflow:auto; position: absolute; left: 0; - top: 0; width: 340px; - height: 100%; + height: calc(100vh - var(--lcp--header--height)); background: #fff; border-right: 2px solid #eee; z-index: 2; outline: 0; -} +} +#lcp-sidecontent #lcp-sidecontent-inner { + padding:10px +} +.admin-bar #lcp-sidecontent { + height:calc(100vh - var(--lcp--header--height) - 32px) +} +#lcp-sidecontent:not(.lcp-fixed) { + top:0 +} #lcp-viewport-outer.lcp-has-sticky-header #lcp-sidecontent { top: var(--lcp--header--height); position:fixed!important; @@ -116,10 +124,10 @@ Version: 0.0.1 width: 100% } #lcp-sidecontent {top:var(--lcp---header--height)} -#lcp-sidecontent { +#lcp-sidecontent:not(.lcp-fixed) { top: calc(var(--lcp--header--height) ); } -.admin-bar #lcp-sidecontent.lcp-fixed { +#lcp-viewport-outer:not(.lcp-has-sticky-header).admin-bar #lcp-sidecontent.lcp-fixed { top: calc(var(--lcp--header--height) + 32px); } @@ -130,7 +138,12 @@ Version: 0.0.1 right: 0; z-index: 3; } - +#lcp-header-sidecontent.lcp-fixed { + height:100vh +} +.admin-bar #lcp-sidecontent.lcp-fixed { + height:calc(100vh - 32px) +} #lcp-header-container.lcp-sticky-on-scroll.lcp-fixed { position: fixed; top:32px; @@ -306,3 +319,12 @@ Version: 0.0.1 display: block; } + + +#lcp-sidecontent { + overflow: scroll; + scrollbar-color: red orange; + scrollbar-width: thin; + border-radius:5px + } + diff --git a/theme.json b/theme.json index a025fba..c63fc04 100644 --- a/theme.json +++ b/theme.json @@ -5,6 +5,7 @@ ], "settings": { + "appearanceTools": true, "color": { "defaultDuotone": false,