11import React , { useState , useRef , useEffect } from 'react'
2+ import { Styles , Config } from '../shared/types.js'
23import { getHandleValue } from '../utils/utils.js'
3- import { Styles } from '../shared/types.js'
44import { usePicker } from '../context.js'
55import {
66 usePaintSat ,
@@ -13,6 +13,7 @@ const AdvBar = ({
1313 value,
1414 reffy,
1515 label,
16+ config,
1617 callback,
1718 squareWidth,
1819 openAdvanced,
@@ -22,12 +23,14 @@ const AdvBar = ({
2223 reffy : any
2324 value : number
2425 label : string
26+ config : Config
2527 squareWidth : number
2628 openAdvanced : boolean
2729 defaultStyles : Styles
2830 pickerIdSuffix : string
2931 callback : ( arg0 : number ) => void
3032} ) => {
33+ const { barSize } = config
3134 const [ dragging , setDragging ] = useState < boolean > ( false )
3235 const [ handleTop , setHandleTop ] = useState < number > ( 2 )
3336 const left = value * ( squareWidth - 18 )
@@ -42,13 +45,13 @@ const AdvBar = ({
4245
4346 const handleMove = ( e : any ) => {
4447 if ( dragging ) {
45- callback ( getHandleValue ( e ) )
48+ callback ( getHandleValue ( e , barSize ) )
4649 }
4750 }
4851
4952 const handleClick = ( e : any ) => {
5053 if ( ! dragging ) {
51- callback ( getHandleValue ( e ) )
54+ callback ( getHandleValue ( e , barSize ) )
5255 }
5356 }
5457
@@ -125,7 +128,7 @@ const AdvBar = ({
125128}
126129
127130const AdvancedControls = ( { openAdvanced } : { openAdvanced : boolean } ) => {
128- const { tinyColor, handleChange, squareWidth, hc, defaultStyles, pickerIdSuffix } = usePicker ( )
131+ const { config , tinyColor, handleChange, squareWidth, hc, defaultStyles, pickerIdSuffix } = usePicker ( )
129132 const { s, l } = tinyColor . toHsl ( )
130133
131134 const satRef = useRef ( null )
@@ -180,15 +183,17 @@ const AdvancedControls = ({ openAdvanced }: { openAdvanced: boolean }) => {
180183 < AdvBar
181184 value = { s }
182185 reffy = { satRef }
183- callback = { satDesat }
186+ config = { config }
184187 label = "Saturation"
188+ callback = { satDesat }
185189 squareWidth = { squareWidth }
186190 openAdvanced = { openAdvanced }
187191 defaultStyles = { defaultStyles }
188192 pickerIdSuffix = { pickerIdSuffix }
189193 />
190194 < AdvBar
191195 value = { l }
196+ config = { config }
192197 reffy = { lightRef }
193198 label = "Lightness"
194199 callback = { setLight }
@@ -199,6 +204,7 @@ const AdvancedControls = ({ openAdvanced }: { openAdvanced: boolean }) => {
199204 />
200205 < AdvBar
201206 value = { hc ?. v }
207+ config = { config }
202208 reffy = { brightRef }
203209 label = "Brightness"
204210 callback = { setBright }
0 commit comments