Skip to content

Instantly share code, notes, and snippets.

@zzarcon
Last active January 4, 2017 22:19
Show Gist options
  • Save zzarcon/9b5b5e1e15aee9682de930cf141a0713 to your computer and use it in GitHub Desktop.
Save zzarcon/9b5b5e1e15aee9682de930cf141a0713 to your computer and use it in GitHub Desktop.
Webcomponent custom styles example
/** @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} />
}
}
@treshugart
Copy link

You don't need the wrapping <div /> and you should self-close <sk-tags />.

@treshugart
Copy link

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).

@treshugart
Copy link

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.

@zzarcon
Copy link
Author

zzarcon commented Jan 3, 2017

@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