Skip to content

Commit

Permalink
color input cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
argyleink committed Apr 2, 2024
1 parent 5ff32f3 commit 235600a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/features/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Color from 'colorjs.io'
import { getStyle, contrast_color } from '../utilities/'

const state = {
active_color: 'background',
active_color: 'undefined',
elements: [],
}

Expand Down Expand Up @@ -75,9 +75,9 @@ export function ColorPicker(pallete, selectorEngine) {
: new TinyColor(getStyle(el, 'borderColor'))
}

let fg = FG.toHslString()
let bg = BG.toHslString()
let bo = BO.toHslString()
let fg = `#`+FG.toHex()
let bg = `#`+BG.toHex()
let bo = `#`+BO.toHex()

isMeaningfulForeground = FG.originalInput !== 'rgb(0, 0, 0)' || (el.children.length === 0 && el.textContent !== '')
isMeaningfulBackground = BG.originalInput !== 'rgba(0, 0, 0, 0)'
Expand All @@ -96,9 +96,12 @@ export function ColorPicker(pallete, selectorEngine) {
const bg_icon = isMeaningfulBackground ? contrast_color(bg) : ''
const bo_icon = isMeaningfulBorder ? contrast_color(bo) : ''

fgInput.attr('value', `#`+FG.toHex())
bgInput.attr('value', `#`+BG.toHex())
boInput.attr('value', `#`+BO.toHex())
fgInput.attr('value', fg)
bgInput.attr('value', bg)
boInput.attr('value', bo)
fgInput.value = fg
bgInput.value = bg
boInput.value = bo

foregroundPicker.attr('style', `
--contextual_color: ${new_fg};
Expand Down

0 comments on commit 235600a

Please sign in to comment.