PluginProbe ʕ •ᴥ•ʔ
Author Website Templates – Create Writer, Author & Publisher Websites Easily / 1.1.9
Author Website Templates – Create Writer, Author & Publisher Websites Easily v1.1.9
trunk 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9
author-website-templates / build / blocks / child-author / activity-card / index.js
author-website-templates / build / blocks / child-author / activity-card Last commit date
block.json 1 month ago index.asset.php 1 month ago index.js 1 month ago
index.js
1 lines
1 (()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,a=window.wp.components,r=window.wp.i18n,i=window.wp.element,o=window.ReactJSXRuntime,l=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"awt/child-author-activity-card","title":"Activity Card","category":"author-website-templates","icon":"index-card","description":"Individual activity card for the Activities section","keywords":["activity","card","child-author"],"parent":["awt/child-author-activities"],"usesContext":["awt/activityStyle"],"textdomain":"author-website-templates","editorScript":"file:./index.js","attributes":{"imageId":{"type":"number","default":0},"cardStyle":{"type":"string","default":"fun"},"iconSvg":{"type":"string","default":""},"imageUrl":{"type":"string","default":""},"title":{"type":"string","default":"Activity Title"},"description":{"type":"string","default":"Activity description goes here..."},"hoverEffect":{"type":"string","default":"scale","enum":["rotate-left","scale","rotate-right"]},"cardUrl":{"type":"string","default":""},"openInNewTab":{"type":"boolean","default":false}},"supports":{"html":false,"reusable":false},"style":"file:./index.css"}');(0,e.registerBlockType)(l.name,{...l,edit:function({attributes:e,setAttributes:l,context:s}){const{imageId:n,imageUrl:c,title:d,description:h,hoverEffect:p,cardUrl:u,openInNewTab:g,cardStyle:m,iconSvg:x}=e,b="fun"===m,w="elegant"===m;(0,i.useEffect)(()=>{s["awt/activityStyle"]&&s["awt/activityStyle"]!==m&&l({cardStyle:s["awt/activityStyle"]})},[s["awt/activityStyle"],m,l]);const v=e=>{l({imageId:e.id,imageUrl:e.url})},y=(0,t.useBlockProps)({className:w?"block bg-white p-8 rounded-lg shadow-sm border border-gray-100 text-center group hover:shadow-lg transition-all duration-300 "+(u?"cursor-pointer":""):`block bg-white p-8 rounded-xl shadow-lg transition-all duration-300 hover:shadow-2xl ${(()=>{switch(p){case"rotate-left":return"hover:rotate-[-2deg]";case"rotate-right":return"hover:rotate-[2deg]";default:return"hover:scale-105"}})()} ${u?"cursor-pointer":""}`}),f=w?"text-xl font-serif font-bold text-brand-dark mb-3":"text-2xl font-black text-center text-navy mb-2",_=w?"text-brand-gray text-sm leading-relaxed":"text-center text-navy/70";return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(t.InspectorControls,{children:[(0,o.jsx)(a.PanelBody,{title:(0,r.__)("Activity Card Settings","author-website-templates"),initialOpen:!0,children:b?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"sidebar-image-control",style:{marginBottom:"16px"},children:[(0,o.jsx)("p",{style:{marginBottom:"8px",fontWeight:"600"},children:(0,r.__)("Activity Image","author-website-templates")}),(0,o.jsx)(t.MediaUploadCheck,{children:(0,o.jsx)(t.MediaUpload,{onSelect:v,allowedTypes:["image"],value:n,render:({open:e})=>(0,o.jsx)(o.Fragment,{children:c?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("img",{src:c,alt:d,style:{width:"100%",height:"auto",marginBottom:"10px",borderRadius:"8px"}}),(0,o.jsx)(a.Button,{variant:"secondary",onClick:e,style:{width:"100%",marginBottom:"8px"},children:(0,r.__)("Replace Image","author-website-templates")}),(0,o.jsx)(a.Button,{variant:"link",isDestructive:!0,onClick:()=>l({imageId:0,imageUrl:""}),children:(0,r.__)("Remove","author-website-templates")})]}):(0,o.jsx)(a.Button,{variant:"primary",onClick:e,style:{width:"100%"},children:(0,r.__)("Upload Image","author-website-templates")})})})})]}),(0,o.jsx)(a.SelectControl,{label:(0,r.__)("Hover Effect","author-website-templates"),value:p,options:[{label:(0,r.__)("Rotate Left (-2deg)","author-website-templates"),value:"rotate-left"},{label:(0,r.__)("Scale (1.05x)","author-website-templates"),value:"scale"},{label:(0,r.__)("Rotate Right (2deg)","author-website-templates"),value:"rotate-right"}],onChange:e=>l({hoverEffect:e}),help:(0,r.__)("Choose the hover animation for this card","author-website-templates")})]}):(0,o.jsx)(a.TextareaControl,{label:(0,r.__)("SVG Icon Code","author-website-templates"),value:x,onChange:e=>l({iconSvg:e}),help:(0,r.__)("Paste raw SVG code here (e.g. from Heroicons)","author-website-templates"),rows:5})}),(0,o.jsxs)(a.PanelBody,{title:(0,r.__)("Link Settings","author-website-templates"),initialOpen:!1,children:[(0,o.jsx)(a.TextControl,{label:(0,r.__)("Card URL (Optional)","author-website-templates"),value:u,onChange:e=>l({cardUrl:e}),placeholder:"https://example.com",help:(0,r.__)("If provided, the entire card becomes a clickable link","author-website-templates"),type:"url"}),u&&(0,o.jsx)(a.ToggleControl,{label:(0,r.__)("Open in New Tab","author-website-templates"),checked:g,onChange:e=>l({openInNewTab:e})})]})]}),(0,o.jsxs)("div",{...y,children:[u&&(0,o.jsxs)("div",{style:{position:"absolute",top:"10px",right:"10px",background:"#0073aa",color:"white",borderRadius:"4px",padding:"4px 8px",fontSize:"11px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"4px"},children:[(0,o.jsx)("span",{children:"🔗"}),g?"":""]}),b?(0,o.jsx)(t.MediaUploadCheck,{children:(0,o.jsx)(t.MediaUpload,{onSelect:v,allowedTypes:["image"],value:n,render:({open:e})=>(0,o.jsx)("div",{className:"mx-auto mb-4 cursor-pointer",onClick:e,children:c?(0,o.jsx)("img",{src:c,alt:d,className:"mx-auto"}):(0,o.jsx)("div",{className:"bg-gray-200 w-24 h-24 mx-auto flex items-center justify-center rounded",children:(0,o.jsx)(a.Button,{variant:"primary",onClick:e,children:(0,r.__)("Upload","author-website-templates")})})})})}):(0,o.jsx)("div",{className:"w-16 h-16 bg-gray-200 rounded-full flex items-center justify-center mx-auto mb-6 text-brand-dark group-hover:bg-brand-dark group-hover:text-white transition-colors",dangerouslySetInnerHTML:{__html:x||'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>'}}),(0,o.jsx)(t.RichText,{tagName:"h3",className:f,value:d,onChange:e=>l({title:e}),placeholder:(0,r.__)("Activity title...","author-website-templates")}),(0,o.jsx)(t.RichText,{tagName:"p",className:_,value:h,onChange:e=>l({description:e}),placeholder:(0,r.__)("Activity description...","author-website-templates")})]})]})},save:function({attributes:e}){const{imageUrl:a,title:r,description:i,hoverEffect:l,cardUrl:s,openInNewTab:n,cardStyle:c,iconSvg:d}=e,h="fun"===c,p="elegant"===c,u=s?"a":"div",g=s?{href:s,target:n?"_blank":"_self",rel:n?"noopener noreferrer":void 0}:{},m=t.useBlockProps.save({className:p?"block bg-white p-8 rounded-lg shadow-sm border border-gray-100 text-center group hover:shadow-lg transition-all duration-300":`block bg-white p-8 rounded-xl shadow-lg transition-all duration-300 hover:shadow-2xl ${(()=>{switch(l){case"rotate-left":return"hover:rotate-[-2deg]";case"rotate-right":return"hover:rotate-[2deg]";default:return"hover:scale-105"}})()}`}),x=p?"text-xl font-serif font-bold text-brand-dark mb-3":"text-2xl font-black text-center text-navy mb-2",b=p?"text-brand-gray text-sm leading-relaxed":"text-center text-navy/70";return(0,o.jsxs)(u,{...m,...g,children:[h&&a&&(0,o.jsx)("img",{src:a,alt:r,className:"mx-auto mb-4"}),p&&(0,o.jsx)("div",{className:"w-16 h-16 bg-gray-200 rounded-full flex items-center justify-center mx-auto mb-6 text-brand-dark group-hover:bg-brand-dark group-hover:text-white transition-colors",dangerouslySetInnerHTML:{__html:d}}),(0,o.jsx)(t.RichText.Content,{tagName:"h3",className:x,value:r}),(0,o.jsx)(t.RichText.Content,{tagName:"p",className:b,value:i})]})}})})();