Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Emotion] Convert EuiModal #6321

Merged
merged 28 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c80c82f
[Emotion] Convert `modal`
miukimiu Oct 24, 2022
5f8418c
Fix weird bug in Chrome with parent `overflow: hidden` and children w…
miukimiu Oct 26, 2022
ad14381
Better styles and fixed `euiOverflowShadowStyles`
miukimiu Oct 26, 2022
d115136
Adding CL
miukimiu Oct 26, 2022
a19dd98
Added `euiAnimSlideInUp`
miukimiu Oct 26, 2022
1a6ac92
Removing unnecessary class name
miukimiu Oct 27, 2022
999cd39
REVERT ME - To test bug with `mask-image`
miukimiu Oct 27, 2022
37bf45f
Added `shouldRenderCustomStyles()` tests
miukimiu Oct 27, 2022
17da165
Cleaned up docs code and converted to TS
miukimiu Oct 27, 2022
05c6860
Adding bug fix in CL
miukimiu Oct 27, 2022
0dec04e
CL again
miukimiu Oct 27, 2022
8722ab8
CL again 😭
miukimiu Oct 27, 2022
ff33864
Changing examples source types to TSX
miukimiu Oct 27, 2022
70d40a7
Merge remote-tracking branch 'upstream/main' into emotion-convert-modal
miukimiu Oct 31, 2022
d23c156
Merge remote-tracking branch 'upstream/main' into emotion-convert-modal
miukimiu Nov 4, 2022
68d5c5f
Reverting example and renaming to `*.tsx`
miukimiu Nov 4, 2022
efae049
Remove bug fix entry from CL
miukimiu Nov 4, 2022
692e00d
Merge remote-tracking branch 'upstream/main' into emotion-convert-modal
miukimiu Nov 17, 2022
2eada08
Merge branch 'main' into emotion-convert-modal
cee-chen Nov 18, 2022
5709a77
DRY out `initialFocus` types/prop docs + add `defaultFocusedButton` p…
cee-chen Nov 18, 2022
d51d28b
[EuiModalHeader] misc cleanup
cee-chen Nov 18, 2022
92b4067
Clean up unnecessary width CSS
cee-chen Nov 18, 2022
334ce8c
Simplify `style` logic + switch to logical property
cee-chen Nov 18, 2022
16ecde8
[opinionated] Rename `defaultMaxWidth` class modifier
cee-chen Nov 18, 2022
2f46f29
Fix `maxWidth` conditional class logic + write unit tests
cee-chen Nov 18, 2022
3d0a929
Use `inset` shorthand
cee-chen Nov 18, 2022
95c5d69
[EuiModal] Fix box-shadows
cee-chen Nov 18, 2022
d73eaf2
Restore `!important`s required for style.width overrides
cee-chen Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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