Supernova-Studio / exporter-ios

Supernova iOS Swift UI exporter that allows conversion of design system data and elements into valid, production-ready Swift UI Code
MIT License
9 stars 12 forks source link

Use view modifier instead of extension #8

Closed coolbaluk closed 3 months ago

coolbaluk commented 1 year ago

👋

There are BREAKING CHANGES in this PR, they are all resolved by doing a find and replace but breaking nonetheless, which is why I've pushed the version to be 2.0.0. I believe they offer greater flexibility and would allow for the generation to work in a wider set of circumstances. Please read the README.md first for the new usage of the tokens.

Context:

These changes allow the use of multiple design systems or brands alongside each other in the same application by removing namespace clashes due to the use of extensions.

Use case:

Having dark mode tokens as a separate brand in supernova.

Proposed changes:

  1. color, gradient and measure tokens do not use extensions anymore and are exposed via the struct directly, mirroring the existing measures implementation Before Color.Token.tokenName After ColorToken.tokenName

  2. borders, shadows, radii and text styles do not use extensions anymore and are exposed via view modifiers Before Text("Styled text").textStyleUi11Regular() After Text("Styled text").modifier(TextStyleUi11Regular())

  3. took the opportunity to do a refresh on the docs & the file names : )

Note for reviewers:

The diffs look larger than they are due to the indentation changes, apart from the above changes the rest of the logic is untouched.

Update (12.09)

Introduce a colorThemeable.swift file to allow for a theme swicher to be used like such:

var colorToken: ColorTokenThemeable.Type {
        switch currentTheme {
        case .light:
            return DesignSystem.ColorToken.self
        case .dark:
            return DesignSystemDark.ColorToken.self
        }
    }