aboutsummaryrefslogtreecommitdiff
path: root/src/services/theme_data/theme3_slot_functions.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2024-02-21 22:18:56 +0200
committerHenry Jameson <me@hjkos.com>2024-02-21 22:18:56 +0200
commit8a21594dbc5075b92d245f4c83530c7dae71c62a (patch)
treed471f798fe698dec8d0be36304605a339a85d634 /src/services/theme_data/theme3_slot_functions.js
parent7041d29eded837fb2b98670fa4758846ab3db9c3 (diff)
shadow slots work + minor fixes
Diffstat (limited to 'src/services/theme_data/theme3_slot_functions.js')
-rw-r--r--src/services/theme_data/theme3_slot_functions.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/services/theme_data/theme3_slot_functions.js b/src/services/theme_data/theme3_slot_functions.js
index 2324e121..2715c827 100644
--- a/src/services/theme_data/theme3_slot_functions.js
+++ b/src/services/theme_data/theme3_slot_functions.js
@@ -1,7 +1,7 @@
import { convert, brightness } from 'chromatism'
import { alphaBlend, relativeLuminance } from '../color_convert/color_convert.js'
-export const process = (text, functions, findColor, dynamicVars, staticVars) => {
+export const process = (text, functions, { findColor, findShadow }, { dynamicVars, staticVars }) => {
const { funcName, argsString } = /\$(?<funcName>\w+)\((?<argsString>[#a-zA-Z0-9-,.'"\s]*)\)/.exec(text).groups
const args = argsString.split(/,/g).map(a => a.trim())
@@ -9,27 +9,27 @@ export const process = (text, functions, findColor, dynamicVars, staticVars) =>
if (args.length < func.argsNeeded) {
throw new Error(`$${funcName} requires at least ${func.argsNeeded} arguments, but ${args.length} were provided`)
}
- return func.exec(args, findColor, dynamicVars, staticVars)
+ return func.exec(args, { findColor, findShadow }, { dynamicVars, staticVars })
}
export const colorFunctions = {
alpha: {
argsNeeded: 2,
- exec: (args, findColor, dynamicVars, staticVars) => {
+ exec: (args, { findColor }, { dynamicVars, staticVars }) => {
const [color, amountArg] = args
- const colorArg = convert(findColor(color, dynamicVars, staticVars)).rgb
+ const colorArg = convert(findColor(color, { dynamicVars, staticVars })).rgb
const amount = Number(amountArg)
return { ...colorArg, a: amount }
}
},
blend: {
argsNeeded: 3,
- exec: (args, findColor, dynamicVars, staticVars) => {
+ exec: (args, { findColor }, { dynamicVars, staticVars }) => {
const [backgroundArg, amountArg, foregroundArg] = args
- const background = convert(findColor(backgroundArg, dynamicVars, staticVars)).rgb
- const foreground = convert(findColor(foregroundArg, dynamicVars, staticVars)).rgb
+ const background = convert(findColor(backgroundArg, { dynamicVars, staticVars })).rgb
+ const foreground = convert(findColor(foregroundArg, { dynamicVars, staticVars })).rgb
const amount = Number(amountArg)
return alphaBlend(background, amount, foreground)
@@ -37,10 +37,10 @@ export const colorFunctions = {
},
mod: {
argsNeeded: 2,
- exec: (args, findColor, dynamicVars, staticVars) => {
+ exec: (args, { findColor }, { dynamicVars, staticVars }) => {
const [colorArg, amountArg] = args
- const color = convert(findColor(colorArg, dynamicVars, staticVars)).rgb
+ const color = convert(findColor(colorArg, { dynamicVars, staticVars })).rgb
const amount = Number(amountArg)
const effectiveBackground = dynamicVars.lowerLevelBackground
@@ -54,7 +54,7 @@ export const colorFunctions = {
export const shadowFunctions = {
borderSide: {
argsNeeded: 3,
- exec: (args, findColor, dynamicVars, staticVars) => {
+ exec: (args, { findColor }) => {
const [color, side, alpha = '1', widthArg = '1', inset = 'inset'] = args
const width = Number(widthArg)
@@ -86,7 +86,7 @@ export const shadowFunctions = {
break
}
})
- return targetShadow
+ return [targetShadow]
}
}
}