Skip to content

Commit

Permalink
refactor: rename type aliases for tokens providers (#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 18, 2024
1 parent db5a45f commit def7d05
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 62 deletions.
56 changes: 28 additions & 28 deletions OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ open class OUDSTheme: @unchecked Sendable {
// MARK: - Properties

/// All color semantic tokens exposed in one object
public let colors: AllColorSemanticTokens
public let colors: AllColorSemanticTokensProvider

/// All border semantic tokens exposed in one object
public let borders: AllBorderSemanticTokens
public let borders: AllBorderSemanticTokensProvider

/// All elevation semantic tokens exposed in one object
public let elevations: AllElevationSemanticTokens
public let elevations: AllElevationSemanticTokensProvider

/// A theme can have a custom font which is not the system font
public let fontFamily: FontFamilySemanticToken?

/// All font semantic tokens exposed in one object
public let fonts: AllFontSemanticTokens
public let fonts: AllFontSemanticTokensProvider

/// All grid semantic tokens exposed in one object
public let grids: AllGridSemanticTokens
public let grids: AllGridSemanticTokensProvider

/// All opacity semantic tokens exposed in one object
public let opacities: AllOpacitySemanticTokens
public let opacities: AllOpacitySemanticTokensProvider

/// All size semantic tokens exposed in one object
public let sizes: AllSizeSemanticTokens
public let sizes: AllSizeSemanticTokensProvider

/// All size semantic tokens exposed in one object
public let spaces: AllSpaceSemanticTokens
public let spaces: AllSpaceSemanticTokensProvider

// TODO: Add components tokens

Expand All @@ -71,14 +71,14 @@ open class OUDSTheme: @unchecked Sendable {
/// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensProvider`
/// - sizes: An object providing all the size semantic tokens, by default `OUDSSizeSemanticTokensProvider`
/// - spaces: An object providing all the space semantic tokens, by default `OUDSSpaceSemanticTokensProvider`
public init(colors: AllColorSemanticTokens = OUDSColorSemanticTokensProvider(),
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(),
fonts: AllFontSemanticTokens = OUDSFontSemanticTokensProvider(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensProvider(),
sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensProvider(),
spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensProvider()) {
public init(colors: AllColorSemanticTokensProvider = OUDSColorSemanticTokensProvider(),
borders: AllBorderSemanticTokensProvider = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokensProvider = OUDSElevationSemanticTokensProvider(),
fonts: AllFontSemanticTokensProvider = OUDSFontSemanticTokensProvider(),
grids: AllGridSemanticTokensProvider = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokensProvider = OUDSOpacitySemanticTokensProvider(),
sizes: AllSizeSemanticTokensProvider = OUDSSizeSemanticTokensProvider(),
spaces: AllSpaceSemanticTokensProvider = OUDSSpaceSemanticTokensProvider()) {
self.colors = colors
self.borders = borders
self.elevations = elevations
Expand All @@ -93,23 +93,23 @@ open class OUDSTheme: @unchecked Sendable {
/// Defines a basic kind of abstract theme to subclass then.
/// - Parameters:
/// - colors: An object providing all the color semantic tokens, as `AllColorSemanticTokens` implementation
/// - borders: An object providing all the border semantic tokens, as `BorderSemanticTokens` implementation
/// - elevations: An object providing all the elevation semantic tokens, by default `AllElevationSemanticTokens`
/// - borders: An object providing all the border semantic tokens, as `AllBorderSemanticTokensProvider` implementation
/// - elevations: An object providing all the elevation semantic tokens, by default `AllElevationSemanticTokensProvider`
/// - fontFamily: Set `nil` if system font to use, otherwise use the `FontFamilySemanticToken` you want to apply
/// - fonts: An object providing all the font semantic tokens, by default `AllFontemanticTokens`
/// - grids: An object providing all the grid semantic tokens, by default `AllGridSemanticTokens`
/// - opacities: An object providing all the opacity semantic tokens, as `AllOpacitySemanticTokens` implementation
/// - opacities: An object providing all the opacity semantic tokens, as `AllOpacitySemanticTokensProvider` implementation
/// - sizes: An object providing all the size semantic tokens, as `AllSizeSemanticTokens` implementation
/// - spaces: An object providing all the space semantic tokens, as `AllSpaceSemanticTokens` implementation
public init(colors: AllColorSemanticTokens,
borders: AllBorderSemanticTokens,
elevations: AllElevationSemanticTokens,
/// - spaces: An object providing all the space semantic tokens, as `AllSpaceSemanticTokensProvider` implementation
public init(colors: AllColorSemanticTokensProvider,
borders: AllBorderSemanticTokensProvider,
elevations: AllElevationSemanticTokensProvider,
fontFamily: FontFamilySemanticToken?,
fonts: AllFontSemanticTokens,
grids: AllGridSemanticTokens,
opacities: AllOpacitySemanticTokens,
sizes: AllSizeSemanticTokens,
spaces: AllSpaceSemanticTokens) {
fonts: AllFontSemanticTokensProvider,
grids: AllGridSemanticTokensProvider,
opacities: AllOpacitySemanticTokensProvider,
sizes: AllSizeSemanticTokensProvider,
spaces: AllSpaceSemanticTokensProvider) {
self.colors = colors
self.borders = borders
self.elevations = elevations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import OUDSTokensSemantic

/// Overrides **all** the elevation semantic tokens, both simple, multiple and composites (from its super class, i.e. `OUDSElevationSemanticTokensProvider` so as to test overriding of them (unit tests)
/// and to act like smoke tests with crashing tests if some tokens disappeared.
/// This ``MockThemeElevationSemanticTokensProvider`` will be asigned in ``MockTheme`` as an ``AllElevationSemanticTokens`` implementation.
/// This ``MockThemeElevationSemanticTokensProvider`` will be asigned in ``MockTheme`` as an ``AllElevationSemanticTokensProvider`` implementation.
final class MockThemeElevationSemanticTokensProvider: OUDSElevationSemanticTokensProvider {

// MARK: Semantic token - Elevation - Box shadow (Composites)
Expand Down
2 changes: 1 addition & 1 deletion OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ open class MockTheme: OUDSTheme, @unchecked Sendable {
}

/// For ``OtherMockTheme``
init(colors: AllColorSemanticTokens) {
init(colors: AllColorSemanticTokensProvider) {
super.init(colors: colors,
borders: MockThemeBorderSemanticTokensProvider(),
elevations: MockThemeElevationSemanticTokensProvider(),
Expand Down
30 changes: 15 additions & 15 deletions OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,29 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
/// This constructor is defined for `InverseTheme`.
/// - Parameters:
/// - colors: An object providing all the color semantic tokens, as `AllColorSemanticTokens` implementation
public init(colors: AllColorSemanticTokens) {
public init(colors: AllColorSemanticTokensProvider) {
// Not init log here as constructor used for `InverseTheme` and not for `OrangeTheme`
super.init(colors: colors)
}

/// 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 `OrangeThemeColorSemanticTokensProvider`
/// - 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`
/// - borders: An object providing all the border semantic tokens, as `AllBorderSemanticTokensProvider` implementation, default set to `OUDSBorderSemanticTokensProvider`
/// - elevations: An object providing all the elevation semantic tokens, by default `AllElevationSemanticTokensProvider`, 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 `OUDSOpacitySemanticTokensProvider`
/// - sizes: An object providing all the size semantic tokens, as `AllSizeSemanticTokens` implementation, default set to `OUDSSizeSemanticTokensProvider`
/// - spaces: An object providing all the space semantic tokens, as `AllSpaceSemanticTokens` implementation, default set to `OUDSSpaceSemanticTokensProvider`
override public init(colors: AllColorSemanticTokens = OrangeThemeColorSemanticTokensProvider(),
borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(),
fonts: AllFontSemanticTokens = OUDSFontSemanticTokensProvider(),
grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensProvider(),
sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensProvider(),
spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensProvider()) {
/// - grids: An object providing all the grid semantic tokens, by default `AllGridSemanticTokensProvider`, default set to `OUDSGridSemanticTokensProvider`
/// - opacities: An object providing all the opacity semantic tokens, as `AllOpacitySemanticTokensProvider` implementation, default set to `OUDSOpacitySemanticTokensProvider`
/// - sizes: An object providing all the size semantic tokens, as `AllSizeSemanticTokensProvider` implementation, default set to `OUDSSizeSemanticTokensProvider`
/// - spaces: An object providing all the space semantic tokens, as `AllSpaceSemanticTokensProvider` implementation, default set to `OUDSSpaceSemanticTokensProvider`
override public init(colors: AllColorSemanticTokensProvider = OrangeThemeColorSemanticTokensProvider(),
borders: AllBorderSemanticTokensProvider = OUDSBorderSemanticTokensProvider(),
elevations: AllElevationSemanticTokensProvider = OUDSElevationSemanticTokensProvider(),
fonts: AllFontSemanticTokensProvider = OUDSFontSemanticTokensProvider(),
grids: AllGridSemanticTokensProvider = OUDSGridSemanticTokensProvider(),
opacities: AllOpacitySemanticTokensProvider = OUDSOpacitySemanticTokensProvider(),
sizes: AllSizeSemanticTokensProvider = OUDSSizeSemanticTokensProvider(),
spaces: AllSpaceSemanticTokensProvider = OUDSSpaceSemanticTokensProvider()) {
OUDSLogger.debug("Init of OrangeTheme")
super.init(colors: colors,
borders: borders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import OUDSFoundations

/// A class which wraps all **border semantic tokens** and expose them.
/// This provider should be integrated as a ``AllBorderSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllBorderSemanticTokensProvider`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import OUDSFoundations

/// A class which wraps all **color semantic tokens**, *multiple* or not, and expose them.
/// This provider should be integrated as a ``AllColorSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllColorSemanticTokensProvider`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import OUDSFoundations

/// A class which wraps all **elevation semantic tokens**, *multiple*, *composite* or not, and expose them.
/// This provider should be integrated as a ``AllElevationSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllElevationSemanticTokensProvider`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import OUDSFoundations

/// A class which wraps all **font semantic tokens**, *multiple*, *composite* or not, and expose them.
/// This provider should be integrated as a ``AllFontSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllFontSemanticTokensProvider`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import OUDSFoundations

/// A class which wraps all **grid semantic tokens** and expose them.
/// This provider should be integrated as a ``AllGridSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllGridSemanticTokensProvider`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import OUDSFoundations

/// A class which wraps all **opacity semantic tokens** and expose them.
/// This provider should be integrated as a ``AllOpacitySemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllOpacitySemanticTokensProvider`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import OUDSFoundations

/// A class which wraps all **size semantic tokens**, *multiple* or not, and expose them.
/// This provider should be integrated as a ``AllSizeSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllSizeSemanticTokensProvider`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@
/// A type alias only for ``BorderSemanticTokens`` so as to keep consistency with other type aliases
/// merging several protocols
/// For example ``OUDSBorderSemanticTokensProvider`` matches this type alias.
public typealias AllBorderSemanticTokens = BorderSemanticTokens
public typealias AllBorderSemanticTokensProvider = BorderSemanticTokens

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

/// A type alias only for ``GridSemanticTokens`` so as to keep consistency with other type aliases
/// merging several protocols.
/// For example ``OUDSGridSemanticTokensProvider`` matches this type alias.
public typealias AllGridSemanticTokens = GridSemanticTokens
public typealias AllGridSemanticTokensProvider = GridSemanticTokens

/// A type alias which merges ``ColorSemanticTokens`` and ``ColorMultipleSemanticTokens``.
/// It helps in the end to define a provider for all the semantic tokens of colors, multiple or not, generated or not.
/// For example ``OUDSColorSemanticTokensProvider`` matches this type alias.
public typealias AllColorSemanticTokens = ColorSemanticTokens & ColorMultipleSemanticTokens
public typealias AllColorSemanticTokensProvider = ColorSemanticTokens & ColorMultipleSemanticTokens

/// A type alias which merges ``ElevationSemanticTokens``, ``ElevationCompositeSemanticTokens`` and ``ElevationMultipleSemanticTokens``.
/// It helps in the end to define a provider for all the semantic tokens of elevations, multiple or not, generated or not.
/// For example ``OUDSElevationSemanticTokensProvider`` matches this type alias.
public typealias AllElevationSemanticTokens = ElevationSemanticTokens & ElevationCompositeSemanticTokens & ElevationMultipleSemanticTokens
public typealias AllElevationSemanticTokensProvider = ElevationSemanticTokens & ElevationCompositeSemanticTokens & ElevationMultipleSemanticTokens

/// A type alias which merges ``FontSemanticTokens``, ``FontCompositeSemanticTokens`` and ``FontMultipleSemanticTokens``.
/// It helps in the end to define a provider for all the semantic tokens of fonts, multiple, composite, or not, generated or not.
/// For example ``OUDSFontSemanticTokensProvider`` matches this type alias.
public typealias AllFontSemanticTokens = FontSemanticTokens & FontCompositeSemanticTokens & FontMultipleSemanticTokens
public typealias AllFontSemanticTokensProvider = FontSemanticTokens & FontCompositeSemanticTokens & FontMultipleSemanticTokens

/// A type alias which merges ``SizeSemanticTokens`` and ``SizeMultipleSemanticTokens``.
/// It helps in the end to define a provider for all the semantic tokens of size, multiple or not, generated or not.
/// For example ``OUDSSizeSemanticTokensProvider`` matches this type alias.
public typealias AllSizeSemanticTokens = SizeSemanticTokens & SizeMultipleSemanticTokens
public typealias AllSizeSemanticTokensProvider = SizeSemanticTokens & SizeMultipleSemanticTokens

/// A type alias which merges ``SpaceSemanticTokens`` and ``SpaceMultipleSemanticTokens``.
/// It helps in the end to define a provider for all the semantic tokens of space, multiple or not, generated or not.
/// For example ``OUDSSpaceSemanticTokensProvider`` matches this type alias.
public typealias AllSpaceSemanticTokens = SpaceSemanticTokens & SpaceMultipleSemanticTokens
public typealias AllSpaceSemanticTokensProvider = SpaceSemanticTokens & SpaceMultipleSemanticTokens
Loading

0 comments on commit def7d05

Please sign in to comment.