diff --git a/docs/components/Layout/index.jsx b/docs/components/Layout/index.jsx
index 3bd7cf8bf..6d6767629 100644
--- a/docs/components/Layout/index.jsx
+++ b/docs/components/Layout/index.jsx
@@ -16,6 +16,7 @@ import AlertExample from '../../examples/AlertExample';
import CheckboxExample from '../../examples/CheckboxExample';
import CheckboxGroupExample from '../../examples/CheckboxGroupExample';
import RadioExample from '../../examples/RadioExample';
+import RadioGroupExample from '../../examples/RadioGroupExample';
import SelectExample from '../../examples/SelectExample';
import DatePickerExample from '../../examples/DatePickerExample';
import BorderedWellExample from '../../examples/BorderedWellExample';
@@ -178,6 +179,7 @@ class PageLayout extends React.Component {
+
diff --git a/docs/examples/CheckboxExample.jsx b/docs/examples/CheckboxExample.jsx
index 48294ab7e..c06ca1cd8 100644
--- a/docs/examples/CheckboxExample.jsx
+++ b/docs/examples/CheckboxExample.jsx
@@ -36,6 +36,15 @@ const exampleProps = {
{
label: '',
propTypes: [
+ {
+ propType: 'id',
+ type: 'string',
+ },
+ {
+ propType: 'className',
+ type: 'string',
+ note: 'This class will be applied to the input element',
+ },
{
propType: 'name',
type: 'string',
@@ -47,15 +56,16 @@ const exampleProps = {
{
propType: 'value',
type: 'string',
- note: 'Required.',
},
{
propType: 'checked',
type: 'bool',
+ defaultValue: false,
},
{
propType: 'disabled',
type: 'bool',
+ defaultValue: false,
},
{
propType: 'dts',
@@ -63,7 +73,7 @@ const exampleProps = {
},
{
propType: 'onChange',
- type: 'function',
+ type: 'func',
},
],
},
diff --git a/docs/examples/CheckboxGroupExample.jsx b/docs/examples/CheckboxGroupExample.jsx
index 5478af419..e6a215047 100644
--- a/docs/examples/CheckboxGroupExample.jsx
+++ b/docs/examples/CheckboxGroupExample.jsx
@@ -35,9 +35,22 @@ const exampleProps = {
{
label: '',
propTypes: [
+ {
+ propType: 'id',
+ type: 'string',
+ },
+ {
+ propType: 'className',
+ type: 'string',
+ },
{
propType: 'name',
type: 'string',
+ note: (
+
+ Required. All Checkboxes within this group will have the same name
+
+ ),
},
{
propType: 'value',
@@ -46,11 +59,18 @@ const exampleProps = {
},
{
propType: 'children',
- type: ' elements',
+ type: 'arrayOf elements',
+ note: Required.,
},
{
propType: 'onChange',
- type: 'Function',
+ type: 'func',
+ note: 'Triggers when selection changes.',
+ },
+ {
+ propType: 'dts',
+ type: 'string',
+ note: 'render `data-test-selector` onto the component. It can be useful for testing.',
},
],
},
diff --git a/docs/examples/RadioExample.jsx b/docs/examples/RadioExample.jsx
index 4e4f0672f..da9e6dbb1 100644
--- a/docs/examples/RadioExample.jsx
+++ b/docs/examples/RadioExample.jsx
@@ -1,48 +1,74 @@
import React from 'react';
import Example from '../components/Example';
-import { Radio, RadioGroup } from '../../src';
+import Radio from 'adslot-ui/Radio';
class RadioExample extends React.PureComponent {
+ onChange(event) {
+ _.noop();
+ }
+
render() {
return (
-
-
-
-
+
);
}
}
const exampleProps = {
componentName: 'Radio',
- designNotes: (
-
- Radio buttons used for making a single selection from multiple options. Only
- one selection can ever be made from the radio button group at a time.
-
- ),
- exampleCodeSnippet: `
-
-
-
- `,
+ notes: '',
+ exampleCodeSnippet: ``,
propTypeSectionArray: [
{
propTypes: [
+ {
+ propType: 'id',
+ type: 'string',
+ },
+ {
+ propType: 'className',
+ type: 'string',
+ note: 'This class will be applied to the input element',
+ },
+ {
+ propType: 'name',
+ type: 'string',
+ },
{
propType: 'label',
- type: 'node',
- note: 'Usually fine to rely on a string but can pass HTML e.g. for a url.',
+ type: 'string',
},
{
propType: 'value',
type: 'string',
},
+ {
+ propType: 'dts',
+ type: 'string',
+ note: 'render `data-test-selector` onto the component. It can be useful for testing.',
+ },
+ {
+ propType: 'disabled',
+ type: 'bool',
+ defaultValue: false,
+ },
+ {
+ propType: 'checked',
+ type: 'bool',
+ defaultValue: false,
+ },
{
propType: 'onChange',
type: 'func',
diff --git a/docs/examples/RadioGroupExample.jsx b/docs/examples/RadioGroupExample.jsx
new file mode 100644
index 000000000..8ca6982df
--- /dev/null
+++ b/docs/examples/RadioGroupExample.jsx
@@ -0,0 +1,89 @@
+import React from 'react';
+import Example from '../components/Example';
+import RadioGroup from 'adslot-ui/RadioGroup';
+import Radio from 'adslot-ui/Radio';
+
+class RadioGroupExample extends React.PureComponent {
+ onChangeGroup(event) {
+ _.noop();
+ }
+
+ onChangeIndividual(event) {
+ _.noop();
+ }
+
+ render() {
+ return (
+
+
+
+
+
+ );
+ }
+}
+
+const exampleProps = {
+ componentName: 'RadioGroup',
+ designNotes: (
+
+ Radio buttons used for making a single selection from multiple options. Only
+ one selection can ever be made from the radio button group at a time.
+
+ ),
+ notes: '',
+ exampleCodeSnippet: `
+
+
+
+`,
+ propTypeSectionArray: [
+ {
+ propTypes: [
+ {
+ propType: 'id',
+ type: 'string',
+ },
+ {
+ propType: 'className',
+ type: 'string',
+ },
+ {
+ propType: 'name',
+ type: 'string',
+ note: (
+
+ Required. All Radio buttons within this group will have the same name
+
+ ),
+ },
+ {
+ propType: 'value',
+ type: 'string',
+ note: 'value of the selected radio button, should be one of children values',
+ },
+ {
+ propType: 'children',
+ type: 'arrayOf elements',
+ note: Required.,
+ },
+ {
+ propType: 'onChange',
+ type: 'func',
+ note: 'Triggers when selection changes.',
+ },
+ {
+ propType: 'dts',
+ type: 'string',
+ note: 'render `data-test-selector` onto the component. It can be useful for testing.',
+ },
+ ],
+ },
+ ],
+};
+
+export default () => (
+
+
+
+);
diff --git a/src/components/adslot-ui/Checkbox/index.jsx b/src/components/adslot-ui/Checkbox/index.jsx
index 0c432b2c5..a56465fae 100644
--- a/src/components/adslot-ui/Checkbox/index.jsx
+++ b/src/components/adslot-ui/Checkbox/index.jsx
@@ -1,7 +1,6 @@
import React from 'react';
-import PropTypes from 'prop-types';
-import { expandDts } from 'lib/utils';
-
+import { expandDts } from '../../../lib/utils';
+import { checkboxPropTypes } from '../../prop-types/inputPropTypes';
import './styles.scss';
class Checkbox extends React.Component {
@@ -28,29 +27,25 @@ class Checkbox extends React.Component {
}
render() {
- const { name, value, label, dts } = this.props;
- const optional = {
- id: this.props.id ? this.props.id : null,
- className: this.props.className ? this.props.className : null,
+ const { name, value, label, dts, disabled, id, className } = this.props;
+ const checkboxInputProps = {
+ type: 'checkbox',
+ name,
+ checked: this.state.checked,
+ disabled,
+ onChange: this.onChangeDefault,
+ value,
+ id,
+ className,
+ 'data-name': this.props['data-name'],
};
- if (this.props['data-name']) {
- optional['data-name'] = this.props['data-name'];
- }
+
return (
-