Skip to content

Commit 3dbe772

Browse files
committed
refactor(review): rename wrapper to provider for tokens of colors (#79)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 6309b9b commit 3dbe772

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorMultipleSemanticTokens.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import OUDSTokensSemantic
2222
// swiftlint:disable line_length
2323

2424
/// Defines wrapper objects for `ColorSemanticTokens` so as to pack them as light and dark mode colors.
25-
/// These values can be overriden inside `OUDSColorSemanticTokensWrapper` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination.
25+
/// These values can be overriden inside `OUDSColorSemanticTokensProvider` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination.
2626
/// Some tokens do not have values assigned in the design system, and must be overriden.
2727
/// Some tokens must be overriden in `OrangeTheme` side because they rely on Orange brand colors.
2828
/// Helps to expose color semantic tokens with two values to use depending to the color scheme (*Figma* cannot manage such tokens and generate them).
29-
extension OUDSColorSemanticTokensWrapper: ColorMultipleSemanticTokens {
29+
extension OUDSColorSemanticTokensProvider: ColorMultipleSemanticTokens {
3030

3131
// MARK: - Color - Opacity - Invisible
3232

OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import OUDSTokensSemantic
1919

2020
// swiftlint:disable identifier_name
2121

22-
extension OUDSColorSemanticTokensWrapper: ColorSemanticTokens {
22+
extension OUDSColorSemanticTokensProvider: ColorSemanticTokens {
2323
@objc open var colorOpacityInvisibleBlackLight: ColorSemanticToken { ColorRawTokens.colorOpacityBlack0 }
2424
@objc open var colorOpacityInvisibleWhiteLight: ColorSemanticToken { ColorRawTokens.colorOpacityWhite0 }
2525
@objc open var colorOpacityInvisibleBlackDark: ColorSemanticToken { ColorRawTokens.colorOpacityWhite0 }

OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ open class OUDSTheme: @unchecked Sendable {
6363
/// Defines a basic kind of abstract theme to subclass then.
6464
/// No custom font family will be used.
6565
/// - Parameters:
66-
/// - colors: An object providing all the color semantic tokens, by default `OUDSColorSemanticTokensWrapper`
66+
/// - colors: An object providing all the color semantic tokens, by default `OUDSColorSemanticTokensProvider`
6767
/// - borders: An object providing all the border semantic tokens, by default `OUDSBorderSemanticTokensProvider`
6868
/// - elevations: An object providing all the elevation semantic tokens, by default `OUDSElevationSemanticTokensWrapper`
6969
/// - fonts: An object providing all the font semantic tokens, by default `OUDSFontSemanticTokensWrapper`
7070
/// - grids: An object providing all the grid semantic tokens, by default `OUDSGridSemanticTokensWrapper`
7171
/// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensWrapper`
7272
/// - sizes: An object providing all the size semantic tokens, by default `OUDSSizeSemanticTokensWrapper`
7373
/// - spaces: An object providing all the space semantic tokens, by default `OUDSSpaceSemanticTokensWrapper`
74-
public init(colors: AllColorSemanticTokens = OUDSColorSemanticTokensWrapper(),
74+
public init(colors: AllColorSemanticTokens = OUDSColorSemanticTokensProvider(),
7575
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(),
7676
elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensWrapper(),
7777
fonts: AllFontSemanticTokens = OUDSFontSemanticTokensWrapper(),

OUDS/Core/OUDS/Sources/_OUDS.docc/Tokens.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protocol ColorSemanticTokens {
5353
}
5454

5555
// Define the semantic tokens exposed through the theme
56-
extension OUDSColorSemanticTokensWrapper: ColorSemanticTokens {
56+
extension OUDSColorSemanticTokensProvider: ColorSemanticTokens {
5757

5858
// Color is available in the module of OUDSTheme
5959
@objc open var colorBgPrimary: ColorSemanticToken { ColorRawTokens.colorFunctionalWhite }
@@ -66,7 +66,7 @@ extension OUDSColorSemanticTokensWrapper: ColorSemanticTokens {
6666
}
6767

6868
// Add missing values
69-
extension OrangeColorSemanticTokensWrapper: OUDSColorSemanticTokensWrapper {
69+
extension OrangeColorSemanticTokensWrapper: OUDSColorSemanticTokensProvider {
7070

7171
// Define value value with the accessible token
7272
@objc open var colorBgSecondary: ColorSemanticToken { OrangeBrandColorRawTokens.colorOrange200 }

OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllColorSemanticTokens.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import OUDSTokensSemantic
1919
// swiftlint:disable required_deinit
2020
// swiftlint:disable type_body_length
2121

22-
/// Overrides **all** the color semantic tokens (from its super class, i.e. `OUDSColorSemanticTokensWrapper`) so as to test overriding of them (unit tests)
22+
/// Overrides **all** the color semantic tokens (from its super class, i.e. `OUDSColorSemanticTokensProvider`) so as to test overriding of them (unit tests)
2323
/// and to act like smoke tests with crashing tests if some tokens disappeared.
2424
/// This ``MockThemeColorSemanticTokensWrapper`` will be asigned in ``MockTheme`` as an ``AllColorSemanticTokens`` implementation.
25-
open class MockThemeColorSemanticTokensWrapper: OUDSColorSemanticTokensWrapper {
25+
open class MockThemeColorSemanticTokensWrapper: OUDSColorSemanticTokensProvider {
2626

2727
static let mockThemeMultipleColorSemanticTokens = MultipleColorSemanticTokens("#68489D")
2828
static let mockThemeSemanticColorTokens: ColorSemanticToken = "#68489D"

OUDS/Core/Themes/Orange/Sources/OrangeTheme+SemanticColorTokens.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import OUDSTokensSemantic
2323

2424
/// Overrides some color tokens using values available in ``OrangeBrandColorRawTokens``.
2525
/// In fact the *tokenator* is not able to do the magic needed using the JSON file produced by *Figma*.
26-
/// Some color tokens are not isolated by theme in *Figma*, thus the abstract `OUDSColorSemanticTokensWrapper` in `OUDS` module faces issues by defining tokens with raw tokens not defined in `ColorRawTokens` but in ``OrangeBrandColorRawTokens``. Thus when the `OUDSColorSemanticTokensWrapper` has its colors tokens updated, a manual update must be done to replace unknown tokens by `fatalError` (i.e. must be overriden somewhere somehow) in that file and in this ``OrangeTheme`` file tokens must be overriden and manualy updated with the expected values.
26+
/// Some color tokens are not isolated by theme in *Figma*, thus the abstract `OUDSColorSemanticTokensProvider` in `OUDS` module faces issues by defining tokens with raw tokens not defined in `ColorRawTokens` but in ``OrangeBrandColorRawTokens``. Thus when the `OUDSColorSemanticTokensProvider` has its colors tokens updated, a manual update must be done to replace unknown tokens by `fatalError` (i.e. must be overriden somewhere somehow) in that file and in this ``OrangeTheme`` file tokens must be overriden and manualy updated with the expected values.
2727
///
2828
/// // For example, in OUDSTheme colors:
2929
///
@@ -50,7 +50,7 @@ import OUDSTokensSemantic
5050
///
5151
/// In few words, we need to keep isolated tokens and brand colors, provide kind of abstract architecture with isolated and overridable themes, but face troubles with *Figma* design kit having conception issues and producing JSON not reflecting the reality making *tokenator* unable to build the expected Swift code.
5252
/// We get uncompilable code for color tokens update and need to make the merge manualy.
53-
open class OrangeThemeColorSemanticTokensWrapper: OUDSColorSemanticTokensWrapper {
53+
open class OrangeThemeColorSemanticTokensWrapper: OUDSColorSemanticTokensProvider {
5454

5555
// MARK: - Init
5656

OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSColorSemanticTokensWrapper.swift renamed to OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSColorSemanticTokensProvider.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import OUDSFoundations
1919
///
2020
/// ```swift
2121
/// // Define your own wrapper for color semantic tokens
22-
/// class CustomColorTokensWrapper: OUDSColorSemanticTokensWrapper {
22+
/// class CustomColorTokensWrapper: OUDSColorSemanticTokensProvider {
2323
///
2424
/// // Then override the color semantic tokens you want, using the color raw tokens available
2525
///
@@ -49,11 +49,11 @@ import OUDSFoundations
4949
/// ```swift
5050
/// OrangeTheme(colors: CustomColorTokensWrapper())
5151
/// ```
52-
open class OUDSColorSemanticTokensWrapper {
52+
open class OUDSColorSemanticTokensProvider {
5353

5454
/// Intializes the wrapper
5555
public init() {
56-
OUDSLogger.debug("Init of OUDSColorSemanticTokensWrapper")
56+
OUDSLogger.debug("Init of OUDSColorSemanticTokensProvider")
5757
}
5858

5959
deinit{ }
@@ -62,5 +62,5 @@ open class OUDSColorSemanticTokensWrapper {
6262
// Note: So as to help the integration of generated code produced by the tokenator
6363
// the implemention of ColorSemanticTokens and ColorMultipleSemanticTokens are not here but in OUDS/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift
6464
// and OUDS/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorMultipleSemanticTokens.swift
65-
// This declaration of OUDSColorSemanticTokensWrapper is here to allow to write documentation.
65+
// This declaration of OUDSColorSemanticTokensProvider is here to allow to write documentation.
6666
}

OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public typealias AllGridSemanticTokens = GridSemanticTokens
2828

2929
/// A type alias which merges ``ColorSemanticTokens`` and ``ColorMultipleSemanticTokens``.
3030
/// It helps in the end to define a wrapper for all the semantic tokens of colors, multiple or not, generated or not.
31-
/// For example ``OUDSColorSemanticTokensWrapper`` matches this type alias.
31+
/// For example ``OUDSColorSemanticTokensProvider`` matches this type alias.
3232
public typealias AllColorSemanticTokens = ColorSemanticTokens & ColorMultipleSemanticTokens
3333

3434
/// A type alias which merges ``ElevationSemanticTokens``, ``ElevationCompositeSemanticTokens`` and ``ElevationMultipleSemanticTokens``.

OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ protocol ColorSemanticTokens {
2727
}
2828

2929
// Ensure you have a wrapper
30-
open class OUDSColorSemanticTokensWrapper { }
30+
open class OUDSColorSemanticTokensProvider { }
3131

3232
// Define the semantic tokens to expose through the theme thanks to the wrapper
33-
extension OUDSColorSemanticTokensWrapper: ColorSemanticTokens {
33+
extension OUDSColorSemanticTokensProvider: ColorSemanticTokens {
3434

3535
// Color is available in the module of OUDSTheme
3636
@objc open var colorBgPrimary: ColorSemanticToken { ColorRawTokens.colorFunctionalWhite }
@@ -76,14 +76,14 @@ public protocol ColorMultipleSemanticTokens { ... }
7676
public typealias AllColorSemanticTokens = ColorSemanticTokens & ColorMultipleSemanticTokens
7777

7878
// For example, the wrapper for the colors basically is:
79-
open class OUDSColorSemanticTokensWrapper { ... }
79+
open class OUDSColorSemanticTokensProvider { ... }
8080

8181
// The wrapper is composed by protocols containing tokens
82-
extension OUDSColorSemanticTokensWrapper: ColorSemanticTokens {
82+
extension OUDSColorSemanticTokensProvider: ColorSemanticTokens {
8383
@objc open var colorOpacityInvisibleBlackLight: ColorSemanticToken { ColorRawTokens.colorOpacityBlack0 }
8484
@objc open var colorOpacityInvisibleWhiteLight: ColorSemanticToken { ColorRawTokens.colorOpacityWhite0 }
8585
}
86-
extension OUDSColorSemanticTokensWrapper: ColorMultipleSemanticTokens {
86+
extension OUDSColorSemanticTokensProvider: ColorMultipleSemanticTokens {
8787
@objc open var colorOpacityInvisibleBlack: MultipleColorSemanticTokens { MultipleColorSemanticTokens(light: colorOpacityInvisibleBlackLight, dark: colorOpacityInvisibleBlackDark) }
8888
}
8989

0 commit comments

Comments
 (0)