Skip to content

Commit

Permalink
refactor(review): rename wrapper to provider for tokens of grids (#79)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp committed Dec 17, 2024
1 parent 899ebf1 commit c854d33
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ 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`
public init(colors: AllColorSemanticTokens = OUDSColorSemanticTokensProvider(),
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(),
fonts: AllFontSemanticTokens = OUDSFontSemanticTokensProvider(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper(),
sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensWrapper(),
spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) {
Expand Down
4 changes: 2 additions & 2 deletions OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -134,7 +134,7 @@ class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensWrapper {

// Token wrapper for grid

class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensWrapper {
class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensProvider {
override var gridExtraCompactColumnGap: GridSemanticToken {
GridRawTokens.gridColumnGap200
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ 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`
override public init(colors: AllColorSemanticTokens = OrangeThemeColorSemanticTokensWrapper(),
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(),
fonts: AllFontSemanticTokens = OUDSFontSemanticTokensProvider(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper(),
sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensWrapper(),
spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -143,7 +143,7 @@ class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensWrapper {

// Token wrapper for grid

class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensWrapper {
class YourAppThemeGridTokensWrapper: OUDSGridSemanticTokensProvider {
override var gridExtraCompactColumnGap: GridSemanticToken {
GridRawTokens.gridColumnGap200
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -53,17 +53,17 @@ 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{ }

// ଘ( ・ω・)_/゚・:*:・。☆
// 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.
}
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down

0 comments on commit c854d33

Please sign in to comment.