-
Notifications
You must be signed in to change notification settings - Fork 319
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
[docs] Review CSS Styles page for technical accuracy #353
Comments
https://lit-element.polymer-project.org/guide/styles#use-the-custom-element-tag-as-a-selector |
"Use JavaScript expressions in LitElement style blocks"
|
@keanulee What if
If |
Looking at your snippet, there's a limitation on what actually works with JS expressions in style which might make the above code not behave as expected.
Using constants for theme styling across elements is fine, but it's still recommended to make the expression a complete // 2 style tags with different text content, `partialStyle` parsed twice.
// element-one
html`<style>
:host {
color: blue;
}
${partialStyle}
</style>`;
// element-two
html`<style>
:host {
color: red;
}
${partialStyle}
</style>`; // `completeStyle` has same text content, only parsed once.
// element-one
html`<style>
:host {
color: blue;
}
</style>
${completeStyle}`;
// element-two
html`<style>
:host {
color: red;
}
</style>
${completeStyle}`; |
@keanulee Could you clarify in the |
const partialStyle = `
:host {
background: white;
border: 1px solid black;
}
...
`;
const completeStyle = html`
<style>
:host {
background: white;
border: 1px solid black;
}
...
</style>
`; Looking back, my example styles are missing selectors. Will edit. |
Regarding "...the |
|
Hot damn and hallelujah! You had me worried there. For the particular problem I'm working on--parsing a 3rd party file format and rendering the native form into a browser--there's no limit of the different styles similar elements can have. In Polymer 2, I could put the values directly into my
I learned early on this was not an option with LitElement. In this portion of my app, where styles are abitrary and out of my control, I've been using style attributes as I build instances on-the-fly. |
The documentation for styles does not differentiate between the Hmm... Maybe (my) words are not good to describe this. Here is, what I mean in a code snippet:
References: |
Possible improvement for the docs that I am wondering about: What is the best practice for handling use of global custom properties in lit-element components, such that they work in IE11? One approach is to simply define them at the document level, and rely on css property fallbacks inside the component for IE11. This is what I'd normally expect (aside form IE11), but it requires components to have the respective values as fallback. An alternative approach would be to define those styles in a css template and import them into the component so that they work IE11 without the component needed to rely on fallback values. |
Review the content at https://lit-element.polymer-project.org/guide/styles for technical accuracy only.
Markdown source: https://github.com/Polymer/lit-element/blob/master/docs/_guide/styles.md
:host
vs custom element tag<style></style>
The text was updated successfully, but these errors were encountered: