| 1 |
( function () { |
| 2 |
var el = wp.element.createElement; |
| 3 |
var Fragment = wp.element.Fragment; |
| 4 |
var useState = wp.element.useState; |
| 5 |
var __ = wp.i18n.__; |
| 6 |
var registerBlockType = wp.blocks.registerBlockType; |
| 7 |
var InspectorControls = wp.blockEditor.InspectorControls; |
| 8 |
var MediaUpload = wp.blockEditor.MediaUpload; |
| 9 |
var MediaUploadCheck = wp.blockEditor.MediaUploadCheck; |
| 10 |
var useBlockProps = wp.blockEditor.useBlockProps; |
| 11 |
var PanelBody = wp.components.PanelBody; |
| 12 |
var Button = wp.components.Button; |
| 13 |
var ToggleControl = wp.components.ToggleControl; |
| 14 |
var RangeControl = wp.components.RangeControl; |
| 15 |
var SelectControl = wp.components.SelectControl; |
| 16 |
var TextControl = wp.components.TextControl; |
| 17 |
var ColorPicker = wp.components.ColorPicker; |
| 18 |
var Popover = wp.components.Popover; |
| 19 |
|
| 20 |
var _tc; function getTypoControl() { return _tc || (_tc = window.bkbgTypographyControl); } |
| 21 |
var _tv; function getTypoCssVars() { return _tv || (_tv = window.bkbgTypoCssVars); } |
| 22 |
|
| 23 |
var STYLE_OPTIONS = [ |
| 24 |
{ label: __('Cards', 'blockenberg'), value: 'cards' }, |
| 25 |
{ label: __('Minimal', 'blockenberg'), value: 'minimal' }, |
| 26 |
{ label: __('Inline', 'blockenberg'), value: 'inline' }, |
| 27 |
]; |
| 28 |
var HOVER_OPTIONS = [ |
| 29 |
{ label: __('Lift', 'blockenberg'), value: 'lift' }, |
| 30 |
{ label: __('Glow', 'blockenberg'), value: 'glow' }, |
| 31 |
{ label: __('None', 'blockenberg'), value: 'none' }, |
| 32 |
]; |
| 33 |
var SHADOW_OPTIONS = [ |
| 34 |
{ label: __('None', 'blockenberg'), value: 'none' }, |
| 35 |
{ label: __('Small', 'blockenberg'), value: 'sm' }, |
| 36 |
{ label: __('Medium', 'blockenberg'), value: 'md' }, |
| 37 |
]; |
| 38 |
var PROF_OPTIONS = [ |
| 39 |
{ label: __('Dots', 'blockenberg'), value: 'dots' }, |
| 40 |
{ label: __('Bar', 'blockenberg'), value: 'bar' }, |
| 41 |
{ label: __('Label', 'blockenberg'), value: 'label' }, |
| 42 |
]; |
| 43 |
var PROF_LABELS = ['Beginner', 'Basic', 'Intermediate', 'Advanced', 'Expert']; |
| 44 |
|
| 45 |
function makeId() { return 'ts' + Math.random().toString(36).substr(2, 6); } |
| 46 |
|
| 47 |
function buildWrapStyle(a) { |
| 48 |
var shadow = a.cardShadow === 'sm' ? '0 1px 4px rgba(0,0,0,0.07)' |
| 49 |
: a.cardShadow === 'md' ? '0 4px 16px rgba(0,0,0,0.1)' : 'none'; |
| 50 |
return { |
| 51 |
'--bkbg-ts-shadow': shadow, |
| 52 |
'--bkbg-ts-radius': a.cardRadius + 'px', |
| 53 |
'--bkbg-ts-pad': a.cardPadding + 'px', |
| 54 |
'--bkbg-ts-card-bg': a.cardBg, |
| 55 |
'--bkbg-ts-border': a.cardBorderColor, |
| 56 |
'--bkbg-ts-label-color': a.labelColor, |
| 57 |
'--bkbg-ts-desc-color': a.descColor, |
| 58 |
'--bkbg-ts-cat-color': a.categoryLabelColor, |
| 59 |
'--bkbg-ts-cat-size': a.categoryLabelSize + 'px', |
| 60 |
'--bkbg-ts-accent': a.accentColor, |
| 61 |
'--bkbg-ts-icon-size': a.iconSize + 'px', |
| 62 |
paddingTop: a.paddingTop + 'px', |
| 63 |
paddingBottom: a.paddingBottom + 'px', |
| 64 |
backgroundColor: a.bgColor || undefined |
| 65 |
}; |
| 66 |
} |
| 67 |
|
| 68 |
function renderColorControl(key, label, value, onChange, openKey, setOpenKey) { |
| 69 |
var isOpen = openKey === key; |
| 70 |
return el('div', { key: key, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 0', gap: '8px' } }, |
| 71 |
el('span', { style: { fontSize: '12px', color: '#1e1e1e', flex: 1, lineHeight: 1.4 } }, label), |
| 72 |
el('div', { style: { position: 'relative', flexShrink: 0 } }, |
| 73 |
el('button', { type: 'button', title: value || 'default', onClick: function () { setOpenKey(isOpen ? null : key); }, style: { width: '28px', height: '28px', borderRadius: '4px', border: isOpen ? '2px solid #007cba' : '2px solid #ddd', cursor: 'pointer', padding: 0, background: value || '#cccccc' } }), |
| 74 |
isOpen && el(Popover, { position: 'bottom left', onClose: function () { setOpenKey(null); } }, |
| 75 |
el('div', { style: { padding: '8px' } }, |
| 76 |
el(ColorPicker, { color: value, enableAlpha: true, onChange: onChange }) |
| 77 |
) |
| 78 |
) |
| 79 |
) |
| 80 |
); |
| 81 |
} |
| 82 |
|
| 83 |
/* ── Proficiency indicator ─────────────────────────────────────────────── */ |
| 84 |
function ProfIndicator(props) { |
| 85 |
var level = props.level || 0; /* 1-5 */ |
| 86 |
var style = props.style; |
| 87 |
var color = props.color; |
| 88 |
if (!level || level < 1) return null; |
| 89 |
|
| 90 |
if (style === 'dots') { |
| 91 |
return el('div', { style: { display: 'flex', gap: '3px', justifyContent: 'center', marginTop: '6px' } }, |
| 92 |
[1,2,3,4,5].map(function (n) { |
| 93 |
return el('div', { key: n, style: { width: '6px', height: '6px', borderRadius: '50%', background: n <= level ? color : '#e5e7eb' } }); |
| 94 |
}) |
| 95 |
); |
| 96 |
} |
| 97 |
if (style === 'bar') { |
| 98 |
return el('div', { style: { height: '3px', background: '#e5e7eb', borderRadius: '3px', marginTop: '8px', overflow: 'hidden' } }, |
| 99 |
el('div', { style: { height: '100%', width: ((level / 5) * 100) + '%', background: color, borderRadius: '3px' } }) |
| 100 |
); |
| 101 |
} |
| 102 |
if (style === 'label') { |
| 103 |
return el('span', { style: { fontSize: '10px', color: color, fontWeight: 600, background: color + '18', padding: '2px 6px', borderRadius: '99px', display: 'inline-block', marginTop: '6px' } }, PROF_LABELS[level - 1] || ''); |
| 104 |
} |
| 105 |
return null; |
| 106 |
} |
| 107 |
|
| 108 |
/* ── Single tech item ─────────────────────────────────────────────────── */ |
| 109 |
function TechItem(props) { |
| 110 |
var item = props.item; |
| 111 |
var a = props.a; |
| 112 |
var isCards = a.displayStyle === 'cards'; |
| 113 |
var isInline = a.displayStyle === 'inline'; |
| 114 |
|
| 115 |
var cardStyle = Object.assign({ |
| 116 |
display: 'flex', |
| 117 |
flexDirection: isInline ? 'row' : 'column', |
| 118 |
alignItems: 'center', |
| 119 |
gap: isInline ? '10px' : '6px', |
| 120 |
textDecoration: 'none', |
| 121 |
transition: 'transform 0.22s ease, box-shadow 0.22s ease', |
| 122 |
}, isCards ? { |
| 123 |
background: 'var(--bkbg-ts-card-bg)', |
| 124 |
borderRadius: 'var(--bkbg-ts-radius)', |
| 125 |
padding: 'var(--bkbg-ts-pad)', |
| 126 |
boxShadow: 'var(--bkbg-ts-shadow)', |
| 127 |
border: a.showBorder ? '1px solid var(--bkbg-ts-border)' : 'none', |
| 128 |
} : {}); |
| 129 |
|
| 130 |
var imgEl = item.imageUrl |
| 131 |
? el('img', { src: item.imageUrl, alt: item.name || '', style: { width: 'var(--bkbg-ts-icon-size)', height: 'var(--bkbg-ts-icon-size)', objectFit: 'contain', filter: a.grayscale ? 'grayscale(100%)' : 'none', transition: 'filter 0.22s ease', display: 'block', flexShrink: 0 } }) |
| 132 |
: el('div', { style: { width: 'var(--bkbg-ts-icon-size)', height: 'var(--bkbg-ts-icon-size)', background: '#f3f4f6', borderRadius: '8px', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '10px', color: '#9ca3af', flexShrink: 0 } }, __('Logo', 'blockenberg')); |
| 133 |
|
| 134 |
return el('div', { className: 'bkbg-ts-item bkbg-ts-hover-' + a.hoverEffect + (a.animate ? ' bkbg-ts-anim' : ''), style: cardStyle }, |
| 135 |
imgEl, |
| 136 |
el('div', { style: { display: 'flex', flexDirection: 'column', alignItems: isInline ? 'flex-start' : 'center' } }, |
| 137 |
a.showLabel && el('span', { className: 'bkbg-ts-label', style: { color: 'var(--bkbg-ts-label-color)', textAlign: 'center' } }, item.name), |
| 138 |
a.showDescription && item.description && el('span', { className: 'bkbg-ts-desc', style: { color: 'var(--bkbg-ts-desc-color)', textAlign: 'center' } }, item.description), |
| 139 |
a.showProficiency && item.proficiency |
| 140 |
? el(ProfIndicator, { level: item.proficiency, style: a.proficiencyStyle, color: a.accentColor }) |
| 141 |
: null |
| 142 |
) |
| 143 |
); |
| 144 |
} |
| 145 |
|
| 146 |
registerBlockType('blockenberg/tech-stack', { |
| 147 |
title: __('Tech Stack', 'blockenberg'), |
| 148 |
icon: 'admin-tools', |
| 149 |
category: 'bkbg-business', |
| 150 |
description: __('Showcase your technology stack with category grouping, logos, and proficiency levels.', 'blockenberg'), |
| 151 |
|
| 152 |
edit: function (props) { |
| 153 |
var a = props.attributes; |
| 154 |
var setAttributes = props.setAttributes; |
| 155 |
|
| 156 |
var openColorKeyState = useState(null); |
| 157 |
var openColorKey = openColorKeyState[0]; |
| 158 |
var setOpenColorKey = openColorKeyState[1]; |
| 159 |
|
| 160 |
var blockProps = useBlockProps((function () { |
| 161 |
var _tvf = getTypoCssVars(); |
| 162 |
var s = Object.assign({}, buildWrapStyle(a)); |
| 163 |
if (_tvf) { |
| 164 |
Object.assign(s, _tvf(a.labelTypo, '--bktst-lb-')); |
| 165 |
Object.assign(s, _tvf(a.descTypo, '--bktst-ds-')); |
| 166 |
} |
| 167 |
return { style: s }; |
| 168 |
})()); |
| 169 |
|
| 170 |
function cc(key, label, attrKey) { |
| 171 |
return renderColorControl(key, label, a[attrKey], function (val) { |
| 172 |
var upd = {}; upd[attrKey] = val; setAttributes(upd); |
| 173 |
}, openColorKey, setOpenColorKey); |
| 174 |
} |
| 175 |
|
| 176 |
function setCat(catId, patch) { |
| 177 |
setAttributes({ categories: a.categories.map(function (c) { return c.id === catId ? Object.assign({}, c, patch) : c; }) }); |
| 178 |
} |
| 179 |
function addCat() { |
| 180 |
setAttributes({ categories: a.categories.concat([{ id: makeId(), label: 'New Category', items: [{ id: makeId(), name: 'New Tool', imageUrl: '', imageId: 0, url: '', linkTarget: false, description: '', proficiency: 3 }] }]) }); |
| 181 |
} |
| 182 |
function removeCat(catId) { |
| 183 |
if (a.categories.length <= 1) return; |
| 184 |
setAttributes({ categories: a.categories.filter(function (c) { return c.id !== catId; }) }); |
| 185 |
} |
| 186 |
function addItem(catId) { |
| 187 |
setCat(catId, { items: (a.categories.find(function (c) { return c.id === catId; }).items || []).concat([{ id: makeId(), name: 'New Tool', imageUrl: '', imageId: 0, url: '', linkTarget: false, description: '', proficiency: 3 }]) }); |
| 188 |
} |
| 189 |
function updateItem(catId, itemId, key, val) { |
| 190 |
setCat(catId, { items: a.categories.find(function (c) { return c.id === catId; }).items.map(function (it) { if (it.id !== itemId) return it; var u = Object.assign({}, it); u[key] = val; return u; }) }); |
| 191 |
} |
| 192 |
function removeItem(catId, itemId) { |
| 193 |
var cat = a.categories.find(function (c) { return c.id === catId; }); |
| 194 |
if ((cat.items || []).length <= 1) return; |
| 195 |
setCat(catId, { items: cat.items.filter(function (it) { return it.id !== itemId; }) }); |
| 196 |
} |
| 197 |
|
| 198 |
return el(Fragment, null, |
| 199 |
el(InspectorControls, null, |
| 200 |
el(PanelBody, { title: __('Display', 'blockenberg'), initialOpen: true }, |
| 201 |
el(SelectControl, { label: __('Display style', 'blockenberg'), value: a.displayStyle, options: STYLE_OPTIONS, onChange: function (v) { setAttributes({ displayStyle: v }); } }), |
| 202 |
el(SelectControl, { label: __('Hover effect', 'blockenberg'), value: a.hoverEffect, options: HOVER_OPTIONS, onChange: function (v) { setAttributes({ hoverEffect: v }); } }), |
| 203 |
el(RangeControl, { label: __('Columns', 'blockenberg'), value: a.columns, min: 2, max: 8, onChange: function (v) { setAttributes({ columns: v }); } }), |
| 204 |
el(RangeControl, { label: __('Gap (px)', 'blockenberg'), value: a.gap, min: 8, max: 48, onChange: function (v) { setAttributes({ gap: v }); } }), |
| 205 |
el(RangeControl, { label: __('Category gap (px)', 'blockenberg'), value: a.categoryGap, min: 16, max: 80, onChange: function (v) { setAttributes({ categoryGap: v }); } }), |
| 206 |
el(RangeControl, { label: __('Icon size (px)', 'blockenberg'), value: a.iconSize, min: 24, max: 96, onChange: function (v) { setAttributes({ iconSize: v }); } }), |
| 207 |
el(ToggleControl, { label: __('Show label', 'blockenberg'), checked: a.showLabel, onChange: function (v) { setAttributes({ showLabel: v }); }, __nextHasNoMarginBottom: true }), |
| 208 |
el(ToggleControl, { label: __('Show description', 'blockenberg'), checked: a.showDescription, onChange: function (v) { setAttributes({ showDescription: v }); }, __nextHasNoMarginBottom: true }), |
| 209 |
el(ToggleControl, { label: __('Show category headers', 'blockenberg'), checked: a.showCategories, onChange: function (v) { setAttributes({ showCategories: v }); }, __nextHasNoMarginBottom: true }), |
| 210 |
el(ToggleControl, { label: __('Grayscale logos', 'blockenberg'), checked: a.grayscale, onChange: function (v) { setAttributes({ grayscale: v }); }, __nextHasNoMarginBottom: true }), |
| 211 |
el(ToggleControl, { label: __('Color on hover', 'blockenberg'), checked: a.colorOnHover, onChange: function (v) { setAttributes({ colorOnHover: v }); }, __nextHasNoMarginBottom: true }), |
| 212 |
el(ToggleControl, { label: __('Animate on scroll', 'blockenberg'), checked: a.animate, onChange: function (v) { setAttributes({ animate: v }); }, __nextHasNoMarginBottom: true }) |
| 213 |
), |
| 214 |
el(PanelBody, { title: __('Proficiency', 'blockenberg'), initialOpen: false }, |
| 215 |
el(ToggleControl, { label: __('Show proficiency', 'blockenberg'), checked: a.showProficiency, onChange: function (v) { setAttributes({ showProficiency: v }); }, __nextHasNoMarginBottom: true }), |
| 216 |
a.showProficiency && el(SelectControl, { label: __('Style', 'blockenberg'), value: a.proficiencyStyle, options: PROF_OPTIONS, onChange: function (v) { setAttributes({ proficiencyStyle: v }); } }) |
| 217 |
), |
| 218 |
a.displayStyle === 'cards' && el(PanelBody, { title: __('Card Style', 'blockenberg'), initialOpen: false }, |
| 219 |
el(RangeControl, { label: __('Radius (px)', 'blockenberg'), value: a.cardRadius, min: 0, max: 32, onChange: function (v) { setAttributes({ cardRadius: v }); } }), |
| 220 |
el(RangeControl, { label: __('Padding (px)', 'blockenberg'), value: a.cardPadding, min: 8, max: 48, onChange: function (v) { setAttributes({ cardPadding: v }); } }), |
| 221 |
el(SelectControl, { label: __('Shadow', 'blockenberg'), value: a.cardShadow, options: SHADOW_OPTIONS, onChange: function (v) { setAttributes({ cardShadow: v }); } }), |
| 222 |
el(ToggleControl, { label: __('Show border', 'blockenberg'), checked: a.showBorder, onChange: function (v) { setAttributes({ showBorder: v }); }, __nextHasNoMarginBottom: true }) |
| 223 |
), |
| 224 |
el(PanelBody, { title: __('Typography', 'blockenberg'), initialOpen: false }, |
| 225 |
getTypoControl()({ label: __('Label', 'blockenberg'), value: a.labelTypo, onChange: function (v) { setAttributes({ labelTypo: v }); } }), |
| 226 |
getTypoControl()({ label: __('Description', 'blockenberg'), value: a.descTypo, onChange: function (v) { setAttributes({ descTypo: v }); } }), |
| 227 |
el(RangeControl, { label: __('Category label size (px)', 'blockenberg'), value: a.categoryLabelSize, min: 9, max: 16, onChange: function (v) { setAttributes({ categoryLabelSize: v }); } }) |
| 228 |
), |
| 229 |
el(PanelBody, { title: __('Colors', 'blockenberg'), initialOpen: false }, |
| 230 |
cc('accentColor', __('Accent / proficiency', 'blockenberg'), 'accentColor'), |
| 231 |
cc('cardBg', __('Card background', 'blockenberg'), 'cardBg'), |
| 232 |
cc('labelColor', __('Label text', 'blockenberg'), 'labelColor'), |
| 233 |
cc('descColor', __('Description', 'blockenberg'), 'descColor'), |
| 234 |
cc('catColor', __('Category label', 'blockenberg'), 'categoryLabelColor'), |
| 235 |
cc('cardBorder', __('Card border', 'blockenberg'), 'cardBorderColor'), |
| 236 |
cc('bgColor', __('Section background', 'blockenberg'), 'bgColor') |
| 237 |
), |
| 238 |
el(PanelBody, { title: __('Spacing', 'blockenberg'), initialOpen: false }, |
| 239 |
el(RangeControl, { label: __('Padding top (px)', 'blockenberg'), value: a.paddingTop, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingTop: v }); } }), |
| 240 |
el(RangeControl, { label: __('Padding bottom (px)', 'blockenberg'), value: a.paddingBottom, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingBottom: v }); } }) |
| 241 |
), |
| 242 |
el(PanelBody, { title: __('Categories & Tools', 'blockenberg'), initialOpen: false }, |
| 243 |
a.categories.map(function (cat) { |
| 244 |
return el(PanelBody, { key: cat.id, title: cat.label || __('Category', 'blockenberg'), initialOpen: false }, |
| 245 |
el(TextControl, { label: __('Category name', 'blockenberg'), value: cat.label, onChange: function (v) { setCat(cat.id, { label: v }); } }), |
| 246 |
(cat.items || []).map(function (item) { |
| 247 |
return el('div', { key: item.id, style: { background: '#f9fafb', borderRadius: '8px', padding: '10px', marginBottom: '8px' } }, |
| 248 |
el(MediaUploadCheck, null, |
| 249 |
el(MediaUpload, { |
| 250 |
onSelect: function (media) { setCat(cat.id, { items: (a.categories.find(function (c) { return c.id === cat.id; }).items || []).map(function (it) { return it.id !== item.id ? it : Object.assign({}, it, { imageUrl: media.url, imageId: media.id }); }) }); }, |
| 251 |
allowedTypes: ['image'], value: item.imageId, |
| 252 |
render: function (p) { |
| 253 |
return el('div', { style: { display: 'flex', gap: '8px', alignItems: 'center', marginBottom: '8px' } }, |
| 254 |
item.imageUrl && el('img', { src: item.imageUrl, style: { width: '36px', height: '36px', objectFit: 'contain' } }), |
| 255 |
el(Button, { onClick: p.open, variant: item.imageUrl ? 'secondary' : 'primary', size: 'compact' }, item.imageUrl ? __('Replace logo', 'blockenberg') : __('Upload logo', 'blockenberg')) |
| 256 |
); |
| 257 |
} |
| 258 |
}) |
| 259 |
), |
| 260 |
el(TextControl, { label: __('Name', 'blockenberg'), value: item.name, onChange: function (v) { updateItem(cat.id, item.id, 'name', v); } }), |
| 261 |
a.showDescription && el(TextControl, { label: __('Short description', 'blockenberg'), value: item.description, onChange: function (v) { updateItem(cat.id, item.id, 'description', v); } }), |
| 262 |
a.showProficiency && el(RangeControl, { label: __('Proficiency (1-5)', 'blockenberg'), value: item.proficiency, min: 1, max: 5, onChange: function (v) { updateItem(cat.id, item.id, 'proficiency', v); } }), |
| 263 |
el(TextControl, { label: __('Link URL (optional)', 'blockenberg'), value: item.url, onChange: function (v) { updateItem(cat.id, item.id, 'url', v); } }), |
| 264 |
(cat.items || []).length > 1 && el(Button, { onClick: function () { removeItem(cat.id, item.id); }, variant: 'tertiary', isDestructive: true, size: 'compact' }, __('Remove tool', 'blockenberg')) |
| 265 |
); |
| 266 |
}), |
| 267 |
el(Button, { onClick: function () { addItem(cat.id); }, variant: 'secondary', size: 'compact', style: { marginBottom: '8px' } }, __('+ Add Tool', 'blockenberg')), |
| 268 |
a.categories.length > 1 && el(Button, { onClick: function () { removeCat(cat.id); }, variant: 'tertiary', isDestructive: true, size: 'compact' }, __('Remove category', 'blockenberg')) |
| 269 |
); |
| 270 |
}), |
| 271 |
el(Button, { onClick: addCat, variant: 'primary', style: { marginTop: '8px' } }, __('+ Add Category', 'blockenberg')) |
| 272 |
) |
| 273 |
), |
| 274 |
|
| 275 |
el('div', blockProps, |
| 276 |
el('div', { className: 'bkbg-ts bkbg-ts--' + a.displayStyle, style: { display: 'flex', flexDirection: 'column', gap: a.categoryGap + 'px' } }, |
| 277 |
a.categories.map(function (cat) { |
| 278 |
return el('div', { key: cat.id, className: 'bkbg-ts-cat' }, |
| 279 |
a.showCategories && el('p', { style: { fontSize: 'var(--bkbg-ts-cat-size)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.1em', color: 'var(--bkbg-ts-cat-color)', margin: '0 0 16px' } }, cat.label), |
| 280 |
el('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(' + a.columns + ', 1fr)', gap: a.gap + 'px' } }, |
| 281 |
(cat.items || []).map(function (item) { |
| 282 |
return el(TechItem, { key: item.id, item: item, a: a }); |
| 283 |
}) |
| 284 |
) |
| 285 |
); |
| 286 |
}) |
| 287 |
) |
| 288 |
) |
| 289 |
); |
| 290 |
}, |
| 291 |
|
| 292 |
save: function (props) { |
| 293 |
var a = props.attributes; |
| 294 |
return el('div', wp.blockEditor.useBlockProps.save((function () { |
| 295 |
var _tvf = getTypoCssVars(); |
| 296 |
var s = Object.assign({}, buildWrapStyle(a)); |
| 297 |
if (_tvf) { |
| 298 |
Object.assign(s, _tvf(a.labelTypo, '--bktst-lb-')); |
| 299 |
Object.assign(s, _tvf(a.descTypo, '--bktst-ds-')); |
| 300 |
} |
| 301 |
return { className: 'bkbg-ts-wrapper bkbg-ts--' + a.displayStyle, style: s }; |
| 302 |
})()), |
| 303 |
el('div', { className: 'bkbg-ts', style: { display: 'flex', flexDirection: 'column', gap: a.categoryGap + 'px' } }, |
| 304 |
a.categories.map(function (cat) { |
| 305 |
return el('div', { key: cat.id, className: 'bkbg-ts-cat' }, |
| 306 |
a.showCategories && el('p', { className: 'bkbg-ts-cat-label', style: { fontSize: 'var(--bkbg-ts-cat-size)', color: 'var(--bkbg-ts-cat-color)' } }, cat.label), |
| 307 |
el('div', { className: 'bkbg-ts-grid', style: { display: 'grid', gridTemplateColumns: 'repeat(' + a.columns + ', 1fr)', gap: a.gap + 'px' } }, |
| 308 |
(cat.items || []).map(function (item) { |
| 309 |
var isInline = a.displayStyle === 'inline'; |
| 310 |
var isCards = a.displayStyle === 'cards'; |
| 311 |
var tagName = item.url ? 'a' : 'div'; |
| 312 |
var linkProps = item.url ? { href: item.url, target: item.linkTarget ? '_blank' : undefined, rel: item.linkTarget ? 'noopener noreferrer' : undefined } : {}; |
| 313 |
return el(tagName, Object.assign({ key: item.id, className: 'bkbg-ts-item bkbg-ts-hover-' + a.hoverEffect + (a.animate ? ' bkbg-ts-anim' : '') }, linkProps), |
| 314 |
item.imageUrl && el('img', { src: item.imageUrl, alt: item.name || '', loading: 'lazy', style: { width: 'var(--bkbg-ts-icon-size)', height: 'var(--bkbg-ts-icon-size)', objectFit: 'contain', filter: a.grayscale ? 'grayscale(100%)' : 'none' } }), |
| 315 |
el('div', { className: 'bkbg-ts-label-wrap' }, |
| 316 |
a.showLabel && el('span', { className: 'bkbg-ts-label', style: { color: 'var(--bkbg-ts-label-color)' } }, item.name), |
| 317 |
a.showDescription && item.description && el('span', { className: 'bkbg-ts-desc', style: { color: 'var(--bkbg-ts-desc-color)' } }, item.description), |
| 318 |
a.showProficiency && item.proficiency && (function () { |
| 319 |
if (a.proficiencyStyle === 'dots') { |
| 320 |
return el('div', { className: 'bkbg-ts-prof-dots' }, |
| 321 |
[1,2,3,4,5].map(function (n) { return el('div', { key: n, style: { background: n <= item.proficiency ? a.accentColor : '#e5e7eb' } }); }) |
| 322 |
); |
| 323 |
} |
| 324 |
if (a.proficiencyStyle === 'bar') { |
| 325 |
return el('div', { className: 'bkbg-ts-prof-bar' }, |
| 326 |
el('div', { style: { width: ((item.proficiency / 5) * 100) + '%', background: a.accentColor } }) |
| 327 |
); |
| 328 |
} |
| 329 |
return el('span', { className: 'bkbg-ts-prof-label', style: { color: a.accentColor, background: a.accentColor + '18' } }, PROF_LABELS[item.proficiency - 1] || ''); |
| 330 |
})() |
| 331 |
) |
| 332 |
); |
| 333 |
}) |
| 334 |
) |
| 335 |
); |
| 336 |
}) |
| 337 |
) |
| 338 |
); |
| 339 |
} |
| 340 |
}); |
| 341 |
}() ); |
| 342 |
|