Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoped css #34

Closed
nevf opened this issue Jan 21, 2018 · 5 comments
Closed

Scoped css #34

nevf opened this issue Jan 21, 2018 · 5 comments

Comments

@nevf
Copy link

nevf commented Jan 21, 2018

I am currently using Riot.js in my Web App Clibu and like the look off slim.js, especially as it doesn't require a compile step and child component access seems simpler.

Riot.js enables css to be specified along with the component markup, scoping it to the component.

I couldn't see any mention of css in your doc's - is this possible?

@eavichay
Copy link
Member

eavichay commented Jan 22, 2018

Using SHADOW DOM plus adding your style node into your markup is the way to go.

import { useShadow } from 'slim-js/Decorators';

@tag...
@template... (including style node)
@useShadow(true)
class MyComponent extends Slim {
...
}

@David-Mulder
Copy link

Except that this won't work in IE11 which is still commonly supported :'( ShadyCSS support would be nice.

@eavichay
Copy link
Member

Basically, if you use ShadyCSS you can always trigger the applyShadyCss on your element in the 'onRender' function. I think that a shady-css "polyfill" can be added (externally) as an optional file in slim.js package, as the actual file size is critical. Simply override the base class' connectedCallback and add the shadyCss apply trigger.

WDYT?

@David-Mulder
Copy link

Will have to take a look at the applyShadyCss function, didn't realize that was possible as well.

@eavichay
Copy link
Member

eavichay commented Apr 1, 2018

I will add automatically invocation of shadyCSS on the connectedCallback, but polyfills must be loaded beforehand for performance...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants