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

feat(Form): add inverted prop #1218

Merged
merged 1 commit into from
Jan 24, 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
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>
<Form inverted>
<Form.Group widths='equal'>
<Form.Input label='First name' placeholder='First name' />
<Form.Input label='Last name' 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
7 changes: 6 additions & 1 deletion docs/app/Examples/collections/Form/Variations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ const FormFormVariationsExamples = () => (
<ExampleSection title='Form Variations'>
<ComponentExample
title='Size'
description='A form can vary in size'
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 @@ -195,6 +195,9 @@ export default class Form extends Component {
/** Automatically show any error Message children */
error: PropTypes.bool,

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

/** Automatically show a loading indicator */
loading: PropTypes.bool,

Expand Down Expand Up @@ -252,6 +255,7 @@ export default class Form extends Component {
children,
className,
error,
inverted,
loading,
reply,
size,
Expand All @@ -264,6 +268,7 @@ export default class Form extends Component {
'ui',
size,
useKeyOnly(error, 'error'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(loading, 'loading'),
useKeyOnly(reply, 'reply'),
useKeyOnly(success, 'success'),
Expand Down
3 changes: 3 additions & 0 deletions src/collections/Form/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ interface FormProps {
/** Automatically show any error Message children */
error?: boolean;

/** A form can have its color inverted for contrast */
inverted?: boolean;

/** Automatically show a loading indicator */
loading?: boolean;

Expand Down
3 changes: 2 additions & 1 deletion test/specs/collections/Form/Form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ describe('Form', () => {
])
common.rendersChildren(Form)

common.propKeyOnlyToClassName(Form, 'loading')
common.propKeyOnlyToClassName(Form, 'error')
common.propKeyOnlyToClassName(Form, 'inverted')
common.propKeyOnlyToClassName(Form, 'loading')
common.propKeyOnlyToClassName(Form, 'reply')
common.propKeyOnlyToClassName(Form, 'success')
common.propKeyOnlyToClassName(Form, 'warning')
Expand Down