react-mwc
Version:
A thin React wrapper for Material Design (Web) Components
32 lines (28 loc) • 816 B
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import themeOptions from './theme-options';
import simpleComponentFactory from '../Base/simple-component-factory';
export var Theme = simpleComponentFactory('Theme', {
tag: 'span',
classNames: function classNames(props) {
var use = Array.isArray(props.use) ? props.use : [props.use];
return use.map(function (v) {
return 'mdc-theme--' + v;
});
},
propTypes: {
use: PropTypes.oneOfType([PropTypes.oneOf(themeOptions), PropTypes.arrayOf(PropTypes.oneOf(themeOptions))]).isRequired
},
defaultProps: {
use: undefined
},
propMeta: {
use: {
type: 'String | Array',
desc: 'Alias for the "theme" prop'
}
},
consumeProps: ['use']
});
export default Theme;