-
Notifications
You must be signed in to change notification settings - Fork 206
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0e0ca6f
Update/embed styles examples and some editing for consistency
7ccb8d1
Further refinements to examples and text
4fbe0a3
Merge branch 'master' into styles
aa3cf06
Move styling examples
1b7b544
Use playground examples rather than ful ide.
aef7d33
Update examples to use TypeScript and remove unused examples
35b3a8f
Merge branch 'master' into styles
d93fa4c
Address review feedback.
99ba611
Reduced # of samples from 13 to 6.
adb1439
Update packages/lit-dev-content/site/guide/components/styles.md
7461f98
Update packages/lit-dev-content/site/guide/components/styles.md
01ad3d4
Update packages/lit-dev-content/site/guide/components/styles.md
bd1ed00
Update packages/lit-dev-content/site/guide/components/styles.md
e47fb13
Address review feedback.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
packages/lit-dev-content/site/_includes/projects/docs/components/style/basic/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script type="module" src="./my-element.js"></script> | ||
|
||
<my-element></my-element> |
14 changes: 14 additions & 0 deletions
14
packages/lit-dev-content/site/_includes/projects/docs/components/style/basic/my-element.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement } from 'lit/decorators'; | ||
|
||
@customElement('my-element') | ||
export class MyElement extends LitElement { | ||
static styles = css` | ||
p { | ||
color: green; | ||
} | ||
`; | ||
protected render() { | ||
return html`<p>I am green!</p>`; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/lit-dev-content/site/_includes/projects/docs/components/style/basic/project.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"files": { | ||
"my-element.ts": {}, | ||
"index.html": {} | ||
|
||
}, | ||
"importMap": { | ||
"imports": { | ||
"lit": "https://cdn.skypack.dev/lit", | ||
"lit/": "https://cdn.skypack.dev/lit/" | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/lit-dev-content/site/_includes/projects/docs/components/style/host/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<script type="module" src="./my-element.js"></script> | ||
|
||
<my-element></my-element> | ||
<my-element class="blue"></my-element> |
20 changes: 20 additions & 0 deletions
20
packages/lit-dev-content/site/_includes/projects/docs/components/style/host/my-element.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement } from 'lit/decorators/custom-element'; | ||
|
||
@customElement('my-element') | ||
export class MyElement extends LitElement { | ||
static styles = css` | ||
:host { | ||
display: block; | ||
background-color: lightgray; | ||
padding: 8px; | ||
} | ||
:host(.blue) { | ||
background-color: aliceblue; | ||
color: darkgreen; | ||
} | ||
`; | ||
protected render() { | ||
return html`Hello World`; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/lit-dev-content/site/_includes/projects/docs/components/style/host/project.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"files": { | ||
"my-element.ts": {}, | ||
"index.html": {} | ||
}, | ||
"importMap": { | ||
"imports": { | ||
"lit": "https://cdn.skypack.dev/lit", | ||
"lit/": "https://cdn.skypack.dev/lit/" | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/lit-dev-content/site/_includes/projects/docs/components/style/maps/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script src="./my-element.js" type="module"></script> | ||
|
||
<my-element></my-element> |
23 changes: 23 additions & 0 deletions
23
packages/lit-dev-content/site/_includes/projects/docs/components/style/maps/my-element.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement, property } from 'lit/decorators'; | ||
import { classMap } from 'lit/directives/class-map'; | ||
import { styleMap } from 'lit/directives/style-map'; | ||
|
||
@customElement('my-element') | ||
export class MyElement extends LitElement { | ||
static styles = css` | ||
.someclass { border: 1px solid red; padding: 4px; } | ||
.anotherclass { background-color: navy; } | ||
`; | ||
@property() | ||
classes = { someclass: true, anotherclass: true }; | ||
@property() | ||
styles = { color: 'lightgreen', fontFamily: 'Roboto' }; | ||
protected render() { | ||
return html` | ||
<div class=${classMap(this.classes)} style=${styleMap(this.styles)}> | ||
Some content | ||
</div> | ||
`; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/lit-dev-content/site/_includes/projects/docs/components/style/maps/project.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"files": { | ||
"my-element.ts": {}, | ||
"index.html": {} | ||
}, | ||
"importMap": { | ||
"imports": { | ||
"lit": "https://cdn.skypack.dev/lit", | ||
"lit/": "https://cdn.skypack.dev/lit/" | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
.../lit-dev-content/site/_includes/projects/docs/components/style/slottedselector/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script type="module" src="./my-element.js"></script> | ||
|
||
<my-element> | ||
<p>Slotted paragraph</p> | ||
<span slot="hi">Slotted span inside a div</span> | ||
</my-element> |
17 changes: 17 additions & 0 deletions
17
...t-dev-content/site/_includes/projects/docs/components/style/slottedselector/my-element.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement } from 'lit/decorators'; | ||
|
||
@customElement('my-element') | ||
export class MyElement extends LitElement { | ||
static styles = css` | ||
::slotted(*) { font-family: Roboto; } | ||
::slotted(p) { color: blue; } | ||
div ::slotted(*) { color: red; } | ||
`; | ||
protected render() { | ||
return html` | ||
<slot></slot> | ||
<div><slot name="hi"></slot></div> | ||
`; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...it-dev-content/site/_includes/projects/docs/components/style/slottedselector/project.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"files": { | ||
"my-element.ts": {}, | ||
"index.html": {} | ||
}, | ||
"importMap": { | ||
"imports": { | ||
"lit": "https://cdn.skypack.dev/lit", | ||
"lit/": "https://cdn.skypack.dev/lit/" | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ages/lit-dev-content/site/_includes/projects/docs/components/style/superstyles/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script type="module" src="./my-element.js"></script> | ||
|
||
<my-element></my-element> |
15 changes: 15 additions & 0 deletions
15
...s/lit-dev-content/site/_includes/projects/docs/components/style/superstyles/my-element.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { css } from 'lit'; | ||
import { customElement } from 'lit/decorators'; | ||
import { SuperElement } from './super-element.js'; | ||
|
||
@customElement('my-element') | ||
export class MyElement extends SuperElement { | ||
static get styles() { | ||
return [ | ||
super.styles, | ||
css`div { | ||
color: red; | ||
}` | ||
]; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...es/lit-dev-content/site/_includes/projects/docs/components/style/superstyles/project.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"files": { | ||
"my-element.ts": {}, | ||
"super-element.ts": {}, | ||
"index.html": {} | ||
}, | ||
"importMap": { | ||
"imports": { | ||
"lit": "https://cdn.skypack.dev/lit", | ||
"lit/": "https://cdn.skypack.dev/lit/" | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...it-dev-content/site/_includes/projects/docs/components/style/superstyles/super-element.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement } from 'lit/decorators'; | ||
|
||
@customElement('super-element') | ||
export class SuperElement extends LitElement { | ||
static styles = css` | ||
div { | ||
border: 1px solid gray; | ||
padding: 8px; | ||
} | ||
`; | ||
protected render() { | ||
return html` | ||
<div>Content</div> | ||
`; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/lit-dev-content/site/_includes/projects/docs/components/style/theming/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script type="module" src="./my-element.js"></script> | ||
|
||
<style> | ||
html { | ||
--theme-primary: green; | ||
--theme-secondary: aliceblue; | ||
--theme-warning: red; | ||
--theme-font-family: Roboto; | ||
} | ||
my-element { | ||
--my-element-text-color: var(--theme-primary); | ||
--my-element-background-color: var(--theme-secondary); | ||
--my-element-font-family: var(--theme-font-family); | ||
} | ||
.warning { | ||
--my-element-text-color: var(--theme-warning); | ||
} | ||
</style> | ||
<my-element></my-element> | ||
<my-element class="warning"></my-element> |
19 changes: 19 additions & 0 deletions
19
packages/lit-dev-content/site/_includes/projects/docs/components/style/theming/my-element.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { LitElement, html, css } from 'lit'; | ||
import { customElement } from 'lit/decorators'; | ||
|
||
@customElement('my-element') | ||
export class MyElement extends LitElement { | ||
static styles = css` | ||
:host { | ||
color: var(--my-element-text-color, black); | ||
background: var(--my-element-background-color, white); | ||
font-family: var(--my-element-font-family, Roboto); | ||
display: block; | ||
padding: 8px; | ||
margin: 8px; | ||
} | ||
`; | ||
protected render() { | ||
return html`<div>Hello World</div>`; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/lit-dev-content/site/_includes/projects/docs/components/style/theming/project.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"files": { | ||
"my-element.ts": {}, | ||
"index.html": {} | ||
}, | ||
"importMap": { | ||
"imports": { | ||
"lit": "https://cdn.skypack.dev/lit", | ||
"lit/": "https://cdn.skypack.dev/lit/" | ||
} | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
packages/lit-dev-content/site/_includes/projects/style/classmap/index.html
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
packages/lit-dev-content/site/_includes/projects/style/classmap/my-element.js
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/lit-dev-content/site/_includes/projects/style/classmap/project.json
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
packages/lit-dev-content/site/_includes/projects/style/customproperties/index.html
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
packages/lit-dev-content/site/_includes/projects/style/customproperties/my-element.js
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/lit-dev-content/site/_includes/projects/style/customproperties/project.json
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/lit-dev-content/site/_includes/projects/style/host/index.html
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
packages/lit-dev-content/site/_includes/projects/style/host/my-element.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.