Skip to content

Commit

Permalink
feat(Form): add prop for inverted classname
Browse files Browse the repository at this point in the history
  • Loading branch information
vageeshb committed Jan 24, 2017
1 parent 5e190fe commit d5d9187
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import { Button, Form, Segment } from 'semantic-ui-react'


const FormExampleInverted = () => (
<Segment inverted={true}>
<Form inverted={true}>
<Form.Group widths='equal'>
<Form.Field label='First name' control='input' placeholder='First name' />
<Form.Field label='Last name' control='input' placeholder='Last name' />
</Form.Group>
<Form.Checkbox label='I agree to the Terms and Conditions' />
<Button type='submit'>Submit</Button>
</Form>
</Segment>
)
export default FormExampleInverted
5 changes: 5 additions & 0 deletions docs/app/Examples/collections/Form/Variations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const FormFormVariationsExamples = () => (
description='A form can vary in size'
examplePath='collections/Form/Variations/FormExampleSize'
/>
<ComponentExample
title='Inverted'
description='A form on a dark background may have to invert its color scheme'
examplePath='collections/Form/Variations/FormExampleInverted'
/>
</ExampleSection>
)

Expand Down
5 changes: 5 additions & 0 deletions src/collections/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ export default class Form extends Component {
/** A form can vary in size */
size: PropTypes.oneOf(_meta.props.size),

/** A form can have its color inverted for contrast */
inverted: PropTypes.bool,

/** Automatically show any success Message children */
success: PropTypes.bool,

Expand Down Expand Up @@ -258,11 +261,13 @@ export default class Form extends Component {
success,
warning,
widths,
inverted,
} = this.props

const classes = cx(
'ui',
size,
useKeyOnly(inverted, 'inverted'),
useKeyOnly(error, 'error'),
useKeyOnly(loading, 'loading'),
useKeyOnly(reply, 'reply'),
Expand Down
1 change: 1 addition & 0 deletions test/specs/collections/Form/Form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Form', () => {
common.propKeyOnlyToClassName(Form, 'reply')
common.propKeyOnlyToClassName(Form, 'success')
common.propKeyOnlyToClassName(Form, 'warning')
common.propKeyOnlyToClassName(Form, 'inverted')

common.propValueOnlyToClassName(Form, 'size', _.without(SUI.SIZES, 'medium'))

Expand Down

0 comments on commit d5d9187

Please sign in to comment.