fix: prevent double updateUI, move imports to top, label for attributes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { hexToRgb, rgbToHex, hexToHsl, hslToHex, hslToRgb, rgbToHsl } from './converter.js';
|
||||
import { hexToHsl, hslToHex, hslToRgb, rgbToHsl } from './converter.js';
|
||||
import { state } from './app.js';
|
||||
|
||||
function hslToDisplay({ h, s, l }) { return h + ', ' + s + '%, ' + l + '%'; }
|
||||
@@ -39,7 +39,6 @@ export function initEingabe(onSaveFavorit, onSaveSchema) {
|
||||
if (/^#[0-9a-fA-F]{6}$/.test(val)) {
|
||||
const hsl = hexToHsl(val);
|
||||
state.setColor(hsl);
|
||||
updateUI(hsl);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -48,7 +47,6 @@ export function initEingabe(onSaveFavorit, onSaveSchema) {
|
||||
if (rgb) {
|
||||
const hsl = rgbToHsl(rgb);
|
||||
state.setColor(hsl);
|
||||
updateUI(hsl);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -56,11 +54,16 @@ export function initEingabe(onSaveFavorit, onSaveSchema) {
|
||||
const hsl = parseHsl(hslInput.value);
|
||||
if (hsl) {
|
||||
state.setColor(hsl);
|
||||
updateUI(hsl);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('colorChanged', () => updateUI(state.color));
|
||||
document.addEventListener('colorChanged', () => {
|
||||
if (document.activeElement !== hexInput &&
|
||||
document.activeElement !== rgbInput &&
|
||||
document.activeElement !== hslInput) {
|
||||
updateUI(state.color);
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('eingabe-fav-btn').addEventListener('click', () => {
|
||||
onSaveFavorit(state.color);
|
||||
|
||||
Reference in New Issue
Block a user