import React from 'react'; import _ from 'lodash'; import classNames from 'classnames'; import PropTypes from 'prop-types'; import { Card, CardBody, Button, FormGroup, CustomInput } from 'reactstrap'; import './../../styles/components/theme-selector.scss'; import { Consumer } from './ThemeContext'; class ThemeSelector extends React.Component { static propTypes = { style: PropTypes.string.isRequired, color: PropTypes.string.isRequired, styleOptions: PropTypes.array, styleDisabled: PropTypes.bool, colorOptions: PropTypes.array, onChangeTheme: PropTypes.func, }; static defaultProps = { styleOptions: [ { name: 'Light', value: 'light' }, { name: 'Dark', value: 'dark' }, { name: 'Color', value: 'color' } ], colorOptions: [ { name: 'Primary', value: 'primary' }, { name: 'Success', value: 'success' }, { name: 'Info', value: 'info' }, { name: 'Danger', value: 'danger' }, { name: 'Warning', value: 'warning' }, { name: 'Indigo', value: 'indigo' }, { name: 'Purple', value: 'purple' }, { name: 'Pink', value: 'pink' }, { name: 'Yellow', value: 'yellow' } ] }; constructor(props) { super(props); this.state = { isActive: false, initialStyle: '', initialColor: '', }; } componentDidMount() { this.setState({ initialColor: this.props.color, initialStyle: this.props.style }); } render() { const rootClass = classNames('theme-config', { 'theme-config--active': this.state.isActive, }); return (
Configurator
Nav Color { _.map(this.props.colorOptions, (option, index) => ( { if (ev.target.checked) { this.props.onChangeTheme({ color: option.value }); } }} label={( { option.name } )} /> )) } Nav Style { _.map(this.props.styleOptions, (option, index) => ( { if (ev.target.checked) { this.props.onChangeTheme({ style: option.value }); } }} label={ option.name } /> )) }
); } } const ContextThemeSelector = (props) => { (themeState) => } export { ContextThemeSelector as ThemeSelector };