Skip to content

Commit

Permalink
docs(Ref): add a basic example (#2226)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored and levithomason committed Oct 29, 2017
1 parent 7bb5156 commit f555a97
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 6 deletions.
42 changes: 42 additions & 0 deletions docs/app/Examples/addons/Ref/Types/RefExampleRef.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { Component } from 'react'
import { Grid, Table, Ref, Segment } from 'semantic-ui-react'

export default class RefExampleRef extends Component {
state = {}

handleRef = node => this.setState({ node })

render() {
const { node } = this.state

return (
<Grid columns={2}>
<Grid.Column>
<Ref innerRef={this.handleRef}>
<Segment>An example node</Segment>
</Ref>
</Grid.Column>
<Grid.Column>
{node && (
<Table>
<Table.Body>
<Table.Row>
<Table.Cell>nodeName</Table.Cell>
<Table.Cell>{node.nodeName}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>nodeType</Table.Cell>
<Table.Cell>{node.nodeType}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>textContent</Table.Cell>
<Table.Cell>{node.textContent}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
)}
</Grid.Column>
</Grid>
)
}
}
21 changes: 21 additions & 0 deletions docs/app/Examples/addons/Ref/Types/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'

const RefTypesExamples = () => (
<ExampleSection title='Types'>
<ComponentExample
title='Ref'
description={(
<span>
A component exposes the <code>innerRef</code> prop that always returns the DOM node of both functional and
class component children.
</span>
)}
examplePath='addons/Ref/Types/RefExampleRef'
/>
</ExampleSection>
)

export default RefTypesExamples
10 changes: 10 additions & 0 deletions docs/app/Examples/addons/Ref/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 RefExamples = () => (
<div>
<Types />
</div>
)

export default RefExamples
8 changes: 2 additions & 6 deletions docs/app/Examples/modules/Popup/Types/PopupExampleTitled.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ const users = [
avatar: '/assets/images/avatar/small/matt.jpg',
},
]
/* TODO: Remove <div> wrapper after all our components will be classes */

const PopupExampleTitled = () => (
<div>
{users.map(user => (
<Popup
key={user.name}
trigger={(
<div>
<Image src={user.avatar} avatar />
</div>
)}
trigger={<Image src={user.avatar} avatar />}
header={user.name}
content={user.bio}
/>
Expand Down

0 comments on commit f555a97

Please sign in to comment.