Skip to content

Commit

Permalink
boolean widget & some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
daddykotex committed May 3, 2017
1 parent b2b2a78 commit 7760699
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ Widgets define the data type and interface for entry fields. Netlify CMS comes w
Widget | UI | Data Type
--- | --- | ---
`string` | text input | string
`boolean` | select input | dropdown filled true and false
`text` | text area input | plain text, multiline input
`number` | text input with `+` and `-` buttons | number
`markdown` | rich text editor with raw option | markdown-formatted string
`datetime` | date picker widget | ISO date string
`image` | file picker widget with drag-and-drop | file path saved as string, image uploaded to media folder
`hidden` | No UI | Hidden element, typically only useful with a `default` attribute
`list` | text input | strings separated by commas
`file` | file input | input file upload
`select` | select input | dropdown filled with `options` from the config
`object` | custom | `fields` as a list defined in the config

We’re always adding new widgets, and you can also [create your own](/docs/extending).
2 changes: 2 additions & 0 deletions src/components/Widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ObjectControl from './Widgets/ObjectControl';
import ObjectPreview from './Widgets/ObjectPreview';
import RelationControl from './Widgets/RelationControl';
import RelationPreview from './Widgets/RelationPreview';
import BooleanControl from './Widgets/BooleanControl';


registry.registerWidget('string', StringControl, StringPreview);
Expand All @@ -39,6 +40,7 @@ registry.registerWidget('datetime', DateTimeControl, DateTimePreview);
registry.registerWidget('select', SelectControl, SelectPreview);
registry.registerWidget('object', ObjectControl, ObjectPreview);
registry.registerWidget('relation', RelationControl, RelationPreview);
registry.registerWidget('boolean', BooleanControl);
registry.registerWidget('unknown', UnknownControl, UnknownPreview);

export function resolveWidget(name) { // eslint-disable-line
Expand Down
17 changes: 17 additions & 0 deletions src/components/Widgets/BooleanControl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { PropTypes } from 'react';
import Switch from 'react-toolbox/lib/switch';

const BooleanControl = ({ onChange, forID, value }) => (
<Switch
checked={value}
onChange={onChange}
/>
);

BooleanControl.propTypes = {
onChange: PropTypes.func.isRequired,
forID: PropTypes.string.isRequired,
value: PropTypes.node,
};

export default BooleanControl;

0 comments on commit 7760699

Please sign in to comment.