Skip to content

Update styles documentation #126

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

Merged
merged 14 commits into from
Feb 24, 2021
Merged

Update styles documentation #126

merged 14 commits into from
Feb 24, 2021

Conversation

sorvell
Copy link
Member

@sorvell sorvell commented Jan 26, 2021

Fixes #59 and #60. Refines text and examples for consistency and presentation.

@sorvell sorvell requested a review from arthurevans January 26, 2021 02:27
@nicolejadeyee nicolejadeyee added this to the Website complete milestone Feb 10, 2021
@@ -0,0 +1,13 @@
import { LitElement, html, css, customElement } from 'lit-element';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to lit and lit/decorators throughout

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


We recommend using CSS properties to create [customizable styles](#customizable). However, you can also include `<style>` elements in a LitElement template. These are updated per instance.
We recommend placing your styles in a static `styles` property for optimal performance; however, the element's static `styles` are evaluated **once per class**. Sometimes, you might need to customize styles **per instance**. For this, we recommend using CSS properties to create [themable elements](#theming). Alternatively, you can also include `<style>` elements in a LitElement template. These are updated per instance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We say "We recommend placing your styles in a static styles" 3x in the doc... I guess the redundancy is intentional given the perf impact?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaked language.

{% include projects/style/perinstanceexpressions/my-element.js %}
```
* Separate styles that require per-instance evaluation from those that don't.
* Evaluate per-instance CSS properties by creating an expression that captures that property inside a complete `<style>` block. Include it in your template.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement is hard to follow, not sure what "Evaluate per-instance CSS properties" means.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

import { customElement } from 'lit/decorators/custom-element';
import { property } from 'lit/decorators/property';
import { classMap } from 'lit/directives/class-map';
import { styleMap } from 'lit/directives/style-map';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine to just do import {customElement, property} from 'lit/decorators'; (at least that's what I've been doing in examples...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@arthurevans arthurevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few suggestions.

I think we should cut back on the interactive examples here and move a number of these into playground examples instead. But I think we can merge and iterate on that.


</div>

### Inheriting styles
### Inheriting styles from a superclass

Using an array of tagged template literals, a component can inherit the styles from a LitElement superclass, and add its own styles:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrase LitElement superclass seems kind of awkward. Can we just say superclass here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Steven Orvell and others added 6 commits February 22, 2021 18:28
@sorvell sorvell merged commit ebb19e3 into master Feb 24, 2021
@justinfagnani justinfagnani deleted the styles branch April 1, 2021 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Components--Styles-- Add Interactive Examples
4 participants