mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Change component into a function
This commit is contained in:
parent
a1b8fd2a2b
commit
195c060a01
1 changed files with 21 additions and 27 deletions
|
|
@ -7,41 +7,35 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { FieldCheckbox } from '../../components';
|
||||
import css from './FieldGroupCheckbox.css';
|
||||
|
||||
class FieldGroupCheckbox extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { selected: [] };
|
||||
}
|
||||
const FieldGroupCheckbox = props => {
|
||||
const { rootClassName, className, id, legend, options, twoColumns } = props;
|
||||
|
||||
render() {
|
||||
const { rootClassName, className, id, legend, options, twoColumns } = this.props;
|
||||
const classes = classNames(rootClassName || css.root, className);
|
||||
const listClasses = twoColumns ? classNames(css.list, css.twoColumns) : css.list;
|
||||
const classes = classNames(rootClassName || css.root, className);
|
||||
const listClasses = twoColumns ? classNames(css.list, css.twoColumns) : css.list;
|
||||
|
||||
return (
|
||||
<fieldset className={classes}>
|
||||
{legend ? <legend>{legend}</legend> : null}
|
||||
<ul className={listClasses}>
|
||||
{options.map(option => {
|
||||
const fieldId = `${id}.${option.key}`;
|
||||
return (
|
||||
<li key={fieldId} className={css.item}>
|
||||
<FieldCheckbox id={fieldId} name={option.key} label={option.label} />
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<fieldset className={classes}>
|
||||
{legend ? <legend>{legend}</legend> : null}
|
||||
<ul className={listClasses}>
|
||||
{options.map(option => {
|
||||
const fieldId = `${id}.${option.key}`;
|
||||
return (
|
||||
<li key={fieldId} className={css.item}>
|
||||
<FieldCheckbox id={fieldId} name={option.key} label={option.label} />
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</fieldset>
|
||||
);
|
||||
};
|
||||
|
||||
FieldGroupCheckbox.defaultProps = {
|
||||
rootClassName: null,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue