Skip to content

Commit 04a81c6

Browse files
committed
Convert EuiOverlayMask to @emotion/css
- body overflow CSS still needs to be `@emotion/react`, and should be moved into a different file
1 parent d08a00b commit 04a81c6

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

src/components/overlay_mask/overlay_mask.styles.ts

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,30 @@
66
* Side Public License, v 1.
77
*/
88

9-
import { css } from '@emotion/react';
9+
import { css } from '@emotion/css';
1010
import { logicalCSS, euiAnimFadeIn } from '../../global_styling';
1111
import { transparentize, UseEuiTheme } from '../../services';
1212

1313
export const euiOverlayMaskStyles = ({ euiTheme }: UseEuiTheme) => ({
1414
euiOverlayMask: css`
15-
.euiOverlayMask {
16-
position: fixed;
17-
${logicalCSS('top', 0)}
18-
${logicalCSS('left', 0)}
19-
${logicalCSS('right', 0)}
20-
${logicalCSS('bottom', 0)}
21-
display: flex;
22-
align-items: center;
23-
justify-content: center;
24-
${logicalCSS('padding-bottom', '10vh')};
25-
animation: ${euiAnimFadeIn} ${euiTheme.animation.fast} ease-in;
26-
background: ${transparentize(euiTheme.colors.ink, 0.5)};
27-
}
15+
position: fixed;
16+
${logicalCSS('top', 0)}
17+
${logicalCSS('left', 0)}
18+
${logicalCSS('right', 0)}
19+
${logicalCSS('bottom', 0)}
20+
display: flex;
21+
align-items: center;
22+
justify-content: center;
23+
${logicalCSS('padding-bottom', '10vh')};
24+
animation: ${euiAnimFadeIn} ${euiTheme.animation.fast} ease-in;
25+
background: ${transparentize(euiTheme.colors.ink, 0.5)};
2826
`,
2927
aboveHeader: css`
30-
.euiOverlayMask {
31-
z-index: ${euiTheme.levels.mask};
32-
}
28+
z-index: ${euiTheme.levels.mask};
3329
`,
3430
belowHeader: css`
35-
.euiOverlayMask {
36-
z-index: ${euiTheme.levels.maskBelowHeader};
37-
// TODO: use size variable when EuiHeader is converted
38-
${logicalCSS('top', `${euiTheme.base * 3}px`)};
39-
}
31+
z-index: ${euiTheme.levels.maskBelowHeader};
32+
// TODO: use size variable when EuiHeader is converted
33+
${logicalCSS('top', `${euiTheme.base * 3}px`)};
4034
`,
4135
});
42-
43-
export const euiOverlayMaskBodyStyles = css`
44-
body {
45-
overflow: hidden;
46-
}
47-
`;

src/components/overlay_mask/overlay_mask.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ import React, {
2020
useEffect,
2121
useState,
2222
} from 'react';
23-
import classNames from 'classnames';
23+
import { cx } from '@emotion/css';
2424
import { Global } from '@emotion/react';
2525
import { CommonProps, keysOf } from '../common';
2626
import { useCombinedRefs, useEuiTheme } from '../../services';
2727
import { EuiPortal } from '../portal';
28-
import {
29-
euiOverlayMaskStyles,
30-
euiOverlayMaskBodyStyles,
31-
} from './overlay_mask.styles';
28+
import { euiOverlayMaskStyles } from './overlay_mask.styles';
29+
import { euiOverlayMaskBodyStyles } from './overlay_mask_body.styles';
3230

3331
export interface EuiOverlayMaskInterface {
3432
/**
@@ -69,10 +67,10 @@ export const EuiOverlayMask: FunctionComponent<EuiOverlayMaskProps> = ({
6967
]);
7068
const euiTheme = useEuiTheme();
7169
const styles = euiOverlayMaskStyles(euiTheme);
72-
const cssStyles = [
70+
const cssStyles = cx([
7371
styles.euiOverlayMask,
7472
styles[`${headerZindexLocation}Header`],
75-
];
73+
]);
7674

7775
useEffect(() => {
7876
if (!overlayMaskNode) return;
@@ -90,13 +88,12 @@ export const EuiOverlayMask: FunctionComponent<EuiOverlayMaskProps> = ({
9088

9189
useEffect(() => {
9290
if (!overlayMaskNode) return;
93-
overlayMaskNode.className = classNames('euiOverlayMask', className);
94-
}, [overlayMaskNode, className]);
91+
overlayMaskNode.className = cx('euiOverlayMask', cssStyles, className);
92+
}, [overlayMaskNode, cssStyles, className]);
9593

9694
return (
9795
<EuiPortal portalRef={combinedMaskRef}>
9896
<Global styles={euiOverlayMaskBodyStyles} />
99-
<Global styles={cssStyles} />
10097
{children}
10198
</EuiPortal>
10299
);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { css } from '@emotion/react';
10+
11+
export const euiOverlayMaskBodyStyles = css`
12+
body {
13+
overflow: hidden;
14+
}
15+
`;

0 commit comments

Comments
 (0)