Created
February 12, 2016 20:29
-
-
Save tbranyen/4336b59e11812fb679d3 to your computer and use it in GitHub Desktop.
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 { StyleSheet, css } from 'aphrodite'; | |
import { innerHTML } from 'diffhtml'; | |
const styles = StyleSheet.create({ | |
red: { | |
backgroundColor: 'red' | |
}, | |
blue: { | |
backgroundColor: 'blue' | |
}, | |
hover: { | |
':hover': { | |
backgroundColor: 'red' | |
} | |
}, | |
small: { | |
'@media (max-width: 600px)': { | |
backgroundColor: 'red', | |
} | |
} | |
}); | |
class App extends HTMLElement { | |
attachedCallback() { | |
this.render(); | |
} | |
render() { | |
innerHTML(this, ` | |
<div> | |
<span class="${css(styles.red)}"> | |
This is red. | |
</span> | |
<span class="${css(styles.hover)}"> | |
This turns red on hover. | |
</span> | |
<span class="${css(styles.small)}"> | |
This turns red when the browser is less than 600px width. | |
</span> | |
<span class="${css(styles.red, styles.blue)}"> | |
This is blue. | |
</span> | |
<span class="${css(styles.blue, styles.small)}"> | |
This is blue and turns red when the browser is less than | |
600px width. | |
</span> | |
</div> | |
`); | |
} | |
} | |
document.registerElement('my-app', App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment