Skip to content
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

docs(Portal): add Example under Addons Section of Docs #1860

Merged
merged 6 commits into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.