| 1 |
( function () { |
| 2 |
var el = window.wp.element.createElement; |
| 3 |
var { registerBlockType } = window.wp.blocks; |
| 4 |
var { InspectorControls, MediaUpload, MediaUploadCheck, PanelColorSettings, useBlockProps } = window.wp.blockEditor; |
| 5 |
var { PanelBody, RangeControl, SelectControl, TextControl, TextareaControl, ToggleControl, Button } = window.wp.components; |
| 6 |
var { __ } = window.wp.i18n; |
| 7 |
|
| 8 |
var _tc; function getTypoControl(){ return _tc || (_tc = window.bkbgTypographyControl); } |
| 9 |
var _tv; function getTypoCssVars(){ return _tv || (_tv = window.bkbgTypoCssVars); } |
| 10 |
|
| 11 |
var LAYOUTS = [{label:'Vertical',value:'vertical'},{label:'Horizontal',value:'horizontal'}]; |
| 12 |
|
| 13 |
function Stars(rating, color) { |
| 14 |
var out = ''; for (var i=1; i<=5; i++) out += (i<=rating?'� |
| 15 |
':'☆'); |
| 16 |
return el('span',{style:{color:color,fontSize:'16px',letterSpacing:'1px'}},out); |
| 17 |
} |
| 18 |
|
| 19 |
function ProductPreview(a) { |
| 20 |
var features = (a.features||'').split('\n').filter(Boolean); |
| 21 |
var isH = a.layoutStyle === 'horizontal'; |
| 22 |
|
| 23 |
var cardStyle = { |
| 24 |
background:a.cardBg, border:'1px solid '+a.cardBorder, |
| 25 |
borderRadius:a.cardRadius+'px', |
| 26 |
boxShadow:a.cardShadow?'0 8px 32px rgba(0,0,0,0.10)':'none', |
| 27 |
overflow:'hidden', display:'flex', flexDirection:isH?'row':'column', |
| 28 |
position:'relative', |
| 29 |
}; |
| 30 |
var imgStyle = { |
| 31 |
background: a.imgBg, |
| 32 |
backgroundImage: a.imageUrl?'url('+a.imageUrl+')':'none', |
| 33 |
backgroundSize:'contain', backgroundPosition:'center', backgroundRepeat:'no-repeat', |
| 34 |
height: isH ? 'auto' : a.imgHeight+'px', |
| 35 |
minHeight: isH ? a.imgHeight+'px' : undefined, |
| 36 |
width: isH ? '40%' : '100%', |
| 37 |
flexShrink: 0, |
| 38 |
display:'flex', alignItems:'center', justifyContent:'center', |
| 39 |
}; |
| 40 |
|
| 41 |
return el('div',{className:'bkprc-card',style:cardStyle}, |
| 42 |
a.showBadge&&a.badge&&el('div',{className:'bkprc-badge',style:{ |
| 43 |
position:'absolute',top:'12px',left:'12px',zIndex:1, |
| 44 |
background:a.badgeBg,color:a.badgeColor, |
| 45 |
borderRadius:'6px',padding:'4px 10px',fontSize:'12px',fontWeight:700, |
| 46 |
}},a.badge), |
| 47 |
|
| 48 |
el('div',{className:'bkprc-img',style:imgStyle}, |
| 49 |
!a.imageUrl&&el('span',{className:'dashicons dashicons-format-image',style:{fontSize:'60px',width:'60px',height:'60px',color:'#d1d5db',lineHeight:1}}), |
| 50 |
), |
| 51 |
|
| 52 |
el('div',{className:'bkprc-body',style:{padding:'24px',flex:1,display:'flex',flexDirection:'column',gap:'10px'}}, |
| 53 |
el('h3',{className:'bkprc-name',style:{margin:0,color:a.nameColor}},a.productName), |
| 54 |
|
| 55 |
a.showRating&&el('div',{style:{display:'flex',alignItems:'center',gap:'8px'}}, |
| 56 |
Stars(a.rating, a.priceColor), |
| 57 |
el('span',{style:{fontSize:'12px',color:'#9ca3af'}},a.ratingCount+' reviews'), |
| 58 |
), |
| 59 |
|
| 60 |
el('div',{style:{display:'flex',alignItems:'baseline',gap:'10px',marginTop:'4px'}}, |
| 61 |
el('span',{className:'bkprc-price',style:{color:a.priceColor}},a.price), |
| 62 |
a.showOriginal&&a.originalPrice&&el('span',{style:{fontSize:'16px',color:a.originalPriceColor,textDecoration:'line-through'}},a.originalPrice), |
| 63 |
), |
| 64 |
|
| 65 |
a.description&&el('p',{className:'bkprc-desc',style:{margin:0,color:a.descColor}},a.description), |
| 66 |
|
| 67 |
a.showFeatures&&features.length>0&&el('ul',{style:{margin:'4px 0 0',padding:'0 0 0 16px',listStyle:'none',display:'flex',flexDirection:'column',gap:'4px'}}, |
| 68 |
features.map(function(f,i){ |
| 69 |
return el('li',{key:i,className:'bkprc-feature',style:{color:a.featureColor,paddingLeft:'6px'}}, |
| 70 |
el('span',{style:{color:a.priceColor,marginRight:'6px',fontWeight:700}},'✓'),f); |
| 71 |
}) |
| 72 |
), |
| 73 |
|
| 74 |
el('div',{style:{display:'flex',gap:'10px',marginTop:'auto',paddingTop:'8px',flexWrap:'wrap'}}, |
| 75 |
el('a',{className:'bkprc-btn bkprc-btn-primary',href:a.btnUrl,style:{flex:1,display:'flex',alignItems:'center',justifyContent:'center',gap:'6px',background:a.btnBg,color:a.btnColor,padding:'12px 20px',borderRadius:a.btnRadius+'px',textAlign:'center'}}, |
| 76 |
el('span',{className:'dashicons dashicons-cart',style:{fontSize:'18px',width:'18px',height:'18px',lineHeight:1}}), |
| 77 |
a.btnLabel), |
| 78 |
a.showSecondBtn&&el('a',{className:'bkprc-btn bkprc-btn-secondary',href:a.secondBtnUrl,style:{flex:1,display:'flex',alignItems:'center',justifyContent:'center',background:a.secondBtnBg,color:a.secondBtnColor,padding:'12px 20px',borderRadius:a.btnRadius+'px',textAlign:'center'}}, |
| 79 |
a.secondBtnLabel), |
| 80 |
), |
| 81 |
), |
| 82 |
); |
| 83 |
} |
| 84 |
|
| 85 |
/* ── deprecated: v1 save (inline font styles, old scalar attrs) ── */ |
| 86 |
var v1Attributes = { |
| 87 |
imageUrl:{type:'string',default:''},imageId:{type:'number',default:0}, |
| 88 |
productName:{type:'string',default:'Premium Wireless Headphones'}, |
| 89 |
description:{type:'string',default:'Crystal-clear audio with active noise cancellation, 30-hour battery life, and premium comfort cushions.'}, |
| 90 |
price:{type:'string',default:'$149.99'},originalPrice:{type:'string',default:'$199.99'}, |
| 91 |
showOriginal:{type:'boolean',default:true},currency:{type:'string',default:''}, |
| 92 |
badge:{type:'string',default:'Best Seller'},showBadge:{type:'boolean',default:true}, |
| 93 |
badgeBg:{type:'string',default:'#f59e0b'},badgeColor:{type:'string',default:'#ffffff'}, |
| 94 |
features:{type:'string',default:'Active Noise Cancellation\n30-hour battery\nBluetooth 5.3\nFoldable design\nCarrying case included'}, |
| 95 |
showFeatures:{type:'boolean',default:true}, |
| 96 |
rating:{type:'number',default:4},ratingCount:{type:'string',default:'128'},showRating:{type:'boolean',default:true}, |
| 97 |
btnLabel:{type:'string',default:'Buy Now'},btnUrl:{type:'string',default:'#'}, |
| 98 |
btnBg:{type:'string',default:'#6c3fb5'},btnColor:{type:'string',default:'#ffffff'},btnRadius:{type:'number',default:10}, |
| 99 |
secondBtnLabel:{type:'string',default:'View Details'},secondBtnUrl:{type:'string',default:'#'}, |
| 100 |
showSecondBtn:{type:'boolean',default:false},secondBtnBg:{type:'string',default:'#f3f4f6'},secondBtnColor:{type:'string',default:'#374151'}, |
| 101 |
layoutStyle:{type:'string',default:'vertical'}, |
| 102 |
cardBg:{type:'string',default:'#ffffff'},cardBorder:{type:'string',default:'#e5e7eb'}, |
| 103 |
cardRadius:{type:'number',default:16},cardShadow:{type:'boolean',default:true}, |
| 104 |
imgHeight:{type:'number',default:260},imgBg:{type:'string',default:'#f9fafb'}, |
| 105 |
nameColor:{type:'string',default:'#1f2937'},priceColor:{type:'string',default:'#6c3fb5'}, |
| 106 |
originalPriceColor:{type:'string',default:'#9ca3af'},descColor:{type:'string',default:'#6b7280'}, |
| 107 |
featureColor:{type:'string',default:'#374151'}, |
| 108 |
nameFontSize:{type:'number',default:20},nameFontWeight:{type:'string',default:'800'}, |
| 109 |
priceFontSize:{type:'number',default:26},descFontSize:{type:'number',default:14}, |
| 110 |
descLineHeight:{type:'number',default:1.6},featureFontSize:{type:'number',default:14}, |
| 111 |
btnFontSize:{type:'number',default:15}, |
| 112 |
}; |
| 113 |
|
| 114 |
var deprecated = [{ |
| 115 |
attributes: v1Attributes, |
| 116 |
save: function({attributes:a}) { |
| 117 |
var features = (a.features||'').split('\n').filter(Boolean); |
| 118 |
var isH = a.layoutStyle === 'horizontal'; |
| 119 |
var cardStyle = { |
| 120 |
background:a.cardBg,border:'1px solid '+a.cardBorder,borderRadius:a.cardRadius+'px', |
| 121 |
boxShadow:a.cardShadow?'0 8px 32px rgba(0,0,0,0.10)':'none', |
| 122 |
overflow:'hidden',display:'flex',flexDirection:isH?'row':'column',position:'relative', |
| 123 |
}; |
| 124 |
var imgStyle = { |
| 125 |
background:a.imgBg,backgroundImage:a.imageUrl?'url('+a.imageUrl+')':'none', |
| 126 |
backgroundSize:'contain',backgroundPosition:'center',backgroundRepeat:'no-repeat', |
| 127 |
height:isH?'auto':a.imgHeight+'px',minHeight:isH?a.imgHeight+'px':undefined, |
| 128 |
width:isH?'40%':'100%',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center', |
| 129 |
}; |
| 130 |
return el('div',{className:'bkprc-card',style:cardStyle}, |
| 131 |
a.showBadge&&a.badge&&el('div',{style:{position:'absolute',top:'12px',left:'12px',zIndex:1,background:a.badgeBg,color:a.badgeColor,borderRadius:'6px',padding:'4px 10px',fontSize:'12px',fontWeight:700}},a.badge), |
| 132 |
|
| 133 |
el('div',{className:'bkprc-img',style:imgStyle}, |
| 134 |
!a.imageUrl&&el('span',{className:'dashicons dashicons-format-image',style:{fontSize:'60px',width:'60px',height:'60px',color:'#d1d5db',lineHeight:1}}), |
| 135 |
), |
| 136 |
|
| 137 |
el('div',{style:{padding:'24px',flex:1,display:'flex',flexDirection:'column',gap:'10px'}}, |
| 138 |
el('h3',{style:{margin:0,fontSize:(a.nameFontSize||20)+'px',fontWeight:a.nameFontWeight||800,color:a.nameColor,lineHeight:1.2}},a.productName), |
| 139 |
|
| 140 |
a.showRating&&el('div',{style:{display:'flex',alignItems:'center',gap:'8px'}}, |
| 141 |
el('span',{style:{color:a.priceColor,fontSize:'16px',letterSpacing:'1px'}},'� |
| 142 |
'.repeat(a.rating)+'☆'.repeat(5-a.rating)), |
| 143 |
el('span',{style:{fontSize:'12px',color:'#9ca3af'}},a.ratingCount+' reviews'), |
| 144 |
), |
| 145 |
|
| 146 |
el('div',{style:{display:'flex',alignItems:'baseline',gap:'10px',marginTop:'4px'}}, |
| 147 |
el('span',{style:{fontSize:(a.priceFontSize||26)+'px',fontWeight:900,color:a.priceColor}},a.price), |
| 148 |
a.showOriginal&&a.originalPrice&&el('span',{style:{fontSize:'16px',color:a.originalPriceColor,textDecoration:'line-through'}},a.originalPrice), |
| 149 |
), |
| 150 |
|
| 151 |
a.description&&el('p',{style:{margin:0,fontSize:(a.descFontSize||14)+'px',color:a.descColor,lineHeight:a.descLineHeight||1.6}},a.description), |
| 152 |
|
| 153 |
a.showFeatures&&features.length>0&&el('ul',{style:{margin:'4px 0 0',padding:'0 0 0 16px',listStyle:'none',display:'flex',flexDirection:'column',gap:'4px'}}, |
| 154 |
features.map(function(f,i){ |
| 155 |
return el('li',{key:i,style:{fontSize:(a.featureFontSize||14)+'px',color:a.featureColor,lineHeight:1.5,paddingLeft:'6px'}}, |
| 156 |
el('span',{style:{color:a.priceColor,marginRight:'6px',fontWeight:700}},'✓'),f); |
| 157 |
}) |
| 158 |
), |
| 159 |
|
| 160 |
el('div',{style:{display:'flex',gap:'10px',marginTop:'auto',paddingTop:'8px',flexWrap:'wrap'}}, |
| 161 |
el('a',{className:'bkprc-btn',href:a.btnUrl,style:{flex:1,display:'flex',alignItems:'center',justifyContent:'center',gap:'6px',background:a.btnBg,color:a.btnColor,padding:'12px 20px',borderRadius:a.btnRadius+'px',fontWeight:700,textDecoration:'none',fontSize:(a.btnFontSize||15)+'px',textAlign:'center'}}, |
| 162 |
el('span',{className:'dashicons dashicons-cart',style:{fontSize:'18px',width:'18px',height:'18px',lineHeight:1}}), |
| 163 |
a.btnLabel), |
| 164 |
a.showSecondBtn&&el('a',{href:a.secondBtnUrl,style:{flex:1,display:'flex',alignItems:'center',justifyContent:'center',background:a.secondBtnBg,color:a.secondBtnColor,padding:'12px 20px',borderRadius:a.btnRadius+'px',fontWeight:600,textDecoration:'none',fontSize:((a.btnFontSize||15)-1)+'px',textAlign:'center'}}, |
| 165 |
a.secondBtnLabel), |
| 166 |
), |
| 167 |
), |
| 168 |
); |
| 169 |
} |
| 170 |
}]; |
| 171 |
|
| 172 |
registerBlockType('blockenberg/product-card', { |
| 173 |
deprecated: deprecated, |
| 174 |
|
| 175 |
edit: function(props) { |
| 176 |
var a = props.attributes; |
| 177 |
var set = props.setAttributes; |
| 178 |
var TC = getTypoControl(); |
| 179 |
var blockProps = useBlockProps((function(){ |
| 180 |
var fn = getTypoCssVars(); |
| 181 |
var s = {}; |
| 182 |
if(fn){ |
| 183 |
Object.assign(s, fn(a.nameTypo||{}, '--bkprc-nm-')); |
| 184 |
Object.assign(s, fn(a.priceTypo||{}, '--bkprc-pr-')); |
| 185 |
Object.assign(s, fn(a.descTypo||{}, '--bkprc-ds-')); |
| 186 |
Object.assign(s, fn(a.featureTypo||{}, '--bkprc-ft-')); |
| 187 |
Object.assign(s, fn(a.btnTypo||{}, '--bkprc-bt-')); |
| 188 |
} |
| 189 |
return { style: s }; |
| 190 |
})()); |
| 191 |
return el('div',blockProps, |
| 192 |
el(InspectorControls,null, |
| 193 |
el(PanelBody,{title:__('Product Info'),initialOpen:true}, |
| 194 |
el(TextControl,{label:__('Product Name'),value:a.productName,onChange:v=>set({productName:v})}), |
| 195 |
el(TextareaControl,{label:__('Description'),value:a.description,rows:3,onChange:v=>set({description:v})}), |
| 196 |
el(TextControl,{label:__('Price'),value:a.price,onChange:v=>set({price:v})}), |
| 197 |
el(TextControl,{label:__('Original Price (crossed out)'),value:a.originalPrice,onChange:v=>set({originalPrice:v})}), |
| 198 |
el(ToggleControl,{label:__('Show Original Price'),checked:a.showOriginal,onChange:v=>set({showOriginal:v}),__nextHasNoMarginBottom:true}), |
| 199 |
), |
| 200 |
el(PanelBody,{title:__('Badge & Rating'),initialOpen:false}, |
| 201 |
el(ToggleControl,{label:__('Show Badge'),checked:a.showBadge,onChange:v=>set({showBadge:v}),__nextHasNoMarginBottom:true}), |
| 202 |
a.showBadge&&el(TextControl,{label:__('Badge Text'),value:a.badge,onChange:v=>set({badge:v})}), |
| 203 |
el(ToggleControl,{label:__('Show Rating'),checked:a.showRating,onChange:v=>set({showRating:v}),__nextHasNoMarginBottom:true}), |
| 204 |
a.showRating&&el(RangeControl,{label:__('Stars (1-5)'),value:a.rating,min:1,max:5,onChange:v=>set({rating:v})}), |
| 205 |
a.showRating&&el(TextControl,{label:__('Review Count'),value:a.ratingCount,onChange:v=>set({ratingCount:v})}), |
| 206 |
), |
| 207 |
el(PanelBody,{title:__('Features List'),initialOpen:false}, |
| 208 |
el(ToggleControl,{label:__('Show Features'),checked:a.showFeatures,onChange:v=>set({showFeatures:v}),__nextHasNoMarginBottom:true}), |
| 209 |
el(TextareaControl,{label:__('Features (one per line)'),value:a.features,rows:6,onChange:v=>set({features:v})}), |
| 210 |
), |
| 211 |
el(PanelBody,{title:__('Buttons'),initialOpen:false}, |
| 212 |
el(TextControl,{label:__('Primary Button Label'),value:a.btnLabel,onChange:v=>set({btnLabel:v})}), |
| 213 |
el(TextControl,{label:__('Primary Button URL'),value:a.btnUrl,onChange:v=>set({btnUrl:v})}), |
| 214 |
el(ToggleControl,{label:__('Second Button'),checked:a.showSecondBtn,onChange:v=>set({showSecondBtn:v}),__nextHasNoMarginBottom:true}), |
| 215 |
a.showSecondBtn&&el(TextControl,{label:__('Second Button Label'),value:a.secondBtnLabel,onChange:v=>set({secondBtnLabel:v})}), |
| 216 |
a.showSecondBtn&&el(TextControl,{label:__('Second Button URL'),value:a.secondBtnUrl,onChange:v=>set({secondBtnUrl:v})}), |
| 217 |
el(RangeControl,{label:__('Button Radius (px)'),value:a.btnRadius,min:0,max:50,onChange:v=>set({btnRadius:v})}), |
| 218 |
), |
| 219 |
el(PanelBody,{title:__('Image'),initialOpen:false}, |
| 220 |
el(MediaUploadCheck,null, |
| 221 |
el(MediaUpload,{onSelect:m=>set({imageUrl:m.url,imageId:m.id}),allowedTypes:['image'],value:a.imageId, |
| 222 |
render:({open})=>el(Button,{onClick:open,variant:'secondary',style:{width:'100%',justifyContent:'center',marginBottom:'8px'}}, |
| 223 |
a.imageUrl?__('Change Image'):__('Select Image')) |
| 224 |
}) |
| 225 |
), |
| 226 |
a.imageUrl&&el(Button,{isDestructive:true,isSmall:true,onClick:()=>set({imageUrl:'',imageId:0})},__('Remove Image')), |
| 227 |
el(RangeControl,{label:__('Image Height (px)'),value:a.imgHeight,min:100,max:600,onChange:v=>set({imgHeight:v})}), |
| 228 |
), |
| 229 |
el(PanelBody,{title:__('Card Style'),initialOpen:false}, |
| 230 |
el(SelectControl,{label:__('Layout'),value:a.layoutStyle,options:LAYOUTS,onChange:v=>set({layoutStyle:v})}), |
| 231 |
el(RangeControl,{label:__('Card Radius (px)'),value:a.cardRadius,min:0,max:32,onChange:v=>set({cardRadius:v})}), |
| 232 |
el(ToggleControl,{label:__('Card Shadow'),checked:a.cardShadow,onChange:v=>set({cardShadow:v}),__nextHasNoMarginBottom:true}), |
| 233 |
), |
| 234 |
el(PanelBody,{title:__('Typography'),initialOpen:false}, |
| 235 |
TC && el(TC, {label:__('Product Name'),typo:a.nameTypo||{},onChange:function(v){set({nameTypo:v});}}), |
| 236 |
TC && el(TC, {label:__('Price'),typo:a.priceTypo||{},onChange:function(v){set({priceTypo:v});}}), |
| 237 |
TC && el(TC, {label:__('Description'),typo:a.descTypo||{},onChange:function(v){set({descTypo:v});}}), |
| 238 |
TC && el(TC, {label:__('Features'),typo:a.featureTypo||{},onChange:function(v){set({featureTypo:v});}}), |
| 239 |
TC && el(TC, {label:__('Buttons'),typo:a.btnTypo||{},onChange:function(v){set({btnTypo:v});}}), |
| 240 |
), |
| 241 |
el(PanelColorSettings,{title:__('Colors'),initialOpen:false,colorSettings:[ |
| 242 |
{label:__('Card Background'),value:a.cardBg,onChange:v=>set({cardBg:v||'#ffffff'})}, |
| 243 |
{label:__('Card Border'),value:a.cardBorder,onChange:v=>set({cardBorder:v||'#e5e7eb'})}, |
| 244 |
{label:__('Image Area BG'),value:a.imgBg,onChange:v=>set({imgBg:v||'#f9fafb'})}, |
| 245 |
{label:__('Product Name'),value:a.nameColor,onChange:v=>set({nameColor:v||'#1f2937'})}, |
| 246 |
{label:__('Price'),value:a.priceColor,onChange:v=>set({priceColor:v||'#6c3fb5'})}, |
| 247 |
{label:__('Original Price'),value:a.originalPriceColor,onChange:v=>set({originalPriceColor:v||'#9ca3af'})}, |
| 248 |
{label:__('Description'),value:a.descColor,onChange:v=>set({descColor:v||'#6b7280'})}, |
| 249 |
{label:__('Feature Text'),value:a.featureColor,onChange:v=>set({featureColor:v||'#374151'})}, |
| 250 |
{label:__('Button BG'),value:a.btnBg,onChange:v=>set({btnBg:v||'#6c3fb5'})}, |
| 251 |
{label:__('Button Text'),value:a.btnColor,onChange:v=>set({btnColor:v||'#ffffff'})}, |
| 252 |
{label:__('Badge BG'),value:a.badgeBg,onChange:v=>set({badgeBg:v||'#f59e0b'})}, |
| 253 |
{label:__('Badge Text'),value:a.badgeColor,onChange:v=>set({badgeColor:v||'#ffffff'})}, |
| 254 |
]}), |
| 255 |
), |
| 256 |
ProductPreview(a), |
| 257 |
); |
| 258 |
}, |
| 259 |
|
| 260 |
save: function({attributes:a}) { |
| 261 |
var fn = getTypoCssVars(); |
| 262 |
var typoStyle = {}; |
| 263 |
if(fn){ |
| 264 |
Object.assign(typoStyle, fn(a.nameTypo||{}, '--bkprc-nm-')); |
| 265 |
Object.assign(typoStyle, fn(a.priceTypo||{}, '--bkprc-pr-')); |
| 266 |
Object.assign(typoStyle, fn(a.descTypo||{}, '--bkprc-ds-')); |
| 267 |
Object.assign(typoStyle, fn(a.featureTypo||{}, '--bkprc-ft-')); |
| 268 |
Object.assign(typoStyle, fn(a.btnTypo||{}, '--bkprc-bt-')); |
| 269 |
} |
| 270 |
var features = (a.features||'').split('\n').filter(Boolean); |
| 271 |
var isH = a.layoutStyle === 'horizontal'; |
| 272 |
var cardStyle = Object.assign({},typoStyle,{ |
| 273 |
background:a.cardBg,border:'1px solid '+a.cardBorder,borderRadius:a.cardRadius+'px', |
| 274 |
boxShadow:a.cardShadow?'0 8px 32px rgba(0,0,0,0.10)':'none', |
| 275 |
overflow:'hidden',display:'flex',flexDirection:isH?'row':'column',position:'relative', |
| 276 |
}); |
| 277 |
var imgStyle = { |
| 278 |
background:a.imgBg,backgroundImage:a.imageUrl?'url('+a.imageUrl+')':'none', |
| 279 |
backgroundSize:'contain',backgroundPosition:'center',backgroundRepeat:'no-repeat', |
| 280 |
height:isH?'auto':a.imgHeight+'px',minHeight:isH?a.imgHeight+'px':undefined, |
| 281 |
width:isH?'40%':'100%',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center', |
| 282 |
}; |
| 283 |
return el('div',{className:'bkprc-card',style:cardStyle}, |
| 284 |
a.showBadge&&a.badge&&el('div',{style:{position:'absolute',top:'12px',left:'12px',zIndex:1,background:a.badgeBg,color:a.badgeColor,borderRadius:'6px',padding:'4px 10px',fontSize:'12px',fontWeight:700}},a.badge), |
| 285 |
|
| 286 |
el('div',{className:'bkprc-img',style:imgStyle}, |
| 287 |
!a.imageUrl&&el('span',{className:'dashicons dashicons-format-image',style:{fontSize:'60px',width:'60px',height:'60px',color:'#d1d5db',lineHeight:1}}), |
| 288 |
), |
| 289 |
|
| 290 |
el('div',{className:'bkprc-body',style:{padding:'24px',flex:1,display:'flex',flexDirection:'column',gap:'10px'}}, |
| 291 |
el('h3',{className:'bkprc-name',style:{margin:0,color:a.nameColor}},a.productName), |
| 292 |
|
| 293 |
a.showRating&&el('div',{style:{display:'flex',alignItems:'center',gap:'8px'}}, |
| 294 |
el('span',{style:{color:a.priceColor,fontSize:'16px',letterSpacing:'1px'}},'� |
| 295 |
'.repeat(a.rating)+'☆'.repeat(5-a.rating)), |
| 296 |
el('span',{style:{fontSize:'12px',color:'#9ca3af'}},a.ratingCount+' reviews'), |
| 297 |
), |
| 298 |
|
| 299 |
el('div',{style:{display:'flex',alignItems:'baseline',gap:'10px',marginTop:'4px'}}, |
| 300 |
el('span',{className:'bkprc-price',style:{color:a.priceColor}},a.price), |
| 301 |
a.showOriginal&&a.originalPrice&&el('span',{style:{fontSize:'16px',color:a.originalPriceColor,textDecoration:'line-through'}},a.originalPrice), |
| 302 |
), |
| 303 |
|
| 304 |
a.description&&el('p',{className:'bkprc-desc',style:{margin:0,color:a.descColor}},a.description), |
| 305 |
|
| 306 |
a.showFeatures&&features.length>0&&el('ul',{style:{margin:'4px 0 0',padding:'0 0 0 16px',listStyle:'none',display:'flex',flexDirection:'column',gap:'4px'}}, |
| 307 |
features.map(function(f,i){ |
| 308 |
return el('li',{key:i,className:'bkprc-feature',style:{color:a.featureColor,paddingLeft:'6px'}}, |
| 309 |
el('span',{style:{color:a.priceColor,marginRight:'6px',fontWeight:700}},'✓'),f); |
| 310 |
}) |
| 311 |
), |
| 312 |
|
| 313 |
el('div',{style:{display:'flex',gap:'10px',marginTop:'auto',paddingTop:'8px',flexWrap:'wrap'}}, |
| 314 |
el('a',{className:'bkprc-btn bkprc-btn-primary',href:a.btnUrl,style:{flex:1,display:'flex',alignItems:'center',justifyContent:'center',gap:'6px',background:a.btnBg,color:a.btnColor,padding:'12px 20px',borderRadius:a.btnRadius+'px',textAlign:'center'}}, |
| 315 |
el('span',{className:'dashicons dashicons-cart',style:{fontSize:'18px',width:'18px',height:'18px',lineHeight:1}}), |
| 316 |
a.btnLabel), |
| 317 |
a.showSecondBtn&&el('a',{className:'bkprc-btn bkprc-btn-secondary',href:a.secondBtnUrl,style:{flex:1,display:'flex',alignItems:'center',justifyContent:'center',background:a.secondBtnBg,color:a.secondBtnColor,padding:'12px 20px',borderRadius:a.btnRadius+'px',textAlign:'center'}}, |
| 318 |
a.secondBtnLabel), |
| 319 |
), |
| 320 |
), |
| 321 |
); |
| 322 |
} |
| 323 |
}); |
| 324 |
}() ); |
| 325 |
|