-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(Portal): add controlled example (#2156)
- Loading branch information
1 parent
9c97ed9
commit b6fb22d
Showing
3 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
docs/app/Examples/addons/Portal/Types/PortalExampleControlled.js
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,42 @@ | ||
import React, { Component } from 'react' | ||
import { Button, Grid, Header, Segment, Portal } from 'semantic-ui-react' | ||
|
||
export default class PortalExampleControlled extends Component { | ||
state = { | ||
open: false, | ||
} | ||
|
||
handleClick = () => this.setState({ open: !this.state.open }) | ||
|
||
handleClose = () => this.setState({ open: false }) | ||
|
||
render() { | ||
const { open } = this.state | ||
|
||
return ( | ||
<Grid columns={2}> | ||
<Grid.Column> | ||
<Button | ||
content={open ? 'Close Portal' : 'Open Portal'} | ||
negative={open} | ||
positive={!open} | ||
onClick={this.handleClick} | ||
/> | ||
|
||
<Portal | ||
closeOnTriggerClick | ||
openOnTriggerClick | ||
onClose={this.handleClose} | ||
open={open} | ||
> | ||
<Segment style={{ left: '40%', position: 'fixed', top: '50%', zIndex: 1000 }}> | ||
<Header>This is a controlled portal</Header> | ||
<p>Portals have tons of great callback functions to hook into.</p> | ||
<p>To close, simply click the close button or click away</p> | ||
</Segment> | ||
</Portal> | ||
</Grid.Column> | ||
</Grid> | ||
) | ||
} | ||
} |
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