()
| 18 | import {_theme, tempGray} from './initialTheme'; |
| 19 | |
| 20 | function paramSetup() { |
| 21 | let setFirstColorSmoothing = false; |
| 22 | let url = new URL(window.location); |
| 23 | let params = new URLSearchParams(sanitizeQueryString(url.search.slice(1))); |
| 24 | let themeBase = document.getElementById('themeBase'); |
| 25 | let RATIOS; |
| 26 | let RATIOCOLORS; |
| 27 | |
| 28 | let themeNameInput = document.getElementById('themeNameInput'); |
| 29 | if (params.has('name')) { |
| 30 | themeNameInput.value = params.get('name').toString(); |
| 31 | let characters = params.get('name').toString().length; |
| 32 | themeNameInput.style.width = `${characters + 4}ch`; |
| 33 | } else { |
| 34 | themeNameInput.value = 'Untitled'; |
| 35 | let characters = 'Untitled'.length; |
| 36 | themeNameInput.style.width = `${characters + 4}ch`; |
| 37 | } |
| 38 | // updateThemeTitle(); |
| 39 | |
| 40 | if (params.has('config') && params.get('config') !== undefined) { |
| 41 | let configParam = params.get('config'); |
| 42 | let config = JSON.parse(configParam); |
| 43 | let colorScales = config.colorScales; |
| 44 | let baseScale = config.baseScale; |
| 45 | let lightness = config.lightness ? config.lightness : config.brightness; |
| 46 | |
| 47 | let contrast; |
| 48 | let formula; |
| 49 | if (!config.formula) { |
| 50 | formula = 'wcag2'; |
| 51 | } else { |
| 52 | formula = config.formula; |
| 53 | } |
| 54 | _theme.formula = formula; |
| 55 | |
| 56 | if (!config.contrast) { |
| 57 | contrast = 1; |
| 58 | } else { |
| 59 | contrast = config.contrast; |
| 60 | } |
| 61 | |
| 62 | if (colorScales.length > 0) { |
| 63 | _theme.removeColor = tempGray; |
| 64 | |
| 65 | colorScales.map((color, i) => { |
| 66 | let colorName = color.name; |
| 67 | let keyColors = color.colorKeys; |
| 68 | let colorSpaceVal = color.colorSpace ?? color.colorspace; |
| 69 | let ratios = color.ratios; |
| 70 | let smooth = i === 0 ? false : color.smooth; |
| 71 | if (color.smooth === 'true') { |
| 72 | if (colorSpaceVal === 'OKLAB' || colorSpaceVal === 'OKLCH') setFirstColorSmoothing = true; |
| 73 | } |
| 74 | |
| 75 | // Create color scale item |
| 76 | let newColor = new Leo.BackgroundColor({ |
| 77 | name: colorName, |
no test coverage detected