@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useRef, MutableRefObject } from 'react'
33import * as styles from './styles/time-dropdown'
44import useConfig from '../hooks/config-context'
55import { getScrollBarWidth } from '../helpers/dom'
6- import { getTimeValue } from '../helpers/utils'
6+ import { getNormalizedTimeValue } from '../helpers/utils'
77import { ElementRef } from '../helpers/types'
88import { CLOCK_VALUES , MODE } from '../helpers/constants'
99import useTimekeeperState from '../hooks/state-context'
@@ -24,7 +24,7 @@ export default function TimeDropdown({ close }: Props) {
2424 const selectedOption : ElementLiRef = useRef ( null )
2525
2626 const options = CLOCK_VALUES [ mode ] . dropdown
27- const selected = getTimeValue ( mode , time ) . toString ( )
27+ const selected = getNormalizedTimeValue ( mode , time ) . toString ( )
2828
2929 function disableBodyScroll ( ) {
3030 document . documentElement . style . paddingRight = scrollbarWidth + 'px'
@@ -86,16 +86,22 @@ export default function TimeDropdown({ close }: Props) {
8686 className = "react-timekeeper__time-dropdown"
8787 >
8888 < ul css = { styles . options } className = "react-timekeeper__dropdown-numbers" >
89- { options . map ( ( o ) => (
90- < li
91- ref = { ( el ) => ( selected === o ? ( selectedOption . current = el ) : '' ) }
92- css = { styles . option ( selected === o ) }
93- key = { o }
94- onClick = { ( ) => select ( o ) }
95- >
96- { o }
97- </ li >
98- ) ) }
89+ { options . map ( ( o ) => {
90+ const isSelected = selected === o
91+ return (
92+ < li
93+ ref = { ( el ) => ( isSelected ? ( selectedOption . current = el ) : '' ) }
94+ className = { `react-timekeeper__dropdown-number ${
95+ isSelected ? 'react-timekeeper__dropdown-number--active' : ''
96+ } `}
97+ css = { styles . option ( isSelected ) }
98+ key = { o }
99+ onClick = { ( ) => select ( o ) }
100+ >
101+ { o }
102+ </ li >
103+ )
104+ } ) }
99105 </ ul >
100106 </ div >
101107 )
0 commit comments