UNPKG

10.6 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getStyles = void 0;
4var tslib_1 = require("tslib");
5var style_utilities_1 = require("@fluentui/style-utilities");
6var utilities_1 = require("@fluentui/utilities");
7var globalClassNames = {
8 count: 'ms-Pivot-count',
9 icon: 'ms-Pivot-icon',
10 linkIsSelected: 'is-selected',
11 link: 'ms-Pivot-link',
12 linkContent: 'ms-Pivot-linkContent',
13 root: 'ms-Pivot',
14 rootIsLarge: 'ms-Pivot--large',
15 rootIsTabs: 'ms-Pivot--tabs',
16 text: 'ms-Pivot-text',
17 linkInMenu: 'ms-Pivot-linkInMenu',
18 overflowMenuButton: 'ms-Pivot-overflowMenuButton',
19};
20var getLinkStyles = function (props, classNames, isLinkInOverflowMenu) {
21 var _a, _b, _c;
22 if (isLinkInOverflowMenu === void 0) { isLinkInOverflowMenu = false; }
23 var linkSize = props.linkSize, linkFormat = props.linkFormat;
24 var _d = props.theme, semanticColors = _d.semanticColors, fonts = _d.fonts;
25 var rootIsLarge = linkSize === 'large';
26 var rootIsTabs = linkFormat === 'tabs';
27 return [
28 fonts.medium,
29 {
30 color: semanticColors.actionLink,
31 padding: '0 8px',
32 position: 'relative',
33 backgroundColor: 'transparent',
34 border: 0,
35 borderRadius: 0,
36 selectors: {
37 ':hover': {
38 backgroundColor: semanticColors.buttonBackgroundHovered,
39 color: semanticColors.buttonTextHovered,
40 cursor: 'pointer',
41 },
42 ':active': {
43 backgroundColor: semanticColors.buttonBackgroundPressed,
44 color: semanticColors.buttonTextHovered,
45 },
46 ':focus': {
47 outline: 'none',
48 },
49 },
50 },
51 !isLinkInOverflowMenu && [
52 {
53 display: 'inline-block',
54 lineHeight: 44,
55 height: 44,
56 marginRight: 8,
57 textAlign: 'center',
58 selectors: (_a = {},
59 _a["." + utilities_1.IsFocusVisibleClassName + " &:focus"] = {
60 outline: "1px solid " + semanticColors.focusBorder,
61 },
62 _a["." + utilities_1.IsFocusVisibleClassName + " &:focus:after"] = {
63 content: 'attr(data-content)',
64 position: 'relative',
65 border: 0,
66 },
67 _a[':before'] = {
68 backgroundColor: 'transparent',
69 bottom: 0,
70 content: '""',
71 height: 2,
72 left: 8,
73 position: 'absolute',
74 right: 8,
75 transition: "left " + style_utilities_1.AnimationVariables.durationValue2 + " " + style_utilities_1.AnimationVariables.easeFunction2 + ",\n right " + style_utilities_1.AnimationVariables.durationValue2 + " " + style_utilities_1.AnimationVariables.easeFunction2,
76 },
77 _a[':after'] = {
78 color: 'transparent',
79 content: 'attr(data-content)',
80 display: 'block',
81 fontWeight: style_utilities_1.FontWeights.bold,
82 height: 1,
83 overflow: 'hidden',
84 visibility: 'hidden',
85 },
86 _a),
87 },
88 rootIsLarge && {
89 fontSize: fonts.large.fontSize,
90 },
91 rootIsTabs && [
92 {
93 marginRight: 0,
94 height: 44,
95 lineHeight: 44,
96 backgroundColor: semanticColors.buttonBackground,
97 padding: '0 10px',
98 verticalAlign: 'top',
99 selectors: (_b = {
100 ':focus': {
101 outlineOffset: '-1px',
102 }
103 },
104 _b["." + utilities_1.IsFocusVisibleClassName + " &:focus::before"] = {
105 height: 'auto',
106 background: 'transparent',
107 transition: 'none',
108 },
109 _b['&:hover, &:focus'] = {
110 color: semanticColors.buttonTextCheckedHovered,
111 },
112 _b['&:active, &:hover'] = {
113 color: semanticColors.primaryButtonText,
114 backgroundColor: semanticColors.primaryButtonBackground,
115 },
116 _b["&." + classNames.linkIsSelected] = {
117 backgroundColor: semanticColors.primaryButtonBackground,
118 color: semanticColors.primaryButtonText,
119 fontWeight: style_utilities_1.FontWeights.regular,
120 selectors: (_c = {
121 ':before': {
122 backgroundColor: 'transparent',
123 transition: 'none',
124 position: 'absolute',
125 top: 0,
126 left: 0,
127 right: 0,
128 bottom: 0,
129 content: '""',
130 height: 0,
131 },
132 ':hover': {
133 backgroundColor: semanticColors.primaryButtonBackgroundHovered,
134 color: semanticColors.primaryButtonText,
135 },
136 '&:active': {
137 backgroundColor: semanticColors.primaryButtonBackgroundPressed,
138 color: semanticColors.primaryButtonText,
139 }
140 },
141 _c[style_utilities_1.HighContrastSelector] = tslib_1.__assign({ fontWeight: style_utilities_1.FontWeights.semibold, color: 'HighlightText', background: 'Highlight' }, style_utilities_1.getHighContrastNoAdjustStyle()),
142 _c),
143 },
144 _b),
145 },
146 ],
147 ],
148 ];
149};
150var getStyles = function (props) {
151 var _a, _b, _c, _d;
152 var className = props.className, linkSize = props.linkSize, linkFormat = props.linkFormat, theme = props.theme;
153 var semanticColors = theme.semanticColors, fonts = theme.fonts;
154 var classNames = style_utilities_1.getGlobalClassNames(globalClassNames, theme);
155 var rootIsLarge = linkSize === 'large';
156 var rootIsTabs = linkFormat === 'tabs';
157 return {
158 root: [
159 classNames.root,
160 fonts.medium,
161 style_utilities_1.normalize,
162 {
163 position: 'relative',
164 color: semanticColors.link,
165 whiteSpace: 'nowrap',
166 },
167 rootIsLarge && classNames.rootIsLarge,
168 rootIsTabs && classNames.rootIsTabs,
169 className,
170 ],
171 itemContainer: {
172 selectors: {
173 '&[hidden]': {
174 display: 'none',
175 },
176 },
177 },
178 link: tslib_1.__spreadArray(tslib_1.__spreadArray([
179 classNames.link
180 ], getLinkStyles(props, classNames)), [
181 (_a = {},
182 _a["&[data-is-overflowing='true']"] = {
183 display: 'none',
184 },
185 _a),
186 ]),
187 overflowMenuButton: [
188 classNames.overflowMenuButton,
189 (_b = {
190 visibility: 'hidden',
191 position: 'absolute',
192 right: 0
193 },
194 _b["." + classNames.link + "[data-is-overflowing='true'] ~ &"] = {
195 visibility: 'visible',
196 position: 'relative',
197 },
198 _b),
199 ],
200 linkInMenu: tslib_1.__spreadArray(tslib_1.__spreadArray([
201 classNames.linkInMenu
202 ], getLinkStyles(props, classNames, true)), [
203 {
204 textAlign: 'left',
205 width: '100%',
206 height: 36,
207 lineHeight: 36,
208 },
209 ]),
210 linkIsSelected: [
211 classNames.link,
212 classNames.linkIsSelected,
213 {
214 fontWeight: style_utilities_1.FontWeights.semibold,
215 selectors: (_c = {
216 ':before': {
217 backgroundColor: semanticColors.inputBackgroundChecked,
218 selectors: (_d = {},
219 _d[style_utilities_1.HighContrastSelector] = {
220 backgroundColor: 'Highlight',
221 },
222 _d),
223 },
224 ':hover::before': {
225 left: 0,
226 right: 0,
227 }
228 },
229 _c[style_utilities_1.HighContrastSelector] = {
230 color: 'Highlight',
231 },
232 _c),
233 },
234 ],
235 linkContent: [
236 classNames.linkContent,
237 {
238 flex: '0 1 100%',
239 selectors: {
240 '& > * ': {
241 marginLeft: 4,
242 },
243 '& > *:first-child': {
244 marginLeft: 0,
245 },
246 },
247 },
248 ],
249 text: [
250 classNames.text,
251 {
252 display: 'inline-block',
253 verticalAlign: 'top',
254 },
255 ],
256 count: [
257 classNames.count,
258 {
259 display: 'inline-block',
260 verticalAlign: 'top',
261 },
262 ],
263 icon: classNames.icon,
264 };
265};
266exports.getStyles = getStyles;
267//# sourceMappingURL=Pivot.styles.js.map
\No newline at end of file