diff options
| author | Henry Jameson <me@hjkos.com> | 2024-07-17 17:19:57 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2024-07-17 17:19:57 +0300 |
| commit | 40c9163d215b5ac7b69437f3585586b2174211ca (patch) | |
| tree | 44555e278889ce5b91adb8a8feec36241cb4bbad /src/modules/interface.js | |
| parent | 9d76fcc425abe1236304c270765ffdb4e6d0ba6e (diff) | |
optimizations, WIP theme selector
Diffstat (limited to 'src/modules/interface.js')
| -rw-r--r-- | src/modules/interface.js | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/src/modules/interface.js b/src/modules/interface.js index a9cd70e5..a0746052 100644 --- a/src/modules/interface.js +++ b/src/modules/interface.js @@ -234,25 +234,6 @@ const interfaceMod = { return } - const normalizeThemeData = (themeData) => { - if (themeData.themeFileVerison === 1) { - return generatePreset(themeData).theme - } - // New theme presets don't have 'theme' property, they use 'source' - const themeSource = themeData.source - - let out // shout, shout let it all out - if (!themeData.theme || (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION)) { - out = themeSource || themeData - } else { - out = themeData.theme - } - - // generatePreset here basically creates/updates "snapshot", - // while also fixing the 2.2 -> 2.3 colors/shadows/etc - return generatePreset(out).theme - } - let promise = null if (themeName) { @@ -320,3 +301,38 @@ const interfaceMod = { } export default interfaceMod + +export const normalizeThemeData = (input) => { + let themeData = input + + if (Array.isArray(themeData)) { + themeData = { colors: {} } + themeData.colors.bg = input[1] + themeData.colors.fg = input[2] + themeData.colors.text = input[3] + themeData.colors.link = input[4] + themeData.colors.cRed = input[5] + themeData.colors.cGreen = input[6] + themeData.colors.cBlue = input[7] + themeData.colors.cOrange = input[8] + return generatePreset(themeData).theme + } + + if (themeData.themeFileVerison === 1) { + return generatePreset(themeData).theme + } + + // New theme presets don't have 'theme' property, they use 'source' + const themeSource = themeData.source + + let out // shout, shout let it all out + if (!themeData.theme || (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION)) { + out = themeSource || themeData + } else { + out = themeData.theme + } + + // generatePreset here basically creates/updates "snapshot", + // while also fixing the 2.2 -> 2.3 colors/shadows/etc + return generatePreset(out).theme +} |
