From 7f0e0bd0a5e94f5c9a9fb15cee3ca58ac26bde61 Mon Sep 17 00:00:00 2001 From: Zam Date: Sun, 12 Feb 2023 14:55:29 +0200 Subject: [PATCH 1/2] Re-add hsl-split-decimal --- src/SettingHandlers.ts | 1 + src/SettingsManager.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/SettingHandlers.ts b/src/SettingHandlers.ts index 2d47409..9b6d205 100644 --- a/src/SettingHandlers.ts +++ b/src/SettingHandlers.ts @@ -115,6 +115,7 @@ export type ColorFormat = | 'hsl' | 'hsl-values' | 'hsl-split' + | 'hsl-split-decimal' | 'rgb' | 'rgb-values' | 'rgb-split' diff --git a/src/SettingsManager.ts b/src/SettingsManager.ts index efb4cc9..218d415 100644 --- a/src/SettingsManager.ts +++ b/src/SettingsManager.ts @@ -98,6 +98,33 @@ function generateColorVariables( return out; } + case 'hsl-split-decimal': { + const hsl = parsedColor.hsl(); + const h = isNaN(hsl[0]) ? 0 : hsl[0]; + const out = [ + { + key: `${key}-h`, + value: h.toString(), + }, + { + key: `${key}-s`, + value: hsl[1].toString(), + }, + { + key: `${key}-l`, + value: hsl[2].toString(), + }, + ...alts, + ]; + + if (opacity) + out.push({ + key: `${key}-a`, + value: parsedColor.alpha().toString(), + }); + + return out; + } case 'rgb': return [ { From 82e52b65062401706ae0bc35d19d3fb0f14355de Mon Sep 17 00:00:00 2001 From: Zam Date: Sun, 12 Feb 2023 14:55:59 +0200 Subject: [PATCH 2/2] Re-add documentation for hsl-split-decimal --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d3a5ac..51ebc61 100644 --- a/README.md +++ b/README.md @@ -379,7 +379,7 @@ body.theme-dark.css-settings-manager { --accent: #2DB253; } ### `variable-color` formatting options -There are 7 formatting options: +There are 8 formatting options: - `hex` @@ -475,6 +475,23 @@ When `opacity` is set to `true`: --accent-a: 1; ``` +- `hsl-split-decimal` + +``` +--accent-h: 211; +--accent-s: 1; +--accent-l: 0.5; +``` + +When `opacity` is set to `true`: + +``` +--accent-h: 211; +--accent-s: 1; +--accent-l: 0.5; +--accent-a: 1; +``` + ## `color-gradient` `color-gradient` outputs a fixed number of colors along a gradient between two existing color variables. A `format` attribute is also required. *Note: The `to` variable must be set in style settings for the gradient to be generated. Also, gradients will only be generated using colors defined under the current style settings `id`.*