lit / lit-element

LEGACY REPO. This repository is for maintenance of the legacy LitElement library. The LitElement base class is now part of the Lit library, which is developed in the lit monorepo.
https://lit-element.polymer-project.org
BSD 3-Clause "New" or "Revised" License
4.49k stars 319 forks source link

Nested components, slot and text styling #1198

Closed YannDuv closed 3 years ago

YannDuv commented 3 years ago

Description

Click !

- Task
Maybe one of the following ideas:
  - modify `::slotted(*)` to style raw string
  - update css selectors to use the name of the web-component (exemple: `simple-text { color: crimson }` )
  - create a new selector for that or accept something like `::slotted(:root)` (or `:default`, `:current`, …)

## Acceptance criteria

`"bloody"` should be **crimson** and not **pink** :

```html
<!DOCTYPE html>
<body>
  <simple-button>
    bloody
  </simple-button>
</body>
import {html, css, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';

@customElement('simple-text')
export class Child extends LitElement {
  static styles = css`p { color: pink ; font-weight: bold  }`;

  render() {
    return html`<p><slot></slot></p>`;
  }
}

@customElement('simple-button')
export class Parent extends LitElement {
  static styles = css`button { color: blue } ::slotted(*) {color: crimson}`;

  render() {
    return html`<button>Hello <simple-text><slot></slot></simple-text> button!</button>`;
  }
}
YannDuv commented 3 years ago

I think I made a mistake posting it on lit-element. I recreated a ticket on lit here