From 892f6e2f9c6524bae66e54e135755deee6d04474 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Lapersonne Date: Fri, 13 Dec 2024 16:16:48 +0100 Subject: [PATCH] chore: change parameters and attributes order for themes (#79) Signed-off-by: Pierre-Yves Lapersonne --- .../Sources/Extensions/View+Typography.swift | 46 ++++++++-------- .../TypographyModifier.swift | 4 +- .../_OUDSComponents.docc/_OUDSComponents.md | 2 +- .../OUDS/Sources/OUDSTheme/OUDSTheme.swift | 54 +++++++++---------- .../OUDSTheme/MockThemes/MockTheme.swift | 20 +++---- .../TestThemeOverrideOfThemeProperties.swift | 6 +-- .../Themes/Orange/Sources/OrangeTheme.swift | 20 +++---- .../Pages/Tokens/Font/FontTokenPage.swift | 2 +- 8 files changed, 77 insertions(+), 77 deletions(-) diff --git a/OUDS/Core/Components/Sources/Extensions/View+Typography.swift b/OUDS/Core/Components/Sources/Extensions/View+Typography.swift index 51b83d89bf..7cd190a7ad 100644 --- a/OUDS/Core/Components/Sources/Extensions/View+Typography.swift +++ b/OUDS/Core/Components/Sources/Extensions/View+Typography.swift @@ -23,7 +23,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeDisplayLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeDisplayLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeDisplayLarge)) } /// Modifies the current `View` to apply a *display medium* typography. @@ -31,7 +31,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeDisplayMedium(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeDisplayMedium)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeDisplayMedium)) } /// Modifies the current `View` to apply a *display small* typography. @@ -39,7 +39,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeDisplaySmall(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeDisplaySmall)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeDisplaySmall)) } /// Modifies the current `View` to apply a *heading x large* typography. @@ -47,7 +47,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeHeadingXLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeHeadingXLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeHeadingXLarge)) } /// Modifies the current `View` to apply a *heading large* typography. @@ -55,7 +55,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeHeadingLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeHeadingLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeHeadingLarge)) } /// Modifies the current `View` to apply a *heading medium* typography. @@ -63,7 +63,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeHeadingMedium(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeHeadingMedium)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeHeadingMedium)) } /// Modifies the current `View` to apply a *heading small* typography. @@ -71,7 +71,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeHeadingSmall(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeHeadingSmall)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeHeadingSmall)) } /// Modifies the current `View` to apply a *body default large* typography. @@ -79,7 +79,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeBodyDefaultLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyDefaultLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyDefaultLarge)) } /// Modifies the current `View` to apply a *body default medium* typography. @@ -87,7 +87,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeBodyDefaultMedium(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyDefaultMedium)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyDefaultMedium)) } /// Modifies the current `View` to apply a *body default small* typography. @@ -95,7 +95,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeBodyDefaultSmall(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyDefaultSmall)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyDefaultSmall)) } /// Modifies the current `View` to apply a *body strong large* typography. @@ -103,7 +103,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeBodyStrongLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyStrongLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyStrongLarge)) } /// Modifies the current `View` to apply a *body strong medium* typography. @@ -111,7 +111,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeBodyStrongMedium(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyStrongMedium)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyStrongMedium)) } /// Modifies the current `View` to apply a *body strong small* typography. @@ -119,7 +119,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeBodyStrongSmall(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyStrongSmall)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyStrongSmall)) } /// Modifies the current `View` to apply a *label default x large* typography. @@ -127,7 +127,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelDefaultXLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeLabelDefaultXLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeLabelDefaultXLarge)) } /// Modifies the current `View` to apply a *label default large* typography. @@ -135,7 +135,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelDefaultLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyDefaultLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyDefaultLarge)) } /// Modifies the current `View` to apply a *label default medium* typography. @@ -143,7 +143,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelDefaultMedium(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyDefaultMedium)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyDefaultMedium)) } /// Modifies the current `View` to apply a *label default small* typography. @@ -151,7 +151,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelDefaultSmall(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeBodyDefaultSmall)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeBodyDefaultSmall)) } /// Modifies the current `View` to apply a *label strong x large* typography. @@ -159,7 +159,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelStrongXLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeLabelStrongXLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeLabelStrongXLarge)) } /// Modifies the current `View` to apply a *label strong large* typography. @@ -167,7 +167,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelStrongLarge(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeLabelStrongLarge)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeLabelStrongLarge)) } /// Modifies the current `View` to apply a *label strong medium* typography. @@ -175,7 +175,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelStrongMedium(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeLabelStrongMedium)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeLabelStrongMedium)) } /// Modifies the current `View` to apply a *label strong small* typography. @@ -183,7 +183,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeLabelStrongSmall(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeLabelStrongSmall)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeLabelStrongSmall)) } /// Modifies the current `View` to apply a *code medium* typography. @@ -191,7 +191,7 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeCodeMedium(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeCodeMedium)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeCodeMedium)) } /// Modifies the current `View` to apply a *code small* typography. @@ -199,6 +199,6 @@ extension View { /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable font semantic token. /// - Returns some View: The current `View` but with new typography applied public func typeCodeSmall(_ theme: OUDSTheme) -> some View { - self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, font: theme.fonts.typeCodeSmall)) + self.modifier(TypographyModifier(fontFamily: theme.fontFamily, font: theme.fonts.typeCodeSmall)) } } diff --git a/OUDS/Core/Components/Sources/ViewModifiers/TypographyModifiers/TypographyModifier.swift b/OUDS/Core/Components/Sources/ViewModifiers/TypographyModifiers/TypographyModifier.swift index 2796ab9508..0322c8dc78 100644 --- a/OUDS/Core/Components/Sources/ViewModifiers/TypographyModifiers/TypographyModifier.swift +++ b/OUDS/Core/Components/Sources/ViewModifiers/TypographyModifiers/TypographyModifier.swift @@ -27,7 +27,7 @@ import SwiftUI struct TypographyModifier: ViewModifier { /// The name of a possible custom font family, or `nil` if the font is use is _system font_ - let customFontFamily: FontFamilyRawToken? + let fontFamily: FontFamilyRawToken? /// The typography to apply for *compact* or *regular* modes, i.e. font tokens let font: MultipleFontCompositeRawTokens @@ -61,7 +61,7 @@ struct TypographyModifier: ViewModifier { // using UIFontMetrics to scale the font size, ensuring Dynamic Type support let scaledFontSize = UIFontMetrics.default.scaledValue(for: fontSize) - if let fontFamilyName = customFontFamily { + if let fontFamilyName = fontFamily { let composedFontFamily = fontFamilyName.compose(withFont: "\(adaptiveFont.weight.fontWeight)") let customFont: Font = .custom(composedFontFamily, size: adaptiveFont.size) return customFont diff --git a/OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md b/OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md index 8fb9e71148..67bf5c2414 100644 --- a/OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md +++ b/OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md @@ -53,7 +53,7 @@ public static let typeBold1050 = FontCompositeRawToken(size: fontSize1050, lineH ``` However the _theme_ must know which _font family_ to apply, and this font family can be a _custom one_ or the _system one_. -Thus, we let the users define the font family they want by overriding the `customFontFamily` property. This value will be used to compute the typography, if not defined the systme font will be used. +Thus, we let the users define the font family they want by overriding the `fontFamily` property. This value will be used to compute the typography, if not defined the systme font will be used. Thus, if you want to apply a specific typography to a `View`, supposing you defined previously the semantic tokens, just call the method you want and gives as parameter the theme (to get the custom font if defined): diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift index bccdd7069a..47815b480d 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift @@ -29,76 +29,76 @@ open class OUDSTheme: @unchecked Sendable { // MARK: - Properties - /// All border semantic tokens exposed in one object - public let borders: AllBorderSemanticTokens - - /// All opacity semantic tokens exposed in one object - public let opacities: AllOpacitySemanticTokens - /// All color semantic tokens exposed in one object public let colors: AllColorSemanticTokens + /// All border semantic tokens exposed in one object + public let borders: AllBorderSemanticTokens + /// All elevation semantic tokens exposed in one object public let elevations: AllElevationSemanticTokens + /// 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 /// All grid semantic tokens exposed in one object public let grids: AllGridSemanticTokens - /// A theme can have a custom font which is not the system font - public let customFontFamily: FontFamilySemanticToken? + /// All opacity semantic tokens exposed in one object + public let opacities: AllOpacitySemanticTokens // MARK: - Initializers /// Defines a basic kind of abstract theme to subclass then. /// No custom font family will be used. /// - Parameters: - /// - borders: An object providing all the border semantic tokens, by default `OUDSBorderSemanticTokensWrapper` - /// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensWrapper` /// - colors: An object providing all the color semantic tokens, by default `OUDSColorSemanticTokensWrapper` + /// - borders: An object providing all the border semantic tokens, by default `OUDSBorderSemanticTokensWrapper` /// - 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` - public init(borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensWrapper(), - opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper(), - colors: AllColorSemanticTokens = OUDSColorSemanticTokensWrapper(), + /// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensWrapper` + public init(colors: AllColorSemanticTokens = OUDSColorSemanticTokensWrapper(), + borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensWrapper(), elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensWrapper(), fonts: AllFontSemanticTokens = OUDSFontSemanticTokensWrapper(), - grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper()) { - self.borders = borders - self.opacities = opacities + grids: AllGridSemanticTokens = OUDSGridSemanticTokensWrapper(), + opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensWrapper()) { self.colors = colors + self.borders = borders self.elevations = elevations + fontFamily = nil self.fonts = fonts self.grids = grids - customFontFamily = nil + self.opacities = opacities } /// Defines a basic kind of abstract theme to subclass then. /// - Parameters: - /// - borders: An object providing all the border semantic tokens, as `BorderSemanticTokens` implementation - /// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation /// - 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` + /// - 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` - /// - customFontFamily: Set `nil` if system font to use, otherwise use the `FontFamilySemanticToken` you want to apply - public init(borders: AllBorderSemanticTokens, - opacities: AllOpacitySemanticTokens, - colors: AllColorSemanticTokens, + /// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation + public init(colors: AllColorSemanticTokens, + borders: AllBorderSemanticTokens, elevations: AllElevationSemanticTokens, + fontFamily: FontFamilySemanticToken?, fonts: AllFontSemanticTokens, grids: AllGridSemanticTokens, - customFontFamily: FontFamilySemanticToken?) { - self.borders = borders - self.opacities = opacities + opacities: AllOpacitySemanticTokens) { self.colors = colors + self.borders = borders self.elevations = elevations + self.fontFamily = fontFamily self.fonts = fonts self.grids = grids - self.customFontFamily = customFontFamily + self.opacities = opacities } deinit { } diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme.swift index 262907211b..89bd545a2b 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme.swift @@ -28,28 +28,28 @@ import OUDSTokensSemantic open class MockTheme: OUDSTheme, @unchecked Sendable { convenience init() { - self.init(customFont: nil) + self.init(fontFamily: nil) } /// For ``OtherMockTheme`` init(colors: AllColorSemanticTokens) { - super.init(borders: MockThemeBorderSemanticTokensWrapper(), - opacities: MockThemeOpacitySemanticTokensWrapper(), - colors: colors, + super.init(colors: colors, + borders: MockThemeBorderSemanticTokensWrapper(), elevations: MockThemeElevationSemanticTokensWrapper(), + fontFamily: nil, fonts: MockThemeFontSemanticTokensWrapper(), grids: MockThemeGridSemanticTokensWrapper(), - customFontFamily: nil) + opacities: MockThemeOpacitySemanticTokensWrapper()) } - init(customFont: String?) { - super.init(borders: MockThemeBorderSemanticTokensWrapper(), - opacities: MockThemeOpacitySemanticTokensWrapper(), - colors: MockThemeColorSemanticTokensWrapper(), + init(fontFamily: String?) { + super.init(colors: MockThemeColorSemanticTokensWrapper(), + borders: MockThemeBorderSemanticTokensWrapper(), elevations: MockThemeElevationSemanticTokensWrapper(), + fontFamily: fontFamily, fonts: MockThemeFontSemanticTokensWrapper(), grids: MockThemeGridSemanticTokensWrapper(), - customFontFamily: customFont) + opacities: MockThemeOpacitySemanticTokensWrapper()) } deinit { } diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfThemeProperties.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfThemeProperties.swift index d09410f0b6..b54a268d66 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfThemeProperties.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfThemeProperties.swift @@ -31,9 +31,9 @@ final class TestThemeOverrideOfThemeProperties: XCTestCase { inheritedTheme = MockTheme(customFont: "Mr R08øT") } - func testInheritedThemeCanOverrideCustomFontFamily() throws { - XCTAssertNotEqual(inheritedTheme.customFontFamily, abstractTheme.customFontFamily) - XCTAssertTrue(inheritedTheme.customFontFamily == "Mr R08øT") + func testInheritedThemeCanOverrideFontFamily() throws { + XCTAssertNotEqual(inheritedTheme.fontFamily, abstractTheme.fontFamily) + XCTAssertTrue(inheritedTheme.fontFamily == "Mr R08øT") } } diff --git a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift index f819d728b1..d792424de7 100644 --- a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift +++ b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift @@ -36,24 +36,24 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable { /// Initializes the `OrangeTheme` and lets children classes to user their own tokens implementations /// - Parameters: - /// - borders: An object providing all the border semantic tokens, as `BorderSemanticTokens` implementation - /// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation /// - 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` /// - fonts: An object providing all the font semantic tokens, by default `AllFontemanticTokens` /// - grids: An object providing all the grid semantic tokens, by default `AllGridSemanticTokens` - override public init(borders: AllBorderSemanticTokens, - opacities: AllOpacitySemanticTokens, - colors: AllColorSemanticTokens, + /// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation + override public init(colors: AllColorSemanticTokens, + borders: AllBorderSemanticTokens, elevations: AllElevationSemanticTokens, fonts: AllFontSemanticTokens, - grids: AllGridSemanticTokens) { - super.init(borders: borders, - opacities: opacities, - colors: colors, + grids: AllGridSemanticTokens, + opacities: AllOpacitySemanticTokens) { + super.init(colors: colors, + borders: borders, elevations: elevations, fonts: fonts, - grids: grids) + grids: grids, + opacities: opacities) } deinit { } diff --git a/Showcase/Showcase/Pages/Tokens/Font/FontTokenPage.swift b/Showcase/Showcase/Pages/Tokens/Font/FontTokenPage.swift index a1fd50adbb..e277cdc082 100644 --- a/Showcase/Showcase/Pages/Tokens/Font/FontTokenPage.swift +++ b/Showcase/Showcase/Pages/Tokens/Font/FontTokenPage.swift @@ -54,7 +54,7 @@ struct FontTokenPage: View { .foregroundStyle(theme.colors.colorContentDefault.color(for: colorScheme)) Group { - Text("family (\(theme.customFontFamily ?? "system")), ") + Text("family (\(theme.fontFamily ?? "system")), ") + Text("weight (\(token.weight)), ") + Text("size (\(token.size, specifier: "%.2f")), ") + Text("lineHeight (\(token.lineHeight, specifier: "%.2f")), ")