-
Notifications
You must be signed in to change notification settings - Fork 842
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
Added maxWidth
prop to EuiFlyout
#1090
Conversation
src/components/flyout/flyout.js
Outdated
} else if (maxWidth !== false) { | ||
// if style has been passed as a prop, add to it | ||
if (style) { | ||
newStyle = style; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to create a new style object here,
newStyle = { ...style, maxWidth };
otherwise this will add the maxWidth
key/value to the original style prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also get confused about JS's stupid array reference stuff and forget about the spread method. Just so I understand, does the way your method work is that it will add the key/value pair of maxWidth
or is it just adding that value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, that actually completely negates the need for the if statement, because if style is empty, then there's just no other key/value pairs. Nice!
- Added `string` to allowed `restrictWidth` prop type of `EuiPage` and `EuiPageBody` - Fixed wrong class name being added to `EuiPageBody` when `restrictWidth !== false` - Added these props to their TS defs
@chandlerprall Can you take another look. I also updated Can you also check that I added the TS stuff correctly? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!; reviewed code changes
@cchaos all looks good to me (including TS defs), thanks for the changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in browser by making my own example. Verified docs and review code.
I like that we're standardizing this kind of variety from a props perspective. It's a nice pattern.
Fixes #1071
Similarly to how
EuiPage
uses therestrictWidth
prop, themaxWidth
prop can be:false
(default): No max-widthtrue
: Adds a pre-defined max width depending on flyoutsize
number
: Will add the number to the style prop as amaxWidth
value inpx
string
: Will add the full string as themaxWidth
value in whatever measurement it providesThe
string
option has now also been added toEuiPage
andEuiPageBody
as well as the simplified style js commented below, including removing the unnecessary--widthIsNotRestricted
classes, and adding this prop to the TS definitions.