Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter setup bugfixes #205

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions packages/ui/src/js/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from './initialTheme';

function paramSetup() {
let setFirstColorSmoothing = false;
let url = new URL(window.location);
let params = new URLSearchParams(url.search.slice(1));
let themeBase = document.getElementById('themeBase');
Expand All @@ -51,6 +52,7 @@ function paramSetup() {
let colorScales = config.colorScales;
let baseScale = config.baseScale;
let lightness = (config.lightness) ? config.lightness : config.brightness;

let contrast;
let formula;
if(!config.formula) {
Expand All @@ -69,12 +71,15 @@ function paramSetup() {
if(colorScales.length > 0) {
_theme.removeColor = tempGray;

colorScales.map(color => {
colorScales.map((color, i) => {
let colorName = color.name;
let keyColors = color.colorKeys;
let colorSpace = color.colorspace;
let ratios = color.ratios;
let smooth = color.smooth;
let smooth = (i === 0) ? false : color.smooth;
if(color.smooth === "true") {
if(color.colorspace === 'OKLAB' || color.colorspace === 'OKLCH') setFirstColorSmoothing = true;
}

// Create color scale item
let newColor = new Leo.BackgroundColor({
Expand Down Expand Up @@ -102,9 +107,12 @@ function paramSetup() {

let slider = document.getElementById('themeBrightnessSlider');
let sliderVal = document.getElementById('themeBrightnessValue');

if(lightness === undefined) lightness = 0;
_theme.lightness = lightness;
slider.value = lightness;
sliderVal.innerHTML = lightness;
_theme.lightness = lightness;


let contrastSlider = document.getElementById('themeContrastSlider');
let contrastSliderVal = document.getElementById('themeContrastValue');
Expand Down Expand Up @@ -225,6 +233,10 @@ function paramSetup() {
}

setTimeout(() => {
if(setFirstColorSmoothing) {
let firstColorName = _theme.colors[0].name;
_theme.updateColor = {name: firstColorName, smooth: 'true'}
}
themeUpdate();
}, 200)
clearParams();
Expand Down