Skip to content

Commit

Permalink
refactor(review): rename wrapper to provider for tokens of opacities (#…
Browse files Browse the repository at this point in the history
…79)

Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp committed Dec 17, 2024
1 parent c854d33 commit c2ece11
Show file tree
Hide file tree
Showing 9 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 OUDSOpacitySemanticTokensWrapper: OpacitySemanticTokens {
extension OUDSOpacitySemanticTokensProvider: OpacitySemanticTokens {
@objc open var opacityInvisible: OpacitySemanticToken { OpacityRawTokens.opacity0 }
@objc open var opacityMedium: OpacitySemanticToken { OpacityRawTokens.opacity320 }
@objc open var opacityOpaque: OpacitySemanticToken { OpacityRawTokens.opacity1000 }
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 @@ -68,15 +68,15 @@ open class OUDSTheme: @unchecked Sendable {
/// - 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 `OUDSGridSemanticTokensProvider`
/// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensWrapper`
/// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensProvider`
/// - 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 = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensProvider(),
sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensWrapper(),
spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) {
self.colors = colors
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 @@ -59,7 +59,7 @@ You will have to override the tokens wrapper you need. To do that, make a subcla
- colors tokens are all defined in `OrangeThemeColorSemanticTokensWrapper`
- borders tokens are in `OUDSBorderSemanticTokensProvider`
- elevations tokens are in `OUDSElevationSemanticTokensProvider`
- opacity tokens are in `OUDSOpacitySemanticTokensWrapper`
- opacity tokens are in `OUDSOpacitySemanticTokensProvider`
- grid tokens are in `OUDSGridSemanticTokensProvider`
- font tokens are in `OUDSFontSemanticTokensProvider`

Expand Down Expand Up @@ -126,7 +126,7 @@ class YourAppThemeElevationTokensWrapper: OUDSElevationSemanticTokensProvider {

// Token wrapper for opacity

class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensWrapper {
class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensProvider {
override var opacityStrong: OpacitySemanticToken {
OpacityRawTokens.opacity920
}
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 opacity semantic tokens (from its super class, i.e. `OUDSOpacitySemanticTokensWrapper`) so as to test overriding of them (unit tests)
/// Overrides **all** the opacity semantic tokens (from its super class, i.e. `OUDSOpacitySemanticTokensProvider`) so as to test overriding of them (unit tests)
/// and to act like smoke tests with crashing tests if some tokens disappeared.
final class MockThemeOpacitySemanticTokensWrapper: OUDSOpacitySemanticTokensWrapper {
final class MockThemeOpacitySemanticTokensWrapper: OUDSOpacitySemanticTokensProvider {

static let mockThemeOpacityRawToken: OpacityRawToken = 713

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 @@ -70,15 +70,15 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
/// - 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 `OUDSGridSemanticTokensProvider`
/// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation, default set to `OUDSOpacitySemanticTokensWrapper`
/// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation, default set to `OUDSOpacitySemanticTokensProvider`
/// - 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 = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensProvider(),
sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensWrapper(),
spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) {
OUDSLogger.debug("Init of OrangeTheme")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ You will have to override the tokens wrapper you need. To do that, make a subcla
- colors tokens are all defined in `OrangeThemeColorSemanticTokensWrapper`
- borders tokens are in `OUDSBorderSemanticTokensProvider`
- elevations tokens are in `OUDSElevationSemanticTokensProvider`
- opacity tokens are in `OUDSOpacitySemanticTokensWrapper`
- opacity tokens are in `OUDSOpacitySemanticTokensProvider`
- grid tokens are in `OUDSGridSemanticTokensProvider`
- font tokens are in `OUDSFontSemanticTokensProvider`

Expand Down Expand Up @@ -135,7 +135,7 @@ class YourAppThemeElevationTokensWrapper: OUDSElevationSemanticTokensProvider {

// Token wrapper for opacity

class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensWrapper {
class YourAppThemeOpacityTokensWrapper: OUDSOpacitySemanticTokensProvider {
override var opacityStrong: OpacitySemanticToken {
OpacityRawTokens.opacity920
}
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 **opacity.**
/// It defines all ``OpacitySemanticToken`` a theme must have.
/// Any opacity semantic token must be declared there as wrappers like ``OUDSOpacitySemanticTokensWrapper`` will then expose them through `OUDSTheme`.
/// Any opacity semantic token must be declared there as wrappers like ``OUDSOpacitySemanticTokensProvider`` will then expose them through `OUDSTheme`.
public protocol OpacitySemanticTokens {

// MARK: Semantic token - Opacity
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 opacity semantic tokens
/// class CustomOpacityTokensWrapper: OUDSOpacitySemanticTokensWrapper {
/// class CustomOpacityTokensWrapper: OUDSOpacitySemanticTokensProvider {
///
/// // Then override the opacity semantic tokens you want, using the opacity raw tokens available
///
Expand All @@ -45,11 +45,11 @@ import OUDSFoundations
/// ```swift
/// OrangeTheme(opacities: CustomOpacityTokensWrapper())
/// ```
open class OUDSOpacitySemanticTokensWrapper {
open class OUDSOpacitySemanticTokensProvider {

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

deinit{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public typealias AllBorderSemanticTokens = BorderSemanticTokens

/// A type alias only for ``OpacitySemanticTokens`` so as to keep consistency with other type aliases
/// merging several protocols.
/// For example ``OUDSOpacitySemanticTokensWrapper`` matches this type alias.
/// For example ``OUDSOpacitySemanticTokensProvider`` matches this type alias.
public typealias AllOpacitySemanticTokens = OpacitySemanticTokens

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

0 comments on commit c2ece11

Please sign in to comment.