Skip to content

Support CSS custom property retrieval when evaluated at runtime #33

@alexlemaire

Description

@alexlemaire

Is your feature request related to a problem? Please describe.
Right now, if we refactor a styles getter from an element to go from

static get styles () {
    return css`
      :host {
        display: inline-block;
        --icon-size: 48px;
        --background-color: white;
        --outline-color: #333;
        --head-color: royalblue;
        --date-color: #333;
        --month-color: white;
        --day-color: #333;
      }
  `
}

to

static get styles () {
    return css`
      ${getHostStyle()}
  `
}

with getHostStyle being a function which returns a css template string containing the previous style for host, we end up being unable to retrieve the custom CSS properties from the styles getter.

This is due to the fact that in the current implementation, the CSS retrieval logic reads our styles getter at build and not at runtime. Therefore it doesn't see the resolution of any functions we may store styles in.

Describe the solution you'd like
We should figure out how to resolve the style as it would at runtime instead of statically checking the build files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions