index.js
1 lines
| 1 | (()=>{"use strict";const e=window.wp.blocks,t=window.wp.i18n,a=window.wp.blockEditor,o=window.wp.components,n=window.wp.element,r=window.ReactJSXRuntime,s=({isLocked:e,children:a})=>e?(0,r.jsxs)("div",{style:{position:"relative",opacity:.5},children:[(0,r.jsx)("div",{style:{pointerEvents:"none"},children:a}),(0,r.jsx)("a",{href:"https://rswpthemes.com/author-portfolio-pro-wordpress-theme/",target:"_blank",rel:"noopener noreferrer",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",background:"rgba(255, 255, 255, 0.4)"},title:(0,t.__)("Click to Upgrade to Pro","author-website-templates"),children:(0,r.jsx)("div",{style:{background:"#fff",padding:"6px 12px",borderRadius:"4px",boxShadow:"0 2px 5px rgba(0,0,0,0.1)",fontSize:"12px",fontWeight:"bold",color:"#333"},children:"🔒 Upgrade to Pro"})})]}):a,l=JSON.parse('{"apiVersion":2,"name":"awt/author-pro-events","version":"1.0.0","title":"Events [Author Pro]","category":"awt-blocks","description":"Display a list of upcoming tour dates, events, or workshops.","supports":{"html":false,"anchor":true,"align":["full"]},"attributes":{"blockId":{"type":"string"},"anchor":{"type":"string","default":""},"align":{"type":"string","default":"full"},"sectionBadge":{"type":"string","default":"Tour Dates"},"sectionTitle":{"type":"string","default":"Upcoming Events & Talks"},"sectionDesc":{"type":"string","default":"Join me in person for book signings, workshops, and keynote sessions."},"events":{"type":"array","default":[{"id":1,"day":"12","monthYear":"Oct, 2025","category":"Book Signing","title":"Atomic Habits: The Masterclass","location":"New York Public Library","time":"10:00 AM - 2:00 PM","btnText":"Get Ticket","btnUrl":"#"},{"id":2,"day":"25","monthYear":"Nov, 2025","category":"Keynote Speech","title":"Global Leadership Summit","location":"London, UK","time":"09:00 AM - 5:00 PM","btnText":"Sold Out","btnUrl":""},{"id":3,"day":"05","monthYear":"Dec, 2025","category":"Workshop","title":"Writing Your First Best-Seller","location":"Online (Zoom)","time":"6:00 PM EST","btnText":"Register Free","btnUrl":"#"}]},"bgColor":{"type":"string","default":""},"accentColor":{"type":"string","default":""},"paddingTop":{"type":"number","default":96},"paddingBottom":{"type":"number","default":96}},"textdomain":"author-website-templates","editorScript":"file:./index.js","render":"file:./render.php"}');(0,e.registerBlockType)(l.name,{...l,edit:function({attributes:e,setAttributes:l}){const{blockId:i,sectionBadge:c,sectionTitle:d,sectionDesc:p,events:x,bgColor:m,accentColor:h,paddingTop:g,paddingBottom:u,anchor:b}=e,w=window.awtVars?.isPro||!1;(0,n.useEffect)(()=>{i||l({blockId:`author-pro-events-${Math.floor(1e4*Math.random())}`})},[i,l]);const v=e.anchor?e.anchor:i,y=`\n #${v} .awt-date-text { color: ${h} !important; }\n #${v} .awt-category { color: ${h} !important; }\n #${v} .awt-event-card:hover { border-color: ${h} !important; }\n \n #${v} .awt-event-card:hover .awt-date-text,\n #${v} .awt-event-card:hover .awt-category {\n color: ${h} !important;\n }\n\n ${m?`#${v} { background-color: ${m} !important; }`:""}\n `,f=(0,a.useBlockProps)({className:"awt-author-pro-events relative py-24 bg-paper",id:e.anchor?void 0:i,style:{paddingTop:`${g}px`,paddingBottom:`${u}px`,backgroundColor:m}}),j=(e,t,a)=>{const o=[...x];o[e][t]=a,l({events:o})},C=()=>{const e={id:Date.now(),day:"01",monthYear:"Jan, 2026",category:"Event Category",title:"New Event Title",location:"Location",time:"10:00 AM - 12:00 PM",btnText:"Details",btnUrl:"#"};l({events:[...x,e]})};return(0,r.jsxs)("div",{...f,children:[(0,r.jsx)("style",{children:y}),(0,r.jsxs)(a.InspectorControls,{children:[(0,r.jsxs)(o.PanelBody,{title:(0,t.__)("Content Settings","author-website-templates"),initialOpen:!0,children:[(0,r.jsx)(o.TextControl,{label:(0,t.__)("Section Badge","author-website-templates"),value:c,onChange:e=>l({sectionBadge:e})}),(0,r.jsx)(o.TextControl,{label:(0,t.__)("Section Title","author-website-templates"),value:d,onChange:e=>l({sectionTitle:e})}),(0,r.jsx)(o.TextControl,{label:(0,t.__)("Section Description","author-website-templates"),value:p,onChange:e=>l({sectionDesc:e})})]}),(0,r.jsxs)(o.PanelBody,{title:(0,t.__)("Events","author-website-templates"),initialOpen:!1,children:[x.map((e,a)=>(0,r.jsxs)("div",{className:"mb-6 p-4 border rounded bg-gray-50",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,r.jsxs)("span",{className:"font-bold",children:["Event ",a+1]}),(0,r.jsx)(o.Button,{isDestructive:!0,isSmall:!0,onClick:()=>(e=>{const t=x.filter((t,a)=>a!==e);l({events:t})})(a),children:"Remove"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.TextControl,{label:(0,t.__)("Day","author-website-templates"),value:e.day,onChange:e=>j(a,"day",e),className:"w-1/3"}),(0,r.jsx)(o.TextControl,{label:(0,t.__)("Month/Year","author-website-templates"),value:e.monthYear,onChange:e=>j(a,"monthYear",e),className:"w-2/3"})]}),(0,r.jsx)(o.TextControl,{label:(0,t.__)("Category","author-website-templates"),value:e.category,onChange:e=>j(a,"category",e)}),(0,r.jsx)(o.TextControl,{label:(0,t.__)("Title","author-website-templates"),value:e.title,onChange:e=>j(a,"title",e)}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.TextControl,{label:(0,t.__)("Location","author-website-templates"),value:e.location,onChange:e=>j(a,"location",e),className:"w-1/2"}),(0,r.jsx)(o.TextControl,{label:(0,t.__)("Time","author-website-templates"),value:e.time,onChange:e=>j(a,"time",e),className:"w-1/2"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.TextControl,{label:(0,t.__)("Button Text","author-website-templates"),value:e.btnText,onChange:e=>j(a,"btnText",e),className:"w-1/2"}),(0,r.jsx)(o.TextControl,{label:(0,t.__)("Button URL","author-website-templates"),value:e.btnUrl,onChange:e=>j(a,"btnUrl",e),className:"w-1/2"})]})]},a)),(0,r.jsx)(s,{isLocked:!w,children:(0,r.jsx)(o.Button,{variant:"primary",onClick:C,className:"w-full justify-center",children:(0,t.__)("Add New Event","author-website-templates")})})]})]}),(0,r.jsxs)(a.InspectorControls,{group:"styles",children:[(0,r.jsxs)(o.PanelBody,{title:(0,t.__)("Spacing","author-website-templates"),initialOpen:!0,children:[(0,r.jsx)(o.RangeControl,{label:(0,t.__)("Top Padding (px)","author-website-templates"),value:g,onChange:e=>l({paddingTop:e}),min:0,max:300}),(0,r.jsx)(o.RangeControl,{label:(0,t.__)("Bottom Padding (px)","author-website-templates"),value:u,onChange:e=>l({paddingBottom:e}),min:0,max:300})]}),(0,r.jsx)(s,{isLocked:!w,children:(0,r.jsx)(a.PanelColorSettings,{title:(0,t.__)("Colors","author-website-templates"),initialOpen:!0,colorSettings:[{value:m,onChange:e=>l({bgColor:e}),label:(0,t.__)("Section Background","author-website-templates")},{value:h,onChange:e=>l({accentColor:e}),label:(0,t.__)("Accent Color","author-website-templates")}]})})]}),(0,r.jsxs)("div",{className:"max-w-5xl mx-auto px-6 lg:px-8",children:[(0,r.jsxs)("div",{className:"text-center mb-16",children:[(0,r.jsx)(a.RichText,{tagName:"span",className:"font-bold text-xs uppercase tracking-widest awt-category block mb-2",value:c,onChange:e=>l({sectionBadge:e}),placeholder:"Badge"}),(0,r.jsx)(a.RichText,{tagName:"h2",className:"text-4xl font-serif font-bold text-primary mt-2",value:d,onChange:e=>l({sectionTitle:e}),placeholder:(0,t.__)("Section Title...","author-website-templates")}),(0,r.jsx)(a.RichText,{tagName:"p",className:"text-secondary mt-4 max-w-2xl mx-auto",value:p,onChange:e=>l({sectionDesc:e}),placeholder:(0,t.__)("Section Description...","author-website-templates")})]}),(0,r.jsxs)("div",{className:"space-y-6",children:[x.map((e,t)=>(0,r.jsxs)("div",{className:"awt-event-card bg-white p-6 md:p-8 rounded-xl border border-gray-100 shadow-sm hover:shadow-lg transition duration-300 flex flex-col md:flex-row items-center gap-6 md:gap-12 group",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center min-w-[80px] text-center",children:[(0,r.jsx)(a.RichText,{tagName:"span",className:"text-3xl font-serif font-bold text-primary transition awt-date-text group-hover:text-accent",value:e.day,onChange:e=>j(t,"day",e),placeholder:"DD"}),(0,r.jsx)(a.RichText,{tagName:"span",className:"text-xs font-bold text-gray-400 uppercase tracking-wider",value:e.monthYear,onChange:e=>j(t,"monthYear",e),placeholder:"Month, Year"})]}),(0,r.jsxs)("div",{className:"flex-1 text-center md:text-left border-t md:border-t-0 md:border-l border-gray-100 pt-4 md:pt-0 md:pl-10 w-full",children:[(0,r.jsx)(a.RichText,{tagName:"span",className:"text-xs font-bold awt-category text-accent uppercase mb-1 block",value:e.category,onChange:e=>j(t,"category",e),placeholder:"Category"}),(0,r.jsx)(a.RichText,{tagName:"h3",className:"text-xl font-bold text-primary mb-2",value:e.title,onChange:e=>j(t,"title",e),placeholder:"Event Title"}),(0,r.jsxs)("div",{className:"flex flex-wrap justify-center md:justify-start gap-4 text-sm text-secondary",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("i",{className:"fas fa-map-marker-alt text-gray-400"}),(0,r.jsx)(a.RichText,{tagName:"span",value:e.location,onChange:e=>j(t,"location",e),placeholder:"Location"})]}),(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("i",{className:"far fa-clock text-gray-400"}),(0,r.jsx)(a.RichText,{tagName:"span",value:e.time,onChange:e=>j(t,"time",e),placeholder:"Time"})]})]})]}),e.btnUrl?(0,r.jsx)("button",{className:"px-6 py-3 border border-primary bg-white text-primary font-bold text-xs uppercase rounded hover:bg-primary hover:text-white transition whitespace-nowrap",children:e.btnText}):(0,r.jsx)("span",{className:"px-6 py-3 border border-primary bg-white text-primary font-bold text-xs uppercase rounded hover:bg-primary hover:text-white transition whitespace-nowrap",children:e.btnText||"Sold Out"})]},t)),(0,r.jsx)(s,{isLocked:!w,children:(0,r.jsxs)("div",{role:"button",onClick:C,className:"w-full border-2 border-dashed border-gray-300 rounded-xl p-8 flex flex-col items-center justify-center text-gray-400 hover:border-primary hover:text-primary hover:bg-gray-50 transition cursor-pointer group",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded-full bg-gray-100 flex items-center justify-center group-hover:bg-white transition mb-3",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),(0,r.jsx)("span",{className:"font-bold text-sm uppercase tracking-wider",children:(0,t.__)("Add New Event","author-website-templates")})]})})]})]})]})}})})(); |