@@ -12,6 +12,7 @@ import {
1212 DARK_THRESHOLD_MAX ,
1313 DARK_THRESHOLD_MIN ,
1414 formatLux ,
15+ sensitivityEnds ,
1516 sensitivityLabel ,
1617} from "../hue/motion" ;
1718import { mq } from "../mq" ;
@@ -361,36 +362,52 @@ type LevelsProps = {
361362
362363const Levels : FC < LevelsProps > = ( { value, max, onChange } ) => {
363364 const theme = useTheme ( ) ;
365+ const [ low , high ] = sensitivityEnds ( max ) ;
364366 return (
365- < div role = "radiogroup" aria-label = "herkkyys" css = { { display : "flex" , gap : 4 } } >
366- { Array . from ( { length : max + 1 } , ( _ , level ) => {
367- const selected = level === value ;
368- return (
369- < button
370- key = { level }
371- type = "button"
372- role = "radio"
373- aria-checked = { selected }
374- aria-label = { sensitivityLabel ( level , max ) }
375- onClick = { ( ) => {
376- if ( ! selected ) onChange ( level ) ;
377- } }
378- css = { {
379- width : 40 ,
380- height : 36 ,
381- border : `1px solid ${ selected ? theme . colors . activity . on : theme . colors . border } ` ,
382- borderRadius : theme . border . radiusPill ,
383- backgroundColor : selected ? theme . colors . activity . onSoft : "transparent" ,
384- color : selected ? theme . colors . activity . on : theme . colors . text . main ,
385- font : "inherit" ,
386- fontVariantNumeric : "tabular-nums" ,
387- cursor : "pointer" ,
388- } }
389- >
390- { level + 1 }
391- </ button >
392- ) ;
393- } ) }
367+ < div css = { { display : "flex" , flexDirection : "column" , gap : 2 } } >
368+ < div role = "radiogroup" aria-label = "herkkyys" css = { { display : "flex" , gap : 4 } } >
369+ { Array . from ( { length : max + 1 } , ( _ , level ) => {
370+ const selected = level === value ;
371+ return (
372+ < button
373+ key = { level }
374+ type = "button"
375+ role = "radio"
376+ aria-checked = { selected }
377+ aria-label = { sensitivityLabel ( level , max ) }
378+ onClick = { ( ) => {
379+ if ( ! selected ) onChange ( level ) ;
380+ } }
381+ css = { {
382+ width : 40 ,
383+ height : 36 ,
384+ border : `1px solid ${ selected ? theme . colors . activity . on : theme . colors . border } ` ,
385+ borderRadius : theme . border . radiusPill ,
386+ backgroundColor : selected ? theme . colors . activity . onSoft : "transparent" ,
387+ color : selected ? theme . colors . activity . on : theme . colors . text . main ,
388+ font : "inherit" ,
389+ fontVariantNumeric : "tabular-nums" ,
390+ cursor : "pointer" ,
391+ } }
392+ >
393+ { level + 1 }
394+ </ button >
395+ ) ;
396+ } ) }
397+ </ div >
398+ < div
399+ aria-hidden
400+ css = { {
401+ display : "flex" ,
402+ justifyContent : "space-between" ,
403+ gap : 8 ,
404+ ...theme . typography . caption ,
405+ color : theme . colors . text . muted ,
406+ } }
407+ >
408+ < span > { `← ${ low } ` } </ span >
409+ < span > { `${ high } →` } </ span >
410+ </ div >
394411 </ div >
395412 ) ;
396413} ;
0 commit comments