Last active
January 4, 2017 22:19
-
-
Save zzarcon/9b5b5e1e15aee9682de930cf141a0713 to your computer and use it in GitHub Desktop.
Webcomponent custom styles example
This file contains hidden or 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
/** @jsx h */ | |
/* | |
Component A passing custom styles to sk-tags | |
*/ | |
import { Component, h } from 'skatejs'; | |
class A extends Component { | |
renderCallback() { | |
const tagStyles = ` | |
.tag { | |
background-color: red; | |
} | |
.wrapper { | |
border: 1px solid black; | |
} | |
`; | |
return <sk-tags styles={tagStyles} /> | |
} | |
} |
Unless you're doing dynamic styles in your style()
function based on props
, I would put the call to styles()
outside of renderCallback()
. It's probably a micro-optimisation here, but it would show best-practices (and that can be noted, if you want).
Do you think using skatepark-core
here detracts from the approachability of the examples? You could just pass a string for the sake of simplicity.
@treshugart updated, I removed the skatepark-core
just to not confuse people. Do you think that the gist makes sense now or is just too simple and doesn't add value to the article? Maybe we can just get rid of it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't need the wrapping
<div />
and you should self-close<sk-tags />
.