diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2024-07-24 18:51:17 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2024-07-24 18:51:17 +0000 |
| commit | 0c9893c8a07426d3e41046663d4072de50eb267c (patch) | |
| tree | dce14332df570a757bf78e769ac6cfd5fb189f58 /src/services/theme_data/css_utils.js | |
| parent | 7a7d80270d1ae041f06c1fd9017135cb5b8c34d6 (diff) | |
| parent | aa7bdbae2173fdb921dd241683c3e0f9bd3aaa82 (diff) | |
Merge branch 'appearance-tab' into 'develop'
Themes 3: Intermission: Appearance Tab and fixes
See merge request pleroma/pleroma-fe!1920
Diffstat (limited to 'src/services/theme_data/css_utils.js')
| -rw-r--r-- | src/services/theme_data/css_utils.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/services/theme_data/css_utils.js b/src/services/theme_data/css_utils.js index a89eac3b..9bce4834 100644 --- a/src/services/theme_data/css_utils.js +++ b/src/services/theme_data/css_utils.js @@ -2,11 +2,6 @@ import { convert } from 'chromatism' import { hex2rgb, rgba2css } from '../color_convert/color_convert.js' -// This changes what backgrounds are used to "stacked" solid colors so you can see -// what theme engine "thinks" is actual background color is for purposes of text color -// generation and for when --stacked variable is used -const DEBUG = false - export const parseCssShadow = (text) => { const dimensions = /(\d[a-z]*\s?){2,4}/.exec(text)?.[0] const inset = /inset/.exec(text)?.[0] @@ -66,7 +61,10 @@ export const getCssShadowFilter = (input) => { .join(' ') } -export const getCssRules = (rules) => rules.map(rule => { +// `debug` changes what backgrounds are used to "stacked" solid colors so you can see +// what theme engine "thinks" is actual background color is for purposes of text color +// generation and for when --stacked variable is used +export const getCssRules = (rules, debug) => rules.map(rule => { let selector = rule.selector if (!selector) { selector = 'html' @@ -93,7 +91,7 @@ export const getCssRules = (rules) => rules.map(rule => { ].join(';\n ') } case 'background': { - if (DEBUG) { + if (debug) { return ` --background: ${getCssColorString(rule.dynamicVars.stacked)}; background-color: ${getCssColorString(rule.dynamicVars.stacked)}; @@ -161,3 +159,15 @@ export const getCssRules = (rules) => rules.map(rule => { footer ].join('\n') }).filter(x => x) + +export const getScopedVersion = (rules, newScope) => { + return rules.map(x => { + if (x.startsWith('html')) { + return x.replace('html', newScope) + } else if (x.startsWith('#content')) { + return x.replace('#content', newScope) + } else { + return newScope + ' > ' + x + } + }) +} |
