UNPKG

9.68 kBJavaScriptView Raw
1"use strict";
2var _a, _b, _c;
3Object.defineProperty(exports, "__esModule", { value: true });
4exports.getStyles = void 0;
5var tslib_1 = require("tslib");
6var Styling_1 = require("../../Styling");
7var MessageBar_types_1 = require("./MessageBar.types");
8var GlobalClassNames = {
9 root: 'ms-MessageBar',
10 error: 'ms-MessageBar--error',
11 blocked: 'ms-MessageBar--blocked',
12 severeWarning: 'ms-MessageBar--severeWarning',
13 success: 'ms-MessageBar--success',
14 warning: 'ms-MessageBar--warning',
15 multiline: 'ms-MessageBar-multiline',
16 singleline: 'ms-MessageBar-singleline',
17 dismissalSingleLine: 'ms-MessageBar-dismissalSingleLine',
18 expandingSingleLine: 'ms-MessageBar-expandingSingleLine',
19 content: 'ms-MessageBar-content',
20 iconContainer: 'ms-MessageBar-icon',
21 text: 'ms-MessageBar-text',
22 innerText: 'ms-MessageBar-innerText',
23 dismissSingleLine: 'ms-MessageBar-dismissSingleLine',
24 expandSingleLine: 'ms-MessageBar-expandSingleLine',
25 dismissal: 'ms-MessageBar-dismissal',
26 expand: 'ms-MessageBar-expand',
27 actions: 'ms-MessageBar-actions',
28 actionsSingleline: 'ms-MessageBar-actionsSingleLine',
29};
30var backgroundColor = (_a = {},
31 _a[MessageBar_types_1.MessageBarType.error] = 'errorBackground',
32 _a[MessageBar_types_1.MessageBarType.blocked] = 'errorBackground',
33 _a[MessageBar_types_1.MessageBarType.success] = 'successBackground',
34 _a[MessageBar_types_1.MessageBarType.warning] = 'warningBackground',
35 _a[MessageBar_types_1.MessageBarType.severeWarning] = 'severeWarningBackground',
36 _a[MessageBar_types_1.MessageBarType.info] = 'infoBackground',
37 _a);
38var highContrastBackgroundColor = (_b = {},
39 _b[MessageBar_types_1.MessageBarType.error] = 'rgba(255, 0, 0, 0.3)',
40 _b[MessageBar_types_1.MessageBarType.blocked] = 'rgba(255, 0, 0, 0.3)',
41 _b[MessageBar_types_1.MessageBarType.success] = 'rgba(48, 241, 73, 0.3)',
42 _b[MessageBar_types_1.MessageBarType.warning] = 'rgba(255, 254, 57, 0.3)',
43 _b[MessageBar_types_1.MessageBarType.severeWarning] = 'rgba(255, 0, 0, 0.3)',
44 _b[MessageBar_types_1.MessageBarType.info] = 'Window',
45 _b);
46var iconColor = (_c = {},
47 _c[MessageBar_types_1.MessageBarType.error] = 'errorIcon',
48 _c[MessageBar_types_1.MessageBarType.blocked] = 'errorIcon',
49 _c[MessageBar_types_1.MessageBarType.success] = 'successIcon',
50 _c[MessageBar_types_1.MessageBarType.warning] = 'warningIcon',
51 _c[MessageBar_types_1.MessageBarType.severeWarning] = 'severeWarningIcon',
52 _c[MessageBar_types_1.MessageBarType.info] = 'infoIcon',
53 _c);
54var getStyles = function (props) {
55 var _a, _b, _c, _d, _e;
56 var theme = props.theme, className = props.className, onDismiss = props.onDismiss, truncated = props.truncated, isMultiline = props.isMultiline, expandSingleLine = props.expandSingleLine, _f = props.messageBarType, messageBarType = _f === void 0 ? MessageBar_types_1.MessageBarType.info : _f;
57 var semanticColors = theme.semanticColors, fonts = theme.fonts;
58 var SmallScreenSelector = Styling_1.getScreenSelector(0, Styling_1.ScreenWidthMaxSmall);
59 var classNames = Styling_1.getGlobalClassNames(GlobalClassNames, theme);
60 var dismissalAndExpandIconStyle = {
61 fontSize: Styling_1.IconFontSizes.xSmall,
62 height: 10,
63 lineHeight: '10px',
64 color: semanticColors.messageText,
65 selectors: (_a = {},
66 _a[Styling_1.HighContrastSelector] = tslib_1.__assign(tslib_1.__assign({}, Styling_1.getHighContrastNoAdjustStyle()), { color: 'WindowText' }),
67 _a),
68 };
69 var dismissalAndExpandStyle = [
70 Styling_1.getFocusStyle(theme, {
71 inset: 1,
72 highContrastStyle: {
73 outlineOffset: '-6px',
74 outline: '1px solid Highlight',
75 },
76 borderColor: 'transparent',
77 }),
78 {
79 flexShrink: 0,
80 width: 32,
81 height: 32,
82 padding: '8px 12px',
83 selectors: {
84 '& .ms-Button-icon': dismissalAndExpandIconStyle,
85 ':hover': {
86 backgroundColor: 'transparent',
87 },
88 ':active': {
89 backgroundColor: 'transparent',
90 },
91 },
92 },
93 ];
94 return {
95 root: [
96 classNames.root,
97 fonts.medium,
98 messageBarType === MessageBar_types_1.MessageBarType.error && classNames.error,
99 messageBarType === MessageBar_types_1.MessageBarType.blocked && classNames.blocked,
100 messageBarType === MessageBar_types_1.MessageBarType.severeWarning && classNames.severeWarning,
101 messageBarType === MessageBar_types_1.MessageBarType.success && classNames.success,
102 messageBarType === MessageBar_types_1.MessageBarType.warning && classNames.warning,
103 isMultiline ? classNames.multiline : classNames.singleline,
104 !isMultiline && onDismiss && classNames.dismissalSingleLine,
105 !isMultiline && truncated && classNames.expandingSingleLine,
106 {
107 background: semanticColors[backgroundColor[messageBarType]],
108 color: semanticColors.messageText,
109 minHeight: 32,
110 width: '100%',
111 display: 'flex',
112 wordBreak: 'break-word',
113 selectors: (_b = {
114 '.ms-Link': {
115 color: semanticColors.messageLink,
116 selectors: {
117 ':hover': {
118 color: semanticColors.messageLinkHovered,
119 },
120 },
121 }
122 },
123 _b[Styling_1.HighContrastSelector] = tslib_1.__assign(tslib_1.__assign({}, Styling_1.getHighContrastNoAdjustStyle()), { background: highContrastBackgroundColor[messageBarType], border: '1px solid WindowText', color: 'WindowText' }),
124 _b),
125 },
126 isMultiline && {
127 flexDirection: 'column',
128 },
129 className,
130 ],
131 content: [
132 classNames.content,
133 {
134 display: 'flex',
135 width: '100%',
136 lineHeight: 'normal',
137 },
138 ],
139 iconContainer: [
140 classNames.iconContainer,
141 {
142 fontSize: Styling_1.IconFontSizes.medium,
143 minWidth: 16,
144 minHeight: 16,
145 display: 'flex',
146 flexShrink: 0,
147 margin: '8px 0 8px 12px',
148 },
149 ],
150 icon: {
151 color: semanticColors[iconColor[messageBarType]],
152 selectors: (_c = {},
153 _c[Styling_1.HighContrastSelector] = tslib_1.__assign(tslib_1.__assign({}, Styling_1.getHighContrastNoAdjustStyle()), { color: 'WindowText' }),
154 _c),
155 },
156 text: [
157 classNames.text,
158 tslib_1.__assign(tslib_1.__assign({ minWidth: 0, display: 'flex', flexGrow: 1, margin: 8 }, fonts.small), { selectors: (_d = {},
159 _d[Styling_1.HighContrastSelector] = tslib_1.__assign({}, Styling_1.getHighContrastNoAdjustStyle()),
160 _d) }),
161 !onDismiss && {
162 marginRight: 12,
163 },
164 ],
165 innerText: [
166 classNames.innerText,
167 {
168 lineHeight: 16,
169 selectors: {
170 '& span a:last-child': {
171 paddingLeft: 4,
172 },
173 },
174 },
175 truncated && {
176 overflow: 'visible',
177 whiteSpace: 'pre-wrap',
178 },
179 !isMultiline && {
180 // In high contrast this causes the top and bottom of links' focus outline to be clipped
181 // (not sure of a good way around that while still maintaining text clipping)
182 overflow: 'hidden',
183 textOverflow: 'ellipsis',
184 whiteSpace: 'nowrap',
185 },
186 !isMultiline &&
187 !truncated && {
188 selectors: (_e = {},
189 _e[SmallScreenSelector] = {
190 overflow: 'visible',
191 whiteSpace: 'pre-wrap',
192 },
193 _e),
194 },
195 expandSingleLine && {
196 overflow: 'visible',
197 whiteSpace: 'pre-wrap',
198 },
199 ],
200 dismissSingleLine: classNames.dismissSingleLine,
201 expandSingleLine: classNames.expandSingleLine,
202 dismissal: [classNames.dismissal, dismissalAndExpandStyle],
203 expand: [classNames.expand, dismissalAndExpandStyle],
204 actions: [
205 isMultiline ? classNames.actions : classNames.actionsSingleline,
206 {
207 display: 'flex',
208 flexGrow: 0,
209 flexShrink: 0,
210 flexBasis: 'auto',
211 flexDirection: 'row-reverse',
212 alignItems: 'center',
213 margin: '0 12px 0 8px',
214 selectors: {
215 '& button:nth-child(n+2)': {
216 marginLeft: 8,
217 },
218 },
219 },
220 isMultiline && {
221 marginBottom: 8,
222 },
223 onDismiss &&
224 !isMultiline && {
225 marginRight: 0,
226 },
227 ],
228 };
229};
230exports.getStyles = getStyles;
231//# sourceMappingURL=MessageBar.styles.js.map
\No newline at end of file