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

Fix input action examples #305

Merged
merged 3 commits into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Button, Checkbox, Dropdown, Form, Input, Message } from 'stardust'
import { Button, Checkbox, Select, Form, Input, Message } from 'stardust'

const fields = {
name: 'empty',
Expand Down Expand Up @@ -32,7 +32,7 @@ const FormSpecifyingValidationRulesExample = (props) => (
<Input placeholder='First Name' name='name' type='text' />
</Form.Field>
<Form.Field label='Gender'>
<Dropdown selection name='gender' options={genderOptions} />
<Select name='gender' options={genderOptions} />
</Form.Field>
</Form.Fields>
<Form.Fields evenlyDivided>
Expand All @@ -44,7 +44,7 @@ const FormSpecifyingValidationRulesExample = (props) => (
</Form.Field>
</Form.Fields>
<Form.Field label='Skills'>
<Dropdown selection multiple name='skills' options={skillsOptions} />
<Select multiple name='skills' options={skillsOptions} />
</Form.Field>
<Form.Field className='inline'>
<Checkbox name='terms' className='hidden' label='I agree to the terms and conditions' />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { Button, Dropdown, Input } from 'stardust'
import { Button, Select, Input } from 'stardust'

export default class InputActionExample extends Component {
render() {
Expand All @@ -10,7 +10,7 @@ export default class InputActionExample extends Component {
]
return (
<Input className='left icon action' icon='search' placeholder='Search...'>
<Dropdown compact selection options={options} defaultValue='articles' />
<Select compact options={options} defaultValue='articles' />
Copy link
Member Author

Choose a reason for hiding this comment

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

Use select components where possible.

<Button type='submit'>Search</Button>
</Input>
)
Expand Down
9 changes: 3 additions & 6 deletions src/elements/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,10 @@ export default class Input extends Component {
const actionChildren = []

Children.forEach(children, child => {
const isButton = child.type.name === 'Button'
const isDropdown = child.type.name === 'Dropdown'
// TODO: use child.type.name === 'Label' once Label component is merged.
const isLabel = _.isString(child.props.className) && !!child.props.className.match(/ui.*label$/)
const childIsAction = !isLabel && isButton || isDropdown
const isAction = _.includes(['Button', 'Dropdown', 'Select'], child.type._meta.name)
const isLabel = child.type._meta.name === 'Label'
Copy link
Member Author

@levithomason levithomason Jun 28, 2016

Choose a reason for hiding this comment

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

This component is being updated in #281, however, this change was made now so the docs aren't broken. The _meta is used to identify the component as the function names are mangled in production.


if (childIsAction) {
if (isAction) {
actionChildren.push(child)
} else if (isLabel) {
labelChildren.push(child)
Expand Down