1- import React , { useState } from ' react'
2- import { CONSTANTS } from ' ../../Utility/config' ;
1+ import React , { useState } from " react" ;
2+ import { CONSTANTS } from " ../../Utility/config" ;
33
4- function ShowValue ( { mainCanvasInputHandler, inputArrayLength} ) {
4+ function ShowValue ( { mainCanvasInputHandler, inputArrayLength } ) {
55 const MARGIN = CONSTANTS . margin ;
66 const SCREEN_WIDTH = window . innerWidth ;
7- const BAR_WIDTH = Math . floor ( ( SCREEN_WIDTH - ( MARGIN * inputArrayLength ) ) / inputArrayLength ) ;
7+ const BAR_WIDTH = Math . floor (
8+ ( SCREEN_WIDTH - MARGIN * inputArrayLength ) / inputArrayLength
9+ ) ;
810
9-
10- const [ enable , setEnable ] = useState ( JSON . parse ( localStorage . getItem ( 'options' ) ) ?. showHeight || false ) ;
11+ const [ enable , setEnable ] = useState (
12+ JSON . parse ( localStorage . getItem ( "options" ) ) ?. showHeight || false
13+ ) ;
1114 return (
12- < div className = { `${ BAR_WIDTH > 25 ? 'block' : 'hidden' } h-[2.6em] dark:lg:hover:bg-gray-500 lg:hover:bg-lightGreen group relative rounded-md ${ mainCanvasInputHandler . state . options . showHeight && "dark:bg-gray-200 bg-lightGreen" } ` } onClick = { ( ) => {
13- mainCanvasInputHandler . setState ( prev => ( { options : { ...prev . options , showHeight : ! mainCanvasInputHandler . state . options . showHeight } } ) ) ;
14- setEnable ( ! enable ) ;
15- let j = JSON . parse ( localStorage . getItem ( 'options' ) ) ;
16- if ( j ) {
17- j [ "showHeight" ] = ! enable ;
18- localStorage . setItem ( 'options' , JSON . stringify ( j ) )
19- }
20- } } >
21-
22- < div className = { `flex items-center justify-center relative cursor-pointer h-full dark:border-[1px] border-2 dark:border-gray-200 border-gray-300 rounded-md ${ mainCanvasInputHandler . state . options . showHeight && "dark:border-gray-400" } ` } >
15+ < div
16+ className = { `${
17+ BAR_WIDTH > 25 ? "block" : "hidden"
18+ } h-[2.6em] dark:lg:hover:bg-gray-500 lg:hover:bg-lightGreen group relative rounded-md ${
19+ mainCanvasInputHandler . state . options . showHeight &&
20+ "dark:bg-gray-200 bg-lightGreen"
21+ } `}
22+ onClick = { ( ) => {
23+ mainCanvasInputHandler . setState ( ( prev ) => ( {
24+ options : {
25+ ...prev . options ,
26+ showHeight : ! mainCanvasInputHandler . state . options . showHeight ,
27+ } ,
28+ } ) ) ;
29+ setEnable ( ! enable ) ;
30+ let j = JSON . parse ( localStorage . getItem ( "options" ) ) ;
31+ if ( j ) {
32+ j [ "showHeight" ] = ! enable ;
33+ localStorage . setItem ( "options" , JSON . stringify ( j ) ) ;
34+ }
35+ } }
36+ >
37+ < div
38+ className = { `flex items-center justify-center relative cursor-pointer h-full dark:border-[1px] border-2 dark:border-gray-200 border-gray-300 rounded-md ${
39+ mainCanvasInputHandler . state . options . showHeight &&
40+ "dark:border-gray-400"
41+ } `}
42+ >
2343 < div className = { `p-2 peer group` } >
24- { < div className = { `scale-[1.3] lg:group-hover:text-white ${ mainCanvasInputHandler . state . options . showHeight ? "text-white dark:text-[#7B7B7c]" : "text-[#7B7B7c]" } w-5 text-center font-bold` } > H</ div > }
25- </ div >
26- </ div >
27- < p className = { `shadow-lg bg-white z-10 text-[.9em] absolute top-[4.4em] left-[50%] -translate-x-[50%] p-2 rounded-md hidden group-hover:block tool-tip-options text-gray-600 whitespace-nowrap font-semibold` } > Show height</ p >
44+ {
45+ < div
46+ className = { `scale-[1.3] lg:group-hover:text-white ${
47+ mainCanvasInputHandler . state . options . showHeight
48+ ? "text-white dark:text-[#7B7B7c]"
49+ : "text-[#7B7B7c]"
50+ } w-5 text-center font-bold`}
51+ >
52+ H
53+ </ div >
54+ }
55+ </ div >
56+ </ div >
57+ < p
58+ className = { `shadow-lg bg-white z-10 text-[.9em] absolute top-[4.4em] left-[50%] -translate-x-[50%] p-2 rounded-md hidden group-hover:block tool-tip-options text-gray-600 whitespace-nowrap font-semibold` }
59+ >
60+ Show height
61+ </ p >
2862 </ div >
29- )
63+ ) ;
3064}
3165
32- export default ShowValue ;
66+ export default ShowValue ;
0 commit comments