@fluentui/web-components 1.6.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +103 -1
- package/CHANGELOG.md +40 -2
- package/dist/dts/calendar/calendar.stories.d.ts +86 -0
- package/dist/dts/calendar/calendar.styles.d.ts +7 -0
- package/dist/dts/calendar/index.d.ts +18 -0
- package/dist/dts/color/palette.d.ts +43 -1
- package/dist/dts/color/recipes/contrast-and-delta-swatch-set.d.ts +11 -0
- package/dist/dts/color/recipes/contrast-swatch.d.ts +12 -0
- package/dist/dts/color/recipes/delta-swatch-set.d.ts +36 -0
- package/dist/dts/color/recipes/{neutral-divider.d.ts → delta-swatch.d.ts} +3 -2
- package/dist/dts/color/recipes/focus-stroke.d.ts +2 -2
- package/dist/dts/color/recipes/foreground-on-accent.d.ts +6 -0
- package/dist/dts/color/recipes/gradient-shadow-stroke.d.ts +7 -0
- package/dist/dts/color/recipes/gradient-swatch.d.ts +36 -0
- package/dist/dts/color/recipes/neutral-layer-1.d.ts +4 -0
- package/dist/dts/color/recipes/neutral-layer-2.d.ts +1 -5
- package/dist/dts/color/recipes/neutral-layer-3.d.ts +1 -1
- package/dist/dts/color/recipes/neutral-layer-4.d.ts +1 -1
- package/dist/dts/color/recipes/neutral-layer-floating.d.ts +1 -1
- package/dist/dts/color/recipes/underline-stroke.d.ts +7 -0
- package/dist/dts/color/swatch.d.ts +7 -0
- package/dist/dts/color/utilities/base-layer-luminance.d.ts +2 -2
- package/dist/dts/combobox/index.d.ts +1 -2
- package/dist/dts/custom-elements.d.ts +4 -2
- package/dist/dts/data-grid/data-grid-row.styles.d.ts +1 -1
- package/dist/dts/data-grid/index.d.ts +1 -1
- package/dist/dts/design-system-provider/index.d.ts +14 -29
- package/dist/dts/design-tokens.d.ts +198 -82
- package/dist/dts/menu/index.d.ts +11 -6
- package/dist/dts/menu/menu.stories.d.ts +1 -1
- package/dist/dts/select/index.d.ts +1 -1
- package/dist/dts/select/select.stories.d.ts +8 -0
- package/dist/dts/select/select.styles.d.ts +1 -0
- package/dist/dts/skeleton/skeleton.stories.d.ts +1 -0
- package/dist/dts/styles/elevation.d.ts +44 -5
- package/dist/dts/styles/patterns/button.styles.d.ts +7 -6
- package/dist/dts/styles/patterns/index.d.ts +1 -1
- package/dist/dts/styles/patterns/input.styles.d.ts +22 -0
- package/dist/dts/text-area/text-area.stories.d.ts +1 -1
- package/dist/dts/tree-view/tree-view.stories.d.ts +0 -5
- package/dist/esm/accordion/accordion-item/accordion-item.styles.js +54 -17
- package/dist/esm/accordion/accordion-item/index.js +4 -22
- package/dist/esm/accordion/accordion.styles.js +4 -4
- package/dist/esm/anchor/anchor.stories.js +2 -2
- package/dist/esm/anchor/anchor.styles.js +8 -2
- package/dist/esm/badge/badge.styles.js +10 -2
- package/dist/esm/breadcrumb-item/breadcrumb-item.styles.js +44 -53
- package/dist/esm/breadcrumb-item/index.js +2 -4
- package/dist/esm/button/button.stories.js +1 -1
- package/dist/esm/button/button.styles.js +21 -71
- package/dist/esm/calendar/calendar.stories.js +115 -0
- package/dist/esm/calendar/calendar.styles.js +133 -0
- package/dist/esm/calendar/index.js +31 -0
- package/dist/esm/card/card.stories.js +14 -0
- package/dist/esm/card/card.styles.js +23 -32
- package/dist/esm/card/index.js +1 -1
- package/dist/esm/checkbox/checkbox.styles.js +58 -51
- package/dist/esm/checkbox/index.js +5 -13
- package/dist/esm/color/palette.js +174 -12
- package/dist/esm/color/recipes/contrast-and-delta-swatch-set.js +28 -0
- package/dist/esm/color/recipes/contrast-swatch.js +12 -0
- package/dist/esm/color/recipes/delta-swatch-set.js +53 -0
- package/dist/esm/color/recipes/{neutral-divider.js → delta-swatch.js} +3 -2
- package/dist/esm/color/recipes/focus-stroke.js +4 -3
- package/dist/esm/color/recipes/foreground-on-accent.js +14 -0
- package/dist/esm/color/recipes/gradient-shadow-stroke.js +54 -0
- package/dist/esm/color/recipes/gradient-swatch.js +36 -0
- package/dist/esm/color/recipes/neutral-layer-1.js +7 -1
- package/dist/esm/color/recipes/neutral-layer-2.js +3 -9
- package/dist/esm/color/recipes/neutral-layer-3.js +3 -3
- package/dist/esm/color/recipes/neutral-layer-4.js +3 -3
- package/dist/esm/color/recipes/neutral-layer-floating.js +3 -4
- package/dist/esm/color/recipes/underline-stroke.js +31 -0
- package/dist/esm/color/swatch.js +22 -2
- package/dist/esm/color/utilities/base-layer-luminance.js +2 -2
- package/dist/esm/combobox/combobox.stories.js +1 -0
- package/dist/esm/combobox/index.js +6 -9
- package/dist/esm/custom-elements.js +3 -1
- package/dist/esm/data-grid/data-grid-cell.styles.js +4 -4
- package/dist/esm/data-grid/data-grid-row.styles.js +3 -3
- package/dist/esm/design-system-provider/design-system-provider.vscode.definition.json +17 -9
- package/dist/esm/design-system-provider/index.js +24 -39
- package/dist/esm/design-tokens.js +303 -217
- package/dist/esm/dialog/dialog.styles.js +2 -3
- package/dist/esm/divider/divider.styles.js +1 -2
- package/dist/esm/flipper/flipper.styles.js +28 -65
- package/dist/esm/flipper/index.js +4 -8
- package/dist/esm/listbox/listbox.styles.js +8 -29
- package/dist/esm/listbox-option/listbox-option.styles.js +52 -35
- package/dist/esm/menu/index.js +16 -6
- package/dist/esm/menu/menu.stories.js +16 -2
- package/dist/esm/menu/menu.styles.js +38 -27
- package/dist/esm/menu-item/index.js +6 -33
- package/dist/esm/menu-item/menu-item.stories.js +1 -1
- package/dist/esm/menu-item/menu-item.styles.js +58 -84
- package/dist/esm/number-field/index.js +7 -3
- package/dist/esm/number-field/number-field.styles.js +30 -175
- package/dist/esm/progress/progress/index.js +1 -1
- package/dist/esm/progress/progress/progress.styles.js +13 -18
- package/dist/esm/progress/progress-ring/progress-ring.styles.js +65 -69
- package/dist/esm/radio/index.js +3 -1
- package/dist/esm/radio/radio.stories.js +3 -2
- package/dist/esm/radio/radio.styles.js +52 -42
- package/dist/esm/radio-group/radio-group.styles.js +0 -2
- package/dist/esm/select/index.js +6 -9
- package/dist/esm/select/select.stories.js +10 -2
- package/dist/esm/select/select.styles.js +100 -124
- package/dist/esm/select/select.vscode.definition.json +3 -0
- package/dist/esm/skeleton/skeleton.stories.js +3 -2
- package/dist/esm/skeleton/skeleton.styles.js +11 -6
- package/dist/esm/slider/slider.styles.js +54 -14
- package/dist/esm/slider-label/slider-label.styles.js +5 -6
- package/dist/esm/styles/direction.js +1 -1
- package/dist/esm/styles/elevation.js +54 -5
- package/dist/esm/styles/patterns/button.styles.js +274 -294
- package/dist/esm/styles/patterns/index.js +1 -1
- package/dist/esm/styles/patterns/input.styles.js +218 -0
- package/dist/esm/switch/index.js +3 -1
- package/dist/esm/switch/switch.stories.js +3 -3
- package/dist/esm/switch/switch.styles.js +79 -60
- package/dist/esm/tabs/tab/tab.styles.js +11 -14
- package/dist/esm/tabs/tabs.styles.js +9 -8
- package/dist/esm/text-area/text-area.stories.js +2 -2
- package/dist/esm/text-area/text-area.styles.js +16 -96
- package/dist/esm/text-field/text-field.stories.js +1 -1
- package/dist/esm/text-field/text-field.styles.js +16 -144
- package/dist/esm/toolbar/index.js +1 -0
- package/dist/esm/toolbar/toolbar.styles.js +56 -56
- package/dist/esm/tooltip/index.js +2 -4
- package/dist/esm/tooltip/tooltip.styles.js +14 -14
- package/dist/esm/tree-item/index.js +2 -8
- package/dist/esm/tree-item/tree-item.styles.js +45 -80
- package/dist/esm/tree-view/tree-view.stories.js +23 -11
- package/dist/fluent-web-components.api.json +4900 -2353
- package/dist/web-components.d.ts +397 -100
- package/dist/web-components.js +2240 -2175
- package/dist/web-components.min.js +158 -128
- package/docs/api-report.md +338 -80
- package/package.json +2 -5
- package/public/switches.ts +13 -14
- package/dist/dts/color/recipes/accent-fill.d.ts +0 -7
- package/dist/dts/color/recipes/accent-foreground.d.ts +0 -7
- package/dist/dts/color/recipes/neutral-fill-contrast.d.ts +0 -7
- package/dist/dts/color/recipes/neutral-fill-input.d.ts +0 -7
- package/dist/dts/color/recipes/neutral-fill-inverse.d.ts +0 -7
- package/dist/dts/color/recipes/neutral-fill-layer.d.ts +0 -6
- package/dist/dts/color/recipes/neutral-fill-stealth.d.ts +0 -7
- package/dist/dts/color/recipes/neutral-fill.d.ts +0 -14
- package/dist/dts/color/recipes/neutral-foreground-hint.d.ts +0 -10
- package/dist/dts/color/recipes/neutral-foreground.d.ts +0 -6
- package/dist/dts/color/recipes/neutral-layer-card-container.d.ts +0 -6
- package/dist/dts/color/recipes/neutral-stroke-strong.d.ts +0 -7
- package/dist/dts/color/recipes/neutral-stroke.d.ts +0 -7
- package/dist/dts/styles/patterns/input.d.ts +0 -4
- package/dist/dts/utilities/math.d.ts +0 -24
- package/dist/esm/color/recipes/accent-fill.js +0 -18
- package/dist/esm/color/recipes/accent-foreground.js +0 -31
- package/dist/esm/color/recipes/neutral-fill-contrast.js +0 -26
- package/dist/esm/color/recipes/neutral-fill-input.js +0 -14
- package/dist/esm/color/recipes/neutral-fill-inverse.js +0 -26
- package/dist/esm/color/recipes/neutral-fill-layer.js +0 -7
- package/dist/esm/color/recipes/neutral-fill-stealth.js +0 -14
- package/dist/esm/color/recipes/neutral-fill.js +0 -21
- package/dist/esm/color/recipes/neutral-foreground-hint.js +0 -10
- package/dist/esm/color/recipes/neutral-foreground.js +0 -6
- package/dist/esm/color/recipes/neutral-layer-card-container.js +0 -9
- package/dist/esm/color/recipes/neutral-stroke-strong.js +0 -15
- package/dist/esm/color/recipes/neutral-stroke.js +0 -18
- package/dist/esm/styles/patterns/input.js +0 -31
- package/dist/esm/utilities/math.js +0 -49
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { css } from '@microsoft/fast-element';
|
|
2
|
+
import { DesignToken, disabledCursor, focusVisible, } from '@microsoft/fast-foundation';
|
|
3
|
+
import { SystemColors } from '@microsoft/fast-web-utilities';
|
|
4
|
+
import { accentFillRest, bodyFont, controlCornerRadius, disabledOpacity, focusStrokeWidth, neutralFillInputFocus, neutralFillInputHover, neutralFillInputRecipe, neutralFillInputRest, neutralFillSecondaryHover, neutralFillSecondaryRecipe, neutralFillSecondaryRest, neutralForegroundHintRecipe, neutralForegroundRest, neutralStrokeInputHover, neutralStrokeInputRest, neutralStrokeRest, strokeWidth, typeRampBaseFontSize, typeRampBaseLineHeight, } from '../../design-tokens';
|
|
5
|
+
import { heightNumber } from '../size';
|
|
6
|
+
const placeholderRest = DesignToken.create('input-placeholder-rest').withDefault((target) => {
|
|
7
|
+
const baseRecipe = neutralFillInputRecipe.getValueFor(target);
|
|
8
|
+
const hintRecipe = neutralForegroundHintRecipe.getValueFor(target);
|
|
9
|
+
return hintRecipe.evaluate(target, baseRecipe.evaluate(target).rest);
|
|
10
|
+
});
|
|
11
|
+
const placeholderHover = DesignToken.create('input-placeholder-hover').withDefault((target) => {
|
|
12
|
+
const baseRecipe = neutralFillInputRecipe.getValueFor(target);
|
|
13
|
+
const hintRecipe = neutralForegroundHintRecipe.getValueFor(target);
|
|
14
|
+
return hintRecipe.evaluate(target, baseRecipe.evaluate(target).hover);
|
|
15
|
+
});
|
|
16
|
+
const filledPlaceholderRest = DesignToken.create('input-filled-placeholder-rest').withDefault((target) => {
|
|
17
|
+
const baseRecipe = neutralFillSecondaryRecipe.getValueFor(target);
|
|
18
|
+
const hintRecipe = neutralForegroundHintRecipe.getValueFor(target);
|
|
19
|
+
return hintRecipe.evaluate(target, baseRecipe.evaluate(target).rest);
|
|
20
|
+
});
|
|
21
|
+
const filledPlaceholderHover = DesignToken.create('input-filled-placeholder-hover').withDefault((target) => {
|
|
22
|
+
const baseRecipe = neutralFillSecondaryRecipe.getValueFor(target);
|
|
23
|
+
const hintRecipe = neutralForegroundHintRecipe.getValueFor(target);
|
|
24
|
+
return hintRecipe.evaluate(target, baseRecipe.evaluate(target).hover);
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export const inputStyles = (context, definition, rootSelector) => css `
|
|
30
|
+
:host {
|
|
31
|
+
font-family: ${bodyFont};
|
|
32
|
+
font-size: ${typeRampBaseFontSize};
|
|
33
|
+
line-height: ${typeRampBaseLineHeight};
|
|
34
|
+
color: ${neutralForegroundRest};
|
|
35
|
+
fill: currentcolor;
|
|
36
|
+
outline: none;
|
|
37
|
+
user-select: none;
|
|
38
|
+
position: relative;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${rootSelector} {
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
position: relative;
|
|
44
|
+
color: inherit;
|
|
45
|
+
background: padding-box linear-gradient(${neutralFillInputRest}, ${neutralFillInputRest}),
|
|
46
|
+
border-box ${neutralStrokeInputRest};
|
|
47
|
+
border: calc(${strokeWidth} * 1px) solid transparent;
|
|
48
|
+
border-radius: calc(${controlCornerRadius} * 1px);
|
|
49
|
+
height: calc(${heightNumber} * 1px);
|
|
50
|
+
font-family: inherit;
|
|
51
|
+
font-size: inherit;
|
|
52
|
+
line-height: inherit;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.control {
|
|
56
|
+
width: 100%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.control:hover,
|
|
60
|
+
.control:${focusVisible},
|
|
61
|
+
.control:disabled,
|
|
62
|
+
.control:active {
|
|
63
|
+
outline: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.label {
|
|
67
|
+
display: block;
|
|
68
|
+
color: ${neutralForegroundRest};
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
font-size: ${typeRampBaseFontSize};
|
|
71
|
+
line-height: ${typeRampBaseLineHeight};
|
|
72
|
+
margin-bottom: 4px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.label__hidden {
|
|
76
|
+
display: none;
|
|
77
|
+
visibility: hidden;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host(:hover:not([disabled]):not(:focus-within)) ${rootSelector} {
|
|
81
|
+
background: padding-box linear-gradient(${neutralFillInputHover}, ${neutralFillInputHover}),
|
|
82
|
+
border-box ${neutralStrokeInputHover};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:host(:not([disabled]):focus-within) ${rootSelector} {
|
|
86
|
+
background: padding-box linear-gradient(${neutralFillInputFocus}, ${neutralFillInputFocus}),
|
|
87
|
+
border-box ${neutralStrokeInputRest};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.control::placeholder {
|
|
91
|
+
color: ${placeholderRest};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:host(:hover:not([disabled]):not(:focus-within)) .control::placeholder {
|
|
95
|
+
color: ${placeholderHover};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host([disabled]) ${rootSelector}, :host([readonly]) ${rootSelector}, :host([disabled]) .label,
|
|
99
|
+
:host([readonly]) .label,
|
|
100
|
+
:host([disabled]) .control,
|
|
101
|
+
:host([readonly]) .control {
|
|
102
|
+
cursor: ${disabledCursor};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host([disabled]) {
|
|
106
|
+
opacity: ${disabledOpacity};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
:host([disabled]) ${rootSelector} {
|
|
110
|
+
background: padding-box linear-gradient(${neutralFillInputRest}, ${neutralFillInputRest}),
|
|
111
|
+
border-box ${neutralStrokeRest};
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
/**
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
export const inputStateStyles = (context, definition, rootSelector) => css `
|
|
118
|
+
:host(:not([disabled]):active)::after {
|
|
119
|
+
left: 50%;
|
|
120
|
+
width: 40%;
|
|
121
|
+
transform: translateX(-50%);
|
|
122
|
+
border-bottom-left-radius: 0;
|
|
123
|
+
border-bottom-right-radius: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
:host(:not([disabled]):focus-within)::after {
|
|
127
|
+
left: 0;
|
|
128
|
+
width: 100%;
|
|
129
|
+
transform: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host(:not([disabled]):active)::after,
|
|
133
|
+
:host(:not([disabled]):focus-within:not(:active))::after {
|
|
134
|
+
content: '';
|
|
135
|
+
position: absolute;
|
|
136
|
+
height: calc(${focusStrokeWidth} * 1px);
|
|
137
|
+
bottom: 0;
|
|
138
|
+
border-bottom: calc(${focusStrokeWidth} * 1px) solid ${accentFillRest};
|
|
139
|
+
border-bottom-left-radius: calc(${controlCornerRadius} * 1px);
|
|
140
|
+
border-bottom-right-radius: calc(${controlCornerRadius} * 1px);
|
|
141
|
+
z-index: 2;
|
|
142
|
+
transition: all 300ms cubic-bezier(0.1, 0.9, 0.2, 1);
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
/**
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
export const inputFilledStyles = (context, definition, rootSelector) => css `
|
|
149
|
+
:host ${rootSelector} {
|
|
150
|
+
background: ${neutralFillSecondaryRest};
|
|
151
|
+
border-color: transparent;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
:host(:hover:not([disabled]):not(:focus-within)) ${rootSelector} {
|
|
155
|
+
background: ${neutralFillSecondaryHover};
|
|
156
|
+
border-color: transparent;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.control::placeholder {
|
|
160
|
+
color: ${filledPlaceholderRest};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:host(:hover:not([disabled]):not(:focus-within)) .control::placeholder {
|
|
164
|
+
color: ${filledPlaceholderHover};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
:host(:focus-within:not([disabled])) ${rootSelector} {
|
|
168
|
+
border-color: transparent;
|
|
169
|
+
box-shadow: none;
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
/**
|
|
173
|
+
* @internal
|
|
174
|
+
*/
|
|
175
|
+
export const inputForcedColorStyles = (context, definition, rootSelector) => css `
|
|
176
|
+
:host ${rootSelector} {
|
|
177
|
+
background: ${SystemColors.Field};
|
|
178
|
+
border-color: ${SystemColors.FieldText};
|
|
179
|
+
}
|
|
180
|
+
:host(:hover:not([disabled]):not(:focus-within)) ${rootSelector} {
|
|
181
|
+
border-color: ${SystemColors.Highlight};
|
|
182
|
+
}
|
|
183
|
+
:host(:not([disabled]):active)::after,
|
|
184
|
+
:host(:not([disabled]):focus-within:not(:active))::after {
|
|
185
|
+
border-bottom-color: ${SystemColors.Highlight};
|
|
186
|
+
}
|
|
187
|
+
:host([disabled]) {
|
|
188
|
+
opacity: 1;
|
|
189
|
+
}
|
|
190
|
+
:host([disabled]) ${rootSelector} {
|
|
191
|
+
border-color: ${SystemColors.GrayText};
|
|
192
|
+
}
|
|
193
|
+
:host([disabled]) ::placeholder,
|
|
194
|
+
:host([disabled]) ::-webkit-input-placeholder,
|
|
195
|
+
:host([disabled]) .label {
|
|
196
|
+
color: ${SystemColors.GrayText};
|
|
197
|
+
fill: currentcolor;
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
200
|
+
/**
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
export const inputFilledForcedColorStyles = (context, definition, rootSelector) => css `
|
|
204
|
+
:host ${rootSelector},
|
|
205
|
+
:host(:hover:not([disabled])) ${rootSelector},
|
|
206
|
+
:host(:active:not([disabled])) ${rootSelector},
|
|
207
|
+
:host(:focus-within:not([disabled])) ${rootSelector} {
|
|
208
|
+
background: ${SystemColors.Field};
|
|
209
|
+
border-color: ${SystemColors.FieldText};
|
|
210
|
+
}
|
|
211
|
+
:host(:not([disabled]):active)::after,
|
|
212
|
+
:host(:not([disabled]):focus-within:not(:active))::after {
|
|
213
|
+
border-bottom-color: ${SystemColors.Highlight};
|
|
214
|
+
}
|
|
215
|
+
:host([disabled]) ${rootSelector} {
|
|
216
|
+
border-color: ${SystemColors.GrayText};
|
|
217
|
+
}
|
|
218
|
+
`;
|
package/dist/esm/switch/index.js
CHANGED
|
@@ -14,7 +14,9 @@ export const fluentSwitch = Switch.compose({
|
|
|
14
14
|
template,
|
|
15
15
|
styles,
|
|
16
16
|
switch: `
|
|
17
|
-
<
|
|
17
|
+
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
|
18
|
+
<rect x="2" y="2" width="12" height="12" rx="6"/>
|
|
19
|
+
</svg>
|
|
18
20
|
`,
|
|
19
21
|
});
|
|
20
22
|
/**
|
|
@@ -11,18 +11,18 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
|
-
const SwitchTemplate = ({ checked, disabled }) => `
|
|
14
|
+
const SwitchTemplate = ({ checked, disabled, label }) => `
|
|
15
15
|
<fluent-switch
|
|
16
16
|
${checked ? 'checked' : ''}
|
|
17
17
|
${disabled ? 'disabled' : ''}
|
|
18
|
-
|
|
18
|
+
>${label}
|
|
19
19
|
<span slot="checked-message">On</span>
|
|
20
20
|
<span slot="unchecked-message">Off</span>
|
|
21
|
-
<label for="direction-switch">Captions:</label>
|
|
22
21
|
</fluent-switch>
|
|
23
22
|
`;
|
|
24
23
|
export const Switch = SwitchTemplate.bind({});
|
|
25
24
|
Switch.args = {
|
|
25
|
+
label: 'Label',
|
|
26
26
|
checked: false,
|
|
27
27
|
disabled: false,
|
|
28
28
|
};
|
|
@@ -2,7 +2,7 @@ import { css } from '@microsoft/fast-element';
|
|
|
2
2
|
import { SystemColors } from '@microsoft/fast-web-utilities';
|
|
3
3
|
import { disabledCursor, display, focusVisible, forcedColorsStylesheetBehavior, } from '@microsoft/fast-foundation';
|
|
4
4
|
import { DirectionalStyleSheetBehavior, heightNumber } from '../styles';
|
|
5
|
-
import { accentFillActive, accentFillHover, accentFillRest, bodyFont, designUnit, disabledOpacity, fillColor, focusStrokeOuter, foregroundOnAccentActive, foregroundOnAccentHover, foregroundOnAccentRest,
|
|
5
|
+
import { accentFillActive, accentFillHover, accentFillRest, bodyFont, designUnit, disabledOpacity, fillColor, focusStrokeOuter, foregroundOnAccentActive, foregroundOnAccentHover, foregroundOnAccentRest, neutralFillInputAltActive, neutralFillInputAltFocus, neutralFillInputAltHover, neutralFillInputAltRest, neutralForegroundRest, neutralStrokeStrongActive, neutralStrokeStrongHover, neutralStrokeStrongRest, strokeWidth, typeRampBaseFontSize, typeRampBaseLineHeight, } from '../design-tokens';
|
|
6
6
|
export const switchStyles = (context, definition) => css `
|
|
7
7
|
:host([hidden]) {
|
|
8
8
|
display: none;
|
|
@@ -12,7 +12,6 @@ export const switchStyles = (context, definition) => css `
|
|
|
12
12
|
align-items: center;
|
|
13
13
|
outline: none;
|
|
14
14
|
font-family: ${bodyFont};
|
|
15
|
-
margin: calc(${designUnit} * 1px) 0;
|
|
16
15
|
${
|
|
17
16
|
/*
|
|
18
17
|
* Chromium likes to select label text or the default slot when
|
|
@@ -26,8 +25,10 @@ export const switchStyles = (context, definition) => css `
|
|
|
26
25
|
|
|
27
26
|
:host(.disabled) .label,
|
|
28
27
|
:host(.readonly) .label,
|
|
28
|
+
:host(.disabled) .switch,
|
|
29
29
|
:host(.readonly) .switch,
|
|
30
|
-
:host(.disabled) .
|
|
30
|
+
:host(.disabled) .status-message,
|
|
31
|
+
:host(.readonly) .status-message {
|
|
31
32
|
cursor: ${disabledCursor};
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -37,34 +38,48 @@ export const switchStyles = (context, definition) => css `
|
|
|
37
38
|
box-sizing: border-box;
|
|
38
39
|
width: calc(((${heightNumber} / 2) + ${designUnit}) * 2px);
|
|
39
40
|
height: calc(((${heightNumber} / 2) + ${designUnit}) * 1px);
|
|
40
|
-
background: ${
|
|
41
|
+
background: ${neutralFillInputAltRest};
|
|
41
42
|
border-radius: calc(${heightNumber} * 1px);
|
|
42
43
|
border: calc(${strokeWidth} * 1px) solid ${neutralStrokeStrongRest};
|
|
44
|
+
cursor: pointer;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
:host(:
|
|
46
|
-
background: ${
|
|
47
|
+
:host(:not(.disabled):hover) .switch {
|
|
48
|
+
background: ${neutralFillInputAltHover};
|
|
47
49
|
border-color: ${neutralStrokeStrongHover};
|
|
48
|
-
cursor: pointer;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
:host(:
|
|
52
|
-
background: ${
|
|
52
|
+
:host(:not(.disabled):active) .switch {
|
|
53
|
+
background: ${neutralFillInputAltActive};
|
|
53
54
|
border-color: ${neutralStrokeStrongActive};
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
:host(:${focusVisible}) .switch {
|
|
57
|
-
box-shadow: 0 0 0
|
|
58
|
+
box-shadow: 0 0 0 1px ${fillColor}, 0 0 0 3px ${focusStrokeOuter};
|
|
59
|
+
background: ${neutralFillInputAltFocus};
|
|
58
60
|
border-color: ${focusStrokeOuter};
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
.checked
|
|
63
|
+
:host(.checked) .switch {
|
|
64
|
+
background: ${accentFillRest};
|
|
65
|
+
border-color: transparent;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host(.checked:not(.disabled):hover) .switch {
|
|
69
|
+
background: ${accentFillHover};
|
|
70
|
+
border-color: transparent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host(.checked:not(.disabled):active) .switch {
|
|
74
|
+
background: ${accentFillActive};
|
|
75
|
+
border-color: transparent;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
slot[name='switch'] {
|
|
62
79
|
position: absolute;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
background: ${neutralForegroundRest};
|
|
67
|
-
border-radius: 50%;
|
|
80
|
+
display: flex;
|
|
81
|
+
border: 1px solid transparent; /* Spacing included in the transform reference box */
|
|
82
|
+
fill: ${neutralForegroundRest};
|
|
68
83
|
transition: all 0.2s ease-in-out;
|
|
69
84
|
}
|
|
70
85
|
|
|
@@ -88,37 +103,38 @@ export const switchStyles = (context, definition) => css `
|
|
|
88
103
|
cursor: pointer;
|
|
89
104
|
}
|
|
90
105
|
|
|
91
|
-
::slotted(
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
::slotted([slot="checked-message"]),
|
|
107
|
+
::slotted([slot="unchecked-message"]) {
|
|
108
|
+
margin-inline-start: calc(${designUnit} * 2px + 2px);
|
|
94
109
|
}
|
|
95
110
|
|
|
96
|
-
:host(
|
|
97
|
-
background: ${
|
|
111
|
+
:host(.checked) .switch {
|
|
112
|
+
background: ${accentFillRest};
|
|
98
113
|
}
|
|
99
114
|
|
|
100
|
-
:host([
|
|
101
|
-
|
|
115
|
+
:host(.checked) .switch slot[name='switch'] {
|
|
116
|
+
fill: ${foregroundOnAccentRest};
|
|
117
|
+
filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.15));
|
|
102
118
|
}
|
|
103
119
|
|
|
104
|
-
:host(
|
|
120
|
+
:host(.checked:not(.disabled)) .switch:hover {
|
|
105
121
|
background: ${accentFillHover};
|
|
106
122
|
}
|
|
107
123
|
|
|
108
|
-
:host(
|
|
109
|
-
|
|
124
|
+
:host(.checked:not(.disabled)) .switch:hover slot[name='switch'] {
|
|
125
|
+
fill: ${foregroundOnAccentHover};
|
|
110
126
|
}
|
|
111
127
|
|
|
112
|
-
:host(
|
|
128
|
+
:host(.checked:not(.disabled)) .switch:active {
|
|
113
129
|
background: ${accentFillActive};
|
|
114
130
|
}
|
|
115
131
|
|
|
116
|
-
:host(
|
|
117
|
-
|
|
132
|
+
:host(.checked:not(.disabled)) .switch:active slot[name='switch'] {
|
|
133
|
+
fill: ${foregroundOnAccentActive};
|
|
118
134
|
}
|
|
119
135
|
|
|
120
|
-
:host(
|
|
121
|
-
box-shadow: 0 0 0
|
|
136
|
+
:host(.checked:${focusVisible}:not(.disabled)) .switch {
|
|
137
|
+
box-shadow: 0 0 0 1px ${fillColor}, 0 0 0 3px ${focusStrokeOuter};
|
|
122
138
|
border-color: transparent;
|
|
123
139
|
}
|
|
124
140
|
|
|
@@ -130,71 +146,74 @@ export const switchStyles = (context, definition) => css `
|
|
|
130
146
|
display: none;
|
|
131
147
|
}
|
|
132
148
|
|
|
133
|
-
:host(
|
|
149
|
+
:host(.checked) .unchecked-message {
|
|
134
150
|
display: none;
|
|
135
151
|
}
|
|
136
152
|
|
|
137
|
-
:host(
|
|
153
|
+
:host(.checked) .checked-message {
|
|
138
154
|
display: block;
|
|
139
155
|
}
|
|
140
156
|
`.withBehaviors(new DirectionalStyleSheetBehavior(css `
|
|
141
|
-
|
|
142
|
-
left:
|
|
157
|
+
slot[name='switch'] {
|
|
158
|
+
left: 0;
|
|
143
159
|
}
|
|
144
160
|
|
|
145
|
-
:host([
|
|
146
|
-
left:
|
|
161
|
+
:host(.checked) slot[name='switch'] {
|
|
162
|
+
left: 100%;
|
|
163
|
+
transform: translateX(-100%);
|
|
147
164
|
}
|
|
148
165
|
`, css `
|
|
149
|
-
|
|
150
|
-
right:
|
|
166
|
+
slot[name='switch'] {
|
|
167
|
+
right: 0;
|
|
151
168
|
}
|
|
152
169
|
|
|
153
|
-
:host([
|
|
154
|
-
right:
|
|
170
|
+
:host(.checked) slot[name='switch'] {
|
|
171
|
+
right: 100%;
|
|
172
|
+
transform: translateX(100%);
|
|
155
173
|
}
|
|
156
174
|
`), forcedColorsStylesheetBehavior(css `
|
|
157
|
-
.
|
|
158
|
-
:host(:enabled) .switch:active .checked-indicator {
|
|
175
|
+
:host(:not(.disabled)) .switch slot[name='switch'] {
|
|
159
176
|
forced-color-adjust: none;
|
|
160
|
-
|
|
177
|
+
fill: ${SystemColors.FieldText};
|
|
161
178
|
}
|
|
162
179
|
.switch {
|
|
163
|
-
forced-color-adjust: none;
|
|
164
180
|
background: ${SystemColors.Field};
|
|
165
181
|
border-color: ${SystemColors.FieldText};
|
|
166
182
|
}
|
|
167
|
-
:host(:enabled) .switch:hover {
|
|
168
|
-
background: ${SystemColors.HighlightText};
|
|
169
|
-
border-color: ${SystemColors.Highlight};
|
|
170
|
-
}
|
|
171
183
|
:host(.checked) .switch {
|
|
172
184
|
background: ${SystemColors.Highlight};
|
|
173
185
|
border-color: ${SystemColors.Highlight};
|
|
174
186
|
}
|
|
175
|
-
:host(.
|
|
176
|
-
:host(:
|
|
187
|
+
:host(:not(.disabled):hover) .switch ,
|
|
188
|
+
:host(:not(.disabled):active) .switch,
|
|
189
|
+
:host(.checked:not(.disabled):hover) .switch {
|
|
177
190
|
background: ${SystemColors.HighlightText};
|
|
178
191
|
border-color: ${SystemColors.Highlight};
|
|
179
192
|
}
|
|
180
|
-
:host(.checked) .
|
|
181
|
-
|
|
193
|
+
:host(.checked:not(.disabled)) .switch slot[name="switch"] {
|
|
194
|
+
fill: ${SystemColors.HighlightText};
|
|
182
195
|
}
|
|
183
|
-
:host(.checked:
|
|
184
|
-
|
|
196
|
+
:host(.checked:not(.disabled):hover) .switch slot[name='switch'] {
|
|
197
|
+
fill: ${SystemColors.Highlight};
|
|
185
198
|
}
|
|
186
199
|
:host(:${focusVisible}) .switch {
|
|
200
|
+
forced-color-adjust: none;
|
|
201
|
+
background: ${SystemColors.Field};
|
|
187
202
|
border-color: ${SystemColors.Highlight};
|
|
188
|
-
box-shadow: 0 0 0
|
|
203
|
+
box-shadow: 0 0 0 1px ${SystemColors.Highlight}, 0 0 0 3px ${SystemColors.FieldText};
|
|
189
204
|
}
|
|
190
|
-
:host(.checked:${focusVisible}:
|
|
191
|
-
|
|
205
|
+
:host(.checked:${focusVisible}:not(.disabled)) .switch {
|
|
206
|
+
forced-color-adjust: none;
|
|
207
|
+
background: ${SystemColors.Highlight};
|
|
208
|
+
box-shadow: 0 0 0 1px ${SystemColors.Field}, 0 0 0 3px ${SystemColors.FieldText};
|
|
209
|
+
border-color: ${SystemColors.Field};
|
|
192
210
|
}
|
|
193
211
|
:host(.disabled) {
|
|
194
212
|
opacity: 1;
|
|
195
213
|
}
|
|
196
|
-
:host(.disabled)
|
|
197
|
-
|
|
214
|
+
:host(.disabled) slot[name='switch'] {
|
|
215
|
+
forced-color-adjust: none;
|
|
216
|
+
fill: ${SystemColors.GrayText};
|
|
198
217
|
}
|
|
199
218
|
:host(.disabled) .switch {
|
|
200
219
|
background: ${SystemColors.Field};
|
|
@@ -10,15 +10,16 @@ export const tabStyles = (context, definition) => css `
|
|
|
10
10
|
font-size: ${typeRampBaseFontSize};
|
|
11
11
|
font-weight: 400;
|
|
12
12
|
line-height: ${typeRampBaseLineHeight};
|
|
13
|
-
height: calc(${heightNumber} * 1px);
|
|
13
|
+
height: calc((${heightNumber} + (${designUnit} * 2)) * 1px);
|
|
14
14
|
padding: 0 calc((6 + (${designUnit} * 2 * ${density})) * 1px);
|
|
15
15
|
color: ${neutralForegroundRest};
|
|
16
16
|
border-radius: calc(${controlCornerRadius} * 1px);
|
|
17
17
|
border: calc(${strokeWidth} * 1px) solid transparent;
|
|
18
18
|
align-items: center;
|
|
19
19
|
justify-content: center;
|
|
20
|
-
grid-row: 1;
|
|
20
|
+
grid-row: 1 / 3;
|
|
21
21
|
cursor: pointer;
|
|
22
|
+
outline: none;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
:host([aria-selected='true']) {
|
|
@@ -31,18 +32,13 @@ export const tabStyles = (context, definition) => css `
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
:host(:${focusVisible}) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px) ${focusStrokeOuter};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
:host(:focus) {
|
|
40
|
-
outline: none;
|
|
35
|
+
border-color: ${focusStrokeOuter};
|
|
36
|
+
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px) ${focusStrokeOuter} inset;
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
:host(.vertical) {
|
|
44
|
-
justify-content:
|
|
45
|
-
grid-column:
|
|
40
|
+
justify-content: start;
|
|
41
|
+
grid-column: 1 / 3;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
:host(.vertical[aria-selected='true']) {
|
|
@@ -66,16 +62,17 @@ export const tabStyles = (context, definition) => css `
|
|
|
66
62
|
:host(:hover),
|
|
67
63
|
:host(.vertical:hover),
|
|
68
64
|
:host([aria-selected='true']:hover) {
|
|
69
|
-
background:
|
|
70
|
-
color: ${SystemColors.
|
|
65
|
+
background: transparent;
|
|
66
|
+
color: ${SystemColors.Highlight};
|
|
71
67
|
fill: currentcolor;
|
|
72
68
|
}
|
|
73
69
|
:host([aria-selected='true']) {
|
|
74
|
-
background:
|
|
70
|
+
background: transparent;
|
|
75
71
|
color: ${SystemColors.Highlight};
|
|
76
72
|
fill: currentcolor;
|
|
77
73
|
}
|
|
78
74
|
:host(:${focusVisible}) {
|
|
75
|
+
background: transparent;
|
|
79
76
|
border-color: ${SystemColors.ButtonText};
|
|
80
77
|
box-shadow: none;
|
|
81
78
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { css } from '@microsoft/fast-element';
|
|
2
2
|
import { SystemColors } from '@microsoft/fast-web-utilities';
|
|
3
3
|
import { display, forcedColorsStylesheetBehavior, } from '@microsoft/fast-foundation';
|
|
4
|
-
import { accentFillRest, bodyFont, controlCornerRadius, neutralForegroundRest, typeRampBaseFontSize, typeRampBaseLineHeight, } from '../design-tokens';
|
|
4
|
+
import { accentFillRest, bodyFont, controlCornerRadius, focusStrokeWidth, neutralForegroundRest, typeRampBaseFontSize, typeRampBaseLineHeight, } from '../design-tokens';
|
|
5
|
+
import { heightNumber } from '../styles';
|
|
5
6
|
export const tabsStyles = (context, definition) => css `
|
|
6
7
|
${display('grid')} :host {
|
|
7
8
|
box-sizing: border-box;
|
|
@@ -15,7 +16,7 @@ export const tabsStyles = (context, definition) => css `
|
|
|
15
16
|
|
|
16
17
|
.tablist {
|
|
17
18
|
display: grid;
|
|
18
|
-
grid-template-rows:
|
|
19
|
+
grid-template-rows: calc(${heightNumber} * 1px); auto;
|
|
19
20
|
grid-template-columns: auto;
|
|
20
21
|
position: relative;
|
|
21
22
|
width: max-content;
|
|
@@ -80,6 +81,7 @@ export const tabsStyles = (context, definition) => css `
|
|
|
80
81
|
grid-row: 1;
|
|
81
82
|
width: 3px;
|
|
82
83
|
height: 20px;
|
|
84
|
+
margin-inline-start: calc(${focusStrokeWidth} * 1px);
|
|
83
85
|
border-radius: calc(${controlCornerRadius} * 1px);
|
|
84
86
|
align-self: center;
|
|
85
87
|
background: ${accentFillRest};
|
|
@@ -89,9 +91,8 @@ export const tabsStyles = (context, definition) => css `
|
|
|
89
91
|
transition: transform 0.2s linear;
|
|
90
92
|
}
|
|
91
93
|
`.withBehaviors(forcedColorsStylesheetBehavior(css `
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
`));
|
|
94
|
+
.activeIndicator,
|
|
95
|
+
:host(.vertical) .activeIndicator {
|
|
96
|
+
background: ${SystemColors.Highlight};
|
|
97
|
+
}
|
|
98
|
+
`));
|