Last active
January 29, 2017 22:31
-
-
Save tbranyen/bb266287050ea3efef691816a32a653e to your computer and use it in GitHub Desktop.
Web Component Panel (takes in a route and the current activeRoute)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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