2222 * SOFTWARE.
2323 */
2424
25- import type { RangeInputTheme } from '@instructure/shared-types'
25+ import type {
26+ NewComponentTypes ,
27+ SharedTokens ,
28+ TokenBoxshadowValueInst
29+ } from '@instructure/ui-themes'
2630import type { RangeInputProps , RangeInputStyle } from './props'
31+ import { darken , alpha } from '@instructure/ui-color-utils'
32+ import { boxShadowObjectToString } from '@instructure/ui-themes'
33+
34+ /**
35+ * Converts a boxShadow object with multiple shadows to CSS string
36+ */
37+ const convertBoxShadow = ( boxShadowObj : any ) : string => {
38+ if (
39+ boxShadowObj . type &&
40+ ( boxShadowObj . type === 'dropShadow' || boxShadowObj . type === 'innerShadow' )
41+ ) {
42+ return boxShadowObjectToString ( boxShadowObj )
43+ }
44+ return Object . values ( boxShadowObj )
45+ . map ( ( shadow ) => boxShadowObjectToString ( shadow as TokenBoxshadowValueInst ) )
46+ . join ( ', ' )
47+ }
2748
2849/**
2950 * ---
@@ -36,8 +57,9 @@ import type { RangeInputProps, RangeInputStyle } from './props'
3657 * @return {Object } The final style object, which will be used in the component
3758 */
3859const generateStyle = (
39- componentTheme : RangeInputTheme ,
40- props : RangeInputProps
60+ componentTheme : NewComponentTypes [ 'RangeInput' ] ,
61+ props : RangeInputProps ,
62+ sharedTokens : SharedTokens
4163) : RangeInputStyle => {
4264 const { size, thumbVariant } = props
4365 const valueSizeVariants = {
@@ -60,7 +82,9 @@ const generateStyle = (
6082
6183 const trackStyle = {
6284 borderRadius : '0.312em' ,
63- borderColor : 'transparent' ,
85+ borderWidth : '1px' ,
86+ borderStyle : 'solid' ,
87+ borderColor : componentTheme . trackBorderColor ,
6488 color : 'transparent' ,
6589 cursor : 'pointer' ,
6690 background : componentTheme . trackBackground ,
@@ -73,7 +97,7 @@ const generateStyle = (
7397 deprecated : {
7498 width : componentTheme . handleSize ,
7599 height : componentTheme . handleSize ,
76- boxShadow : `0 0.0625rem 0 ${ componentTheme . handleShadowColor } `
100+ boxShadow : `0 0.0625rem 0 ${ darken ( componentTheme . handleShadowColor ) } `
77101 } ,
78102 accessible : {
79103 width : borderedHandleSize ,
@@ -82,7 +106,7 @@ const generateStyle = (
82106 borderColor : componentTheme . handleBorderColor ,
83107 borderStyle : 'solid' ,
84108 boxSizing : 'border-box' ,
85- boxShadow : componentTheme . handleShadow
109+ boxShadow : convertBoxShadow ( componentTheme . boxShadow )
86110 }
87111 }
88112
@@ -101,25 +125,29 @@ const generateStyle = (
101125
102126 const thumbPosition = {
103127 deprecated : {
104- marginTop : `calc(-1 * ${ componentTheme . handleSize } / 4)`
128+ marginTop : `calc(-1 * ${ componentTheme . handleSize } / 4 - 1px )`
105129 } ,
106130 accessible : {
107- marginTop : `calc(-1 * ${ borderedHandleSize } / 4)`
131+ marginTop : `calc(-1 * ${ borderedHandleSize } / 4 - 1px )`
108132 }
109133 }
110134
111135 const thumbFocusActiveStyle = {
112136 deprecated : {
113137 background : componentTheme . handleFocusBackground ,
114- boxShadow : `0 0.0625rem 0 ${ componentTheme . handleShadowColor } , 0 0 0 ${ componentTheme . handleFocusOutlineWidth } ${ componentTheme . handleFocusOutlineColor } `
138+ boxShadow : `0 0.0625rem 0 ${ darken (
139+ componentTheme . handleShadowColor
140+ ) } , 0 0 0 ${ componentTheme . handleFocusOutlineWidth } ${ alpha (
141+ componentTheme . handleFocusOutlineColor ,
142+ 40
143+ ) } `
115144 } ,
116145 accessible : {
117146 background : componentTheme . handleFocusBackground ,
118147 boxShadow :
119- componentTheme . handleShadow +
120- ', ' +
148+ `${ convertBoxShadow ( componentTheme . boxShadow ) } , ` +
121149 `inset 0 0 0 ${ componentTheme . handleFocusInset } ${ componentTheme . handleFocusBackground } , ` +
122- `inset 0 0 0 calc(${ componentTheme . handleFocusInset } + ${ componentTheme . handleFocusRingSize } ) ${ componentTheme . handleFocusRingColor } `
150+ `inset 0 0 0 calc(${ componentTheme . handleFocusInset } + ${ sharedTokens . focusOutline . width } ) ${ sharedTokens . focusOutline . onColor } `
123151 }
124152 }
125153
0 commit comments