4
4
5
5
import { css , ElementStyles } from '@microsoft/fast-element' ;
6
6
import {
7
+ DesignToken ,
7
8
focusVisible ,
8
9
FoundationElementTemplate ,
9
10
TextFieldOptions
10
11
} from '@microsoft/fast-foundation' ;
11
- import { designUnit } from '../design-token' ;
12
+ import { Swatch } from '../colors' ;
13
+ import {
14
+ bodyFont ,
15
+ controlCornerRadius ,
16
+ density ,
17
+ neutralFillRecipe ,
18
+ neutralFillStealthActive ,
19
+ neutralFillStealthHover ,
20
+ neutralFillStealthRecipe ,
21
+ neutralForegroundRest ,
22
+ typeRampBaseFontSize ,
23
+ typeRampBaseLineHeight ,
24
+ designUnit
25
+ } from '../design-tokens' ;
12
26
import { BaseFieldStyles , heightNumber } from '../styles/index' ;
13
27
28
+ const clearButtonHover = DesignToken . create < Swatch > (
29
+ 'clear-button-hover'
30
+ ) . withDefault ( ( target : HTMLElement ) => {
31
+ const buttonRecipe = neutralFillStealthRecipe . getValueFor ( target ) ;
32
+ const inputRecipe = neutralFillRecipe . getValueFor ( target ) ;
33
+ return buttonRecipe . evaluate ( target , inputRecipe . evaluate ( target ) . hover )
34
+ . hover ;
35
+ } ) ;
36
+
37
+ const clearButtonActive = DesignToken . create < Swatch > (
38
+ 'clear-button-active'
39
+ ) . withDefault ( ( target : HTMLElement ) => {
40
+ const buttonRecipe = neutralFillStealthRecipe . getValueFor ( target ) ;
41
+ const inputRecipe = neutralFillRecipe . getValueFor ( target ) ;
42
+ return buttonRecipe . evaluate ( target , inputRecipe . evaluate ( target ) . hover )
43
+ . active ;
44
+ } ) ;
45
+
14
46
export const searchStyles : FoundationElementTemplate <
15
47
ElementStyles ,
16
48
TextFieldOptions
@@ -37,17 +69,37 @@ export const searchStyles: FoundationElementTemplate<
37
69
outline : none;
38
70
}
39
71
40
- /* Cancel margin set for button focus outline */
41
- jp-button {
42
- margin : 0 ;
43
- }
44
-
45
72
.clear-button {
46
- position : absolute;
47
- right : 0 ;
48
- top : 1px ;
49
73
height : calc (100% - 2px );
50
74
opacity : 0 ;
75
+ margin : 1px ;
76
+ background : transparent;
77
+ color : ${ neutralForegroundRest } ;
78
+ fill : currentcolor;
79
+ border : none;
80
+ border-radius : calc (${ controlCornerRadius } * 1px );
81
+ min-width : calc (${ heightNumber } * 1px );
82
+ font-size : ${ typeRampBaseFontSize } ;
83
+ line-height : ${ typeRampBaseLineHeight } ;
84
+ outline : none;
85
+ font-family : ${ bodyFont } ;
86
+ padding : 0 calc ((10 + (${ designUnit } * 2 * ${ density } )) * 1px );
87
+ }
88
+
89
+ .clear-button : hover {
90
+ background : ${ neutralFillStealthHover } ;
91
+ }
92
+
93
+ .clear-button : active {
94
+ background : ${ neutralFillStealthActive } ;
95
+ }
96
+
97
+ : host ([appearance = 'filled' ]) .clear-button : hover {
98
+ background : ${ clearButtonHover } ;
99
+ }
100
+
101
+ : host ([appearance = 'filled' ]) .clear-button : active {
102
+ background : ${ clearButtonActive } ;
51
103
}
52
104
53
105
.input-wrapper {
0 commit comments