diff --git a/README.md b/README.md index 4081ea3b..93841451 100755 --- a/README.md +++ b/README.md @@ -562,7 +562,7 @@ Modify available button styles. ```javascript function myButtonStyleOptions( styleOptions ) { - styleOptions.push( { label: 'My Option', value: 'my-option', color: '#FF0000' } ); + styleOptions.push( { label: 'My Option', value: 'my-option', bgColor: '#FF0000', color: '#FFFFFF } ); return styleOptions; } wp.hooks.addFilter( diff --git a/build/index.asset.php b/build/index.asset.php index 0735be5e..0a152eb7 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '9b6fd2a0b07ab4882cb6'); + array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '50cb7b11519b5b7cfb75'); diff --git a/build/index.js b/build/index.js index d205922c..9a10834b 100644 --- a/build/index.js +++ b/build/index.js @@ -1 +1 @@ -!function(){"use strict";var t,e={489:function(){var t=window.wp.hooks;(0,t.hasFilter)("wpBootstrapBlocks.container.customMarginOptions")&&console.warn("`wpBootstrapBlocks.container.customMarginOptions` filter was renamed to `wpBootstrapBlocks.container.marginAfterOptions`. Please change your filter definition."),(0,t.hasFilter)("wpBootstrapBlocks.container.useFluidContainerPerDefault")&&console.warn("`wpBootstrapBlocks.container.useFluidContainerPerDefault` filter has been removed. Please use `wp_bootstrap_blocks_container_default_attributes` filter (PHP) instead."),(0,t.hasFilter)("wpBootstrapBlocks.row.useOldObjectTemplateStructure")&&console.warn("`wpBootstrapBlocks.row.useOldObjectTemplateStructure` filter has no effect since the old template structure is not supported anymore. You can safely remove this filter.");var e=window.wp.element,o=window.wp.blocks,l=window.wp.components;o.updateCategory&&(0,o.updateCategory)("wp-bootstrap-blocks",{icon:(0,e.createElement)(l.SVG,{viewBox:"0 0 120 120",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Rect,{stroke:"#979797",fill:"#6EA644",x:"-110.5",y:"-123.5",width:"340",height:"367"}),(0,e.createElement)(l.Path,{d:"M105.362393,45.9570783 C103.695123,44.8177711 101.427637,45.2868976 100.293893,46.9623494 C93.6915059,56.9480422 79.6864416,57.4841867 78.952843,57.4841867 C78.8194614,57.4841867 78.7527707,57.4841867 78.6193891,57.4841867 C61.3464764,57.4841867 54.744089,72.2951807 54.4773258,72.8983434 C53.6770365,74.7748494 54.5440166,76.9194277 56.3446678,77.7236446 C56.8115032,77.9246988 57.3450295,78.0587349 57.811865,78.0587349 C59.2123714,78.0587349 60.5461871,77.2545181 61.1464041,75.8471386 C61.2130949,75.7131024 65.7480681,65.5263554 77.418955,64.8561747 L77.418955,83.8222892 C76.9521195,87.9103916 75.0180868,91.127259 71.6168569,93.5399096 C68.0822455,96.0195783 63.3471999,97.2929217 57.5451018,97.2929217 C50.6092605,97.2929217 44.940544,94.8802711 40.7390247,90.121988 C36.4708146,85.3637048 34.3367095,78.5948795 34.3367095,69.8825301 L34.4034003,48.9728916 C34.7368542,41.2658133 36.8042685,35.1671687 40.7390247,30.810994 C45.0072347,26.0527108 50.6092605,23.6400602 57.5451018,23.6400602 C63.3471999,23.6400602 68.0822455,24.9134036 71.6168569,27.3930723 C75.1514684,29.872741 77.1521919,33.2906627 77.4856458,37.7138554 C77.4856458,37.8478916 77.4856458,38.0489458 77.4856458,38.1829819 C77.4856458,40.7296687 79.5530601,42.8072289 82.0873098,42.8072289 C84.6215595,42.8072289 86.6889738,40.7296687 86.6889738,38.1829819 C86.6889738,38.0489458 86.6889738,37.8478916 86.6889738,37.7138554 C86.022066,31.0790663 83.0209807,25.8516566 77.6190274,21.8975904 C72.217074,17.9435241 65.481305,16 57.3450295,16 C47.674866,16 39.8720445,19.2168675 33.9365648,25.5835843 C28.3345391,31.5481928 25.4001447,39.3893072 25.0666908,49.0399096 C25.0666908,49.7100904 25,50.3802711 25,51.0504518 L25.0666908,69.8825301 L25,69.8825301 C25,80.5384036 28.0010852,89.0496988 33.9365648,95.4164157 C39.8720445,101.783133 47.674866,105 57.3450295,105 C65.481305,105 72.217074,103.056476 77.6190274,99.1024096 C82.5541453,95.4834337 85.4885397,90.7251506 86.4889014,84.8275602 L86.6889738,63.7838855 C92.757835,62.309488 101.027492,58.9585843 106.229373,51.0504518 C107.563189,49.375 107.096353,47.0963855 105.362393,45.9570783 Z",stroke:"#FFFFFF",fill:"#FFFFFF"}))});var n=window.wp.i18n,r=window.wp.blockEditor;function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,l=new Array(e);o0}})).hasChildBlocks;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Fluid","wp-bootstrap-blocks")},(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Fluid","wp-bootstrap-blocks"),checked:p,onChange:function(t){i({isFluid:t})}}),(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Fluid Breakpoint","wp-bootstrap-blocks"),disabled:!p,value:m,options:b,onChange:function(t){i({fluidBreakpoint:t})},help:(0,n.__)("Fluid breakpoints only work with Bootstrap v4.4+. The container will be 100% wide until the specified breakpoint is reached, after which max-widths for each of the higher breakpoints will be applied.","wp-bootstrap-blocks")})),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Margin","wp-bootstrap-blocks")},(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Margin After","wp-bootstrap-blocks"),value:w,options:u,onChange:function(t){i({marginAfter:t})}}))),(0,e.createElement)("div",{className:a},(0,e.createElement)(r.InnerBlocks,{renderAppender:d?void 0:function(){return(0,e.createElement)(r.InnerBlocks.ButtonBlockAppender,null)}})))},save:function(){return(0,e.createElement)(r.InnerBlocks.Content,null)}});var O="#007bff",z="#6c757d",x=["label","attributeName","value","setAttributes"],M=[{icon:v,title:(0,n.__)("Align content top","wp-bootstrap-blocks"),align:"top"},{icon:h,title:(0,n.__)("Align content center","wp-bootstrap-blocks"),align:"center"},{icon:k,title:(0,n.__)("Align content bottom","wp-bootstrap-blocks"),align:"bottom"}],V=function(t){var o=t.label,n=t.attributeName,r=t.value,a=t.setAttributes,c=function(t,e){if(null==t)return{};var o,l,n=function(t,e){if(null==t)return{};var o,l,n={},r=Object.keys(t);for(l=0;l=0||(n[o]=t[o]);return n}(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(l=0;l=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(n[o]=t[o])}return n}(t,x);return(0,e.createElement)(l.RangeControl,B({label:o,value:r,onChange:function(t){a(y({},n,t))},min:0,max:12},c))},S=[{name:"primary",color:O},{name:"secondary",color:z}];S=(0,t.applyFilters)("wpBootstrapBlocks.column.bgColorOptions",S);var P=[{label:(0,n.__)("None","wp-bootstrap-blocks"),value:""},{label:(0,n.__)("Small","wp-bootstrap-blocks"),value:"p-2"},{label:(0,n.__)("Medium","wp-bootstrap-blocks"),value:"p-3"},{label:(0,n.__)("Large","wp-bootstrap-blocks"),value:"p-5"}];P=(0,t.applyFilters)("wpBootstrapBlocks.column.paddingOptions",P);function A(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);e&&(l=l.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,l)}return o}(0,o.registerBlockType)("wp-bootstrap-blocks/column",{title:(0,n.__)("Column (Bootstrap)","wp-bootstrap-blocks"),icon:f,category:"wp-bootstrap-blocks",keywords:[(0,n.__)("Column","wp-bootstrap-blocks"),(0,n.__)("Bootstrap Column","wp-bootstrap-blocks"),(0,n.__)("Bootstrap","wp-bootstrap-blocks")],parent:["wp-bootstrap-blocks/row"],getEditWrapperProps:function(t){var e=t.sizeXxl,o=t.sizeXl,l=t.sizeLg,n=t.sizeMd,r=t.sizeSm,a=t.sizeXs,c=t.equalWidthXxl,s=t.equalWidthXl,i=t.equalWidthLg,p=t.equalWidthMd,u=t.equalWidthSm,b=t.equalWidthXs,m=t.bgColor,w=t.padding,d=t.contentVerticalAlignment,k={};if(m){var h=S.find((function(t){return t.name===m}));h&&(k={backgroundColor:h.color})}return{"data-size-xs":c||s||i||p||u||b?0:a,"data-size-sm":c||s||i||p||u?0:r,"data-size-md":c||s||i||p?0:n,"data-size-lg":c||s||i?0:l,"data-size-xl":c||s?0:o,"data-size-xxl":c?0:e,"data-bg-color":m,"data-padding":w,"data-content-vertical-alignment":d,style:k}},edit:function(t){var o=t.attributes,a=t.className,c=t.clientId,u=t.setAttributes,b=(0,s.useSelect)((function(t){return{hasChildBlocks:(0,t("core/block-editor").getBlockOrder)(c).length>0}})).hasChildBlocks,m=o.sizeXxl,w=o.sizeXl,d=o.sizeLg,k=o.sizeMd,h=o.sizeSm,v=o.sizeXs,g=o.equalWidthXxl,_=o.equalWidthXl,f=o.equalWidthLg,C=o.equalWidthMd,E=o.equalWidthSm,B=o.equalWidthXs,y=o.bgColor,O=o.padding,z=o.centerContent,x=o.contentVerticalAlignment;return z&&u({contentVerticalAlignment:"center",centerContent:!1}),(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Column size","wp-bootstrap-blocks"),initialOpen:!1},(0,e.createElement)(V,{label:(0,n.__)("Xs Column count","wp-bootstrap-blocks"),attributeName:"sizeXs",value:v,disabled:B,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Xs equal-width","wp-bootstrap-blocks"),checked:B,onChange:function(t){return u({equalWidthXs:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(V,{label:(0,n.__)("Sm Column count","wp-bootstrap-blocks"),attributeName:"sizeSm",value:h,disabled:E,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Sm equal-width","wp-bootstrap-blocks"),checked:E,onChange:function(t){return u({equalWidthSm:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(V,{label:(0,n.__)("Md Column count","wp-bootstrap-blocks"),attributeName:"sizeMd",value:k,disabled:C,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Md equal-width","wp-bootstrap-blocks"),checked:C,onChange:function(t){return u({equalWidthMd:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(V,{label:(0,n.__)("Lg Column count","wp-bootstrap-blocks"),attributeName:"sizeLg",value:d,disabled:f,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Lg equal-width","wp-bootstrap-blocks"),checked:f,onChange:function(t){return u({equalWidthLg:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(V,{label:(0,n.__)("Xl Column count","wp-bootstrap-blocks"),attributeName:"sizeXl",value:w,disabled:_,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Xl equal-width","wp-bootstrap-blocks"),checked:_,onChange:function(t){return u({equalWidthXl:t})}}),i()&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("hr",null),(0,e.createElement)(V,{label:(0,n.__)("Xxl Column count","wp-bootstrap-blocks"),attributeName:"sizeXxl",value:m,disabled:g,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Xxl equal-width","wp-bootstrap-blocks"),checked:g,onChange:function(t){return u({equalWidthXxl:t})}}))),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Background color","wp-bootstrap-blocks"),initialOpen:!1},(0,e.createElement)(l.ColorPalette,{colors:S,value:y,onChange:function(t){if(t){var e=S.find((function(e){return e.color===t}));e&&u({bgColor:e.name})}else u({bgColor:"",centerContent:!1})},disableCustomColors:!0})),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Padding (inside column)","wp-bootstrap-blocks"),initialOpen:!1},(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Size","wp-bootstrap-blocks"),value:O,options:P,onChange:function(t){u({padding:t})}}))),(0,e.createElement)(r.BlockControls,null,(0,e.createElement)(r.AlignmentToolbar,{value:x,label:(0,n.__)("Change vertical alignment of content","wp-bootstrap-blocks"),onChange:function(t){return u({contentVerticalAlignment:t})},alignmentControls:M})),(0,e.createElement)("div",{className:a},(0,e.createElement)(r.InnerBlocks,{templateLock:!1,renderAppender:b?void 0:function(){return(0,e.createElement)(r.InnerBlocks.ButtonBlockAppender,null)}})))},save:function(){return(0,e.createElement)(r.InnerBlocks.Content,null)}});var H="custom",F=["wp-bootstrap-blocks/column"],j=[{name:"1-1",title:(0,n.__)("2 Columns (1:1)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H25V34H39ZM23 34H9V14H23V34Z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:6}],["wp-bootstrap-blocks/column",{sizeMd:6}]]},{name:"1-2",title:(0,n.__)("2 Columns (1:2)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H20V34H39ZM18 34H9V14H18V34Z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:4}],["wp-bootstrap-blocks/column",{sizeMd:8}]]},{name:"2-1",title:(0,n.__)("2 Columns (2:1)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H30V34H39ZM28 34H9V14H28V34Z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:8}],["wp-bootstrap-blocks/column",{sizeMd:4}]]},{name:"1-1-1",title:(0,n.__)("3 Columns (1:1:1)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",d:"M41 14a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h30a2 2 0 0 0 2-2V14zM28.5 34h-9V14h9v20zm2 0V14H39v20h-8.5zm-13 0H9V14h8.5v20z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:4}],["wp-bootstrap-blocks/column",{sizeMd:4}],["wp-bootstrap-blocks/column",{sizeMd:4}]]}];j=function(t){return t.map((function(t){return function(t){for(var e=1;eo){var l=e.template[o][1];M(t.clientId,l)}})),g({template:t}))}(t.name)},className:_===t.name?"is-active":null},(0,e.createElement)("div",{className:"wp-bootstrap-blocks-template-selector-button-label"},t.title)))})))),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Row options","wp-bootstrap-blocks")},(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("No Gutters","wp-bootstrap-blocks"),checked:f,onChange:function(t){return g({noGutters:t})}}),!f&&(p()?(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Gutters","wp-bootstrap-blocks"),value:z,options:I,onChange:function(t){g({cssGridGutters:t})}}):i()&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Horizontal Gutters","wp-bootstrap-blocks"),value:y,options:L,onChange:function(t){g({horizontalGutters:t})}}),(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Vertical Gutters","wp-bootstrap-blocks"),value:O,options:N,onChange:function(t){g({verticalGutters:t})}}))))),(0,e.createElement)(r.BlockControls,null,!p()&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.AlignmentToolbar,{value:C,label:(0,n.__)("Change horizontal alignment of columns","wp-bootstrap-blocks"),onChange:function(t){return g({alignment:t})},alignmentControls:V}),(0,e.createElement)(r.AlignmentToolbar,{value:E,label:(0,n.__)("Change vertical alignment of columns","wp-bootstrap-blocks"),onChange:function(t){return g({verticalAlignment:t})},alignmentControls:S}))),(0,e.createElement)("div",{className:c},(0,e.createElement)(r.InnerBlocks,{allowedBlocks:F,template:(o=_,a=j.find((function(t){return t.name===o})),a?a.template:[]),templateLock:X(_),orientation:"horizontal"})))},save:function(){return(0,e.createElement)(r.InnerBlocks.Content,null)}});var D=[{label:(0,n.__)("Primary","wp-bootstrap-blocks"),value:"primary",color:O},{label:(0,n.__)("Secondary","wp-bootstrap-blocks"),value:"secondary",color:z}];D=(0,t.applyFilters)("wpBootstrapBlocks.button.styleOptions",D);var R="noreferrer noopener";(0,o.registerBlockType)("wp-bootstrap-blocks/button",{title:(0,n.__)("Button (Bootstrap)","wp-bootstrap-blocks"),icon:_,category:"wp-bootstrap-blocks",keywords:[(0,n.__)("Button","wp-bootstrap-blocks"),(0,n.__)("Bootstrap Button","wp-bootstrap-blocks"),(0,n.__)("Bootstrap","wp-bootstrap-blocks")],example:{},getEditWrapperProps:function(t){return{"data-alignment":t.alignment,"data-style":t.style}},edit:function(t){var o=t.attributes,a=t.className,c=t.isSelected,s=t.setAttributes,i=o.url,p=o.linkTarget,u=o.rel,b=o.text,m=o.style,w=o.alignment,d={backgroundColor:D.length>0?D[0].color:"#007bff"};if(m){var k=D.find((function(t){return t.value===m}));null!=k&&k.color&&(d={backgroundColor:k.color})}return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:a,"data-alignment":w,style:d},(0,e.createElement)(r.RichText,{placeholder:(0,n.__)("Add text...","wp-bootstrap-blocks"),value:b,onChange:function(t){return s({text:t})},allowedFormats:[],keepPlaceholderOnFocus:!0}),(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(l.PanelBody,null,(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Style","wp-bootstrap-blocks"),value:m,options:D,onChange:function(t){s({style:t})}})),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Link settings","wp-bootstrap-blocks")},(0,e.createElement)(l.ToggleControl,{label:(0,n.__)("Open in new tab","wp-bootstrap-blocks"),onChange:function(t){var e=t?"_blank":void 0,o=u;e&&!u?o=R:e||u!==R||(o=void 0),s({linkTarget:e,rel:o})},checked:"_blank"===p}),(0,e.createElement)(l.TextControl,{label:(0,n.__)("Link rel","wp-bootstrap-blocks"),value:u||"",onChange:function(t){s({rel:t})}}))),(0,e.createElement)(r.BlockControls,null,(0,e.createElement)(r.AlignmentToolbar,{value:w,label:(0,n.__)("Change button alignment","wp-bootstrap-blocks"),onChange:function(t){return s({alignment:t})}}))),c&&(0,e.createElement)("form",{className:"wp-block-wp-bootstrap-blocks-button-link",onSubmit:function(t){return t.preventDefault()}},(0,e.createElement)(l.Dashicon,{icon:"admin-links"}),(0,e.createElement)(r.URLInput,{value:i,onChange:function(t){return s({url:t})}}),(0,e.createElement)(l.IconButton,{icon:"editor-break",label:(0,n.__)("Apply","wp-bootstrap-blocks"),type:"submit"})))},save:function(){return null}})}},o={};function l(t){var n=o[t];if(void 0!==n)return n.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,l),r.exports}l.m=e,t=[],l.O=function(e,o,n,r){if(!o){var a=1/0;for(p=0;p=r)&&Object.keys(l.O).every((function(t){return l.O[t](o[s])}))?o.splice(s--,1):(c=!1,r0&&t[p-1][2]>r;p--)t[p]=t[p-1];t[p]=[o,n,r]},l.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},function(){var t={826:0,431:0};l.O.j=function(e){return 0===t[e]};var e=function(e,o){var n,r,a=o[0],c=o[1],s=o[2],i=0;if(a.some((function(e){return 0!==t[e]}))){for(n in c)l.o(c,n)&&(l.m[n]=c[n]);if(s)var p=s(l)}for(e&&e(o);it.length)&&(e=t.length);for(var o=0,l=new Array(e);o0}})).hasChildBlocks;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Fluid","wp-bootstrap-blocks")},(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Fluid","wp-bootstrap-blocks"),checked:p,onChange:function(t){i({isFluid:t})}}),(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Fluid Breakpoint","wp-bootstrap-blocks"),disabled:!p,value:m,options:b,onChange:function(t){i({fluidBreakpoint:t})},help:(0,n.__)("Fluid breakpoints only work with Bootstrap v4.4+. The container will be 100% wide until the specified breakpoint is reached, after which max-widths for each of the higher breakpoints will be applied.","wp-bootstrap-blocks")})),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Margin","wp-bootstrap-blocks")},(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Margin After","wp-bootstrap-blocks"),value:w,options:u,onChange:function(t){i({marginAfter:t})}}))),(0,e.createElement)("div",{className:a},(0,e.createElement)(r.InnerBlocks,{renderAppender:d?void 0:function(){return(0,e.createElement)(r.InnerBlocks.ButtonBlockAppender,null)}})))},save:function(){return(0,e.createElement)(r.InnerBlocks.Content,null)}});var O="#007bff",z="#6c757d",x="#ffffff",M=["label","attributeName","value","setAttributes"],V=[{icon:g,title:(0,n.__)("Align content top","wp-bootstrap-blocks"),align:"top"},{icon:h,title:(0,n.__)("Align content center","wp-bootstrap-blocks"),align:"center"},{icon:k,title:(0,n.__)("Align content bottom","wp-bootstrap-blocks"),align:"bottom"}],S=function(t){var o=t.label,n=t.attributeName,r=t.value,a=t.setAttributes,c=function(t,e){if(null==t)return{};var o,l,n=function(t,e){if(null==t)return{};var o,l,n={},r=Object.keys(t);for(l=0;l=0||(n[o]=t[o]);return n}(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(l=0;l=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(n[o]=t[o])}return n}(t,M);return(0,e.createElement)(l.RangeControl,B({label:o,value:r,onChange:function(t){a(y({},n,t))},min:0,max:12},c))},P=[{name:"primary",color:O},{name:"secondary",color:z}];P=(0,t.applyFilters)("wpBootstrapBlocks.column.bgColorOptions",P);var A=[{label:(0,n.__)("None","wp-bootstrap-blocks"),value:""},{label:(0,n.__)("Small","wp-bootstrap-blocks"),value:"p-2"},{label:(0,n.__)("Medium","wp-bootstrap-blocks"),value:"p-3"},{label:(0,n.__)("Large","wp-bootstrap-blocks"),value:"p-5"}];A=(0,t.applyFilters)("wpBootstrapBlocks.column.paddingOptions",A);function H(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);e&&(l=l.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,l)}return o}(0,o.registerBlockType)("wp-bootstrap-blocks/column",{title:(0,n.__)("Column (Bootstrap)","wp-bootstrap-blocks"),icon:_,category:"wp-bootstrap-blocks",keywords:[(0,n.__)("Column","wp-bootstrap-blocks"),(0,n.__)("Bootstrap Column","wp-bootstrap-blocks"),(0,n.__)("Bootstrap","wp-bootstrap-blocks")],parent:["wp-bootstrap-blocks/row"],getEditWrapperProps:function(t){var e=t.sizeXxl,o=t.sizeXl,l=t.sizeLg,n=t.sizeMd,r=t.sizeSm,a=t.sizeXs,c=t.equalWidthXxl,s=t.equalWidthXl,i=t.equalWidthLg,p=t.equalWidthMd,u=t.equalWidthSm,b=t.equalWidthXs,m=t.bgColor,w=t.padding,d=t.contentVerticalAlignment,k={};if(m){var h=P.find((function(t){return t.name===m}));h&&(k={backgroundColor:h.color})}return{"data-size-xs":c||s||i||p||u||b?0:a,"data-size-sm":c||s||i||p||u?0:r,"data-size-md":c||s||i||p?0:n,"data-size-lg":c||s||i?0:l,"data-size-xl":c||s?0:o,"data-size-xxl":c?0:e,"data-bg-color":m,"data-padding":w,"data-content-vertical-alignment":d,style:k}},edit:function(t){var o=t.attributes,a=t.className,c=t.clientId,u=t.setAttributes,b=(0,s.useSelect)((function(t){return{hasChildBlocks:(0,t("core/block-editor").getBlockOrder)(c).length>0}})).hasChildBlocks,m=o.sizeXxl,w=o.sizeXl,d=o.sizeLg,k=o.sizeMd,h=o.sizeSm,g=o.sizeXs,v=o.equalWidthXxl,f=o.equalWidthXl,_=o.equalWidthLg,C=o.equalWidthMd,E=o.equalWidthSm,B=o.equalWidthXs,y=o.bgColor,O=o.padding,z=o.centerContent,x=o.contentVerticalAlignment;return z&&u({contentVerticalAlignment:"center",centerContent:!1}),(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Column size","wp-bootstrap-blocks"),initialOpen:!1},(0,e.createElement)(S,{label:(0,n.__)("Xs Column count","wp-bootstrap-blocks"),attributeName:"sizeXs",value:g,disabled:B,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Xs equal-width","wp-bootstrap-blocks"),checked:B,onChange:function(t){return u({equalWidthXs:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(S,{label:(0,n.__)("Sm Column count","wp-bootstrap-blocks"),attributeName:"sizeSm",value:h,disabled:E,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Sm equal-width","wp-bootstrap-blocks"),checked:E,onChange:function(t){return u({equalWidthSm:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(S,{label:(0,n.__)("Md Column count","wp-bootstrap-blocks"),attributeName:"sizeMd",value:k,disabled:C,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Md equal-width","wp-bootstrap-blocks"),checked:C,onChange:function(t){return u({equalWidthMd:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(S,{label:(0,n.__)("Lg Column count","wp-bootstrap-blocks"),attributeName:"sizeLg",value:d,disabled:_,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Lg equal-width","wp-bootstrap-blocks"),checked:_,onChange:function(t){return u({equalWidthLg:t})}}),(0,e.createElement)("hr",null),(0,e.createElement)(S,{label:(0,n.__)("Xl Column count","wp-bootstrap-blocks"),attributeName:"sizeXl",value:w,disabled:f,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Xl equal-width","wp-bootstrap-blocks"),checked:f,onChange:function(t){return u({equalWidthXl:t})}}),i()&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("hr",null),(0,e.createElement)(S,{label:(0,n.__)("Xxl Column count","wp-bootstrap-blocks"),attributeName:"sizeXxl",value:m,disabled:v,setAttributes:u}),!p()&&(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("Xxl equal-width","wp-bootstrap-blocks"),checked:v,onChange:function(t){return u({equalWidthXxl:t})}}))),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Background color","wp-bootstrap-blocks"),initialOpen:!1},(0,e.createElement)(l.ColorPalette,{colors:P,value:y,onChange:function(t){if(t){var e=P.find((function(e){return e.color===t}));e&&u({bgColor:e.name})}else u({bgColor:"",centerContent:!1})},disableCustomColors:!0})),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Padding (inside column)","wp-bootstrap-blocks"),initialOpen:!1},(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Size","wp-bootstrap-blocks"),value:O,options:A,onChange:function(t){u({padding:t})}}))),(0,e.createElement)(r.BlockControls,null,(0,e.createElement)(r.AlignmentToolbar,{value:x,label:(0,n.__)("Change vertical alignment of content","wp-bootstrap-blocks"),onChange:function(t){return u({contentVerticalAlignment:t})},alignmentControls:V})),(0,e.createElement)("div",{className:a},(0,e.createElement)(r.InnerBlocks,{templateLock:!1,renderAppender:b?void 0:function(){return(0,e.createElement)(r.InnerBlocks.ButtonBlockAppender,null)}})))},save:function(){return(0,e.createElement)(r.InnerBlocks.Content,null)}});var F="custom",j=["wp-bootstrap-blocks/column"],G=[{name:"1-1",title:(0,n.__)("2 Columns (1:1)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H25V34H39ZM23 34H9V14H23V34Z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:6}],["wp-bootstrap-blocks/column",{sizeMd:6}]]},{name:"1-2",title:(0,n.__)("2 Columns (1:2)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H20V34H39ZM18 34H9V14H18V34Z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:4}],["wp-bootstrap-blocks/column",{sizeMd:8}]]},{name:"2-1",title:(0,n.__)("2 Columns (2:1)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H30V34H39ZM28 34H9V14H28V34Z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:8}],["wp-bootstrap-blocks/column",{sizeMd:4}]]},{name:"1-1-1",title:(0,n.__)("3 Columns (1:1:1)","wp-bootstrap-blocks"),icon:(0,e.createElement)(l.SVG,{width:"48",height:"48",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(l.Path,{fillRule:"evenodd",d:"M41 14a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h30a2 2 0 0 0 2-2V14zM28.5 34h-9V14h9v20zm2 0V14H39v20h-8.5zm-13 0H9V14h8.5v20z"})),templateLock:"all",template:[["wp-bootstrap-blocks/column",{sizeMd:4}],["wp-bootstrap-blocks/column",{sizeMd:4}],["wp-bootstrap-blocks/column",{sizeMd:4}]]}];G=function(t){return t.map((function(t){return function(t){for(var e=1;eo){var l=e.template[o][1];M(t.clientId,l)}})),v({template:t}))}(t.name)},className:f===t.name?"is-active":null},(0,e.createElement)("div",{className:"wp-bootstrap-blocks-template-selector-button-label"},t.title)))})))),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Row options","wp-bootstrap-blocks")},(0,e.createElement)(l.CheckboxControl,{label:(0,n.__)("No Gutters","wp-bootstrap-blocks"),checked:_,onChange:function(t){return v({noGutters:t})}}),!_&&(p()?(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Gutters","wp-bootstrap-blocks"),value:z,options:X,onChange:function(t){v({cssGridGutters:t})}}):i()&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Horizontal Gutters","wp-bootstrap-blocks"),value:y,options:N,onChange:function(t){v({horizontalGutters:t})}}),(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Vertical Gutters","wp-bootstrap-blocks"),value:O,options:I,onChange:function(t){v({verticalGutters:t})}}))))),(0,e.createElement)(r.BlockControls,null,!p()&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.AlignmentToolbar,{value:C,label:(0,n.__)("Change horizontal alignment of columns","wp-bootstrap-blocks"),onChange:function(t){return v({alignment:t})},alignmentControls:V}),(0,e.createElement)(r.AlignmentToolbar,{value:E,label:(0,n.__)("Change vertical alignment of columns","wp-bootstrap-blocks"),onChange:function(t){return v({verticalAlignment:t})},alignmentControls:S}))),(0,e.createElement)("div",{className:c},(0,e.createElement)(r.InnerBlocks,{allowedBlocks:j,template:(o=f,a=G.find((function(t){return t.name===o})),a?a.template:[]),templateLock:q(f),orientation:"horizontal"})))},save:function(){return(0,e.createElement)(r.InnerBlocks.Content,null)}});var R=[{label:(0,n.__)("Primary","wp-bootstrap-blocks"),value:"primary",bgColor:O,color:x},{label:(0,n.__)("Secondary","wp-bootstrap-blocks"),value:"secondary",bgColor:z,color:x}];R=(0,t.applyFilters)("wpBootstrapBlocks.button.styleOptions",R);var Z="noreferrer noopener";(0,o.registerBlockType)("wp-bootstrap-blocks/button",{title:(0,n.__)("Button (Bootstrap)","wp-bootstrap-blocks"),icon:f,category:"wp-bootstrap-blocks",keywords:[(0,n.__)("Button","wp-bootstrap-blocks"),(0,n.__)("Bootstrap Button","wp-bootstrap-blocks"),(0,n.__)("Bootstrap","wp-bootstrap-blocks")],example:{},getEditWrapperProps:function(t){return{"data-alignment":t.alignment,"data-style":t.style}},edit:function(t){var o=t.attributes,a=t.className,c=t.isSelected,s=t.setAttributes,i=o.url,p=o.linkTarget,u=o.rel,b=o.text,m=o.style,w=o.alignment,d={backgroundColor:R.length>0?R[0].bgColor:"#007bff",color:R.length>0?R[0].color:"#ffffff"};if(m){var k=R.find((function(t){return t.value===m}));null!=k&&k.bgColor&&null!=k&&k.color&&(d={backgroundColor:k.bgColor,color:k.color})}return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:a,"data-alignment":w,style:d},(0,e.createElement)(r.RichText,{placeholder:(0,n.__)("Add text...","wp-bootstrap-blocks"),value:b,onChange:function(t){return s({text:t})},allowedFormats:[],keepPlaceholderOnFocus:!0}),(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(l.PanelBody,null,(0,e.createElement)(l.SelectControl,{label:(0,n.__)("Style","wp-bootstrap-blocks"),value:m,options:R,onChange:function(t){s({style:t})}})),(0,e.createElement)(l.PanelBody,{title:(0,n.__)("Link settings","wp-bootstrap-blocks")},(0,e.createElement)(l.ToggleControl,{label:(0,n.__)("Open in new tab","wp-bootstrap-blocks"),onChange:function(t){var e=t?"_blank":void 0,o=u;e&&!u?o=Z:e||u!==Z||(o=void 0),s({linkTarget:e,rel:o})},checked:"_blank"===p}),(0,e.createElement)(l.TextControl,{label:(0,n.__)("Link rel","wp-bootstrap-blocks"),value:u||"",onChange:function(t){s({rel:t})}}))),(0,e.createElement)(r.BlockControls,null,(0,e.createElement)(r.AlignmentToolbar,{value:w,label:(0,n.__)("Change button alignment","wp-bootstrap-blocks"),onChange:function(t){return s({alignment:t})}}))),c&&(0,e.createElement)("form",{className:"wp-block-wp-bootstrap-blocks-button-link",onSubmit:function(t){return t.preventDefault()}},(0,e.createElement)(l.Dashicon,{icon:"admin-links"}),(0,e.createElement)(r.URLInput,{value:i,onChange:function(t){return s({url:t})}}),(0,e.createElement)(l.IconButton,{icon:"editor-break",label:(0,n.__)("Apply","wp-bootstrap-blocks"),type:"submit"})))},save:function(){return null}})}},o={};function l(t){var n=o[t];if(void 0!==n)return n.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,l),r.exports}l.m=e,t=[],l.O=function(e,o,n,r){if(!o){var a=1/0;for(p=0;p=r)&&Object.keys(l.O).every((function(t){return l.O[t](o[s])}))?o.splice(s--,1):(c=!1,r0&&t[p-1][2]>r;p--)t[p]=t[p-1];t[p]=[o,n,r]},l.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},function(){var t={826:0,431:0};l.O.j=function(e){return 0===t[e]};var e=function(e,o){var n,r,a=o[0],c=o[1],s=o[2],i=0;if(a.some((function(e){return 0!==t[e]}))){for(n in c)l.o(c,n)&&(l.m[n]=c[n]);if(s)var p=s(l)}for(e&&e(o);i 0 ? styleOptions[ 0 ].bgColor : DEFAULT_BG_COLOR, + color: styleOptions.length > 0 ? styleOptions[ 0 ].color : DEFAULT_COLOR, }; @@ -73,9 +78,10 @@ const BootstrapButtonEdit = ( { const selectedButtonColor = styleOptions.find( ( styleOption ) => styleOption.value === style ); - if ( selectedButtonColor?.color ) { + if ( selectedButtonColor?.bgColor && selectedButtonColor?.color ) { inlineStyle = { - backgroundColor: selectedButtonColor.color, + backgroundColor: selectedButtonColor.bgColor, + color: selectedButtonColor.color }; } } diff --git a/src/column/edit.js b/src/column/edit.js index d38b32c0..2bf93310 100644 --- a/src/column/edit.js +++ b/src/column/edit.js @@ -23,7 +23,7 @@ import { verticalAlignCenter, verticalAlignTop, } from '../icons'; -import { colors } from '../constants'; +import { bgColors } from '../constants'; const contentVerticalAlignmentControls = [ { @@ -67,8 +67,8 @@ const ColumnSizeRangeControl = ( { }; export let bgColorOptions = [ - { name: 'primary', color: colors.primary }, - { name: 'secondary', color: colors.secondary }, + { name: 'primary', color: bgColors.primary }, + { name: 'secondary', color: bgColors.secondary }, ]; bgColorOptions = applyFilters( diff --git a/src/constants.js b/src/constants.js index 26db8da4..d96a01b6 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,4 +1,8 @@ -export const colors = { +export const bgColors = { primary: '#007bff', secondary: '#6c757d', }; + +export const colors = { + white: '#ffffff' +}; \ No newline at end of file