PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.7
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.7
2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 All 107 releases
b-blocks / build / cards / view.js

view.js in bBlocks – Essential Gutenberg Blocks & Patterns Collection 2.1.7, at build/cards/view.js

1 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";const t=window.ReactDOM,e=t=>{try{const e=new URL(t);return["http:","https:"].includes(e.protocol)?e.toString():null}catch(e){return"string"==typeof t&&t.startsWith("/")&&!t.startsWith("//")?t:null}},n=t=>{const n=(new DOMParser).parseFromString(t,"text/html"),r=["b","strong","i","em","span","a","br"],a=["style","href","target","rel","class"];return n.body.querySelectorAll("*").forEach((t=>{r.includes(t.tagName.toLowerCase())?[...t.attributes].forEach((n=>{if(a.includes(n.name)||t.removeAttribute(n.name),"href"===n.name){const r=e(n.value);r?t.setAttribute("href",r):t.removeAttribute("href")}})):t.remove()})),n.body.innerHTML};window.React;const r="linear-gradient(135deg, #0040E3, #18D4FD)",a=(t,e)=>{return null==(n=e)||""===n||Array.isArray(n)&&0===n.length||"object"==typeof n&&0===Object.keys(n).length||"string"==typeof n&&""===n.trim()||"number"==typeof n&&0===n?"":`${t}: ${e};`;var n},o=t=>{const{side:e=2,vertical:n="0px",horizontal:r="0px",top:a="0px",right:o="0px",bottom:i="0px",left:l="0px"}=t||{};return 2===e?`${n} ${r}`:`${a} ${o} ${i} ${l}`},i=(t,e,n=!0)=>{const{fontFamily:r="Default",fontCategory:o="sans-serif",fontVariant:i=400,fontWeight:l,isUploadFont:s=!0,fontSize:c={desktop:null,tablet:null,mobile:null},fontStyle:d,textTransform:$,textDecoration:g,lineHeight:m,letterSpace:u}=e||{},p=!n||!r||"Default"===r,h=c?.desktop||c,b=c?.tablet||h,y=c?.mobile||b,x=t=>{const e=String(t);return["px","em","rem","%","vh","vw"].some((t=>e.endsWith(t)))?e:"number"==typeof t?`${e}px`:""},f=`\n\t\t${p?"":`font-family: '${r}', ${o};`}\n\t\t${a("font-weight",l)}\n\t\t${a("font-size",x(h))}\n\t\t${a("font-style",d)}\n\t\t${a("text-transform",$)}\n\t\t${a("text-decoration",g)}\n\t\t${a("line-height",m)}\n\t\t${a("letter-spacing",u)}\n\t`,j=i&&400!==i?"400i"===i?":ital@1":i?.includes("00i")?`: ital, wght@1, ${i?.replace("00i","00")} `:`: wght@${i} `:"",k=p?"":`https://fonts.googleapis.com/css2?family=${r?.split(" ").join("+")}${j.replace(/ /g,"")}&display=swap`;return{googleFontLink:!s||p?"":`@import url(${k});`,styles:`${t}{\n\t\t\t${f}\n\t\t}\n\t\t@media only screen and (max-width: 1024px) {\n\t\t\t${t}{\n\t\t\t\t${a("font-size",x(b))}\n\t\t\t}\n\t\t}\n\t\t@media only screen and (max-width: 640px) {\n\t\t\t${t}{\n\t\t\t\t${a("font-size",x(y))}\n\t\t\t}\n\t\t}`.replace(/\s+/g," ").trim()}},l="bBlocksCards",s=window.ReactJSXRuntime,c=({attributes:t,id:n})=>{const{cards:c=[],columnGap:d,rowGap:$,textAlign:g,padding:m,imgHeight:u,catTypo:p,catMargin:h,titleTypo:b,titleMargin:y,descTypo:x,imgWidth:f,imgAlign:j,layout:k}=t,w=`#${n}`,v=`${w} .${l} .${l}-card`,D=`${v} .cardDetails`;return(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n\t\t${i("",p)?.googleFontLink}\n\t\t${i("",b)?.googleFontLink}\n\t\t${i("",x)?.googleFontLink}\n\t\t${i(`${D} .${l}-cardCategory`,p)?.styles}\n\t\t${i(`${v} .${l}-cardTitle`,b)?.styles}\n\t\t${i(`${v} .cardDescription`,x)?.styles}\n\n\t\t${w} .${l}{\n\t\t\tgrid-gap: ${$} ${d};\n\t\t}\n\t\t${v} .${l}-cardImage{\n\t\t\t${a("width",f?`calc( ${f} - 30px)`:"")}\n\t\t\t${a("height",u)}\n\t\t\t${"vertical"===k?(L=j,"left"===L?"margin-inline-end: auto;":"center"===L?"margin-inline: auto;":"margin-inline-start: auto;"):""}\n\t\t}\n\t\t${D}{\n\t\t\ttext-align: ${g};\n\t\t\tpadding: ${o(m)};\n\t\t}\n\t\t${D} .${l}-cardCategory{\n\t\t\tmargin: ${o(h)};\n\t\t}\n\t\t${v} .${l}-cardTitle{\n\t\t\tmargin: ${o(y)};\n\t\t}\n\n\t\t${c.map(((t,o)=>{const{background:i,imgBorder:s,catColor:c,titleColor:d,descColor:$}=t,g=`#${n} #${l}-card-${o}`;return`\n\t\t\t\t${g} .${l}-card{\n\t\t\t\t\t${((t,n=!0,o=!0,i=!0)=>{const{type:l="solid",color:s="",gradient:c=r,image:d={},position:$="center center",attachment:g="",repeat:m="no-repeat",size:u="",overlayColor:p=""}=t||{};return"gradient"===l&&o?a("background",c):"image"===l&&i?`background: ${(t=>{const n=e(t);return n?`url('${n.replace(/['"()]/g,"")}')`:"none"})(d?.url)};\n\t\t\t\t${a("background-color",p)}\n\t\t\t\t${a("background-position",$)}\n\t\t\t\t${a("background-size",u)}\n\t\t\t\t${a("background-repeat",m)}\n\t\t\t\t${a("background-attachment",g)}\n\t\t\t\t${a("background-repeat",m)}\n\t\t\t\tbackground-blend-mode: overlay;`:n&&a("background",s)})(i)}\n\t\t\t\t}\n\t\t\t\t${g} .${l}-cardImage{\n\t\t\t\t\t${(t=>{const{width:e="",style:n="solid",color:r="",side:o="all",radius:i=""}=t||{},l=t=>{const e=o?.toLowerCase();return e?.includes("all")||e?.includes(t)},s=`${e} ${n} ${r}`;return`\n\t\t${e&&0!==parseInt(e)?["top","right","bottom","left"].map((t=>l(t)?`border-${t}: ${s};`:"")).join(""):""}\n\t\t${a("border-radius",i)}\n\t`})(s)}\n\t\t\t\t}\n\t\t\t\t${g} .cardDetails .${l}-cardCategory{\n\t\t\t\t\tcolor: ${c};\n\t\t\t\t}\n\t\t\t\t${g} .${l}-cardTitle{\n\t\t\t\t\tcolor: ${d};\n\t\t\t\t}\n\t\t\t\t${g} .${l}-cardDescription{\n\t\t\t\t\tcolor: ${$};\n\t\t\t\t}\n\t\t\t`})).join(" ")}\n\t\t`.replace(/\s+/g," ")}});var L};document.addEventListener("DOMContentLoaded",(()=>{document.querySelectorAll(".wp-block-b-blocks-cards").forEach((e=>{const r=JSON.parse(e.dataset.attributes),{cards:a=[],columns:o,layout:i,link:$={},imgPos:g,isCat:m,isTitle:u,titlePos:p,isDesc:h}=r,{target:b="_self",element:y="card"}=$;(0,t.createRoot)(e).render((0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c,{attributes:r,id:e.id}),(0,s.jsx)("div",{className:`${l} ${i||"vertical"} columns-${o.desktop} columns-tablet-${o.tablet} columns-mobile-${o.mobile}`,children:a.map(((t,e)=>{const{img:r,cat:a,title:o,desc:i,link:c=""}=t,$=()=>u&&(0,s.jsx)(d,{enabled:"title"===y,url:c,target:b,children:(0,s.jsx)("h3",{className:`${l}-cardTitle`,dangerouslySetInnerHTML:{__html:n(o)}})}),x=()=>r?.url&&(0,s.jsx)(d,{enabled:"image"===y,url:c,target:b,children:(0,s.jsxs)("figure",{className:`${l}-cardImage`,children:[(0,s.jsx)("img",{src:r.url,alt:r?.alt||r?.title}),"image"===p&&(0,s.jsx)($,{})]})});return(0,s.jsx)("div",{id:`${l}-card-${e}`,children:(0,s.jsx)(d,{enabled:"card"===y,url:c,target:b,children:(0,s.jsxs)("div",{className:`${l}-card ${"bottom"===g?"bottomImg":"topImg"}`,children:["top"===g&&(0,s.jsx)(x,{}),(0,s.jsxs)("div",{className:"cardDetails",children:[m&&(0,s.jsx)("h6",{className:`${l}-cardCategory`,dangerouslySetInnerHTML:{__html:n(a)}}),"content"===p&&(0,s.jsx)($,{}),h&&(0,s.jsx)("p",{className:`${l}-cardDescription`,dangerouslySetInnerHTML:{__html:n(i)}})]}),"bottom"===g&&(0,s.jsx)(x,{})]})})},e)}))})]})),e?.removeAttribute("data-attributes")}))}));const d=({enabled:t,url:n,target:r,children:a})=>t&&n?(0,s.jsx)("a",{className:"cardLink",href:e(n),target:r,children:a}):a})();