Skip to content

synthetic-to-native transform should handle SLDS utility classes #34

Open
@nolanlawson

Description

@nolanlawson

One of the biggest blockers of moving from synthetic shadow to native shadow is HTML templates containing SLDS utility classes, e.g.:

<template>
  <h1 class="slds-text-heading_large">SLDS Example</h1>
  <div class="slds-p-top_medium">
    <p>Hello!</p>
  </div>
</template>

As part of synthetic-to-native, we could inject the minimal SLDS style rules into the component.css file, e.g.:

.slds-text-heading_large {
  font-size: 1.75rem;
  line-height: 1.25;
}

.slds-p-top_medium {
  padding-top: 1rem;
}

This would not work for all cases (namely selectors that cross shadow boundaries), but it could be a good ~95% solution with minimal perf impact (since it wouldn't include all of SLDS, just the minimal rules needed).

Another downside is that this would not keep pace with SLDS updates, but maybe this is okay since this is intended as a one-time operation. Perhaps another option here would be to transform from classes to styling hooks (i.e. CSS custom properties, which pierce native shadow roots).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions