Skip to content

Commit

Permalink
default numbers to consts
Browse files Browse the repository at this point in the history
  • Loading branch information
FrantisekMichalSebestyen committed Nov 23, 2023
1 parent a700678 commit 7de6f37
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions resources/js/components/catalog-new/NewColorSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,18 @@
import tinycolor from 'tinycolor2'
import VueSlider from 'vue-slider-component'
const defaultHue = 180
const defaultLightness = 0.5
export default {
props: {
defaultColor: String,
},
data() {
const hue = this.defaultColor ? tinycolor(this.defaultColor).toHsl()?.h : 180
const lightness = this.defaultColor ? tinycolor(this.defaultColor)?.toHsl()?.l : 0.5
const hue = this.defaultColor ? tinycolor(this.defaultColor).toHsl()?.h : defaultHue
const lightness = this.defaultColor
? tinycolor(this.defaultColor)?.toHsl()?.l
: defaultLightness
return {
hue,
immediateHue: hue,
Expand All @@ -92,8 +97,10 @@ export default {
},
watch: {
defaultColor(newDefaultColor) {
this.hue = newDefaultColor ? tinycolor(newDefaultColor).toHsl()?.h : 180
this.lightness = newDefaultColor ? tinycolor(newDefaultColor)?.toHsl()?.l : 0.5
this.hue = newDefaultColor ? tinycolor(newDefaultColor).toHsl()?.h : defaultHue
this.lightness = newDefaultColor
? tinycolor(newDefaultColor)?.toHsl()?.l
: defaultLightness
},
hue(newHue) {
this.immediateHue = newHue
Expand Down

0 comments on commit 7de6f37

Please sign in to comment.