open-wc / custom-elements-manifest

Custom Elements Manifest is a file format that describes custom elements in your project.
https://custom-elements-manifest.open-wc.org/
226 stars 37 forks source link

Support for ElementInternals state #246

Closed KonnorRogers closed 1 month ago

KonnorRogers commented 2 months ago

Would it be possible to add a tag for @state to document CSS Custom States?

thepassle commented 2 months ago

Can you elaborate/show some examples/documentation?

KonnorRogers commented 2 months ago

@thepassle

/** 
 * @state open - When the element is open
 */
class MyEl extends HTMLElement {
  constructor () {
    super()
    this.internals = this.attachInternals()
  }

  open () {
    this.internals.states.add("open")
  }
}

Example of CSS Custom states:

my-el { display: none; }

my-el:state(open) {
  display: block;
}

Also open to @customState since @state can be confused with the decorator from Lit

thepassle commented 2 months ago

I think we should go with @csscustomstate or @cssstate to align with @csspart and @cssproperty

KonnorRogers commented 2 months ago

Works for me.

@cssstate scared me because it seems really easy to typo.

Lookwe69 commented 2 months ago

Why not @internalstate ?

thepassle commented 2 months ago

because its not consistent with @csspart and @cssproperty