From 9efedf2937ea9d91aac9b8c80584f9454872c24d Mon Sep 17 00:00:00 2001 From: Elizabet Oliveira Date: Fri, 18 Nov 2022 22:55:29 +0000 Subject: [PATCH] [Emotion] Convert `EuiModal` (#6321) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [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 --- .../{confirm_modal.js => confirm_modal.tsx} | 2 +- ...l_loading.js => confirm_modal_loading.tsx} | 8 +- .../src/views/modal/{modal.js => modal.tsx} | 0 src-docs/src/views/modal/modal_example.js | 10 +- .../modal/{modal_form.js => modal_form.tsx} | 20 +-- .../modal/{modal_width.js => modal_width.tsx} | 4 +- .../image/image_fullscreen_wrapper.styles.ts | 17 +- src/components/index.scss | 1 - .../__snapshots__/confirm_modal.test.tsx.snap | 40 ++--- .../modal/__snapshots__/modal.test.tsx.snap | 4 +- .../__snapshots__/modal_body.test.tsx.snap | 6 +- .../__snapshots__/modal_footer.test.tsx.snap | 4 +- .../__snapshots__/modal_header.test.tsx.snap | 4 +- .../modal_header_title.test.tsx.snap | 12 +- src/components/modal/_index.scss | 1 - src/components/modal/_modal.scss | 156 ------------------ src/components/modal/confirm_modal.test.tsx | 5 + src/components/modal/confirm_modal.tsx | 18 +- src/components/modal/modal.styles.ts | 81 +++++++++ src/components/modal/modal.test.tsx | 59 ++++++- src/components/modal/modal.tsx | 30 ++-- src/components/modal/modal_body.styles.ts | 39 +++++ src/components/modal/modal_body.test.tsx | 11 +- src/components/modal/modal_body.tsx | 15 +- src/components/modal/modal_footer.styles.ts | 39 +++++ src/components/modal/modal_footer.test.tsx | 15 +- src/components/modal/modal_footer.tsx | 10 +- src/components/modal/modal_header.styles.ts | 31 ++++ src/components/modal/modal_header.test.tsx | 15 +- src/components/modal/modal_header.tsx | 10 +- .../modal/modal_header_title.test.tsx | 15 +- src/components/modal/modal_header_title.tsx | 7 +- src/global_styling/utility/animations.ts | 12 ++ src/themes/amsterdam/overrides/_index.scss | 1 - src/themes/amsterdam/overrides/_modal.scss | 3 - upcoming_changelogs/6321.md | 3 + 36 files changed, 433 insertions(+), 275 deletions(-) rename src-docs/src/views/modal/{confirm_modal.js => confirm_modal.tsx} (98%) rename src-docs/src/views/modal/{confirm_modal_loading.js => confirm_modal_loading.tsx} (94%) rename src-docs/src/views/modal/{modal.js => modal.tsx} (100%) rename src-docs/src/views/modal/{modal_form.js => modal_form.tsx} (91%) rename src-docs/src/views/modal/{modal_width.js => modal_width.tsx} (93%) delete mode 100644 src/components/modal/_index.scss delete mode 100644 src/components/modal/_modal.scss create mode 100644 src/components/modal/modal.styles.ts create mode 100644 src/components/modal/modal_body.styles.ts create mode 100644 src/components/modal/modal_footer.styles.ts create mode 100644 src/components/modal/modal_header.styles.ts delete mode 100644 src/themes/amsterdam/overrides/_modal.scss create mode 100644 upcoming_changelogs/6321.md diff --git a/src-docs/src/views/modal/confirm_modal.js b/src-docs/src/views/modal/confirm_modal.tsx similarity index 98% rename from src-docs/src/views/modal/confirm_modal.js rename to src-docs/src/views/modal/confirm_modal.tsx index 8a4ea147576..b79539692f9 100644 --- a/src-docs/src/views/modal/confirm_modal.js +++ b/src-docs/src/views/modal/confirm_modal.tsx @@ -5,7 +5,7 @@ import { EuiConfirmModal, EuiFlexGroup, EuiFlexItem, -} from '../../../../src/components'; +} from '../../../../src'; export default () => { const [isModalVisible, setIsModalVisible] = useState(false); diff --git a/src-docs/src/views/modal/confirm_modal_loading.js b/src-docs/src/views/modal/confirm_modal_loading.tsx similarity index 94% rename from src-docs/src/views/modal/confirm_modal_loading.js rename to src-docs/src/views/modal/confirm_modal_loading.tsx index 7cfc0558271..4a1fd1b1573 100644 --- a/src-docs/src/views/modal/confirm_modal_loading.js +++ b/src-docs/src/views/modal/confirm_modal_loading.tsx @@ -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); @@ -27,7 +29,7 @@ export default () => { }; const [value, setValue] = useState(''); - const onChange = (e) => { + const onChange = (e: React.ChangeEvent) => { setValue(e.target.value); }; diff --git a/src-docs/src/views/modal/modal.js b/src-docs/src/views/modal/modal.tsx similarity index 100% rename from src-docs/src/views/modal/modal.js rename to src-docs/src/views/modal/modal.tsx diff --git a/src-docs/src/views/modal/modal_example.js b/src-docs/src/views/modal/modal_example.js index 458fc0216f8..a7b648a5428 100644 --- a/src-docs/src/views/modal/modal_example.js +++ b/src-docs/src/views/modal/modal_example.js @@ -131,7 +131,7 @@ export const ModalExample = { { source: [ { - type: GuideSectionTypes.JS, + type: GuideSectionTypes.TSX, code: modalSource, }, ], @@ -167,7 +167,7 @@ export const ModalExample = { title: 'Forms in a modal', source: [ { - type: GuideSectionTypes.JS, + type: GuideSectionTypes.TSX, code: modalFormSource, }, ], @@ -192,7 +192,7 @@ export const ModalExample = { title: 'Confirm modal', source: [ { - type: GuideSectionTypes.JS, + type: GuideSectionTypes.TSX, code: confirmModalSource, }, ], @@ -214,7 +214,7 @@ export const ModalExample = { title: 'Loading and disabling confirm button', source: [ { - type: GuideSectionTypes.JS, + type: GuideSectionTypes.TSX, code: confirmModalLoadingSource, }, ], @@ -236,7 +236,7 @@ export const ModalExample = { title: 'Widths', source: [ { - type: GuideSectionTypes.JS, + type: GuideSectionTypes.TSX, code: modalWidthSource, }, ], diff --git a/src-docs/src/views/modal/modal_form.js b/src-docs/src/views/modal/modal_form.tsx similarity index 91% rename from src-docs/src/views/modal/modal_form.js rename to src-docs/src/views/modal/modal_form.tsx index 70ef6c67ccb..a9b138235c8 100644 --- a/src-docs/src/views/modal/modal_form.js +++ b/src-docs/src/views/modal/modal_form.tsx @@ -1,4 +1,4 @@ -import React, { useState, Fragment } from 'react'; +import React, { useState } from 'react'; import { EuiButton, @@ -15,7 +15,7 @@ import { EuiSwitch, EuiSuperSelect, EuiText, -} from '../../../../src/components'; +} from '../../../../src'; import { useGeneratedHtmlId } from '../../../../src/services'; @@ -39,36 +39,36 @@ export default () => { value: 'option_one', inputDisplay: 'Option one', dropdownDisplay: ( - + <> Option one

Has a short description giving more detail to the option.

-
+ ), }, { value: 'option_two', inputDisplay: 'Option two', dropdownDisplay: ( - + <> Option two

Has a short description giving more detail to the option.

-
+ ), }, { value: 'option_three', inputDisplay: 'Option three', dropdownDisplay: ( - + <> Option three

Has a short description giving more detail to the option.

-
+ ), }, ]; @@ -90,7 +90,7 @@ export default () => { - + @@ -105,7 +105,7 @@ export default () => { ); - const onSuperSelectChange = (value) => { + const onSuperSelectChange = (value: string) => { setSuperSelectValue(value); }; diff --git a/src-docs/src/views/modal/modal_width.js b/src-docs/src/views/modal/modal_width.tsx similarity index 93% rename from src-docs/src/views/modal/modal_width.js rename to src-docs/src/views/modal/modal_width.tsx index 1a92c52c19c..4ba180ea71f 100644 --- a/src-docs/src/views/modal/modal_width.js +++ b/src-docs/src/views/modal/modal_width.tsx @@ -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); diff --git a/src/components/image/image_fullscreen_wrapper.styles.ts b/src/components/image/image_fullscreen_wrapper.styles.ts index 9230791dbd1..698d662aa7e 100644 --- a/src/components/image/image_fullscreen_wrapper.styles.ts +++ b/src/components/image/image_fullscreen_wrapper.styles.ts @@ -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'; @@ -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}; } @@ -42,15 +43,3 @@ export const euiImageFullscreenWrapperStyles = ( `, }; }; - -const euiImageFullScreen = (size: string) => keyframes` - 0% { - opacity: 0; - transform: translateY(${size}); - } - - 100% { - opacity: 1; - transform: translateY(0); - } -`; diff --git a/src/components/index.scss b/src/components/index.scss index 12530e2af31..12c8908501b 100644 --- a/src/components/index.scss +++ b/src/components/index.scss @@ -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 diff --git a/src/components/modal/__snapshots__/confirm_modal.test.tsx.snap b/src/components/modal/__snapshots__/confirm_modal.test.tsx.snap index 4bfb83a1d64..ab79a4d4291 100644 --- a/src/components/modal/__snapshots__/confirm_modal.test.tsx.snap +++ b/src/components/modal/__snapshots__/confirm_modal.test.tsx.snap @@ -12,13 +12,13 @@ Array [ >
-
-

- A confirmation modal -

-
+ A confirmation modal +
-
-

- A confirmation modal -

-
+ A confirmation modal +