Skip to content

Consider to add Token Aliases concept #9

@rozd

Description

@rozd

Basic

Token Aliases could bring more meaning semantic acting as semantic tokens:

{
  "styles": {
    "colors": ["blueMirage", "beige"],
    "aliases": {
      "onSurface": "blueMirage",
      "surface": "beige"
    }
  }
}

Generated aliases would be a computed properties on new ShapeStyle+ThemeAliases extension and the that delegate to the underlying tokens:

extension ShapeStyle {
    public static var surface: ThemeShapeStyle<Color> { beige }
    public static var onSurface: ThemeShapeStyle<Color> { blueMirage }
}

Composition

It could be valuable to have style composition, like this:

{
  "styles": {
    "colors": ["surface"],
    "shadows": ["soft", "strong"],
    "aliases": {
      "card": [
        "surface", "soft"
      ]
    }
  }
}

Generated ShapeStyle extension would look like:

extension ShapeStyle {
    public static var surface: some ShapeStyle { .surface.soft }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions