功能:同步小程序流程
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
/**
|
||||
* Purpose: HEX_COLOR_PATTERN supports theme.js by holding or executing the hex color pattern page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const HEX_COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/
|
||||
|
||||
/**
|
||||
* Purpose: normalizeHexColor supports theme.js by holding or executing the normalize hex color page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function normalizeHexColor(value) {
|
||||
if (!value || typeof value !== 'string') {
|
||||
return ''
|
||||
@@ -8,6 +16,10 @@ function normalizeHexColor(value) {
|
||||
return HEX_COLOR_PATTERN.test(normalized) ? normalized.toUpperCase() : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: hexToRgb supports theme.js by holding or executing the hex to rgb page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function hexToRgb(color) {
|
||||
const value = color.replace('#', '')
|
||||
return {
|
||||
@@ -17,14 +29,26 @@ function hexToRgb(color) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: toHex supports theme.js by holding or executing the to hex page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function toHex(value) {
|
||||
return Math.min(255, Math.max(0, value)).toString(16).padStart(2, '0').toUpperCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: rgbToHex supports theme.js by holding or executing the rgb to hex page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function rgbToHex(rgb) {
|
||||
return `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: mixColor supports theme.js by holding or executing the mix color page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function mixColor(foreground, background, backgroundWeight) {
|
||||
const fg = hexToRgb(foreground)
|
||||
const bg = hexToRgb(background)
|
||||
@@ -36,6 +60,10 @@ function mixColor(foreground, background, backgroundWeight) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildStyleVars supports theme.js by holding or executing the build style vars page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function buildStyleVars(theme) {
|
||||
const styleVars = [
|
||||
`--theme-primary: ${theme.primaryColor};`,
|
||||
@@ -58,6 +86,10 @@ function buildStyleVars(theme) {
|
||||
return styleVars.join(' ')
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: resolveShopTheme supports theme.js by holding or executing the resolve shop theme page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function resolveShopTheme(source) {
|
||||
const themeSource = source || {}
|
||||
const normalizedPrimaryColor = normalizeHexColor(themeSource.themePrimaryColor)
|
||||
@@ -95,6 +127,10 @@ function resolveShopTheme(source) {
|
||||
return theme
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: DEFAULT_SHOP_THEME supports theme.js by holding or executing the default shop theme page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const DEFAULT_SHOP_THEME = {
|
||||
primaryColor: '#C6597D',
|
||||
secondaryColor: '#E9B7C7',
|
||||
@@ -111,6 +147,10 @@ const DEFAULT_SHOP_THEME = {
|
||||
|
||||
DEFAULT_SHOP_THEME.styleVars = buildStyleVars(DEFAULT_SHOP_THEME)
|
||||
|
||||
/**
|
||||
* Purpose: pageThemeData supports theme.js by holding or executing the page theme data page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function pageThemeData(theme, backgroundImageUrl) {
|
||||
const resolved = theme || DEFAULT_SHOP_THEME
|
||||
const themeData = backgroundImageUrl
|
||||
|
||||
Reference in New Issue
Block a user