@gem-sdk/core 2.0.0-staging.737 → 2.0.0-staging.754
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var constant=require("./constant.js"),colors=require("./colors.js"),makeStyle=require("./make-style.js"),getResonsiveValue=require("./get-resonsive-value.js");const isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?colors.isColor(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return makeStyle.makeStyleResponsive("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,a=i,s=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&s&&s!=i&&(a=s),"FILE_CONTENT"===l&&o?.liquid&&a&&(r=`{{ "${a.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&a&&(r=`{{ "${a}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop"),tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop"),tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop"),tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${colors.getSingleColorVariable(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(e,t)=>{let o=constant.devicesMapping[e]??"";return"fixed"===t?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"100%",[`--h${o}`]:"100%",[`--pos${o}`]:"absolute",[`--bga${o}`]:t}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return["desktop","tablet","mobile"].forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:getResonsiveValue.getResponsiveValueByScreen(o,"desktop"),tablet:getResonsiveValue.getResponsiveValueByScreen(o,"tablet"),mobile:getResonsiveValue.getResponsiveValueByScreen(o,"mobile")},i={};return["desktop","tablet","mobile"].forEach(e=>{let l=getResonsiveValue.getResponsiveValueByScreen(t,e),r=o?getBgImageByDevice(g,e):void 0;l?.includes(GRADIENT_BGR_KEY)?Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:l}):Object.assign(i,{[`--bgc${"desktop"!==e?"-"+e:""}`]:l,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),r&&"none"!==r&&Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:r})}),i};exports.GRADIENT_BGR_KEY=GRADIENT_BGR_KEY,exports.composeBackgroundCss=composeBackgroundCss,exports.getBgByDevice=getBgByDevice,exports.getBgImageByDevice=getBgImageByDevice,exports.getBgVideoByDevice=getBgVideoByDevice,exports.getColor=getColor,exports.getGradientBgrStyleByDevice=getGradientBgrStyleByDevice,exports.getGradientBgrStyleForButton=getGradientBgrStyleForButton,exports.getStyleBackgroundByDevice=getStyleBackgroundByDevice,exports.getStyleBgColor=getStyleBgColor,exports.makeFixedBgAttachment=makeFixedBgAttachment;
|
|
1
|
+
"use strict";var constant=require("./constant.js"),colors=require("./colors.js"),makeStyle=require("./make-style.js"),getResonsiveValue=require("./get-resonsive-value.js");const isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?colors.isColor(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return makeStyle.makeStyleResponsive("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,a=i,s=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&s&&s!=i&&(a=s),"FILE_CONTENT"===l&&o?.liquid&&a&&(r=`{{ "${a.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&a&&(r=`{{ "${a}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop")||"50% 50%",tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop")||"cover",tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop")||"no-repeat",tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return makeStyle.makeStyleResponsive("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${colors.getSingleColorVariable(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(e,t)=>{let o=constant.devicesMapping[e]??"";return"fixed"===t?{wrapper:{[`--pos${o}`]:"absolute",[`--top${o}`]:"0",[`--left${o}`]:"0",[`--w${o}`]:"100%",[`--h${o}`]:"100%"},content:{[`--pos${o}`]:"fixed",[`--w${o}`]:"100vw",[`--h${o}`]:"100vh",[`--bga${o}`]:"unset"}}:{wrapper:{[`--pos${o}`]:"absolute"},content:{[`--w${o}`]:"100%",[`--h${o}`]:"100%",[`--pos${o}`]:"absolute",[`--bga${o}`]:t}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return["desktop","tablet","mobile"].forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:getResonsiveValue.getResponsiveValueByScreen(o,"desktop"),tablet:getResonsiveValue.getResponsiveValueByScreen(o,"tablet"),mobile:getResonsiveValue.getResponsiveValueByScreen(o,"mobile")},i={};return["desktop","tablet","mobile"].forEach(e=>{let l=getResonsiveValue.getResponsiveValueByScreen(t,e),r=o?getBgImageByDevice(g,e):void 0;l?.includes(GRADIENT_BGR_KEY)?Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:l}):Object.assign(i,{[`--bgc${"desktop"!==e?"-"+e:""}`]:l,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),r&&"none"!==r&&Object.assign(i,{[`--bgi${"desktop"!==e?"-"+e:""}`]:r})}),{...i,...getStyleBgPosition(o),...getStyleBgSize(o),...getStyleBgRepeat(o)}};exports.GRADIENT_BGR_KEY=GRADIENT_BGR_KEY,exports.composeBackgroundCss=composeBackgroundCss,exports.getBgByDevice=getBgByDevice,exports.getBgImageByDevice=getBgImageByDevice,exports.getBgVideoByDevice=getBgVideoByDevice,exports.getColor=getColor,exports.getGradientBgrStyleByDevice=getGradientBgrStyleByDevice,exports.getGradientBgrStyleForButton=getGradientBgrStyleForButton,exports.getStyleBackgroundByDevice=getStyleBackgroundByDevice,exports.getStyleBgColor=getStyleBgColor,exports.makeFixedBgAttachment=makeFixedBgAttachment;
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
${c?`text-decoration-line: underline ${$}`:""};
|
|
17
17
|
${g?`text-transform: ${g} ${$}`:""};
|
|
18
18
|
${r&&"none"!==r.type?`text-shadow: ${composeTextShadowCss(r)}`:"none"};
|
|
19
|
-
`},composeTextShadowCss=o=>{let e="number"==typeof o?.angle?o?.angle:0,t=e*Math.PI/180,p=parseFloat(o?.distance??"0");if(isNaN(p))return"none";let s=Math.round(Math.cos(t)*p*100)/100,y=Math.round(Math.sin(t)*p*100)/100;return`${s}px ${y}px ${o?.blur??"0"} ${o.color}`},composeTextHoverColorCss=(o,e)=>{if(o){let t=e?"!important":"",p=o.hover;return`${p?`color: ${p} ${t}`:""}`}};function getCustomCSSByDevice(o,e){if(!o||!e)return{};let t="desktop"!==e&&e?`-${e}`:"",{fontFamily:p}=o?.[e]??{};return{[`--size${t}`]:o?.[e]?.fontSize,[`--lh${t}`]:o?.[e]?.lineHeight,[`--fs${t}`]:o?.[e]?.fontStyle,[`--ff${t}`]:composeFontFamilyTypographyV2({fontFamily:p}),[`--weight${t}`]:o?.[e]?.fontWeight,[`--ls${t}`]:o?.[e]?.letterSpacing}}const composeTypography=o=>o?makeStyle.removeNullUndefined({...getCustomCSSByDevice(o,"desktop"),...getCustomCSSByDevice(o,"tablet"),...getCustomCSSByDevice(o,"mobile")}):{},composeTypographyV2=(o,e)=>o?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:e?.italic?void 0:o?.fontStyle,ff:composeFontFamilyTypographyV2(o),weight:e?.bold?void 0:o?.fontWeight,ls:o?.letterSpacing}),...makeStyle.makeStyleResponsive("size",o?.fontSize),...makeStyle.makeStyleResponsive("lh",o?.lineHeight)}):{},composeFontFamilyTypographyV2=o=>{let{fontFamily:e,isCustom:t,fallbackFontFamily:p,type:s}=o||{};return e?"string"==typeof e?getFontUsedByTypographyV2({fontFamily:e,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")}):"object"==typeof e&&"string"==typeof e?.value?"theme"===e.type?`var(${e?.value}), var(--g-font-body)`:getFontUsedByTypographyV2({fontFamily:e.value,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")}):void 0:t?p:void 0},getFontUsedByTypographyV2=({fontFamily:o,fallbackFontFamily:e})=>{if(o)return`var(--g-font-${o?.replace(/ /g,"-")}, '${o}'), ${e}`},composeTypographyAttr=o=>o?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:o?.italic?"italic":void 0,weight:o?.bold?"bold":void 0,c:colors.getSingleColorVariable(o?.color),tt:o?.transform,tdl:o?.underline?"underline":void 0})}):{},composeTypographyClassName=(o,e)=>o?o?.type&&!isCustomTypo(o.custom)?genTypoClass(o.type):"":e?.type&&genTypoClass(e?.type),composeFallbackTypographyStyle=o=>o.toLocaleLowerCase().includes("heading")?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(o,e,t)=>{if(o){let e=composeFallbackTypographyStyle(o.type??"heading"),p={...o.custom,fallbackFontFamily:e,isCustom:isCustomTypo(o.custom)};return{...composeTypographyV2(p,o.attrs),...!t&&composeTypographyAttr(o.attrs)}}return{...e?.type?{}:composeTypography(e?.custom)}},isCustomTypo=o=>o&&Object.keys(o).length>1||o&&1===Object.keys(o).length&&!o.fontSize;exports.composeFallbackTypographyStyle=composeFallbackTypographyStyle,exports.composeFontFamilyTypographyV2=composeFontFamilyTypographyV2,exports.composeTextHoverColorCss=composeTextHoverColorCss,exports.composeTypography=composeTypography,exports.composeTypographyAttr=composeTypographyAttr,exports.composeTypographyClassName=composeTypographyClassName,exports.composeTypographyCss=composeTypographyCss,exports.composeTypographyStyle=composeTypographyStyle,exports.composeTypographyV2=composeTypographyV2,exports.composeTypographyV2Css=composeTypographyV2Css,exports.genTypoClass=genTypoClass;
|
|
19
|
+
`},composeTextShadowCss=o=>{let e="number"==typeof o?.angle?o?.angle:0,t=e*Math.PI/180,p=parseFloat(o?.distance??"0");if(isNaN(p))return"none";let s=Math.round(Math.cos(t)*p*100)/100,y=Math.round(Math.sin(t)*p*100)/100;return`${s}px ${y}px ${o?.blur??"0"} ${o.color}`},composeTextHoverColorCss=(o,e)=>{if(o){let t=e?"!important":"",p=colors.getSingleColorVariable(o.hover);return`${p?`color: ${p} ${t}`:""}`}};function getCustomCSSByDevice(o,e){if(!o||!e)return{};let t="desktop"!==e&&e?`-${e}`:"",{fontFamily:p}=o?.[e]??{};return{[`--size${t}`]:o?.[e]?.fontSize,[`--lh${t}`]:o?.[e]?.lineHeight,[`--fs${t}`]:o?.[e]?.fontStyle,[`--ff${t}`]:composeFontFamilyTypographyV2({fontFamily:p}),[`--weight${t}`]:o?.[e]?.fontWeight,[`--ls${t}`]:o?.[e]?.letterSpacing}}const composeTypography=o=>o?makeStyle.removeNullUndefined({...getCustomCSSByDevice(o,"desktop"),...getCustomCSSByDevice(o,"tablet"),...getCustomCSSByDevice(o,"mobile")}):{},composeTypographyV2=(o,e)=>o?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:e?.italic?void 0:o?.fontStyle,ff:composeFontFamilyTypographyV2(o),weight:e?.bold?void 0:o?.fontWeight,ls:o?.letterSpacing}),...makeStyle.makeStyleResponsive("size",o?.fontSize),...makeStyle.makeStyleResponsive("lh",o?.lineHeight)}):{},composeFontFamilyTypographyV2=o=>{let{fontFamily:e,isCustom:t,fallbackFontFamily:p,type:s}=o||{};return e?"string"==typeof e?getFontUsedByTypographyV2({fontFamily:e,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")}):"object"==typeof e&&"string"==typeof e?.value?"theme"===e.type?`var(${e?.value}), var(--g-font-body)`:getFontUsedByTypographyV2({fontFamily:e.value,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(s??"heading")}):void 0:t?p:void 0},getFontUsedByTypographyV2=({fontFamily:o,fallbackFontFamily:e})=>{if(o)return`var(--g-font-${o?.replace(/ /g,"-")}, '${o}'), ${e}`},composeTypographyAttr=o=>o?makeStyle.removeNullUndefined({...makeStyle.makeStyle({fs:o?.italic?"italic":void 0,weight:o?.bold?"bold":void 0,c:colors.getSingleColorVariable(o?.color),tt:o?.transform,tdl:o?.underline?"underline":void 0})}):{},composeTypographyClassName=(o,e)=>o?o?.type&&!isCustomTypo(o.custom)?genTypoClass(o.type):"":e?.type&&genTypoClass(e?.type),composeFallbackTypographyStyle=o=>o.toLocaleLowerCase().includes("heading")?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(o,e,t)=>{if(o){let e=composeFallbackTypographyStyle(o.type??"heading"),p={...o.custom,fallbackFontFamily:e,isCustom:isCustomTypo(o.custom)};return{...composeTypographyV2(p,o.attrs),...!t&&composeTypographyAttr(o.attrs)}}return{...e?.type?{}:composeTypography(e?.custom)}},isCustomTypo=o=>o&&Object.keys(o).length>1||o&&1===Object.keys(o).length&&!o.fontSize;exports.composeFallbackTypographyStyle=composeFallbackTypographyStyle,exports.composeFontFamilyTypographyV2=composeFontFamilyTypographyV2,exports.composeTextHoverColorCss=composeTextHoverColorCss,exports.composeTypography=composeTypography,exports.composeTypographyAttr=composeTypographyAttr,exports.composeTypographyClassName=composeTypographyClassName,exports.composeTypographyCss=composeTypographyCss,exports.composeTypographyStyle=composeTypographyStyle,exports.composeTypographyV2=composeTypographyV2,exports.composeTypographyV2Css=composeTypographyV2Css,exports.genTypoClass=genTypoClass;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devicesMapping as e}from"./constant.js";import{isColor as t,getSingleColorVariable as o}from"./colors.js";import{makeStyleResponsive as g}from"./make-style.js";import{getResponsiveValueByScreen as i}from"./get-resonsive-value.js";let isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return g("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?t(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return g("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,B=i,a=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&a&&a!=i&&(B=a),"FILE_CONTENT"===l&&o?.liquid&&B&&(r=`{{ "${B.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&B&&(r=`{{ "${B}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop"),tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return g("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop"),tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return g("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop"),tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return g("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return g("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${o(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(t,o)=>{let g=e[t]??"";return"fixed"===o?{wrapper:{[`--pos${g}`]:"absolute",[`--top${g}`]:"0",[`--left${g}`]:"0",[`--w${g}`]:"100%",[`--h${g}`]:"100%"},content:{[`--pos${g}`]:"fixed",[`--w${g}`]:"100vw",[`--h${g}`]:"100vh",[`--bga${g}`]:"unset"}}:{wrapper:{[`--pos${g}`]:"absolute"},content:{[`--w${g}`]:"100%",[`--h${g}`]:"100%",[`--pos${g}`]:"absolute",[`--bga${g}`]:o}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return["desktop","tablet","mobile"].forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:i(o,"desktop"),tablet:i(o,"tablet"),mobile:i(o,"mobile")},l={};return["desktop","tablet","mobile"].forEach(e=>{let r=i(t,e),B=o?getBgImageByDevice(g,e):void 0;r?.includes(GRADIENT_BGR_KEY)?Object.assign(l,{[`--bgi${"desktop"!==e?"-"+e:""}`]:r}):Object.assign(l,{[`--bgc${"desktop"!==e?"-"+e:""}`]:r,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),B&&"none"!==B&&Object.assign(l,{[`--bgi${"desktop"!==e?"-"+e:""}`]:B})}),l};export{GRADIENT_BGR_KEY,composeBackgroundCss,getBgByDevice,getBgImageByDevice,getBgVideoByDevice,getColor,getGradientBgrStyleByDevice,getGradientBgrStyleForButton,getStyleBackgroundByDevice,getStyleBgColor,makeFixedBgAttachment};
|
|
1
|
+
import{devicesMapping as e}from"./constant.js";import{isColor as t,getSingleColorVariable as o}from"./colors.js";import{makeStyleResponsive as g}from"./make-style.js";import{getResponsiveValueByScreen as i}from"./get-resonsive-value.js";let isEmptyBg=e=>e?.videoHtml5===void 0&&e?.video===void 0&&!e?.videoType,getBgVideoByDevice=(e,t="desktop")=>{let o=e?.[t];if(isEmptyBg(o)&&"desktop"!==t){let t=e?.tablet;o=isEmptyBg(t)?e?.desktop:t}return o},getStyleBackgroundByDevice=(e,t)=>e?{...t?.ignoreBackgroundColor?{}:{...getStyleBgColor(e)},...t?.ignoreBackgroundImage?{}:{...getStyleBgImage(e,t)},...t?.ignoreBackgroundImageProperties?{}:{...getStyleBgPosition(e),...getStyleBgSize(e),...getStyleBgRepeat(e)},...t?.ignoreBgAttachment?{}:getStyleBgAttachment(e)}:{},getStyleBgColor=e=>{let t={desktop:getBgColorByDevice(e,"desktop"),tablet:getBgColorByDevice(e,"tablet"),mobile:getBgColorByDevice(e,"mobile")};return g("bgc",t)},getBgColorByDevice=(e,t)=>getColor(e?.[t]?.color),getColor=e=>e?t(e?.toString())?e:`var(--g-c-${e})`:void 0,getStyleBgImage=(e,t)=>{let o={desktop:getBgImageByDevice(e,"desktop",t),tablet:getBgImageByDevice(e,"tablet",t),mobile:getBgImageByDevice(e,"mobile",t)};return g("bgi",o)},getBgImageByDevice=(e,t,o)=>{let g=e?.[t]?.type==="video";if(g)return;if(e?.[t]?.type==="color")return"url()";let i=e?.[t]?.image?.backupFileKey,l=e?.[t]?.image?.storage,r=e?.[t]?.image?.src,B=i,a=r?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return(i&&a&&a!=i&&(B=a),"FILE_CONTENT"===l&&o?.liquid&&B&&(r=`{{ "${B.replace(".jpeg",".jpg")}" | file_url }}`),("THEME"===l||!l)&&o?.liquid&&B&&(r=`{{ "${B}" | asset_url }}`),"string"==typeof r&&r)?`url(${r})`:void 0!==r?"none":void 0},getStyleBgPosition=e=>{let t={desktop:getBgPositionByDevice(e,"desktop")||"50% 50%",tablet:getBgPositionByDevice(e,"tablet"),mobile:getBgPositionByDevice(e,"mobile")};return g("bgp",t)},getBgPositionByDevice=(e,t)=>{let o=e?.[t]?.position;return o&&`${o.x}% ${o.y}%`},getStyleBgSize=e=>{let t={desktop:getBgSizeByDevice(e,"desktop")||"cover",tablet:getBgSizeByDevice(e,"tablet"),mobile:getBgSizeByDevice(e,"mobile")};return g("bgs",t)},getBgSizeByDevice=(e,t)=>e?.[t]?.size,getStyleBgRepeat=e=>{let t={desktop:getBgRepeatByDevice(e,"desktop")||"no-repeat",tablet:getBgRepeatByDevice(e,"tablet"),mobile:getBgRepeatByDevice(e,"mobile")};return g("bgr",t)},getBgRepeatByDevice=(e,t)=>e?.[t]?.repeat,getStyleBgAttachment=e=>{let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")};return g("bga",t)},getBgAttachmentByDevice=(e,t)=>e?.[t]?.attachment,composeBackgroundCss=e=>`${e?`background-color: ${o(e)};`:void 0}`,makeFixedBgAttachment=e=>{if(!e)return;e.tablet=e.tablet?e.tablet:e.desktop,e.mobile=e.mobile?e.mobile:e.tablet;let t={desktop:getBgAttachmentByDevice(e,"desktop"),tablet:getBgAttachmentByDevice(e,"tablet"),mobile:getBgAttachmentByDevice(e,"mobile")},o={desktop:{...makeFixedBgAttachmentByDevice("desktop",t.desktop)},tablet:{...makeFixedBgAttachmentByDevice("tablet",t.tablet)},mobile:{...makeFixedBgAttachmentByDevice("mobile",t.mobile)}};return{wrapper:{...o.desktop?.wrapper,...o.tablet?.wrapper,...o.mobile?.wrapper},content:{...o.desktop?.content,...o.tablet?.content,...o.mobile?.content}}},makeFixedBgAttachmentByDevice=(t,o)=>{let g=e[t]??"";return"fixed"===o?{wrapper:{[`--pos${g}`]:"absolute",[`--top${g}`]:"0",[`--left${g}`]:"0",[`--w${g}`]:"100%",[`--h${g}`]:"100%"},content:{[`--pos${g}`]:"fixed",[`--w${g}`]:"100vw",[`--h${g}`]:"100vh",[`--bga${g}`]:"unset"}}:{wrapper:{[`--pos${g}`]:"absolute"},content:{[`--w${g}`]:"100%",[`--h${g}`]:"100%",[`--pos${g}`]:"absolute",[`--bga${g}`]:o}}},GRADIENT_BGR_KEY="linear-gradient",getGradientBgrStyleForButton=e=>{if(!e)return;let t={};for(let o of Object.keys(e)){let g=e[o];if(!g?.startsWith(GRADIENT_BGR_KEY))continue;let i="normal"===o?"--bgi":"--hvr-bgi";t[i]=g}return t},getGradientBgrStyleByDevice=(e,t)=>{if(!e)return;let o={};return["desktop","tablet","mobile"].forEach(g=>{if(e[g]?.color?.includes(GRADIENT_BGR_KEY)){let i=`${getBgImageByDevice(e,g)||"url()"}, ${e[g]?.color}`;Object.assign(o,{[`--bgc${"desktop"!==g?"-"+g:""}`]:e[g]?.color,[`--bgi${"desktop"!==g?"-"+g:""}`]:t?.[g]?i:`${e[g]?.color}`})}}),o},getBgByDevice=e=>{let{backgroundColor:t,backgroundImage:o}=e;if(!t&&!o)return;let g={desktop:i(o,"desktop"),tablet:i(o,"tablet"),mobile:i(o,"mobile")},l={};return["desktop","tablet","mobile"].forEach(e=>{let r=i(t,e),B=o?getBgImageByDevice(g,e):void 0;r?.includes(GRADIENT_BGR_KEY)?Object.assign(l,{[`--bgi${"desktop"!==e?"-"+e:""}`]:r}):Object.assign(l,{[`--bgc${"desktop"!==e?"-"+e:""}`]:r,[`--bgi${"desktop"!==e?"-"+e:""}`]:"none"}),B&&"none"!==B&&Object.assign(l,{[`--bgi${"desktop"!==e?"-"+e:""}`]:B})}),{...l,...getStyleBgPosition(o),...getStyleBgSize(o),...getStyleBgRepeat(o)}};export{GRADIENT_BGR_KEY,composeBackgroundCss,getBgByDevice,getBgImageByDevice,getBgVideoByDevice,getColor,getGradientBgrStyleByDevice,getGradientBgrStyleForButton,getStyleBackgroundByDevice,getStyleBgColor,makeFixedBgAttachment};
|
|
@@ -16,4 +16,4 @@ import{getSingleColorVariable as o}from"./colors.js";import{removeNullUndefined
|
|
|
16
16
|
${c?`text-decoration-line: underline ${$}`:""};
|
|
17
17
|
${m?`text-transform: ${m} ${$}`:""};
|
|
18
18
|
${r&&"none"!==r.type?`text-shadow: ${composeTextShadowCss(r)}`:"none"};
|
|
19
|
-
`},composeTextShadowCss=o=>{let e="number"==typeof o?.angle?o?.angle:0,t=e*Math.PI/180,p=parseFloat(o?.distance??"0");if(isNaN(p))return"none";let a=Math.round(Math.cos(t)*p*100)/100,s=Math.round(Math.sin(t)*p*100)/100;return`${a}px ${s}px ${o?.blur??"0"} ${o.color}`},composeTextHoverColorCss=(
|
|
19
|
+
`},composeTextShadowCss=o=>{let e="number"==typeof o?.angle?o?.angle:0,t=e*Math.PI/180,p=parseFloat(o?.distance??"0");if(isNaN(p))return"none";let a=Math.round(Math.cos(t)*p*100)/100,s=Math.round(Math.sin(t)*p*100)/100;return`${a}px ${s}px ${o?.blur??"0"} ${o.color}`},composeTextHoverColorCss=(e,t)=>{if(e){let p=t?"!important":"",a=o(e.hover);return`${a?`color: ${a} ${p}`:""}`}};function getCustomCSSByDevice(o,e){if(!o||!e)return{};let t="desktop"!==e&&e?`-${e}`:"",{fontFamily:p}=o?.[e]??{};return{[`--size${t}`]:o?.[e]?.fontSize,[`--lh${t}`]:o?.[e]?.lineHeight,[`--fs${t}`]:o?.[e]?.fontStyle,[`--ff${t}`]:composeFontFamilyTypographyV2({fontFamily:p}),[`--weight${t}`]:o?.[e]?.fontWeight,[`--ls${t}`]:o?.[e]?.letterSpacing}}let composeTypography=o=>o?e({...getCustomCSSByDevice(o,"desktop"),...getCustomCSSByDevice(o,"tablet"),...getCustomCSSByDevice(o,"mobile")}):{},composeTypographyV2=(o,a)=>o?e({...t({fs:a?.italic?void 0:o?.fontStyle,ff:composeFontFamilyTypographyV2(o),weight:a?.bold?void 0:o?.fontWeight,ls:o?.letterSpacing}),...p("size",o?.fontSize),...p("lh",o?.lineHeight)}):{},composeFontFamilyTypographyV2=o=>{let{fontFamily:e,isCustom:t,fallbackFontFamily:p,type:a}=o||{};return e?"string"==typeof e?getFontUsedByTypographyV2({fontFamily:e,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")}):"object"==typeof e&&"string"==typeof e?.value?"theme"===e.type?`var(${e?.value}), var(--g-font-body)`:getFontUsedByTypographyV2({fontFamily:e.value,fallbackFontFamily:o?.fallbackFontFamily||composeFallbackTypographyStyle(a??"heading")}):void 0:t?p:void 0},getFontUsedByTypographyV2=({fontFamily:o,fallbackFontFamily:e})=>{if(o)return`var(--g-font-${o?.replace(/ /g,"-")}, '${o}'), ${e}`},composeTypographyAttr=p=>p?e({...t({fs:p?.italic?"italic":void 0,weight:p?.bold?"bold":void 0,c:o(p?.color),tt:p?.transform,tdl:p?.underline?"underline":void 0})}):{},composeTypographyClassName=(o,e)=>o?o?.type&&!isCustomTypo(o.custom)?genTypoClass(o.type):"":e?.type&&genTypoClass(e?.type),composeFallbackTypographyStyle=o=>o.toLocaleLowerCase().includes("heading")?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(o,e,t)=>{if(o){let e=composeFallbackTypographyStyle(o.type??"heading"),p={...o.custom,fallbackFontFamily:e,isCustom:isCustomTypo(o.custom)};return{...composeTypographyV2(p,o.attrs),...!t&&composeTypographyAttr(o.attrs)}}return{...e?.type?{}:composeTypography(e?.custom)}},isCustomTypo=o=>o&&Object.keys(o).length>1||o&&1===Object.keys(o).length&&!o.fontSize;export{composeFallbackTypographyStyle,composeFontFamilyTypographyV2,composeTextHoverColorCss,composeTypography,composeTypographyAttr,composeTypographyClassName,composeTypographyCss,composeTypographyStyle,composeTypographyV2,composeTypographyV2Css,genTypoClass};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -37693,7 +37693,17 @@ declare const getGradientBgrStyleByDevice: (backgroundStyle: Partial<Record<Devi
|
|
|
37693
37693
|
declare const getBgByDevice: (data: {
|
|
37694
37694
|
backgroundColor: Partial<Record<Devices, string>> | undefined;
|
|
37695
37695
|
backgroundImage: Partial<Record<Devices, BackgroundImageValue>> | undefined;
|
|
37696
|
-
}) => {
|
|
37696
|
+
}) => {
|
|
37697
|
+
"--bgr": string;
|
|
37698
|
+
"--bgr-tablet": string;
|
|
37699
|
+
"--bgr-mobile": string;
|
|
37700
|
+
"--bgs": string;
|
|
37701
|
+
"--bgs-tablet": string;
|
|
37702
|
+
"--bgs-mobile": string;
|
|
37703
|
+
"--bgp": string;
|
|
37704
|
+
"--bgp-tablet": string;
|
|
37705
|
+
"--bgp-mobile": string;
|
|
37706
|
+
} | undefined;
|
|
37697
37707
|
|
|
37698
37708
|
type Options = {
|
|
37699
37709
|
liquid?: boolean;
|