From c854d3307a6a1f01aade6921e9e206339861f3bb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Lapersonne Date: Tue, 17 Dec 2024 12:01:09 +0100 Subject: [PATCH] refactor(review): rename wrapper to provider for tokens of grids (#79) Signed-off-by: Pierre-Yves Lapersonne --- .../OUDSTheme+GridSemanticTokens.swift | 2 +- OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift | 4 ++-- OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md | 4 ++-- .../MockThemes/MockTheme+AllGridSemanticTokens.swift | 4 ++-- OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift | 4 ++-- .../Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md | 4 ++-- ...Wrapper.swift => OUDSGridSemanticTokensProvider.swift} | 8 ++++---- .../Wrappers/SemanticTokensWrappers+TypeAliases.swift | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) rename OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/{OUDSGridSemanticTokensWrapper.swift => OUDSGridSemanticTokensProvider.swift} (88%) diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift index 85b0e5809b..235eebfafe 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift @@ -15,7 +15,7 @@ import Foundation import OUDSTokensRaw import OUDSTokensSemantic -extension OUDSGridSemanticTokensWrapper: GridSemanticTokens { +extension OUDSGridSemanticTokensProvider: GridSemanticTokens { @objc open var gridCompactColumnGap: GridSemanticToken { GridRawTokens.gridColumnGap100 } @objc open var gridCompactMargin: GridSemanticToken { GridRawTokens.gridMargin300 } @objc open var gridCompactMaxWidth: GridSemanticToken { GridRawTokens.gridMaxWidthCompact } diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift index 61088b0b65..80f7bdaf25 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift @@ -67,7 +67,7 @@ open class OUDSTheme: @unchecked Sendable { /// - borders: An object providing all the border semantic tokens, by default `OUDSBorderSemanticTokensProvider` /// - elevations: An object providing all the elevation semantic tokens, by default `OUDSElevationSemanticTokensProvider` /// - fonts: An object providing all the font semantic tokens, by default `OUDSFontSemanticTokensProvider` - /// - grids: An object providing all the grid semantic tokens, by default `OUDSGridSemanticTokensWrapper` + /// - grids: An object providing all the grid semantic tokens, by default `OUDSGridSemanticTokensProvider` /// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensWrapper` /// - sizes: An object providing all the size semantic tokens, by default `OUDSSizeSemanticTokensWrapper` /// - spaces: An object providing all the space semantic tokens, by default `OUDSSpaceSemanticTokensWrapper` @@ -75,7 +75,7 @@ open class OUDSTheme: @unchecked Sendable { borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(), elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(), fonts: AllFontSemanticTokens = OUDSFontSemanticTokensProvider(), - grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper(), + grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(), opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper(), sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensWrapper(), spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) { diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md index 14400c9c5c..9ec51e5b77 100644 --- a/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md @@ -60,7 +60,7 @@ You will have to override the tokens wrapper you need. To do that, make a subcla - borders tokens are in `OUDSBorderSemanticTokensProvider` - elevations tokens are in `OUDSElevationSemanticTokensProvider` - opacity tokens are in `OUDSOpacitySemanticTokensWrapper` -- grid tokens are in `OUDSGridSemanticTokensWrapper` +- grid tokens are in `OUDSGridSemanticTokensProvider` - font tokens are in `OUDSFontSemanticTokensProvider` Find bellow some example @@ -134,7 +134,7 @@ class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensWrapper { // Token wrapper for grid -class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensWrapper { +class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensProvider { override var gridExtraCompactColumnGap: GridSemanticToken { GridRawTokens.gridColumnGap200 } diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllGridSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllGridSemanticTokens.swift index 5aea2c9be3..9c03e669fe 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllGridSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllGridSemanticTokens.swift @@ -17,9 +17,9 @@ import OUDSTokensSemantic // swiftlint:disable required_deinit -/// Overrides **all** the grid semantic tokens (from its super class, i.e. `OUDSGridSemanticTokensWrapper` so as to test overriding of them (unit tests) +/// Overrides **all** the grid semantic tokens (from its super class, i.e. `OUDSGridSemanticTokensProvider` so as to test overriding of them (unit tests) /// and to act like smoke tests with crashing tests if some tokens disappeared. -final class MockThemeGridSemanticTokensWrapper: OUDSGridSemanticTokensWrapper { +final class MockThemeGridSemanticTokensWrapper: OUDSGridSemanticTokensProvider { static let mockThemeGridRawToken: GridRawToken = 3_630 diff --git a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift index 547374fecd..ca1dfae9a0 100644 --- a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift +++ b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift @@ -69,7 +69,7 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable { /// - borders: An object providing all the border semantic tokens, as `BorderSemanticTokens` implementation, default set to `OUDSBorderSemanticTokensProvider` /// - elevations: An object providing all the elevation semantic tokens, by default `AllElevationSemanticTokens`, default set to `OUDSElevationSemanticTokensProvider` /// - fonts: An object providing all the font semantic tokens, by default `AllFontemanticTokens`, default set to `OUDSFontSemanticTokensProvider` - /// - grids: An object providing all the grid semantic tokens, by default `AllGridSemanticTokens`, default set to `OUDSGridSemanticTokensWrapper` + /// - grids: An object providing all the grid semantic tokens, by default `AllGridSemanticTokens`, default set to `OUDSGridSemanticTokensProvider` /// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation, default set to `OUDSOpacitySemanticTokensWrapper` /// - sizes: An object providing all the size semantic tokens, as `AllSizeSemanticTokens` implementation, default set to `OUDSSizeSemanticTokensWrapper` /// - spaces: An object providing all the space semantic tokens, as `AllSpaceSemanticTokens` implementation, default set to `OUDSSpaceSemanticTokensWrapper` @@ -77,7 +77,7 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable { borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(), elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(), fonts: AllFontSemanticTokens = OUDSFontSemanticTokensProvider(), - grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper(), + grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(), opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper(), sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensWrapper(), spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) { diff --git a/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md b/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md index ee0c886abf..27beeb09a2 100644 --- a/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md +++ b/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md @@ -71,7 +71,7 @@ You will have to override the tokens wrapper you need. To do that, make a subcla - borders tokens are in `OUDSBorderSemanticTokensProvider` - elevations tokens are in `OUDSElevationSemanticTokensProvider` - opacity tokens are in `OUDSOpacitySemanticTokensWrapper` -- grid tokens are in `OUDSGridSemanticTokensWrapper` +- grid tokens are in `OUDSGridSemanticTokensProvider` - font tokens are in `OUDSFontSemanticTokensProvider` ```swift @@ -143,7 +143,7 @@ class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensWrapper { // Token wrapper for grid -class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensWrapper { +class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensProvider { override var gridExtraCompactColumnGap: GridSemanticToken { GridRawTokens.gridColumnGap200 } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSGridSemanticTokensWrapper.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSGridSemanticTokensProvider.swift similarity index 88% rename from OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSGridSemanticTokensWrapper.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSGridSemanticTokensProvider.swift index ea2e3a2c38..c1e768a6df 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSGridSemanticTokensWrapper.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSGridSemanticTokensProvider.swift @@ -19,7 +19,7 @@ import OUDSFoundations /// /// ```swift /// // Define your own wrapper for grid semantic tokens -/// class CustomGridTokensWrapper: OUDSGridSemanticTokensWrapper { +/// class CustomGridTokensWrapper: OUDSGridSemanticTokensProvider { /// /// // Then override the grid semantic tokens you want, using the grid raw tokens available /// @@ -53,11 +53,11 @@ import OUDSFoundations /// ```swift /// OrangeTheme(grids: CustomGridTokensWrapper()) /// ``` -open class OUDSGridSemanticTokensWrapper { +open class OUDSGridSemanticTokensProvider { /// Intializes the wrapper public init() { - OUDSLogger.debug("Init of OUDSGridSemanticTokensWrapper") + OUDSLogger.debug("Init of OUDSGridSemanticTokensProvider") } deinit{ } @@ -65,5 +65,5 @@ open class OUDSGridSemanticTokensWrapper { // ଘ( ・ω・)_/゚・:*:・。☆ // Note: So as to help the integration of generated code produced by the tokenator // the implemention of GridSemanticTokens is not here but in OUDS/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift - // This declaration of OUDSGridSemanticTokensWrapper is here to allow to write documentation. + // This declaration of OUDSGridSemanticTokensProvider is here to allow to write documentation. } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift index c6289a099b..02a2fbeed2 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift @@ -23,7 +23,7 @@ public typealias AllOpacitySemanticTokens = OpacitySemanticTokens /// A type alias only for ``GridSemanticTokens`` so as to keep consistency with other type aliases /// merging several protocols. -/// For example ``OUDSGridSemanticTokensWrapper`` matches this type alias. +/// For example ``OUDSGridSemanticTokensProvider`` matches this type alias. public typealias AllGridSemanticTokens = GridSemanticTokens /// A type alias which merges ``ColorSemanticTokens`` and ``ColorMultipleSemanticTokens``.