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(Ref): add a basic example #2226

Merged
merged 2 commits into from
Oct 29, 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
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>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #2219 was merged stateless component can be used as trigger without warnings 👍

<Image src={user.avatar} avatar />
</div>
)}
trigger={<Image src={user.avatar} avatar />}
header={user.name}
content={user.bio}
/>
Expand Down