import { h, Component } from '/js/web_modules/preact.js'; import htm from '/js/web_modules/htm.js'; const html = htm.bind(h); export default class TabBar extends Component { constructor(props) { super(props); this.state = { activeIndex: 0, }; this.handleTabClick = this.handleTabClick.bind(this); } handleTabClick(index) { this.setState({ activeIndex: index }); } render() { const { tabs, ariaLabel } = this.props; if (!tabs.length) { return null; } if (tabs.length === 1) { return html` ${tabs[0].content} `; } else { return html`
${ tabs.map((tabItem, index) => { const handleClick = () => this.handleTabClick(index); return html` `; }) }
${ tabs.map((tabItem, index) => { return html` `; }) }
`; } } }