MCPcopy Create free account
hub / github.com/adobe/leonardo / paramSetup

Function paramSetup

docs/ui/src/js/params.js:20–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18import {_theme, tempGray} from './initialTheme';
19
20function 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,

Callers 1

theme.jsFile · 0.90

Calls 9

sanitizeQueryStringFunction · 0.90
addColorScaleFunction · 0.90
roundFunction · 0.90
baseScaleOptionsFunction · 0.90
addRatioInputsFunction · 0.90
sortRatiosFunction · 0.90
getClosestColorNameFunction · 0.90
themeUpdateFunction · 0.85
clearParamsFunction · 0.85

Tested by

no test coverage detected