preact-material-components
Version:
preact wrapper for "Material Components for the web"
32 lines • 1.16 kB
JavaScript
import { h } from 'preact';
import MaterialComponent from '../Base/MaterialComponent';
import Icon from '../Icon';
import generateThemeClass from '../themeUtils/generateThemeClass';
export class ButtonIcon extends Icon {
constructor() {
super(...arguments);
this.componentName = 'button__icon';
}
}
export class Button extends MaterialComponent {
constructor() {
super(...arguments);
this.componentName = 'button';
this.mdcProps = ['dense', 'raised', 'unelevated', 'outlined'];
this.themeProps = ['primary', 'secondary'];
}
materialDom(props) {
const ButtonElement = props.href ? 'a' : 'button';
let className = '';
this.themeProps.forEach(themeProp => {
if (themeProp in props && props[themeProp] !== false) {
className += generateThemeClass(themeProp) + ' ';
}
});
return (h(ButtonElement, Object.assign({ ref: this.setControlRef }, props, { className: className }), this.props.children));
}
}
export default class default_1 extends Button {
}
default_1.Icon = ButtonIcon;
//# sourceMappingURL=index.js.map