UNPKG

10.1 kBJavaScriptView Raw
1import { __spreadArrays } from "tslib";
2import { AnimationVariables, FontWeights, getFocusStyle, getGlobalClassNames, keyframes, } from '../../Styling';
3import { memoizeFunction } from '../../Utilities';
4var globalClassNames = {
5 root: 'ms-TeachingBubble',
6 body: 'ms-TeachingBubble-body',
7 bodyContent: 'ms-TeachingBubble-bodycontent',
8 closeButton: 'ms-TeachingBubble-closebutton',
9 content: 'ms-TeachingBubble-content',
10 footer: 'ms-TeachingBubble-footer',
11 header: 'ms-TeachingBubble-header',
12 headerIsCondensed: 'ms-TeachingBubble-header--condensed',
13 headerIsSmall: 'ms-TeachingBubble-header--small',
14 headerIsLarge: 'ms-TeachingBubble-header--large',
15 headline: 'ms-TeachingBubble-headline',
16 image: 'ms-TeachingBubble-image',
17 primaryButton: 'ms-TeachingBubble-primaryButton',
18 secondaryButton: 'ms-TeachingBubble-secondaryButton',
19 subText: 'ms-TeachingBubble-subText',
20 // TODO: Button global class name usage should be converted to a styles function once
21 // Button supports JS styling, which means these button names can be removed.
22 button: 'ms-Button',
23 buttonLabel: 'ms-Button-label',
24};
25var opacityFadeIn = memoizeFunction(function () {
26 return keyframes({
27 '0%': {
28 opacity: 0,
29 animationTimingFunction: AnimationVariables.easeFunction1,
30 transform: 'scale3d(.90,.90,.90)',
31 },
32 '100%': {
33 opacity: 1,
34 transform: 'scale3d(1,1,1)',
35 },
36 });
37});
38var rootStyle = function (isWide, calloutProps) {
39 var _a = calloutProps || {}, calloutWidth = _a.calloutWidth, calloutMaxWidth = _a.calloutMaxWidth;
40 return [
41 {
42 display: 'block',
43 maxWidth: 364,
44 border: 0,
45 outline: 'transparent',
46 width: calloutWidth || 'calc(100% + 1px)',
47 animationName: "" + opacityFadeIn(),
48 animationDuration: '300ms',
49 animationTimingFunction: 'linear',
50 animationFillMode: 'both',
51 },
52 isWide && {
53 maxWidth: calloutMaxWidth || 456,
54 },
55 ];
56};
57var headerStyle = function (classNames, hasCondensedHeadline, hasSmallHeadline) {
58 if (hasCondensedHeadline) {
59 return [
60 classNames.headerIsCondensed,
61 {
62 marginBottom: 14,
63 },
64 ];
65 }
66 return [
67 hasSmallHeadline && classNames.headerIsSmall,
68 !hasSmallHeadline && classNames.headerIsLarge,
69 {
70 selectors: {
71 ':not(:last-child)': {
72 marginBottom: 14,
73 },
74 },
75 },
76 ];
77};
78export var getStyles = function (props) {
79 var _a, _b, _c;
80 var hasCondensedHeadline = props.hasCondensedHeadline, hasSmallHeadline = props.hasSmallHeadline, hasCloseButton = props.hasCloseButton, hasHeadline = props.hasHeadline, isWide = props.isWide, primaryButtonClassName = props.primaryButtonClassName, secondaryButtonClassName = props.secondaryButtonClassName, theme = props.theme, _d = props.calloutProps, calloutProps = _d === void 0 ? { className: undefined, theme: theme } : _d;
81 var hasLargeHeadline = !hasCondensedHeadline && !hasSmallHeadline;
82 var palette = theme.palette, semanticColors = theme.semanticColors, fonts = theme.fonts;
83 var classNames = getGlobalClassNames(globalClassNames, theme);
84 var hideDefaultFocusRing = getFocusStyle(theme, {
85 outlineColor: 'transparent',
86 borderColor: 'transparent',
87 });
88 return {
89 root: [classNames.root, fonts.medium, calloutProps.className],
90 body: [
91 classNames.body,
92 hasCloseButton && !hasHeadline && { marginRight: 24 },
93 {
94 selectors: {
95 ':not(:last-child)': {
96 marginBottom: 20,
97 },
98 },
99 },
100 ],
101 bodyContent: [
102 classNames.bodyContent,
103 {
104 padding: '20px 24px 20px 24px',
105 },
106 ],
107 closeButton: [
108 classNames.closeButton,
109 {
110 position: 'absolute',
111 right: 0,
112 top: 0,
113 margin: '15px 15px 0 0',
114 borderRadius: 0,
115 color: palette.white,
116 fontSize: fonts.small.fontSize,
117 selectors: {
118 ':hover': {
119 background: palette.themeDarkAlt,
120 color: palette.white,
121 },
122 ':active': {
123 background: palette.themeDark,
124 color: palette.white,
125 },
126 ':focus': {
127 border: "1px solid " + semanticColors.variantBorder,
128 },
129 },
130 },
131 ],
132 content: __spreadArrays([
133 classNames.content
134 ], rootStyle(isWide), [
135 isWide && {
136 display: 'flex',
137 },
138 ]),
139 footer: [
140 classNames.footer,
141 {
142 display: 'flex',
143 flex: 'auto',
144 alignItems: 'center',
145 color: palette.white,
146 selectors: (_a = {},
147 // TODO: global class name usage should be converted to a styles function once Button supports JS styling
148 _a["." + classNames.button + ":not(:first-child)"] = {
149 marginLeft: 10,
150 },
151 _a),
152 },
153 ],
154 header: __spreadArrays([
155 classNames.header
156 ], headerStyle(classNames, hasCondensedHeadline, hasSmallHeadline), [
157 hasCloseButton && { marginRight: 24 },
158 (hasCondensedHeadline || hasSmallHeadline) && [
159 fonts.medium,
160 {
161 fontWeight: FontWeights.semibold,
162 },
163 ],
164 ]),
165 headline: [
166 classNames.headline,
167 {
168 margin: 0,
169 color: palette.white,
170 fontWeight: FontWeights.semibold,
171 },
172 hasLargeHeadline && [
173 {
174 fontSize: fonts.xLarge.fontSize,
175 },
176 ],
177 ],
178 imageContent: [
179 classNames.header,
180 classNames.image,
181 isWide && {
182 display: 'flex',
183 alignItems: 'center',
184 maxWidth: 154,
185 },
186 ],
187 primaryButton: [
188 classNames.primaryButton,
189 primaryButtonClassName,
190 hideDefaultFocusRing,
191 {
192 backgroundColor: palette.white,
193 borderColor: palette.white,
194 color: palette.themePrimary,
195 whiteSpace: 'nowrap',
196 selectors: (_b = {},
197 // TODO: global class name usage should be converted to a styles function once Button supports JS styling
198 _b["." + classNames.buttonLabel] = fonts.medium,
199 _b[':hover'] = {
200 backgroundColor: palette.themeLighter,
201 borderColor: palette.themeLighter,
202 color: palette.themePrimary,
203 },
204 _b[':focus'] = {
205 backgroundColor: palette.themeLighter,
206 border: "1px solid " + palette.black,
207 outline: "1px solid " + palette.white,
208 outlineOffset: '-2px',
209 },
210 _b[':active'] = {
211 backgroundColor: palette.white,
212 borderColor: palette.white,
213 color: palette.themePrimary,
214 },
215 _b),
216 },
217 ],
218 secondaryButton: [
219 classNames.secondaryButton,
220 secondaryButtonClassName,
221 {
222 backgroundColor: palette.themePrimary,
223 borderColor: palette.white,
224 whiteSpace: 'nowrap',
225 selectors: (_c = {},
226 // TODO: global class name usage should be converted to a styles function once Button supports JS styling
227 _c["." + classNames.buttonLabel] = [
228 fonts.medium,
229 {
230 color: palette.white,
231 },
232 ],
233 _c[':hover'] = {
234 backgroundColor: palette.themeDarkAlt,
235 borderColor: palette.white,
236 },
237 _c[':focus'] = {
238 backgroundColor: palette.themeDark,
239 border: "1px solid " + palette.black,
240 outline: "1px solid " + palette.white,
241 outlineOffset: '-2px',
242 },
243 _c[':active'] = {
244 backgroundColor: palette.themePrimary,
245 borderColor: palette.white,
246 },
247 _c),
248 },
249 ],
250 subText: [
251 classNames.subText,
252 {
253 margin: 0,
254 fontSize: fonts.medium.fontSize,
255 color: palette.white,
256 fontWeight: FontWeights.regular,
257 },
258 ],
259 subComponentStyles: {
260 callout: {
261 root: __spreadArrays(rootStyle(isWide, calloutProps), [fonts.medium]),
262 beak: [
263 {
264 background: palette.themePrimary,
265 },
266 ],
267 calloutMain: [
268 {
269 background: palette.themePrimary,
270 },
271 ],
272 },
273 },
274 };
275};
276//# sourceMappingURL=TeachingBubble.styles.js.map
\No newline at end of file