UNPKG

preact-material-components

Version:
93 lines 3.32 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { MDCTopAppBar } from '@material/top-app-bar'; import { bind } from 'bind-decorator'; import { h } from 'preact'; import MaterialComponent from '../Base/MaterialComponent'; export class TopAppBarRow extends MaterialComponent { constructor() { super(...arguments); this.componentName = 'top-app-bar__row'; this.mdcProps = []; } materialDom(props) { return h("div", Object.assign({}, props), this.props.children); } } export class TopAppBarSection extends MaterialComponent { constructor() { super(...arguments); this.componentName = 'top-app-bar__section'; this.mdcProps = ['align-start', 'align-end']; } materialDom(props) { return h("section", Object.assign({}, props), props.children); } } export class TopAppBarIcon extends MaterialComponent { constructor() { super(...arguments); this.componentName = 'top-app-bar__icon'; this.mdcProps = []; } materialDom(props) { const className = props.navigation ? 'material-icons mdc-top-app-bar__navigation-icon' : 'material-icons'; return (h("a", Object.assign({ className: className }, props), props.children)); } } export class TopAppBarTitle extends MaterialComponent { constructor() { super(...arguments); this.componentName = 'top-app-bar__title'; this.mdcProps = []; } materialDom(props) { return h("span", Object.assign({}, props), props.children); } } export class TopAppBar extends MaterialComponent { constructor() { super(...arguments); this.componentName = 'top-app-bar'; this.mdcProps = ['short', 'short-collapsed', 'fixed', 'prominent']; } componentDidMount() { super.componentDidMount(); if (this.control) { const comp = new MDCTopAppBar(this.control); comp.listen('MDCTopAppBar:nav', this.onNav); this.MDComponent = comp; } } componentWillUnmount() { super.componentWillUnmount(); if (this.MDComponent) { this.MDComponent.unlisten('MDCTopAppBar:nav', this.onNav); this.MDComponent.destroy(); } } onNav(e) { if (this.props.onNav) { this.props.onNav(e); } } materialDom(props) { return (h("header", Object.assign({ ref: this.setControlRef }, props), props.children)); } } __decorate([ bind ], TopAppBar.prototype, "onNav", null); export default class default_1 extends TopAppBar { } default_1.Section = TopAppBarSection; default_1.Icon = TopAppBarIcon; default_1.Title = TopAppBarTitle; default_1.Row = TopAppBarRow; //# sourceMappingURL=index.js.map