Skip to content

Commit

Permalink
[EuiPopover and parts] Converted to Emotion (#5977)
Browse files Browse the repository at this point in the history
* Move Amsterdam Sass overrides to src/

* [EuiPopoverFooter] Converted except for…

Inherited panel padding/margin

* [EuiPopoverTitle] Converted except for…

Inherited panel padding/margin

* Removed Sass mixin `euiPopoverTitle`

* Added [EuiPopoverArrow] and simplified styles

* [EuiPopover] BREAKING Changed `display` type to accept real CSS `display` values

* Fix grid tests

* WIP: Converted base EuiPaopover and panel styles

* New EuiPopoverPanel for internal use

* Skip test & fix props

* Fixed EuiTour’s styles

* Undo HOC by moving panel styles to it’s own folder

* Created a EuiPopoverPanelContext for passing through `paddingSize`

* [EuiInputPopover] Converted by applying max-width directly in component

* Converted to logical properties

* Convert some docs files to TS

* Increase opacity of shadows in DARK mode

* Cleanup

* cl

* Mostly fix class name output

* Fix TS and rename internal files with `_`

* Attempting to fix props table

* EuiPopoverPanel extends _EuiPanelDivlike and better prop table

* snapshot updates

Co-authored-by: Constance Chen <constance.chen.3@gmail.com>
Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
  • Loading branch information
3 people committed Jul 20, 2022
1 parent 4abbb81 commit b86ee8c
Show file tree
Hide file tree
Showing 92 changed files with 1,484 additions and 1,010 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
EuiPopover,
EuiSpacer,
EuiFieldText,
} from '../../../../src/components';
} from '../../../../src';

export default () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
Expand Down Expand Up @@ -34,7 +34,9 @@ export default () => {

<EuiSpacer />

<EuiButton fill>Submit</EuiButton>
<EuiButton size="s" fill>
Submit
</EuiButton>
</EuiPopover>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { useState } from 'react';

import {
EuiInputPopover,
EuiFieldText,
EuiSpacer,
} from '../../../../src/components';
import { EuiInputPopover, EuiFieldText, EuiSpacer } from '../../../../src';

export default () => {
const [inputWidth, setInputWidth] = useState(200);
Expand All @@ -27,10 +23,9 @@ export default () => {
const inputTwo = (
<EuiFieldText
onFocus={() => {
setInputWidth(400);
setInputWidth(300);
toggleIsPopoverOpenTwo();
}}
style={{ width: inputWidth }}
aria-label="Popover attached to an adjustable sized input element"
/>
);
Expand All @@ -52,6 +47,7 @@ export default () => {
<EuiInputPopover
input={inputTwo}
isOpen={isPopoverOpenTwo}
style={{ width: inputWidth }}
closePopover={() => {
toggleIsPopoverOpenTwo(false);
setInputWidth(200);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import { EuiPopover, EuiButton, EuiText } from '../../../../src/components';
import { EuiPopover, EuiButton, EuiText } from '../../../../src';

export default () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
EuiFlexItem,
EuiSpacer,
EuiText,
} from '../../../../src/components';
} from '../../../../src';

export default () => {
const [isPopoverOpen1, setIsPopoverOpen1] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import { EuiButton, EuiPopover } from '../../../../src/components';
import { EuiButton, EuiPopover } from '../../../../src';

export default () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
Expand Down
4 changes: 3 additions & 1 deletion src-docs/src/views/popover/popover_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
EuiCallOut,
} from '../../../../src/components';

import { EuiPopoverPanelProps } from './props';

import Popover from './popover';
const popoverSource = require('!!raw-loader!./popover');

Expand Down Expand Up @@ -171,7 +173,7 @@ export const PopoverExample = {
</p>
</>
),
props: { EuiPopover },
props: { EuiPopover, EuiPopoverPanelProps },
snippet: popOverSnippet,
demo: <Popover />,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import { EuiButton, EuiPopover } from '../../../../src/components';
import { EuiButton, EuiPopover } from '../../../../src';

export default () => {
const [isExampleShown, setIsExampleShown] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import { EuiPopover, EuiButton, EuiText } from '../../../../src/components';
import { EuiPopover, EuiButton, EuiText } from '../../../../src';

export default () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
EuiFlexItem,
EuiText,
EuiTextColor,
} from '../../../../src/components';
} from '../../../../src';

export default () => {
const [isPopoverOpen1, setIsPopoverOpen1] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
EuiFlexItem,
EuiText,
EuiCode,
} from '../../../../src/components';
} from '../../../../src';

export default () => {
const [isPopoverOpen1, setIsPopoverOpen1] = useState(false);
Expand Down
7 changes: 7 additions & 0 deletions src-docs/src/views/popover/props.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React, { FunctionComponent } from 'react';

import { EuiPopoverPanelProps as _EuiPopoverPanelProps } from '../../../../src/components/popover/popover_panel/_popover_panel';

export const EuiPopoverPanelProps: FunctionComponent<_EuiPopoverPanelProps> = () => (
<div />
);
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default () => {
const focusId = useGeneratedHtmlId();
useEffect(() => {
if (isPopoverOpen) {
document.getElementById(focusId).focus({ preventScroll: true });
document.getElementById(focusId)!.focus({ preventScroll: true });
}
}, [isPopoverOpen, focusId]);

Expand Down
53 changes: 53 additions & 0 deletions src-docs/src/views/theme/sizing/_sizing_js.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {
PADDING_SIZES,
LOGICAL_SIDES,
EuiPanel,
EuiSpacer,
logicalSizeCSS,
logicalSizeStyle,
} from '../../../../../src';

import { ThemeExample } from '../_components/_theme_example';
Expand Down Expand Up @@ -258,6 +261,56 @@ export const UtilsJS = () => {
</EuiText>
</EuiAccordion>
</EuiPanel>

<EuiSpacer size="xl" />

<ThemeExample
title={<code>{'logicalSizeCSS(width, height)'}</code>}
type="function"
description={
<p>
Returns the <strong>string version</strong> of the logical CSS size
properties given <EuiCode language="css">width</EuiCode> and{' '}
<EuiCode language="css">height</EuiCode>. Best used when providing
styles via Emotion&apos;s <EuiCode>{'css``'}</EuiCode> method.
</p>
}
example={
<p
css={[
useEuiBackgroundColorCSS().warning,
logicalSizeCSS('200px', '100px'),
]}
>
<code>{logicalSizeCSS('200px', '100px')}</code>
</p>
}
snippetLanguage="emotion"
snippet={"${logicalSizeCSS('200px', '100px')};"}
/>

<ThemeExample
title={<code>{'logicalStyle(property, value)'}</code>}
type="function"
description={
<p>
Returns the <strong>object version</strong> of the logical CSS size
properties given <EuiCode language="css">width</EuiCode> and{' '}
<EuiCode language="css">height</EuiCode>. Best used when providing
styles via React&apos;s <EuiCode>style</EuiCode> property.
</p>
}
example={
<p
css={css(useEuiBackgroundColorCSS().warning)}
style={logicalSizeStyle('200px', '100px')}
>
<code>{JSON.stringify(logicalSizeStyle('200px', '100px'))}</code>
</p>
}
snippetLanguage="tsx"
snippet={"<p style={logicalSizeStyle('200px', '100px')} />"}
/>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

exports[`CollapsedItemActions render 1`] = `
<div
class="euiPopover euiPopover--anchorLeftCenter"
class="euiPopover emotion-euiPopover"
id="id-actions"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<span
class="euiToolTipAnchor"
Expand Down Expand Up @@ -41,7 +41,7 @@ exports[`CollapsedItemActions render with href and _target provided 1`] = `
</EuiI18n>
}
closePopover={[Function]}
display="inlineBlock"
display="inline-block"
hasArrow={true}
id="id-actions"
isOpen={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<div
class="euiPopover euiPopover--anchorUpRight"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--xSmall"
Expand Down Expand Up @@ -765,10 +765,10 @@ exports[`EuiInMemoryTable with pagination and "show all" page size 1`] = `
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<div
class="euiPopover euiPopover--anchorUpRight"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--xSmall"
Expand Down
28 changes: 14 additions & 14 deletions src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ exports[`EuiBreadcrumbs is rendered 1`] = `
class="euiBreadcrumb euiBreadcrumb--collapsed"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
aria-label="See collapsed breadcrumbs"
Expand Down Expand Up @@ -123,10 +123,10 @@ exports[`EuiBreadcrumbs is rendered with final item as link 1`] = `
class="euiBreadcrumb euiBreadcrumb--collapsed"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
aria-label="See collapsed breadcrumbs"
Expand Down Expand Up @@ -286,10 +286,10 @@ exports[`EuiBreadcrumbs props max renders 1 item 1`] = `
class="euiBreadcrumb euiBreadcrumb--collapsed"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
aria-label="See collapsed breadcrumbs"
Expand Down Expand Up @@ -447,10 +447,10 @@ exports[`EuiBreadcrumbs props responsive is rendered 1`] = `
class="euiBreadcrumb euiBreadcrumb--collapsed"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
aria-label="See collapsed breadcrumbs"
Expand Down Expand Up @@ -536,10 +536,10 @@ exports[`EuiBreadcrumbs props responsive is rendered as false 1`] = `
class="euiBreadcrumb euiBreadcrumb--collapsed"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
aria-label="See collapsed breadcrumbs"
Expand Down Expand Up @@ -604,10 +604,10 @@ exports[`EuiBreadcrumbs props responsive is rendered with custom breakpoints 1`]
class="euiBreadcrumb euiBreadcrumb--collapsed"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
aria-label="See collapsed breadcrumbs"
Expand Down Expand Up @@ -670,10 +670,10 @@ exports[`EuiBreadcrumbs props truncate as false is rendered 1`] = `
class="euiBreadcrumb euiBreadcrumb--collapsed"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor"
class="euiPopover__anchor css-16vtueo-render"
>
<button
aria-label="See collapsed breadcrumbs"
Expand Down
Loading

0 comments on commit b86ee8c

Please sign in to comment.