-
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 Example under Addons Section of Docs (#1860)
* initial commit * fixes linitng erros * chore(permissions): restore to 0644 * chore(permissions): restore to 0755 * style(Portal): cleanup example
- Loading branch information
1 parent
8e09c3a
commit 69553ca
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
docs/app/Examples/addons/Portal/Types/PortalExamplePortal.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,58 @@ | ||
import React, { Component } from 'react' | ||
import { Button, Grid, Header, Segment, Portal } from 'semantic-ui-react' | ||
|
||
export default class ExamplePortal extends Component { | ||
state = { | ||
log: [], | ||
open: false, | ||
} | ||
|
||
handleOpen = () => { | ||
this.setState({ open: true }) | ||
this.writeLog('Portal mounted') | ||
} | ||
|
||
handleClose = () => { | ||
this.setState({ open: false }) | ||
this.writeLog('Portal closed') | ||
} | ||
|
||
writeLog = message => this.setState({ log: [message, ...this.state.log] }) | ||
|
||
render() { | ||
const { log, open } = this.state | ||
|
||
return ( | ||
<Grid columns={2}> | ||
<Grid.Column> | ||
<Portal | ||
closeOnTriggerClick | ||
openOnTriggerClick | ||
trigger={( | ||
<Button | ||
content={open ? 'Close Portal' : 'Open Portal'} | ||
negative={open} | ||
positive={!open} | ||
/> | ||
)} | ||
onOpen={this.handleOpen} | ||
onClose={this.handleClose} | ||
> | ||
<Segment style={{ left: '40%', position: 'fixed', top: '50%', zIndex: 1000 }}> | ||
<Header>This is an example 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.Column> | ||
<Segment> | ||
<pre style={{ height: 200, overflowY: 'scroll' }}> | ||
{log.map((e, i) => <p key={i}>{e}</p>)} | ||
</pre> | ||
</Segment> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
|
||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
const PortalTypesExamples = () => ( | ||
<ExampleSection title='Types'> | ||
<ComponentExample | ||
title='Portal' | ||
description='A basic portal.' | ||
examplePath='addons/Portal/Types/PortalExamplePortal' | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default PortalTypesExamples |
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,10 @@ | ||
import React from 'react' | ||
import Types from './Types' | ||
|
||
const PortalExamples = () => ( | ||
<div> | ||
<Types /> | ||
</div> | ||
) | ||
|
||
export default PortalExamples |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.