Skip to content

Commit

Permalink
[Emotion] Convert EuiModal (#6321)
Browse files Browse the repository at this point in the history
* [Emotion] Convert `modal`

* Fix weird bug in Chrome with parent `overflow: hidden` and children with `image-mask`

* Better styles and fixed `euiOverflowShadowStyles`

* Adding CL

* Added `euiAnimSlideInUp`

* Removing unnecessary class name

* REVERT ME - To test bug with `mask-image`

* Added `shouldRenderCustomStyles()` tests

* Cleaned up docs code and converted to TS

* Adding bug fix in CL

* CL again

* CL again 😭

* Changing examples source types to TSX

* Reverting example and renaming to `*.tsx`

* Remove bug fix entry from CL

* DRY out `initialFocus` types/prop docs + add `defaultFocusedButton` prop docs

* [EuiModalHeader] misc cleanup

* Clean up unnecessary width CSS

* Simplify `style` logic + switch to logical property

* [opinionated] Rename `defaultMaxWidth` class modifier

- to match `defaultMinWidth` modifier, used in EuiButtonDisplay (#6373)

* Fix `maxWidth` conditional class logic + write unit tests

* Use `inset` shorthand

* [EuiModal] Fix box-shadows

* Restore `!important`s required for style.width overrides

Co-authored-by: Constance Chen <constance.chen.3@gmail.com>
  • Loading branch information
miukimiu and cee-chen committed Nov 18, 2022
1 parent f753bc7 commit 9efedf2
Show file tree
Hide file tree
Showing 36 changed files with 433 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
EuiConfirmModal,
EuiFlexGroup,
EuiFlexItem,
} from '../../../../src/components';
} from '../../../../src';

export default () => {
const [isModalVisible, setIsModalVisible] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import {
EuiConfirmModal,
EuiFormRow,
EuiFieldText,
} from '../../../../src/components';
} from '../../../../src';

export default () => {
const [isLoading, setIsLoading] = useState(false);
clearTimeout(searchTimeout);

const searchTimeout = setTimeout(() => {
// Simulate a remotely-executed search.
setIsLoading(false);
}, 1200);

clearTimeout(searchTimeout);

const [isModalVisible, setIsModalVisible] = useState(false);
const showModal = () => {
setIsModalVisible(true);
Expand All @@ -27,7 +29,7 @@ export default () => {
};

const [value, setValue] = useState('');
const onChange = (e) => {
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
};

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src-docs/src/views/modal/modal_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const ModalExample = {
{
source: [
{
type: GuideSectionTypes.JS,
type: GuideSectionTypes.TSX,
code: modalSource,
},
],
Expand Down Expand Up @@ -167,7 +167,7 @@ export const ModalExample = {
title: 'Forms in a modal',
source: [
{
type: GuideSectionTypes.JS,
type: GuideSectionTypes.TSX,
code: modalFormSource,
},
],
Expand All @@ -192,7 +192,7 @@ export const ModalExample = {
title: 'Confirm modal',
source: [
{
type: GuideSectionTypes.JS,
type: GuideSectionTypes.TSX,
code: confirmModalSource,
},
],
Expand All @@ -214,7 +214,7 @@ export const ModalExample = {
title: 'Loading and disabling confirm button',
source: [
{
type: GuideSectionTypes.JS,
type: GuideSectionTypes.TSX,
code: confirmModalLoadingSource,
},
],
Expand All @@ -236,7 +236,7 @@ export const ModalExample = {
title: 'Widths',
source: [
{
type: GuideSectionTypes.JS,
type: GuideSectionTypes.TSX,
code: modalWidthSource,
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, Fragment } from 'react';
import React, { useState } from 'react';

import {
EuiButton,
Expand All @@ -15,7 +15,7 @@ import {
EuiSwitch,
EuiSuperSelect,
EuiText,
} from '../../../../src/components';
} from '../../../../src';

import { useGeneratedHtmlId } from '../../../../src/services';

Expand All @@ -39,36 +39,36 @@ export default () => {
value: 'option_one',
inputDisplay: 'Option one',
dropdownDisplay: (
<Fragment>
<>
<strong>Option one</strong>
<EuiText size="s" color="subdued">
<p>Has a short description giving more detail to the option.</p>
</EuiText>
</Fragment>
</>
),
},
{
value: 'option_two',
inputDisplay: 'Option two',
dropdownDisplay: (
<Fragment>
<>
<strong>Option two</strong>
<EuiText size="s" color="subdued">
<p>Has a short description giving more detail to the option.</p>
</EuiText>
</Fragment>
</>
),
},
{
value: 'option_three',
inputDisplay: 'Option three',
dropdownDisplay: (
<Fragment>
<>
<strong>Option three</strong>
<EuiText size="s" color="subdued">
<p>Has a short description giving more detail to the option.</p>
</EuiText>
</Fragment>
</>
),
},
];
Expand All @@ -90,7 +90,7 @@ export default () => {
</EuiFormRow>

<EuiFormRow label="Range" helpText="Some help text for the range">
<EuiRange min={0} max={100} name="poprange" />
<EuiRange min={0} max={100} value={50} name="poprange" />
</EuiFormRow>

<EuiFormRow label="An EuiSuperSelect">
Expand All @@ -105,7 +105,7 @@ export default () => {
</EuiForm>
);

const onSuperSelectChange = (value) => {
const onSuperSelectChange = (value: string) => {
setSuperSelectValue(value);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
EuiModalHeader,
EuiModalHeaderTitle,
EuiCodeBlock,
} from '../../../../src/components';
import { EuiSpacer } from '../../../../src/components/spacer';
EuiSpacer,
} from '../../../../src';

export default () => {
const [isModalVisible, setIsModalVisible] = useState(false);
Expand Down
17 changes: 3 additions & 14 deletions src/components/image/image_fullscreen_wrapper.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* Side Public License, v 1.
*/

import { css, keyframes } from '@emotion/react';
import { css } from '@emotion/react';
import {
logicalCSS,
logicalTextAlignCSS,
euiCanAnimate,
euiAnimSlideInUp,
} from '../../global_styling';
import { UseEuiTheme } from '../../services';

Expand All @@ -28,7 +29,7 @@ export const euiImageFullscreenWrapperStyles = (
line-height: 0; // Fixes cropping when image is resized by forcing its height to be determined by the image not line-height
${euiCanAnimate} {
animation: ${euiImageFullScreen(euiTheme.size.xxxxl)}
animation: ${euiAnimSlideInUp(euiTheme.size.xxxxl)}
${euiTheme.animation.extraSlow} ${euiTheme.animation.bounce};
}
Expand All @@ -42,15 +43,3 @@ export const euiImageFullscreenWrapperStyles = (
`,
};
};

const euiImageFullScreen = (size: string) => keyframes`
0% {
opacity: 0;
transform: translateY(${size});
}
100% {
opacity: 1;
transform: translateY(0);
}
`;
1 change: 0 additions & 1 deletion src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
@import 'header/index';
@import 'key_pad_menu/index';
@import 'markdown_editor/index';
@import 'modal/index';
@import 'notification/index';
@import 'panel/index';
@import 'page/index'; // Page needs to come after Panel for cascade specificity
Expand Down
40 changes: 18 additions & 22 deletions src/components/modal/__snapshots__/confirm_modal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Array [
>
<div
aria-label="aria-label"
class="euiModal euiModal--maxWidth-default euiModal--confirmation testClass1 testClass2"
class="euiModal euiModal--confirmation testClass1 testClass2 emotion-euiModal-defaultMaxWidth-confirmation"
data-test-subj="test subject string"
tabindex="0"
>
<button
aria-label="Closes this modal window"
class="euiButtonIcon euiButtonIcon--xSmall euiModal__closeIcon emotion-euiButtonIcon-empty-text-hoverStyles"
class="euiButtonIcon euiButtonIcon--xSmall euiModal__closeIcon emotion-euiButtonIcon-empty-text-hoverStyles-euiModal__closeIcon"
type="button"
>
<span
Expand All @@ -29,22 +29,20 @@ Array [
/>
</button>
<div
class="euiModalHeader"
class="euiModalHeader emotion-euiModalHeader"
>
<div
class="euiModalHeader__title"
<h1
class="euiTitle euiModalHeader__title emotion-euiTitle-m"
data-test-subj="confirmModalTitleText"
>
<h1>
A confirmation modal
</h1>
</div>
A confirmation modal
</h1>
</div>
<div
class="euiModalBody"
class="euiModalBody emotion-euiModalBody"
>
<div
class="euiModalBody__overflow"
class="euiModalBody__overflow emotion-euiModalBody__overflow"
>
<div
class="euiText emotion-euiText-m"
Expand All @@ -57,7 +55,7 @@ Array [
</div>
</div>
<div
class="euiModalFooter"
class="euiModalFooter emotion-euiModalFooter"
>
<button
class="euiButtonEmpty css-9t7nyf-empty-primary"
Expand Down Expand Up @@ -112,13 +110,13 @@ Array [
>
<div
aria-label="aria-label"
class="euiModal euiModal--maxWidth-default euiModal--confirmation testClass1 testClass2"
class="euiModal euiModal--confirmation testClass1 testClass2 emotion-euiModal-defaultMaxWidth-confirmation"
data-test-subj="test subject string"
tabindex="0"
>
<button
aria-label="Closes this modal window"
class="euiButtonIcon euiButtonIcon--xSmall euiModal__closeIcon emotion-euiButtonIcon-empty-text-hoverStyles"
class="euiButtonIcon euiButtonIcon--xSmall euiModal__closeIcon emotion-euiButtonIcon-empty-text-hoverStyles-euiModal__closeIcon"
type="button"
>
<span
Expand All @@ -129,19 +127,17 @@ Array [
/>
</button>
<div
class="euiModalHeader"
class="euiModalHeader emotion-euiModalHeader"
>
<div
class="euiModalHeader__title"
<h1
class="euiTitle euiModalHeader__title emotion-euiTitle-m"
data-test-subj="confirmModalTitleText"
>
<h1>
A confirmation modal
</h1>
</div>
A confirmation modal
</h1>
</div>
<div
class="euiModalFooter"
class="euiModalFooter emotion-euiModalFooter"
>
<button
class="euiButtonEmpty css-9t7nyf-empty-primary"
Expand Down
4 changes: 2 additions & 2 deletions src/components/modal/__snapshots__/modal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ exports[`EuiModal renders 1`] = `
>
<div
aria-label="aria-label"
class="euiModal euiModal--maxWidth-default testClass1 testClass2"
class="euiModal testClass1 testClass2 emotion-euiModal-defaultMaxWidth"
data-test-subj="test subject string"
tabindex="0"
>
<button
aria-label="Closes this modal window"
class="euiButtonIcon euiButtonIcon--xSmall euiModal__closeIcon emotion-euiButtonIcon-empty-text-hoverStyles"
class="euiButtonIcon euiButtonIcon--xSmall euiModal__closeIcon emotion-euiButtonIcon-empty-text-hoverStyles-euiModal__closeIcon"
type="button"
>
<span
Expand Down
6 changes: 3 additions & 3 deletions src/components/modal/__snapshots__/modal_body.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders EuiModalBody 1`] = `
exports[`EuiModalBody is rendered 1`] = `
<div
aria-label="aria-label"
class="euiModalBody testClass1 testClass2"
class="euiModalBody testClass1 testClass2 emotion-euiModalBody"
data-test-subj="test subject string"
>
<div
class="euiModalBody__overflow"
class="euiModalBody__overflow emotion-euiModalBody__overflow"
>
children
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/modal/__snapshots__/modal_footer.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders EuiModalFooter 1`] = `
exports[`EuiModalFooter is rendered 1`] = `
<div
aria-label="aria-label"
class="euiModalFooter testClass1 testClass2"
class="euiModalFooter testClass1 testClass2 emotion-euiModalFooter"
data-test-subj="test subject string"
>
children
Expand Down
4 changes: 2 additions & 2 deletions src/components/modal/__snapshots__/modal_header.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders EuiModalHeader 1`] = `
exports[`EuiModalHeader is rendered 1`] = `
<div
aria-label="aria-label"
class="euiModalHeader testClass1 testClass2"
class="euiModalHeader testClass1 testClass2 emotion-euiModalHeader"
data-test-subj="test subject string"
>
children
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders EuiModalHeaderTitle 1`] = `
<div
exports[`EuiModalHeaderTitle is rendered 1`] = `
<h1
aria-label="aria-label"
class="euiModalHeader__title testClass1 testClass2"
class="euiTitle euiModalHeader__title testClass1 testClass2 emotion-euiTitle-m"
data-test-subj="test subject string"
>
<h1>
children
</h1>
</div>
children
</h1>
`;
1 change: 0 additions & 1 deletion src/components/modal/_index.scss

This file was deleted.

Loading

0 comments on commit 9efedf2

Please sign in to comment.