-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor EuiToolTip, add EuiPortal (#484)
Adds `EuiToolTip` and `EuiPortal` components.
- Loading branch information
Showing
36 changed files
with
783 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import { | ||
EuiPortal, | ||
EuiButton, | ||
EuiBottomBar, | ||
} from '../../../../src/components'; | ||
|
||
export class Portal extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
isPortalVisible: false, | ||
}; | ||
|
||
this.togglePortal = this.togglePortal.bind(this); | ||
} | ||
|
||
togglePortal() { | ||
this.setState(prevState => ({ isPortalVisible: !prevState.isPortalVisible })); | ||
} | ||
|
||
render() { | ||
|
||
let portal; | ||
|
||
if (this.state.isPortalVisible) { | ||
portal = ( | ||
<EuiPortal> | ||
<EuiBottomBar> | ||
<p>This element is appended to the body in the DOM if you inspect</p> | ||
</EuiBottomBar> | ||
</EuiPortal> | ||
); | ||
} | ||
return ( | ||
<div> | ||
<EuiButton onClick={this.togglePortal}> | ||
Toggle portal | ||
</EuiButton> | ||
|
||
{portal} | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { | ||
GuideSectionTypes, | ||
} from '../../components'; | ||
|
||
import { | ||
EuiCode, | ||
EuiPortal, | ||
} from '../../../../src/components'; | ||
|
||
import { Portal } from './portal'; | ||
const portalSource = require('!!raw-loader!./portal'); | ||
const portalHtml = renderToHtml(Portal); | ||
|
||
export const PortalExample = { | ||
title: 'Portal', | ||
sections: [{ | ||
title: 'Portal', | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: portalSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: portalHtml, | ||
}], | ||
text: ( | ||
<p> | ||
<EuiCode>EuiPortal</EuiCode> allows you to append its contained children | ||
onto the document body. It is useful for moving fixed elements like modals, | ||
tooltips or toasts when you are worried about a z-index or overflow conflict. | ||
</p> | ||
), | ||
components: { EuiPortal }, | ||
demo: <Portal />, | ||
}], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiIcon, | ||
EuiToolTip, | ||
EuiLink, | ||
EuiText, | ||
EuiFieldText, | ||
EuiSpacer, | ||
EuiButton, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiText> | ||
<p> | ||
This tooltip appears on the{' '} | ||
<EuiToolTip position="top" content="Here is some tooltip text"> | ||
<EuiLink href="#">top</EuiLink> | ||
</EuiToolTip> | ||
</p> | ||
|
||
<p> | ||
This tooltip appears on the{' '} | ||
<EuiToolTip | ||
position="left" | ||
title="Tooltip titles are optional" | ||
content="Here is some tooltip text. Lets add some more content to see how it wraps." | ||
> | ||
<EuiLink href="#">left</EuiLink> | ||
</EuiToolTip> | ||
{' '} and includes the optional title. | ||
</p> | ||
|
||
<p> | ||
This tooltip appears on the{' '} | ||
<EuiToolTip position="right" content="Here is some tooltip text"> | ||
<EuiLink href="#">right</EuiLink> | ||
</EuiToolTip> | ||
</p> | ||
|
||
<p> | ||
This tooltip appears on the bottom of this icon:{' '} | ||
<EuiToolTip position="bottom" content="Here is some tooltip text"> | ||
<EuiIcon tabIndex="0" type="alert" title="Icon with tooltip" /> | ||
</EuiToolTip> | ||
</p> | ||
</EuiText> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiToolTip position="right" content="Works on anything"> | ||
<EuiFieldText placeholder="Hover over me" /> | ||
</EuiToolTip> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiToolTip position="top" content="Works on anything"> | ||
<EuiButton onClick={() => alert('Buttons are still clickable within tooltips.')}>Hover over me</EuiButton> | ||
</EuiToolTip> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { | ||
GuideSectionTypes, | ||
} from '../../components'; | ||
|
||
import { | ||
EuiCode, | ||
EuiToolTip, | ||
} from '../../../../src/components'; | ||
|
||
import ToolTip from './tool_tip'; | ||
const toolTipSource = require('!!raw-loader!./tool_tip'); | ||
const toolTipHtml = renderToHtml(ToolTip); | ||
|
||
export const ToolTipExample = { | ||
title: 'ToolTip', | ||
sections: [{ | ||
title: 'ToolTip', | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: toolTipSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: toolTipHtml, | ||
}], | ||
text: ( | ||
<p> | ||
Wrap <EuiCode>EuiToolTip</EuiCode> around any item that you need a tooltip for. | ||
The <EuiCode>position</EuiCode> prop will take a suggested position, but will | ||
change it if the tool tip gets too close to the edge of the screen. You can use | ||
the <EuiCode>clickOnly</EuiCode> prop to tell the too tip to only appear on click | ||
wrather than on hover. | ||
</p> | ||
), | ||
props: { EuiToolTip }, | ||
demo: <ToolTip />, | ||
}], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.