11import React , { useCallback , useLayoutEffect , useRef , useState } from 'react'
2- import styled from 'styled-components'
2+ import styled , { css } from 'styled-components'
33
44import { spacing , opacity , shape } from '../designparams'
55import { Typography } from '../Typography'
@@ -84,6 +84,7 @@ const BaseLabel = styled.div.attrs<{
8484} ) ) < {
8585 readonly center : number
8686 readonly width : number
87+ readonly disabled : boolean
8788} > `
8889 position: absolute;
8990 cursor: pointer;
@@ -92,6 +93,20 @@ const BaseLabel = styled.div.attrs<{
9293 background-color: ${ ( { theme } ) => theme . color . element11 ( opacity [ 24 ] ) } ;
9394 transform: scaleX(1);
9495 }
96+
97+ ${ ( { disabled } ) =>
98+ disabled
99+ ? css `
100+ pointer-events : none;
101+ opacity : ${ opacity [ 48 ] } ;
102+ `
103+ : undefined } ;
104+ `
105+
106+ const Label = styled ( Typography ) . attrs ( {
107+ variant : 'explanatory-text' ,
108+ } ) `
109+ color: ${ ( { theme } ) => theme . color . text04 ( ) } ;
95110`
96111
97112export const TickMarker : React . FC < Omit < Tick , 'label' > > = ( {
@@ -113,6 +128,10 @@ interface TickLabelProps {
113128 * Label for the tickMarker, eg. `°`
114129 */
115130 readonly label ?: string
131+ /**
132+ * If `true`, the tick label will be disabled
133+ */
134+ readonly disabled ?: boolean
116135 /**
117136 * Executes JavaScript when clicking the value.
118137 */
@@ -124,6 +143,7 @@ export const TickLabel: React.FC<TickLabelProps> = ({
124143 label,
125144 value,
126145 handleChange,
146+ disabled = false ,
127147} ) => {
128148 const [ width , setWidth ] = useState < number > ( 0 )
129149 const el = useRef < HTMLDivElement | null > ( null )
@@ -145,12 +165,10 @@ export const TickLabel: React.FC<TickLabelProps> = ({
145165 } , [ ] )
146166
147167 return (
148- < BaseLabel ref = { el } center = { position } width = { width } >
168+ < BaseLabel ref = { el } center = { position } width = { width } disabled = { disabled } >
149169 < LabelContainer onClick = { handleClick } >
150170 < BoxHalo width = { width } > </ BoxHalo >
151- < Typography variant = "explanatory-text" >
152- { label === undefined ? value : label }
153- </ Typography >
171+ < Label > { label === undefined ? value : label } </ Label >
154172 </ LabelContainer >
155173 </ BaseLabel >
156174 )
0 commit comments