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 EuiFlyout #6108

Closed
wants to merge 33 commits into from
Closed

Conversation

breehall
Copy link
Contributor

@breehall breehall commented Aug 4, 2022

Summary

This PR converts EuiFlyout to Emotion. There are no functional or UI changes within this conversion.

Created EuiFlyout context as a way to pass the value of the padding prop from EuiFlyout down to EuiFlyoutHeader, EuiFlyoutBody, and EuiFlyoutFooter.

Checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • [ ] Props have proper autodocs and playground toggles
  • [ ] Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • [ ] Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

breehall and others added 22 commits February 28, 2022 10:57
Merge Changes from EUI Main
Merging in the latest code from eui/main
Merging in the latest code from main
Merging in the latest code from the main branch
Pulling in the latest code from the main branch
Merging in the latest code from main
…dated euiOverflowShadowStyles to be an export from _helpers.ts to be used as a styling funciton within EuiFlyout
…utHeader, EuiFlyoutFooter, and EuiFlyoutBody
…lyout

Merging in the latest code from the main branch
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6108/

@breehall breehall marked this pull request as ready for review August 4, 2022 15:27
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6108/

@breehall breehall marked this pull request as draft August 4, 2022 16:19
…dating the flmenu close by clicking on the overlay mask was not triggering. Updated this test to click a specific position on the screen to trigger the click
…pear inside of the flyout instead of outside. Updated Collapsible Nav snapshots
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6108/

@breehall breehall marked this pull request as ready for review August 8, 2022 22:26
@@ -54,6 +55,7 @@ export type EuiThemeShape = {
animation: _EuiThemeAnimation;
breakpoint: _EuiThemeBreakpoints;
levels: _EuiThemeLevels;
form: _EuiThemeForm;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally clear on why this needs its own theme level variable rather than us having an exported maxWidth variable within src/components/form - @thompsongl any thoughts on that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; no need to extend the global theme object.

Copy link
Contributor

@cee-chen cee-chen Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@breehall Re-ping on this - can you remove the new form variable from EuiTheme and instead just export euiFormMaxWidth from src/components/form/form.styles.ts?

@breehall breehall marked this pull request as draft August 22, 2022 16:30
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6108/

@breehall breehall marked this pull request as ready for review August 31, 2022 01:17
…the Flyout context. There's no need for these items to be split anymore. Updated references to flyout types in flyout test files
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6108/

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expecting a decent amount of churn from the comments I've already left so far, so going to take a break from reviewing / wait for the next changeset before diving back in!

Comment on lines +24 to +28
import { EuiButtonIcon, EuiButtonIconPropsForButton } from '../button';
import { EuiFocusTrap, EuiFocusTrapProps } from '../focus_trap';
import { EuiOverlayMask, EuiOverlayMaskProps } from '../overlay_mask';

import { CommonProps, keysOf, PropsOfElement } from '../common';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Not a change request, just a comment/suggestion for the future] The number of lines in this file that appear to have been arbitrarily moved around are somewhat confusing/create a decent amount of diff noise. I assume they occurred when you moved types back out of a separate file into this file - in the future, I'd strongly suggest making use of git revert to accomplish undoing code changes as it can help reduce diffs. This in turn helps reduce the number of things code reviewers have to track when reading through code diffs and makes the review experience faster/easier 🤞

@@ -66,21 +70,21 @@ export type EuiFlyoutSize = typeof SIZES[number];
* Custom type checker for named flyout sizes since the prop
* `size` can also be CSSProperties['width'] (string | number)
*/
function isEuiFlyoutSizeNamed(value: any): value is EuiFlyoutSize {
export function isEuiFlyoutSizeNamed(value: any): value is EuiFlyoutSize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[change request] I assume these exports came from the type file undo as well. Can we please remove them if we're not actually importing the fns/vars anywhere?

Comment on lines +52 to 55
export const sideToClassNameMap = {
left: 'euiFlyout--left',
right: null,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No instances of euiFlyout-- references/overrides in Kibana anywhere, so IMO we're safe to remove these classNames and maps entirely.

Suggested change
export const sideToClassNameMap = {
left: 'euiFlyout--left',
right: null,
};

Comment on lines +77 to +85
export const paddingSizeToClassNameMap = {
none: 'euiFlyout--paddingNone',
s: 'euiFlyout--paddingSmall',
m: 'euiFlyout--paddingMedium',
l: 'euiFlyout--paddingLarge',
};

export const PADDING_SIZES = keysOf(paddingSizeToClassNameMap);
type _EuiFlyoutPaddingSize = typeof PADDING_SIZES[number];
export type EuiFlyoutPaddingSize = typeof PADDING_SIZES[number];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Suggested change
export const paddingSizeToClassNameMap = {
none: 'euiFlyout--paddingNone',
s: 'euiFlyout--paddingSmall',
m: 'euiFlyout--paddingMedium',
l: 'euiFlyout--paddingLarge',
};
export const PADDING_SIZES = keysOf(paddingSizeToClassNameMap);
type _EuiFlyoutPaddingSize = typeof PADDING_SIZES[number];
export type EuiFlyoutPaddingSize = typeof PADDING_SIZES[number];
export const PADDING_SIZES = ['none', 's', 'm', 'l'];
type _EuiFlyoutPaddingSize = typeof PADDING_SIZES[number];

Comment on lines 305 to 315
const classes = classnames(
'euiFlyout',
typeToClassNameMap[type as _EuiFlyoutType],
sideToClassNameMap[side as _EuiFlyoutSide],
{
[`euiFlyout--${type}`]: type,
[`euiFlyout--${side}`]: side,
[`euiFlyout--padding-${paddingSize}`]: paddingSize,
},
sizeClassName,
paddingSizeToClassNameMap[paddingSize as _EuiFlyoutPaddingSize],
widthClassName,
className
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to apply any of these modifier classes to EuiFlyout any longer

Suggested change
const classes = classnames(
'euiFlyout',
typeToClassNameMap[type as _EuiFlyoutType],
sideToClassNameMap[side as _EuiFlyoutSide],
{
[`euiFlyout--${type}`]: type,
[`euiFlyout--${side}`]: side,
[`euiFlyout--padding-${paddingSize}`]: paddingSize,
},
sizeClassName,
paddingSizeToClassNameMap[paddingSize as _EuiFlyoutPaddingSize],
widthClassName,
className
);
const classes = classnames('euiFlyout', className);

Comment on lines +9 to +14
import React, {
FunctionComponent,
HTMLAttributes,
ReactNode,
//useContext,
} from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted

Comment on lines +301 to +302
// Footer
euiFlyoutFooter: css`
Copy link
Contributor

@cee-chen cee-chen Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in its own file, flyout_footer.styles.ts and should use BEM namespacing, i.e. euiFlyout__footer
🌟

Comment on lines +267 to +268
// Body
euiFlyoutBody: css`
Copy link
Contributor

@cee-chen cee-chen Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in its own file, flyout_body.styles.ts and should use BEM namespacing, i.e. euiFlyout__body

Comment on lines +244 to +245
// Header
euiFlyoutHeader: css`
Copy link
Contributor

@cee-chen cee-chen Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in its own file, flyout_header.styles.ts and should use BEM namespacing, i.e. euiFlyout__header

Comment on lines +12 to +24
export const getFlyoutPadding = (
paddingSize: EuiFlyoutPaddingSize,
{ euiTheme }: UseEuiTheme
) => {
const paddingModifiers = {
none: 0,
s: euiTheme.size.s,
m: euiTheme.size.base,
l: euiTheme.size.l,
};

return paddingModifiers[paddingSize];
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite seeing why this needs to be in its own separate file/util - I'd suggest only defining it as a map within flyout.styles.ts and using CSS nesting to target padding of flyout children rather than trying to keep our CSS perfectly flat

@thompsongl thompsongl self-requested a review August 31, 2022 18:59
@breehall breehall mentioned this pull request Sep 7, 2022
8 tasks
@breehall
Copy link
Contributor Author

breehall commented Sep 7, 2022

Due to the nature of the changes, I thought it would be best to bring the actual changes over to a new branch and leave everything else to reduce the diff churn from moving around files. I will be closing this PR and using #6213 moving forward. That PR has a summary and a link to the most recent changes requested.

@breehall breehall closed this Sep 7, 2022
@breehall breehall deleted the emotion/flyout branch September 18, 2023 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants