Skip to content

Commit

Permalink
refactor(review): rename wrapper to provider for tokens of borders (#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 b72cc9e commit 6309b9b
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import OUDSTokensRaw
import OUDSTokensSemantic

extension OUDSBorderSemanticTokensWrapper: BorderSemanticTokens {
extension OUDSBorderSemanticTokensProvider: BorderSemanticTokens {
@objc open var borderRadiusDefault: BorderRadiusSemanticToken { BorderRawTokens.borderRadius0 }
@objc open var borderRadiusMedium: BorderRadiusSemanticToken { BorderRawTokens.borderRadius150 }
@objc open var borderRadiusNone: BorderRadiusSemanticToken { BorderRawTokens.borderRadius0 }
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 @@ -64,15 +64,15 @@ open class OUDSTheme: @unchecked Sendable {
/// No custom font family will be used.
/// - Parameters:
/// - colors: An object providing all the color semantic tokens, by default `OUDSColorSemanticTokensWrapper`
/// - borders: An object providing all the border semantic tokens, by default `OUDSBorderSemanticTokensWrapper`
/// - borders: An object providing all the border semantic tokens, by default `OUDSBorderSemanticTokensProvider`
/// - elevations: An object providing all the elevation semantic tokens, by default `OUDSElevationSemanticTokensWrapper`
/// - fonts: An object providing all the font semantic tokens, by default `OUDSFontSemanticTokensWrapper`
/// - grids: An object providing all the grid semantic tokens, by default `OUDSGridSemanticTokensWrapper`
/// - 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 = OUDSColorSemanticTokensWrapper(),
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensWrapper(),
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensWrapper(),
fonts: AllFontSemanticTokens = OUDSFontSemanticTokensWrapper(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper(),
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 @@ -57,7 +57,7 @@ You will have to override the tokens wrapper you need. To do that, make a subcla
- spaces tokens are `OUDSSpaceSemanticTokensWrapper`
- sizes tokens are in `OUDSSizeSemanticTokensWrapper`
- colors tokens are all defined in `OrangeThemeColorSemanticTokensWrapper`
- borders tokens are in `OUDSBorderSemanticTokensWrapper`
- borders tokens are in `OUDSBorderSemanticTokensProvider`
- elevations tokens are in `OUDSElevationSemanticTokensWrapper`
- opacity tokens are in `OUDSOpacitySemanticTokensWrapper`
- grid tokens are in `OUDSGridSemanticTokensWrapper`
Expand Down Expand Up @@ -104,7 +104,7 @@ class YourAppThemeColorTokensWrapper: OrangeThemeColorSemanticTokensWrapper {

// Token wrapper for border

class YourAppThemeBorderTokensWrapper: OUDSBorderSemanticTokensWrapper {
class YourAppThemeBorderTokensWrapper: OUDSBorderSemanticTokensProvider {
override var borderStyleDefault: BorderStyleSemanticToken {
BorderRawTokens.borderStyleDashed
}
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 border semantic tokens (from its super class, i.e. `OUDSBorderSemanticTokensWrapper`) so as to test overriding of them (unit tests)
/// Overrides **all** the border semantic tokens (from its super class, i.e. `OUDSBorderSemanticTokensProvider`) so as to test overriding of them (unit tests)
/// and to act like smoke tests with crashing tests if some tokens disappeared.
final class MockThemeBorderSemanticTokensWrapper: OUDSBorderSemanticTokensWrapper {
final class MockThemeBorderSemanticTokensWrapper: OUDSBorderSemanticTokensProvider {

static let mockThemeBorderWidthRawToken: BorderWidthRawToken = 1_337
static let mockThemeBorderRadiusRawToken: BorderRadiusRawToken = 42
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 @@ -66,15 +66,15 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
/// Initializes the `OrangeTheme` and lets children classes to user their own tokens implementations
/// - Parameters:
/// - colors: An object providing all the color semantic tokens, as `AllColorSemanticTokens` implementation, default set to `OrangeThemeColorSemanticTokensWrapper`
/// - borders: An object providing all the border semantic tokens, as `BorderSemanticTokens` implementation, default set to `OUDSBorderSemanticTokensWrapper`
/// - 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 `OUDSElevationSemanticTokensWrapper`
/// - fonts: An object providing all the font semantic tokens, by default `AllFontemanticTokens`, default set to `OUDSFontSemanticTokensWrapper`
/// - grids: An object providing all the grid semantic tokens, by default `AllGridSemanticTokens`, default set to `OUDSGridSemanticTokensWrapper`
/// - 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 = OUDSBorderSemanticTokensWrapper(),
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensWrapper(),
fonts: AllFontSemanticTokens = OUDSFontSemanticTokensWrapper(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You will have to override the tokens wrapper you need. To do that, make a subcla
- spaces tokens are `OUDSSpaceSemanticTokensWrapper`
- sizes tokens are in `OUDSSizeSemanticTokensWrapper`
- colors tokens are all defined in `OrangeThemeColorSemanticTokensWrapper`
- borders tokens are in `OUDSBorderSemanticTokensWrapper`
- borders tokens are in `OUDSBorderSemanticTokensProvider`
- elevations tokens are in `OUDSElevationSemanticTokensWrapper`
- opacity tokens are in `OUDSOpacitySemanticTokensWrapper`
- grid tokens are in `OUDSGridSemanticTokensWrapper`
Expand Down Expand Up @@ -113,7 +113,7 @@ class YourAppThemeColorTokensWrapper: OrangeThemeColorSemanticTokensWrapper {

// Token wrapper for border

class YourAppThemeBorderTokensWrapper: OUDSBorderSemanticTokensWrapper {
class YourAppThemeBorderTokensWrapper: OUDSBorderSemanticTokensProvider {
override var borderStyleDefault: BorderStyleSemanticToken {
BorderRawTokens.borderStyleDashed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/// This is a group of semantic tokens for **borders**.
/// It defines all ``BorderWidthSemanticToken``, ``BorderRadiusSemanticToken`` and ``BorderStyleSemanticToken`` a theme must have.
/// Any border semantic token must be declared there as wrappers like ``OUDSBorderSemanticTokensWrapper`` will then expose them through `OUDSTheme`.
/// Any border semantic token must be declared there as wrappers like ``OUDSBorderSemanticTokensProvider`` will then expose them through `OUDSTheme`.
public protocol BorderSemanticTokens {

// MARK: - Semantic token - Border - Width
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 border semantic tokens
/// class CustomBorderTokensWrapper: OUDSBorderSemanticTokensWrapper {
/// class CustomBorderTokensWrapper: OUDSBorderSemanticTokensProvider {
///
/// // Then override the border semantic tokens you want, using the border raw tokens available
///
Expand Down Expand Up @@ -51,17 +51,17 @@ import OUDSFoundations
/// ```swift
/// OrangeTheme(borders: CustomBorderTokensWrapper())
/// ```
open class OUDSBorderSemanticTokensWrapper {
open class OUDSBorderSemanticTokensProvider {

/// Intializes the wrapper
public init() {
OUDSLogger.debug("Init of OUDSBorderSemanticTokensWrapper")
OUDSLogger.debug("Init of OUDSBorderSemanticTokensProvider")
}

deinit{ }

// ଘ( ・ω・)_/゚・:*:・。☆
// Note: So as to help the integration of generated code produced by the tokenator
// the implemention of BorderSemanticTokens is not here but in OUDS/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+BorderSemanticTokens.swift
// This declaration of OUDSBorderSemanticTokensWrapper is here to allow to write documentation.
// This declaration of OUDSBorderSemanticTokensProvider is here to allow to write documentation.
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/// A type alias only for ``BorderSemanticTokens`` so as to keep consistency with other type aliases
/// merging several protocols
/// For example ``OUDSBorderSemanticTokensWrapper`` matches this type alias.
/// For example ``OUDSBorderSemanticTokensProvider`` matches this type alias.
public typealias AllBorderSemanticTokens = BorderSemanticTokens

/// A type alias only for ``OpacitySemanticTokens`` so as to keep consistency with other type aliases
Expand Down

0 comments on commit 6309b9b

Please sign in to comment.