Skip to content

Instantly share code, notes, and snippets.

@tbranyen
Last active January 29, 2017 22:31
Show Gist options
  • Save tbranyen/bb266287050ea3efef691816a32a653e to your computer and use it in GitHub Desktop.
Save tbranyen/bb266287050ea3efef691816a32a653e to your computer and use it in GitHub Desktop.
Web Component Panel (takes in a route and the current activeRoute)
import { html } from 'diffhtml';
import { WebComponent, PropTypes } from 'diffhtml-components';
export default class DevtoolsPanels extends WebComponent {
static propTypes = {
route: PropTypes.string,
activeRoute: PropTypes.string,
}
render() {
return html`
<style>${this.styles()}</style>
<div class="panel">
<slot></slot>
</div>
`;
}
styles() {
const { route, activeRoute } = this.props;
const isActive = route === activeRoute;
return `
:host {
display: ${isActive ? 'flex' : 'none'};
flex: auto;
position: relative;
background-color: #FFFFFF;
overflow-y: auto;
}
.panel {
box-sizing: border-box;
display: flex;
flex: 1;
flex-direction: column;
}
`;
}
}
customElements.define('devtools-panels', DevtoolsPanels);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment