@@ -15,7 +15,7 @@ const iconSizes = {
1515 large : '24px' ,
1616} ;
1717
18- // TODO: This 400 style is not in the typography styles.
18+ // This 400 style is not in the typography styles.
1919// May need a design change
2020const contentSizes = {
2121 400 : {
@@ -31,6 +31,36 @@ const fieldHeights = {
3131 large : '40px' ,
3232} ;
3333
34+ /* Since the <select> element must span the full width and cannot have children,
35+ * the right padding needs to be calculated from the sum of the following:
36+ * 1. Field padding-right
37+ * 2. Icon width
38+ * 3. Content-icon spacing
39+ * 4. Content inner padding
40+ */
41+ const paddingRight = {
42+ small : `calc(${ tokens . spacingHorizontalSNudge }
43+ + ${ iconSizes . small }
44+ + ${ tokens . spacingHorizontalXXS }
45+ + ${ tokens . spacingHorizontalXXS } )` ,
46+ medium : `calc(${ tokens . spacingHorizontalMNudge }
47+ + ${ iconSizes . medium }
48+ + ${ tokens . spacingHorizontalXXS }
49+ + ${ tokens . spacingHorizontalXXS } )` ,
50+ large : `calc(${ tokens . spacingHorizontalM }
51+ + ${ iconSizes . large }
52+ + ${ tokens . spacingHorizontalSNudge }
53+ + ${ tokens . spacingHorizontalSNudge } )` ,
54+ } ;
55+
56+ /* Left padding is calculated from the outer padding + inner content padding values
57+ * since <select> can't have additional child content or custom inner layout */
58+ const paddingLeft = {
59+ small : `calc(${ tokens . spacingHorizontalSNudge } + ${ tokens . spacingHorizontalXXS } )` ,
60+ medium : `calc(${ tokens . spacingHorizontalMNudge } + ${ tokens . spacingHorizontalXXS } )` ,
61+ large : `calc(${ tokens . spacingHorizontalM } + ${ tokens . spacingHorizontalSNudge } )` ,
62+ } ;
63+
3464/* end of shared values */
3565
3666const useRootStyles = makeStyles ( {
@@ -91,7 +121,11 @@ const useSelectStyles = makeStyles({
91121 boxShadow : 'none' ,
92122 boxSizing : 'border-box' ,
93123 color : tokens . colorNeutralForeground1 ,
124+ cursor : 'pointer' ,
94125 flexGrow : 1 ,
126+ maxWidth : '100%' ,
127+ paddingBottom : 0 ,
128+ paddingTop : 0 ,
95129
96130 ':focus' : {
97131 outlineWidth : '2px' ,
@@ -108,25 +142,39 @@ const useSelectStyles = makeStyles({
108142 ...shorthands . borderColor ( 'GrayText' ) ,
109143 } ,
110144 } ,
145+
111146 small : {
112147 height : fieldHeights . small ,
113- ...shorthands . padding ( '0' , tokens . spacingHorizontalSNudge ) ,
148+ paddingLeft : paddingLeft . small ,
149+ paddingRight : paddingRight . small ,
114150 ...typographyStyles . caption1 ,
115151 } ,
116152 medium : {
117153 height : fieldHeights . medium ,
118- ...shorthands . padding ( '0' , tokens . spacingHorizontalMNudge ) ,
154+ paddingLeft : paddingLeft . medium ,
155+ paddingRight : paddingRight . medium ,
119156 ...typographyStyles . body1 ,
120157 } ,
121158 large : {
122159 height : fieldHeights . large ,
123- ...shorthands . padding ( '0' , tokens . spacingHorizontalM ) ,
160+ paddingLeft : paddingLeft . large ,
161+ paddingRight : paddingRight . large ,
124162 ...contentSizes [ 400 ] ,
125163 } ,
126164 outline : {
127165 backgroundColor : tokens . colorNeutralBackground1 ,
128166 ...shorthands . border ( '1px' , 'solid' , tokens . colorNeutralStroke1 ) ,
129167 borderBottomColor : tokens . colorNeutralStrokeAccessible ,
168+
169+ '&:hover' : {
170+ ...shorthands . borderColor ( tokens . colorNeutralStroke1Hover ) ,
171+ borderBottomColor : tokens . colorNeutralStrokeAccessible ,
172+ } ,
173+
174+ '&:active' : {
175+ ...shorthands . borderColor ( tokens . colorNeutralStroke1Pressed ) ,
176+ borderBottomColor : tokens . colorNeutralStrokeAccessible ,
177+ } ,
130178 } ,
131179 underline : {
132180 backgroundColor : tokens . colorTransparentBackground ,
@@ -157,7 +205,6 @@ const useIconStyles = makeStyles({
157205 color : tokens . colorNeutralStrokeAccessible ,
158206 display : 'block' ,
159207 position : 'absolute' ,
160- right : tokens . spacingHorizontalMNudge ,
161208 pointerEvents : 'none' ,
162209
163210 // the SVG must have display: block for accurate positioning
@@ -175,22 +222,19 @@ const useIconStyles = makeStyles({
175222 small : {
176223 fontSize : iconSizes . small ,
177224 height : iconSizes . small ,
178- paddingRight : tokens . spacingHorizontalSNudge ,
179- paddingLeft : tokens . spacingHorizontalXXS ,
225+ right : tokens . spacingHorizontalSNudge ,
180226 width : iconSizes . small ,
181227 } ,
182228 medium : {
183229 fontSize : iconSizes . medium ,
184230 height : iconSizes . medium ,
185- paddingRight : tokens . spacingHorizontalM ,
186- paddingLeft : tokens . spacingHorizontalXXS ,
231+ right : tokens . spacingHorizontalMNudge ,
187232 width : iconSizes . medium ,
188233 } ,
189234 large : {
190235 fontSize : iconSizes . large ,
191236 height : iconSizes . large ,
192- paddingRight : tokens . spacingHorizontalM ,
193- paddingLeft : tokens . spacingHorizontalSNudge ,
237+ right : tokens . spacingHorizontalM ,
194238 width : iconSizes . large ,
195239 } ,
196240} ) ;
0 commit comments