Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactoring] Refactoring of theme with wrappers, update documentations #79

Closed
25 of 27 tasks
pylapp opened this issue Aug 26, 2024 · 3 comments · Fixed by #352
Closed
25 of 27 tasks

[Refactoring] Refactoring of theme with wrappers, update documentations #79

pylapp opened this issue Aug 26, 2024 · 3 comments · Fixed by #352
Assignees
Labels
📖 documentation Improvements or additions to documentation 🧩 enhancement Related to enhancements or feature requests 🧬 token Related to tokens (raws, semantics or components)

Comments

@pylapp
Copy link
Member

pylapp commented Aug 26, 2024

Context

Today, it is the duty of a theme to embed, override and provide any raw tokens, semantic tokens and future component tokens. It implies to have finaly a class with thousands of objects.

Indeed this is acceptable because the logic behing OUDS is based on themes which are in fact combinations of values for any tokens.

Today a theme is a Swift class which is not a singleton because we don't want to instanciate such massive objects if we don't use it. Using a singleton won't help to override classes so as to have subthemes.

Howeer we can agree that having thousands properties in one object does not bring a good developer experience (DX), and we may implement another solution with wrappers.

Proposal

We may in fact define as many wrappers as "family" of tokens, i.e. ColorsWrapper, BorderWrapper, TypographiesWrapper, DimensionsWrapper etc. Each wrapper must implement (in the same way as the actual implementation of a theme) a protocol to embed specific items of tokens which will be still overridable. Thus a theme won't implement such protocols anymore but will have inside it all wrappers.
If a theme must be subclasses, it should only create a subclass of a wrapper and add it to the theme.

If could result to something like:

// Basic use

open class MyTheme {

    let colors: ColorsWrapper
    let borders: BordersWrapper
    ...

    init(colors: ColorsWrapper, borders: BordersWrapper() {
        self.colors = colors
        sef.borders = borders
    }
}

open class ColorsWrapper: ColorsSemanticTokens {
    // Implement tokens
}

// Alternative use

final class CustomTheme: MyTheme {

    // Init super
    init() {
        super.init(colors: MyColorsWrapper(), borders: BordersWrapper())
    }
}

final class MyColorsWrapper: ColorsWrapper {
    // Override the semantic token we want
}

Then the old line may move to something else:

// Before
theme.buttonBackgroundColorEmphasisHigh
// After
theme.colors.buttonBackgroundEmphasisHigh // If we suppose we wrap it in a "ColorsWrappers" and not a component token

Way may focus to this topic later when we'll have components tokens and tokens to implement.
This solution is quite elgant and may improve DX buy we may face isues with memory and performances because we keep using plenty of Swift classes in the end.

Definition of Done

  • Migrate OUDSTheme+BorderSemanticTokens
  • Migrate OUDSTheme+OpacitySemanticTokens
  • Migrate OUDSTheme+ColorMultipleSemanticTokens (same wrapper as the one as simple colors)
  • Migrate OUDSTheme+ColorSemanticTokens (same wrapper as the one with multiple colors)
  • Migrate OUDSTheme+ElevationCompositeSemanticTokens (same wrapper as the one with multiple and simple elevations)
  • Migrate OUDSTheme+ElevationMultipleSemanticTokens (same wrapper as the one with composite and simple elevations)
  • Migrate OUDSTheme+ElevationSemanticTokens (same wrapper as the one with composite and multiple elevations)
  • Migrate OUDSTheme+FontCompositeSemanticTokens (same wrapper as the one with multiple and simple font tokens)
  • Migrate OUDSTheme+FontMultipleSemanticTokens (same wrapper as the one with composite and simple font tokens)
  • Migrate OUDSTheme+FontSemanticTokens (same wrapper as the one with multiple and composite font tokens)
  • Migrate OUDSTheme+GridSemanticTokens
  • Migrate OUDSTheme+GridSemanticTokensHelper
  • Migrate OUDSTheme+SizeMultipleSemanticTokens (same wrapper as the one with simple size tokens)
  • Migrate OUDSTheme+SizeSemanticTokens (same wrapper as the one with multiple size tokens)
  • Migrate OUDSTheme+SpaceMultipleSemanticTokens (same wrapper as the one with simple space tokens)
  • Migrate OUDSTheme+SpaceSemanticTokens (same wrapper as the one with multiple space tokens)
  • Check if @objc can be removed, and more documentation about that if not
  • Update OrangeTheme init to let users to use their own wrappers
  • Update InverseTheme init to let users to use their own wrappers
  • Update CHANGELOG
  • Update wiki (how to define theme and override tokens)
  • Update wiki (charts about architecture)
  • Update demo app (use of wrappers through theme)
  • Update all tests (use of wrappers through theme)
  • For each wrapper, ensure the documentation about its use and the override is enough
  • Update DocC catalogs about themes and wrappers
  • Provide a sample app, using OUDS as a dependency, with a local theme overriding only some tokens, so as to check if everything is ok

Note that when migrations are done, contact the @boosted-bot tokenator team to have an update on ther side to make PR with our new architecture (no need to wait for tests and doc updates).

@pylapp pylapp added the ⚠️ on hold Not blocked but should not be processed yet label Aug 26, 2024
@pylapp

This comment has been minimized.

@pylapp pylapp changed the title Refactoring of theme with wrappers [Refactoring] Refactoring of theme with wrappers Oct 2, 2024
@pylapp

This comment has been minimized.

@pylapp pylapp moved this from Triage to Todo in [OUDS] Project Nov 20, 2024
@pylapp pylapp self-assigned this Nov 20, 2024
@pylapp pylapp moved this from Todo to In Progress in [OUDS] Project Dec 13, 2024
@pylapp pylapp added 🧩 enhancement Related to enhancements or feature requests 🧬 token Related to tokens (raws, semantics or components) and removed ⚠️ on hold Not blocked but should not be processed yet labels Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
@pylapp pylapp linked a pull request Dec 13, 2024 that will close this issue
11 tasks
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
pylapp added a commit that referenced this issue Dec 13, 2024
@pylapp
Copy link
Member Author

pylapp commented Dec 13, 2024

Find attached a kind of quick-and-dirty PoC with a local theme, inheriting from OrangeTheme, and using the enw wrappers overriding some tokens (space, size, color, border, elevation, opacity, grid and font).
The architecture works!

cc @ludovic35

OUDS PoC 79.zip

pylapp added a commit that referenced this issue Dec 16, 2024
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
@pylapp pylapp changed the title [Refactoring] Refactoring of theme with wrappers [Refactoring] Refactoring of theme with wrappers, update documentations Dec 16, 2024
@pylapp pylapp added the 📖 documentation Improvements or additions to documentation label Dec 16, 2024
pylapp added a commit that referenced this issue Dec 16, 2024
pylapp added a commit that referenced this issue Dec 16, 2024
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
pylapp added a commit that referenced this issue Dec 16, 2024
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
pylapp added a commit that referenced this issue Dec 16, 2024
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
pylapp added a commit that referenced this issue Dec 16, 2024
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
pylapp added a commit that referenced this issue Dec 17, 2024
- Defines tokens providers embeded in the theme
- Improve documentation (DocC catalogs, Swift doc)

Reviewed-by: Ludovic Pinel <[email protected]>
Acked-by: Ludovic Pinel <[email protected]>
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to Done in [OUDS] Project Dec 17, 2024
pylapp added a commit that referenced this issue Dec 18, 2024
pylapp added a commit that referenced this issue Dec 18, 2024
…ADME (#355)

- Now providers are defined in concrete theme levels, not abstract theme level. It makes possible to freeze some semantic tokens like `colorRepository*`
- Documentation has been updated (catalog, Swift code, README)

Related to #79 

Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
pylapp added a commit that referenced this issue Dec 18, 2024
- Defines tokens providers embeded in the theme
- Improve documentation (DocC catalogs, Swift doc)

Reviewed-by: Ludovic Pinel <[email protected]>
Acked-by: Ludovic Pinel <[email protected]>
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
pylapp added a commit that referenced this issue Dec 18, 2024
…ADME (#355)

- Now providers are defined in concrete theme levels, not abstract theme level. It makes possible to freeze some semantic tokens like `colorRepository*`
- Documentation has been updated (catalog, Swift code, README)

Related to #79 

Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
This was referenced Dec 18, 2024
pylapp added a commit that referenced this issue Dec 18, 2024
Release of version 0.8.0
See bellow the full CHANGELOG details.

Added:
- [Library] New architecture with tokens provider ([#79](#79))
- [DemoApp] Prepare new architecture to add components illustration ([#328](#328))

Changed:
- [Tool] Update `net-http` gem from 0.5.0 to 0.6.0
- [Tool] Update `SwiftLint` pod from v0.57.0 to v0.57.1
- [Tool] Update `SwiftFormat/CLI` pod from v0.54.6 to v0.55.3
- [Tool] Update `fastlane` gem from v2.225.0 to v2.226.0
- [Library] Update `FontSemanticTokens` (tokenator *20241213075501*)
- [Library] Update `FontSemanticTokens` (tokenator *20241211115813*)
- [Library] Update `FontRawTokens` (tokenator *20241211101443*)
- [Tool] Migrate from `xcode_install` to `xcodes` in Fastfile, freeze Xcode version (16.0)
- [Library] Rename `Typography*` tokens and elements to `Font*` ([#322](#322))
- [Library] Update `ColorSemanticTokens` (tokenator *20241204111709*)
- [Library] Update `SpaceSemanticTokens` (tokenator *20241204110127*)
- [Library] Rename `opacityTransparent` opacity semantic token to `opacityInvisible`
- [Library] Update `OpacitySemanticTokens` and `OpacityRawTokens` tokens (tokenator *20241204110957*)
- [Library] Update `OrangeBrandColorRawTokens` tokens (tokenator *20241204111119*)
- [Library] Update `SizeSemanticTokens` tokens (tokenator *20241204110236*)
- [Library] Rename any `sizeIcon**` size semantic tokens applying "T-shirt sizes" template
- [Library] Update `ElevationSemanticTokens` and `ColorRawTokens` tokens (tokenator *20241204111249*)
- [Library] Rename any `colorTransparent*` color semantic tokens to `colorOpacity*`
- [DemoApp] Reactor UI test to use theme in environment ([#299](#299))

Removed:
- [Library] Font raw tokens `fontFamilyBrandDefault`, `fontFamilyBrandTV`, `fontFamilySystemArial`, `fontFamilySystemHelvetica`, `fontFamilySystemNotoSans`, `fontFamilySystemSFPro`, `fontFamilySystemRoboto`, `fontFamilyMonospaceMonaco`, `fontFamilyMonospaceCourierNew`, `fontFamilySystemArial`
- [Library] Space semantic tokens `*WithIcon*`, `*WithArrow*` 
- [Library] Elevation semantic tokens `elevationBlurOverlayDefault`, `elevationBlurOverlayEmphasized`, `elevationXOverlayDefault`, `elevationXOverlayEmphasized`, `elevationYOverlayDefault`, `elevationYOverlayEmphasized`, `elevationColorOverlayDefaultLight`, `elevationColorOverlayEmphasizedLight`, `elevationColorOverlayDefaultDark`, `elevationColorOverlayEmphasizedDark`

Co-authored-by: Pierre-Yves Lapersonne <[email protected]>
Co-authored-by: Ludovic Pinel <[email protected]>
Co-authored-by: boosted-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 documentation Improvements or additions to documentation 🧩 enhancement Related to enhancements or feature requests 🧬 token Related to tokens (raws, semantics or components)
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant