| 1 |
/* ==================================================== |
| 2 |
Minimal Footer — editor (index.js) |
| 3 |
Block: blockenberg/minimal-footer |
| 4 |
==================================================== */ |
| 5 |
( function () { |
| 6 |
var el = wp.element.createElement; |
| 7 |
var useState = wp.element.useState; |
| 8 |
var Fragment = wp.element.Fragment; |
| 9 |
var MediaUpload = wp.blockEditor.MediaUpload; |
| 10 |
var MediaUploadCheck = wp.blockEditor.MediaUploadCheck; |
| 11 |
var registerBlockType = wp.blocks.registerBlockType; |
| 12 |
var InspectorControls = wp.blockEditor.InspectorControls; |
| 13 |
var useBlockProps = wp.blockEditor.useBlockProps; |
| 14 |
var PanelColorSettings = wp.blockEditor.PanelColorSettings; |
| 15 |
var PanelBody = wp.components.PanelBody; |
| 16 |
var RangeControl = wp.components.RangeControl; |
| 17 |
var SelectControl = wp.components.SelectControl; |
| 18 |
var ToggleControl = wp.components.ToggleControl; |
| 19 |
var TextControl = wp.components.TextControl; |
| 20 |
var Button = wp.components.Button; |
| 21 |
var __ = wp.i18n.__; |
| 22 |
|
| 23 |
var _tc, _tv; |
| 24 |
function getTypoControl() { return _tc || (_tc = window.bkbgTypographyControl); } |
| 25 |
function getTypoCssVars() { return _tv || (_tv = window.bkbgTypoCssVars); } |
| 26 |
|
| 27 |
function uid() { return Math.random().toString(36).slice(2,9); } |
| 28 |
|
| 29 |
/* SVG icons for social platforms */ |
| 30 |
var SOCIAL_ICONS = { |
| 31 |
twitter: '𝕏', |
| 32 |
github: '⌥', |
| 33 |
linkedin: 'in', |
| 34 |
facebook: 'f', |
| 35 |
instagram: '⊡', |
| 36 |
youtube: '▶', |
| 37 |
tiktok: '♪', |
| 38 |
discord: '◎', |
| 39 |
other: '↗', |
| 40 |
}; |
| 41 |
|
| 42 |
function wrapStyle(a) { |
| 43 |
return { |
| 44 |
'--bkbg-mf-pt': a.paddingTop + 'px', |
| 45 |
'--bkbg-mf-pb': a.paddingBottom + 'px', |
| 46 |
'--bkbg-mf-bg': a.footerBg, |
| 47 |
'--bkbg-mf-logo-c': a.logoColor, |
| 48 |
'--bkbg-mf-tag-c': a.taglineColor, |
| 49 |
'--bkbg-mf-hdg-c': a.headingColor, |
| 50 |
'--bkbg-mf-link-c': a.linkColor, |
| 51 |
'--bkbg-mf-soc-c': a.socialColor, |
| 52 |
'--bkbg-mf-div-c': a.dividerColor, |
| 53 |
'--bkbg-mf-copy-c': a.copyrightColor, |
| 54 |
'--bkbg-mf-logo-sz': a.logoSize + 'px', |
| 55 |
'--bkbg-mf-link-sz': a.linkSize + 'px', |
| 56 |
'--bkbg-mf-hdg-sz': a.headingSize + 'px', |
| 57 |
}; |
| 58 |
} |
| 59 |
|
| 60 |
/* Inspector: nav column editor */ |
| 61 |
function NavColumnEditor(props) { |
| 62 |
var col = props.col; var idx = props.index; var total = props.total; |
| 63 |
var onUpdate = props.onUpdate; var onDelete = props.onDelete; var onMove = props.onMove; |
| 64 |
var open = useState(idx === 0); var isOpen = open[0]; var setOpen = open[1]; |
| 65 |
|
| 66 |
function updateLink(li, patch) { |
| 67 |
var links = col.links.map(function(l,i){ return i===li ? Object.assign({},l,patch) : l; }); |
| 68 |
onUpdate(idx, { links: links }); |
| 69 |
} |
| 70 |
function deleteLink(li) { onUpdate(idx, { links: col.links.filter(function(_,i){ return i!==li; }) }); } |
| 71 |
function addLink() { onUpdate(idx, { links: col.links.concat([{id:uid(), label:'Link', url:'#'}]) }); } |
| 72 |
|
| 73 |
return el('div', { style:{ borderBottom:'1px solid #e2e8f0', marginBottom:4 } }, |
| 74 |
el('div', { style:{ display:'flex', alignItems:'center', cursor:'pointer', padding:'6px 0' }, onClick:function(){ setOpen(!isOpen); } }, |
| 75 |
el('span', { style:{ flex:1, fontWeight:600, fontSize:12 } }, col.heading || 'Column ' + (idx+1)), |
| 76 |
el('span', null, isOpen ? '▲' : '▼') |
| 77 |
), |
| 78 |
!isOpen ? null : el('div', { style:{ paddingBottom:8 } }, |
| 79 |
el(TextControl, { label:__('Column heading','blockenberg'), value:col.heading, onChange:function(v){ onUpdate(idx,{heading:v}); } }), |
| 80 |
el('p', { style:{ fontWeight:600, fontSize:11, margin:'6px 0 4px' } }, __('Links','blockenberg')), |
| 81 |
col.links.map(function(l, li) { |
| 82 |
return el('div', { key:l.id, style:{ display:'flex', gap:4, marginBottom:4 } }, |
| 83 |
el(TextControl, { value:l.label, onChange:function(v){ updateLink(li,{label:v}); }, placeholder:'Label' }), |
| 84 |
el(TextControl, { value:l.url, onChange:function(v){ updateLink(li,{url:v}); }, placeholder:'URL' }), |
| 85 |
el(Button, { isSmall:true, isDestructive:true, onClick:function(){ deleteLink(li); } }, '✕') |
| 86 |
); |
| 87 |
}), |
| 88 |
el(Button, { isSmall:true, variant:'tertiary', onClick:addLink, style:{marginBottom:8} }, __('+ Link','blockenberg')), |
| 89 |
el('div', { style:{ display:'flex', gap:4 } }, |
| 90 |
el(Button, { isSmall:true, variant:'secondary', disabled:idx===0, onClick:function(){ onMove(idx,idx-1); } }, '↑'), |
| 91 |
el(Button, { isSmall:true, variant:'secondary', disabled:idx===total-1, onClick:function(){ onMove(idx,idx+1); } }, '↓'), |
| 92 |
el(Button, { isSmall:true, isDestructive:true, onClick:function(){ onDelete(idx); } }, __('Delete','blockenberg')) |
| 93 |
) |
| 94 |
) |
| 95 |
); |
| 96 |
} |
| 97 |
|
| 98 |
registerBlockType('blockenberg/minimal-footer', { |
| 99 |
deprecated: [{ |
| 100 |
save: function (props) { |
| 101 |
var a = props.attributes; |
| 102 |
var blockProps = wp.blockEditor.useBlockProps.save({ className:'bkbg-mf-wrap bkbg-mf-layout--' + a.layout, style:wrapStyle(a) }); |
| 103 |
function renderLogoSave() { |
| 104 |
if (a.logoType === 'image' && a.logoImageUrl) { |
| 105 |
return el('img', { src:a.logoImageUrl, alt:a.logoText, className:'bkbg-mf-logo-img', style:{width:a.logoWidth+'px'} }); |
| 106 |
} |
| 107 |
return el('span', { className:'bkbg-mf-logo-text' }, a.logoText); |
| 108 |
} |
| 109 |
return el('footer', blockProps, |
| 110 |
el('div', { className:'bkbg-mf-main' }, |
| 111 |
el('div', { className:'bkbg-mf-brand' }, |
| 112 |
el('a', { href:a.logoUrl || '/', className:'bkbg-mf-logo' }, renderLogoSave()), |
| 113 |
a.showTagline ? el('p', { className:'bkbg-mf-tagline', style:{ fontSize:(a.taglineSize||14)+'px', fontWeight:(a.fontWeight||400) } }, a.tagline) : null |
| 114 |
), |
| 115 |
el('div', { className:'bkbg-mf-nav' }, |
| 116 |
a.navColumns.map(function(col) { |
| 117 |
return el('div', { key:col.id, className:'bkbg-mf-col' }, |
| 118 |
el('p', { className:'bkbg-mf-col-heading' }, col.heading), |
| 119 |
el('ul', { className:'bkbg-mf-col-links' }, |
| 120 |
col.links.map(function(l){ return el('li', { key:l.id }, el('a', { href:l.url }, l.label)); }) |
| 121 |
) |
| 122 |
); |
| 123 |
}) |
| 124 |
) |
| 125 |
), |
| 126 |
a.dividerStyle === 'line' ? el('hr', { className:'bkbg-mf-divider' }) : null, |
| 127 |
el('div', { className:'bkbg-mf-bottom' }, |
| 128 |
a.showCopyright ? el('span', { className:'bkbg-mf-copy', style:{ fontSize:(a.copyrightFontSize||13)+'px', fontWeight:(a.fontWeight||400) } }, a.copyright) : null, |
| 129 |
el('div', { className:'bkbg-mf-bottom-right' }, |
| 130 |
a.showLegalLinks ? el('div', { className:'bkbg-mf-legal' }, |
| 131 |
a.legalLinks.map(function(l){ return el('a', { key:l.id, href:l.url, className:'bkbg-mf-legal-link' }, l.label); }) |
| 132 |
) : null, |
| 133 |
a.showSocials ? el('div', { className:'bkbg-mf-socials' }, |
| 134 |
a.socials.map(function(s){ return el('a', { key:s.id, href:s.url, className:'bkbg-mf-social bkbg-mf-social--'+s.platform, title:s.label, target:'_blank', rel:'noopener noreferrer' }, SOCIAL_ICONS[s.platform] || '↗'); }) |
| 135 |
) : null |
| 136 |
) |
| 137 |
) |
| 138 |
); |
| 139 |
} |
| 140 |
}], |
| 141 |
edit: function (props) { |
| 142 |
var a = props.attributes; |
| 143 |
var setAttr = props.setAttributes; |
| 144 |
|
| 145 |
/* Nav columns */ |
| 146 |
function updateCol(idx, patch) { |
| 147 |
setAttr({ navColumns: a.navColumns.map(function(c,i){ return i===idx ? Object.assign({},c,patch) : c; }) }); |
| 148 |
} |
| 149 |
function deleteCol(idx) { setAttr({ navColumns: a.navColumns.filter(function(_,i){ return i!==idx; }) }); } |
| 150 |
function moveCol(from, to) { |
| 151 |
var arr = a.navColumns.slice(); arr.splice(to, 0, arr.splice(from, 1)[0]); setAttr({ navColumns: arr }); |
| 152 |
} |
| 153 |
function addCol() { setAttr({ navColumns: a.navColumns.concat([{id:uid(), heading:'New Column', links:[{id:uid(), label:'Link', url:'#'}]}]) }); } |
| 154 |
|
| 155 |
/* Socials */ |
| 156 |
function updateSocial(idx, patch) { |
| 157 |
setAttr({ socials: a.socials.map(function(s,i){ return i===idx ? Object.assign({},s,patch) : s; }) }); |
| 158 |
} |
| 159 |
function deleteSocial(idx) { setAttr({ socials: a.socials.filter(function(_,i){ return i!==idx; }) }); } |
| 160 |
function addSocial() { setAttr({ socials: a.socials.concat([{id:uid(), platform:'other', url:'#', label:'Other'}]) }); } |
| 161 |
|
| 162 |
/* Legal links */ |
| 163 |
function updateLegal(idx, patch) { |
| 164 |
setAttr({ legalLinks: a.legalLinks.map(function(l,i){ return i===idx ? Object.assign({},l,patch) : l; }) }); |
| 165 |
} |
| 166 |
function deleteLegal(idx) { setAttr({ legalLinks: a.legalLinks.filter(function(_,i){ return i!==idx; }) }); } |
| 167 |
|
| 168 |
var blockProps = useBlockProps((function () { |
| 169 |
var _tvf = getTypoCssVars(); |
| 170 |
var s = wrapStyle(a); |
| 171 |
Object.assign(s, _tvf(a.logoTypo, '--bkbg-mf-lg-')); |
| 172 |
Object.assign(s, _tvf(a.taglineTypo, '--bkbg-mf-tg-')); |
| 173 |
Object.assign(s, _tvf(a.headingTypo, '--bkbg-mf-hd-')); |
| 174 |
Object.assign(s, _tvf(a.linkTypo, '--bkbg-mf-lk-')); |
| 175 |
Object.assign(s, _tvf(a.copyrightTypo, '--bkbg-mf-cp-')); |
| 176 |
return { className:'bkbg-mf-wrap bkbg-mf-layout--' + a.layout, style: s }; |
| 177 |
})()); |
| 178 |
|
| 179 |
var inspector = el(InspectorControls, null, |
| 180 |
el(PanelBody, { title:__('Logo','blockenberg'), initialOpen:true }, |
| 181 |
el(SelectControl, { label:__('Logo type','blockenberg'), value:a.logoType, options:[{label:'Text',value:'text'},{label:'Image',value:'image'}], onChange:function(v){ setAttr({logoType:v}); } }), |
| 182 |
a.logoType === 'text' ? el(TextControl, { label:__('Logo text','blockenberg'), value:a.logoText, onChange:function(v){ setAttr({logoText:v}); } }) : |
| 183 |
el(MediaUploadCheck, null, el(MediaUpload, { |
| 184 |
onSelect:function(m){ setAttr({logoImageUrl:m.url, logoImageId:m.id}); }, |
| 185 |
allowedTypes:['image'], value:a.logoImageId, |
| 186 |
render:function(p){ return el(Button, { variant:'secondary', isSmall:true, onClick:p.open }, a.logoImageUrl ? __('Change logo','blockenberg') : __('Select logo','blockenberg')); } |
| 187 |
})), |
| 188 |
el(TextControl, { label:__('Logo link URL','blockenberg'), value:a.logoUrl, onChange:function(v){ setAttr({logoUrl:v}); } }), |
| 189 |
a.logoType === 'image' ? el(RangeControl, { label:__('Logo width (px)','blockenberg'), value:a.logoWidth, min:60, max:300, onChange:function(v){ setAttr({logoWidth:v}); } }) : null, |
| 190 |
el(ToggleControl, { label:__('Show tagline','blockenberg'), checked:a.showTagline, onChange:function(v){ setAttr({showTagline:v}); } }), |
| 191 |
a.showTagline ? el(TextControl, { label:__('Tagline','blockenberg'), value:a.tagline, onChange:function(v){ setAttr({tagline:v}); } }) : null |
| 192 |
), |
| 193 |
el(PanelBody, { title:__('Navigation columns','blockenberg'), initialOpen:false }, |
| 194 |
a.navColumns.map(function(c,i){ return el(NavColumnEditor, { key:c.id, col:c, index:i, total:a.navColumns.length, onUpdate:updateCol, onDelete:deleteCol, onMove:moveCol }); }), |
| 195 |
el(Button, { variant:'primary', onClick:addCol, style:{marginTop:8} }, __('+ Add column','blockenberg')) |
| 196 |
), |
| 197 |
el(PanelBody, { title:__('Social links','blockenberg'), initialOpen:false }, |
| 198 |
el(ToggleControl, { label:__('Show socials','blockenberg'), checked:a.showSocials, onChange:function(v){ setAttr({showSocials:v}); } }), |
| 199 |
a.socials.map(function(s, i) { |
| 200 |
return el('div', { key:s.id, style:{ borderBottom:'1px solid #eee', paddingBottom:8, marginBottom:4 } }, |
| 201 |
el(SelectControl, { label:__('Platform','blockenberg'), value:s.platform, options:[ |
| 202 |
{label:'Twitter / X',value:'twitter'},{label:'GitHub',value:'github'},{label:'LinkedIn',value:'linkedin'}, |
| 203 |
{label:'Facebook',value:'facebook'},{label:'Instagram',value:'instagram'},{label:'YouTube',value:'youtube'}, |
| 204 |
{label:'TikTok',value:'tiktok'},{label:'Discord',value:'discord'},{label:'Other',value:'other'}, |
| 205 |
], onChange:function(v){ updateSocial(i,{platform:v}); } }), |
| 206 |
el(TextControl, { label:__('URL','blockenberg'), value:s.url, onChange:function(v){ updateSocial(i,{url:v}); } }), |
| 207 |
el(TextControl, { label:__('Label','blockenberg'), value:s.label, onChange:function(v){ updateSocial(i,{label:v}); } }), |
| 208 |
el(Button, { isSmall:true, isDestructive:true, onClick:function(){ deleteSocial(i); } }, __('Delete','blockenberg')) |
| 209 |
); |
| 210 |
}), |
| 211 |
el(Button, { isSmall:true, variant:'tertiary', onClick:addSocial }, __('+ Add social','blockenberg')) |
| 212 |
), |
| 213 |
el(PanelBody, { title:__('Bottom bar','blockenberg'), initialOpen:false }, |
| 214 |
el(ToggleControl, { label:__('Show copyright','blockenberg'), checked:a.showCopyright, onChange:function(v){ setAttr({showCopyright:v}); } }), |
| 215 |
a.showCopyright ? el(TextControl, { label:__('Copyright text','blockenberg'), value:a.copyright, onChange:function(v){ setAttr({copyright:v}); } }) : null, |
| 216 |
el(ToggleControl, { label:__('Show legal links','blockenberg'), checked:a.showLegalLinks, onChange:function(v){ setAttr({showLegalLinks:v}); } }), |
| 217 |
a.legalLinks.map(function(l, i) { |
| 218 |
return el('div', { key:l.id, style:{ display:'flex', gap:4, marginBottom:4 } }, |
| 219 |
el(TextControl, { value:l.label, onChange:function(v){ updateLegal(i,{label:v}); }, placeholder:'Label' }), |
| 220 |
el(TextControl, { value:l.url, onChange:function(v){ updateLegal(i,{url:v}); }, placeholder:'URL' }), |
| 221 |
el(Button, { isSmall:true, isDestructive:true, onClick:function(){ deleteLegal(i); } }, '✕') |
| 222 |
); |
| 223 |
}), |
| 224 |
el(Button, { isSmall:true, variant:'tertiary', onClick:function(){ setAttr({ legalLinks: a.legalLinks.concat([{id:uid(), label:'New link', url:'#'}]) }); } }, __('+ Legal link','blockenberg')), |
| 225 |
el(SelectControl, { label:__('Divider style','blockenberg'), value:a.dividerStyle, options:[{label:'Line',value:'line'},{label:'None',value:'none'}], onChange:function(v){ setAttr({dividerStyle:v}); } }), |
| 226 |
el(SelectControl, { label:__('Layout','blockenberg'), value:a.layout, options:[{label:'Logo left, nav right',value:'logo-left-nav-right'},{label:'Logo centered',value:'logo-center'},{label:'Stacked',value:'stacked'}], onChange:function(v){ setAttr({layout:v}); } }) |
| 227 |
), |
| 228 |
el(PanelBody, { title:__('Typography','blockenberg'), initialOpen:false }, |
| 229 |
el( getTypoControl(), { label: __( 'Logo Text', 'blockenberg' ), value: a.logoTypo, onChange: function (v) { setAttr({ logoTypo: v }); } }), |
| 230 |
el( getTypoControl(), { label: __( 'Tagline', 'blockenberg' ), value: a.taglineTypo, onChange: function (v) { setAttr({ taglineTypo: v }); } }), |
| 231 |
el( getTypoControl(), { label: __( 'Column Heading', 'blockenberg' ), value: a.headingTypo, onChange: function (v) { setAttr({ headingTypo: v }); } }), |
| 232 |
el( getTypoControl(), { label: __( 'Nav Link', 'blockenberg' ), value: a.linkTypo, onChange: function (v) { setAttr({ linkTypo: v }); } }), |
| 233 |
el( getTypoControl(), { label: __( 'Copyright', 'blockenberg' ), value: a.copyrightTypo, onChange: function (v) { setAttr({ copyrightTypo: v }); } }) |
| 234 |
), |
| 235 |
el(PanelBody, { title:__('Spacing','blockenberg'), initialOpen:false }, |
| 236 |
el(RangeControl, { label:__('Padding top (px)','blockenberg'), value:a.paddingTop, min:0, max:160, onChange:function(v){ setAttr({paddingTop:v}); } }), |
| 237 |
el(RangeControl, { label:__('Padding bottom (px)','blockenberg'), value:a.paddingBottom, min:0, max:160, onChange:function(v){ setAttr({paddingBottom:v}); } }) |
| 238 |
), |
| 239 |
el(PanelColorSettings, { title:__('Colors','blockenberg'), initialOpen:false, colorSettings:[ |
| 240 |
{label:__('Footer bg','blockenberg'), value:a.footerBg, onChange:function(v){ setAttr({footerBg:v||''}); }}, |
| 241 |
{label:__('Logo color','blockenberg'), value:a.logoColor, onChange:function(v){ setAttr({logoColor:v||''}); }}, |
| 242 |
{label:__('Tagline','blockenberg'), value:a.taglineColor, onChange:function(v){ setAttr({taglineColor:v||''}); }}, |
| 243 |
{label:__('Column headings','blockenberg'), value:a.headingColor, onChange:function(v){ setAttr({headingColor:v||''}); }}, |
| 244 |
{label:__('Nav links','blockenberg'), value:a.linkColor, onChange:function(v){ setAttr({linkColor:v||''}); }}, |
| 245 |
{label:__('Social icons','blockenberg'), value:a.socialColor, onChange:function(v){ setAttr({socialColor:v||''}); }}, |
| 246 |
{label:__('Divider','blockenberg'), value:a.dividerColor, onChange:function(v){ setAttr({dividerColor:v||''}); }}, |
| 247 |
{label:__('Copyright','blockenberg'), value:a.copyrightColor,onChange:function(v){ setAttr({copyrightColor:v||''}); }}, |
| 248 |
] }) |
| 249 |
); |
| 250 |
|
| 251 |
/* Render logo */ |
| 252 |
function renderLogo() { |
| 253 |
if (a.logoType === 'image' && a.logoImageUrl) { |
| 254 |
return el('img', { src:a.logoImageUrl, alt:a.logoText, className:'bkbg-mf-logo-img', style:{ width:a.logoWidth + 'px' } }); |
| 255 |
} |
| 256 |
return el('span', { className:'bkbg-mf-logo-text' }, a.logoText); |
| 257 |
} |
| 258 |
|
| 259 |
return el(Fragment, null, |
| 260 |
inspector, |
| 261 |
el('footer', blockProps, |
| 262 |
el('div', { className:'bkbg-mf-main' }, |
| 263 |
/* Logo + tagline */ |
| 264 |
el('div', { className:'bkbg-mf-brand' }, |
| 265 |
el('a', { href:'#', className:'bkbg-mf-logo', onClick:function(e){ e.preventDefault(); } }, renderLogo()), |
| 266 |
a.showTagline ? el('p', { className:'bkbg-mf-tagline' }, a.tagline) : null |
| 267 |
), |
| 268 |
/* Nav columns */ |
| 269 |
el('div', { className:'bkbg-mf-nav' }, |
| 270 |
a.navColumns.map(function(col) { |
| 271 |
return el('div', { key:col.id, className:'bkbg-mf-col' }, |
| 272 |
el('p', { className:'bkbg-mf-col-heading' }, col.heading), |
| 273 |
el('ul', { className:'bkbg-mf-col-links' }, |
| 274 |
col.links.map(function(l) { |
| 275 |
return el('li', { key:l.id }, el('a', { href:'#', onClick:function(e){ e.preventDefault(); } }, l.label)); |
| 276 |
}) |
| 277 |
) |
| 278 |
); |
| 279 |
}) |
| 280 |
) |
| 281 |
), |
| 282 |
a.dividerStyle === 'line' ? el('hr', { className:'bkbg-mf-divider' }) : null, |
| 283 |
el('div', { className:'bkbg-mf-bottom' }, |
| 284 |
a.showCopyright ? el('span', { className:'bkbg-mf-copy' }, a.copyright) : null, |
| 285 |
el('div', { className:'bkbg-mf-bottom-right' }, |
| 286 |
a.showLegalLinks ? el('div', { className:'bkbg-mf-legal' }, |
| 287 |
a.legalLinks.map(function(l){ return el('a', { key:l.id, href:'#', className:'bkbg-mf-legal-link', onClick:function(e){ e.preventDefault(); } }, l.label); }) |
| 288 |
) : null, |
| 289 |
a.showSocials ? el('div', { className:'bkbg-mf-socials' }, |
| 290 |
a.socials.map(function(s){ return el('a', { key:s.id, href:'#', className:'bkbg-mf-social bkbg-mf-social--'+s.platform, title:s.label, onClick:function(e){ e.preventDefault(); } }, SOCIAL_ICONS[s.platform] || '↗'); }) |
| 291 |
) : null |
| 292 |
) |
| 293 |
) |
| 294 |
) |
| 295 |
); |
| 296 |
}, |
| 297 |
|
| 298 |
save: function (props) { |
| 299 |
var a = props.attributes; |
| 300 |
var blockProps = wp.blockEditor.useBlockProps.save((function () { |
| 301 |
var _tvf = getTypoCssVars(); |
| 302 |
var s = wrapStyle(a); |
| 303 |
Object.assign(s, _tvf(a.logoTypo, '--bkbg-mf-lg-')); |
| 304 |
Object.assign(s, _tvf(a.taglineTypo, '--bkbg-mf-tg-')); |
| 305 |
Object.assign(s, _tvf(a.headingTypo, '--bkbg-mf-hd-')); |
| 306 |
Object.assign(s, _tvf(a.linkTypo, '--bkbg-mf-lk-')); |
| 307 |
Object.assign(s, _tvf(a.copyrightTypo, '--bkbg-mf-cp-')); |
| 308 |
return { className:'bkbg-mf-wrap bkbg-mf-layout--' + a.layout, style: s }; |
| 309 |
})()); |
| 310 |
|
| 311 |
function renderLogoSave() { |
| 312 |
if (a.logoType === 'image' && a.logoImageUrl) { |
| 313 |
return el('img', { src:a.logoImageUrl, alt:a.logoText, className:'bkbg-mf-logo-img', style:{width:a.logoWidth+'px'} }); |
| 314 |
} |
| 315 |
return el('span', { className:'bkbg-mf-logo-text' }, a.logoText); |
| 316 |
} |
| 317 |
|
| 318 |
return el('footer', blockProps, |
| 319 |
el('div', { className:'bkbg-mf-main' }, |
| 320 |
el('div', { className:'bkbg-mf-brand' }, |
| 321 |
el('a', { href:a.logoUrl || '/', className:'bkbg-mf-logo' }, renderLogoSave()), |
| 322 |
a.showTagline ? el('p', { className:'bkbg-mf-tagline' }, a.tagline) : null |
| 323 |
), |
| 324 |
el('div', { className:'bkbg-mf-nav' }, |
| 325 |
a.navColumns.map(function(col) { |
| 326 |
return el('div', { key:col.id, className:'bkbg-mf-col' }, |
| 327 |
el('p', { className:'bkbg-mf-col-heading' }, col.heading), |
| 328 |
el('ul', { className:'bkbg-mf-col-links' }, |
| 329 |
col.links.map(function(l){ return el('li', { key:l.id }, el('a', { href:l.url }, l.label)); }) |
| 330 |
) |
| 331 |
); |
| 332 |
}) |
| 333 |
) |
| 334 |
), |
| 335 |
a.dividerStyle === 'line' ? el('hr', { className:'bkbg-mf-divider' }) : null, |
| 336 |
el('div', { className:'bkbg-mf-bottom' }, |
| 337 |
a.showCopyright ? el('span', { className:'bkbg-mf-copy' }, a.copyright) : null, |
| 338 |
el('div', { className:'bkbg-mf-bottom-right' }, |
| 339 |
a.showLegalLinks ? el('div', { className:'bkbg-mf-legal' }, |
| 340 |
a.legalLinks.map(function(l){ return el('a', { key:l.id, href:l.url, className:'bkbg-mf-legal-link' }, l.label); }) |
| 341 |
) : null, |
| 342 |
a.showSocials ? el('div', { className:'bkbg-mf-socials' }, |
| 343 |
a.socials.map(function(s){ return el('a', { key:s.id, href:s.url, className:'bkbg-mf-social bkbg-mf-social--'+s.platform, title:s.label, target:'_blank', rel:'noopener noreferrer' }, SOCIAL_ICONS[s.platform] || '↗'); }) |
| 344 |
) : null |
| 345 |
) |
| 346 |
) |
| 347 |
); |
| 348 |
} |
| 349 |
}); |
| 350 |
}() ); |
| 351 |
|