-
Notifications
You must be signed in to change notification settings - Fork 841
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
Fix bug with EuiFlyout maxWidth interfering with responsive mode. #1124
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import { | ||
EuiFlyout, | ||
EuiFlyoutHeader, | ||
EuiFlyoutBody, | ||
EuiButton, | ||
EuiText, | ||
EuiTitle, | ||
} from '../../../../src/components'; | ||
|
||
export class FlyoutLarge extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
isFlyoutVisible: false, | ||
isSwitchChecked: true, | ||
}; | ||
|
||
this.closeFlyout = this.closeFlyout.bind(this); | ||
this.showFlyout = this.showFlyout.bind(this); | ||
} | ||
|
||
onSwitchChange = () => { | ||
this.setState({ | ||
isSwitchChecked: !this.state.isSwitchChecked, | ||
}); | ||
} | ||
|
||
closeFlyout() { | ||
this.setState({ isFlyoutVisible: false }); | ||
} | ||
|
||
showFlyout() { | ||
this.setState({ isFlyoutVisible: true }); | ||
} | ||
|
||
render() { | ||
|
||
let flyout; | ||
if (this.state.isFlyoutVisible) { | ||
flyout = ( | ||
<EuiFlyout | ||
onClose={this.closeFlyout} | ||
size="l" | ||
aria-labelledby="flyoutLargeTitle" | ||
> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiTitle size="m"> | ||
<h2 id="flyoutLargeTitle"> | ||
A large flyout | ||
</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
<EuiText> | ||
<p> | ||
The large flyout is very wide. | ||
</p> | ||
</EuiText> | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
); | ||
} | ||
return ( | ||
<div> | ||
<EuiButton onClick={this.showFlyout}> | ||
Show large flyout | ||
</EuiButton> | ||
|
||
{flyout} | ||
</div> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import { | ||
EuiFlyout, | ||
EuiFlyoutBody, | ||
EuiFlyoutHeader, | ||
EuiButton, | ||
EuiText, | ||
EuiTitle, | ||
EuiFieldText, | ||
EuiForm, | ||
EuiFormRow, | ||
EuiFilePicker, | ||
EuiRange, | ||
EuiSelect, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export class FlyoutMaxWidth extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
isFlyoutVisible: false, | ||
isSwitchChecked: true, | ||
}; | ||
|
||
this.closeFlyout = this.closeFlyout.bind(this); | ||
this.showFlyout = this.showFlyout.bind(this); | ||
} | ||
|
||
onSwitchChange = () => { | ||
this.setState({ | ||
isSwitchChecked: !this.state.isSwitchChecked, | ||
}); | ||
} | ||
|
||
closeFlyout() { | ||
this.setState({ isFlyoutVisible: false }); | ||
} | ||
|
||
showFlyout() { | ||
this.setState({ isFlyoutVisible: true }); | ||
} | ||
|
||
render() { | ||
let flyout; | ||
|
||
if (this.state.isFlyoutVisible) { | ||
flyout = ( | ||
<EuiFlyout | ||
onClose={this.closeFlyout} | ||
aria-labelledby="flyoutMaxWidthTitle" | ||
maxWidth="448px" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we change the examples to not pass the 'px'? I intentionally wanted to mimic the way React handles the |
||
> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiTitle size="m"> | ||
<h2 id="flyoutMaxWidthTitle"> | ||
448px wide flyout | ||
</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
<EuiText> | ||
<p> | ||
In many cases, you’ll want to set a custom width that”s tailored to your content. | ||
In this case, the flyout is an ideal width for form elements. | ||
</p> | ||
</EuiText> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiForm> | ||
<EuiFormRow | ||
label="Text field" | ||
helpText="I am some friendly help text." | ||
> | ||
<EuiFieldText name="first" /> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow | ||
label="Select (with no initial selection)" | ||
> | ||
<EuiSelect | ||
hasNoInitialSelection | ||
options={[ | ||
{ value: 'option_one', text: 'Option one' }, | ||
{ value: 'option_two', text: 'Option two' }, | ||
{ value: 'option_three', text: 'Option three' }, | ||
]} | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow | ||
label="File picker" | ||
> | ||
<EuiFilePicker /> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow | ||
label="Range" | ||
> | ||
<EuiRange | ||
min={0} | ||
max={100} | ||
name="range" | ||
id="range" | ||
/> | ||
</EuiFormRow> | ||
</EuiForm> | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
); | ||
} | ||
|
||
return ( | ||
<div> | ||
<EuiButton onClick={this.showFlyout}> | ||
Show max-width flyout | ||
</EuiButton> | ||
|
||
{flyout} | ||
</div> | ||
); | ||
} | ||
} |
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 updated these examples to use
h2
because in most cases I've seen this heading won't make sense as a top-level heading; instead it will make more sense as a child of the top-level.