701const textBtnHoverSelector = `${itemSelector}:hover .t-btnflex__text, ${itemSelector}:hover .t-store__card__btn-text`;702let css = '';703704if (textBaseRules?.length) {705css += `${textBtnSelector}{${textBaseRules.join('')}}`;706}707708if (textHoverRules?.length) {709css += `\n${textBtnHoverSelector}{${textHoverRules.join('')}}`;710}711712if (textMobileRules?.length) {
css += `\n@media screen and (max-width:480px){${textBtnSelector}{${textMobileRules.join('')}}}`; } return css;}/** * Создает CSS для внешнего вида кнопки * @param {string} recid * @param {string} itemSelector * @param {Record<string, string>} styles * @param {string[]} excludedStyles * @returns {string} */function t_store_createButtonAppereanceCss(recid, itemSelector, styles, excludedStyles) { // Универсальная схема маппинга: ключ конфига -> CSS свойство const cssPropertiesMap = { bgcolor: 'background-color', radius: 'border-radius', wrap: 'white-space', shadow: 'box-shadow', fontweight: 'font-weight', uppercase: 'text-transform', fontsize: 'font-size', fontfamily: 'font-family', lineheight: 'line-height', letterspacing: 'letter-spacing', gap: 'gap', padding: 'padding', iconposition: 'flex-direction', }; if (Array.isArray(excludedStyles) && excludedStyles.length) { const excludedStylesSet = new Set(excludedStyles); for (const key in cssPropertiesMap) { if (excludedStylesSet.has(key)) delete cssPropertiesMap[key]; } } // Построение базовых, hover и мобильных правил const baseRules = t_store_buildBaseButtonCssRules(cssPropertiesMap, styles); const hoverRules = t_store_buildHoverCssRules(styles); const mobileRules = t_store_buildMobileCssRules(cssPropertiesMap, styles); const selector = `#rec${recid} ${itemSelector}`; const hoverSelector = `#rec${recid} ${itemSelector}:hover`; let css = ''; if (baseRules?.length) { css += `${selector}{${baseRules.join('')}}`; } if (hoverRules?.length) { css += `\n${hoverSelector}{${hoverRules.join('')}}`; } if (mobileRules?.length) { css += `\n@media screen and (max-width:480px){${selector}{${mobileRules.join('')}}}`; } return css;}/** * Создает тег CSS-стилей * @param {string} styleId * @param {string} css */function t_store_createСssStyleTag(styleId, css) { let styleEl = document.getElementById(styleId); if (!styleEl) { styleEl = document.createElement('style'); styleEl.id = styleId; (document.head || document.documentElement).appendChild(styleEl); } if (styleEl.styleSheet) { styleEl.styleSheet.cssText = css; } else { styleEl.textContent = css; }}/** * Применяет стили к кнопке сниппета * @param {string} recid * @param {Object} options