Skip to content

Commit

Permalink
docs(Portal): add Example under Addons Section of Docs (#1860)
Browse files Browse the repository at this point in the history
* initial commit

* fixes linitng erros

* chore(permissions): restore to 0644

* chore(permissions): restore to 0755

* style(Portal): cleanup example
  • Loading branch information
alexUXUI authored and levithomason committed Aug 9, 2017
1 parent 8e09c3a commit 69553ca
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/app/Examples/addons/Portal/Types/PortalExamplePortal.js
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>
)
}
}
16 changes: 16 additions & 0 deletions docs/app/Examples/addons/Portal/Types/index.js
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
10 changes: 10 additions & 0 deletions docs/app/Examples/addons/Portal/index.js
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
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 69553ca

Please sign in to comment.