From 9a4db77f4fbad08c381d343e8eed663ec66305a3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Lapersonne Date: Mon, 7 Oct 2024 15:18:30 +0200 Subject: [PATCH] refactor: typography semantic tokens for letter spacing (#155) Closes #155 Signed-off-by: Pierre-Yves Lapersonne --- CHANGELOG.md | 3 +- .../OUDSTheme+TypographySemanticTokens.swift | 53 +++----- .../MockTheme+SpacingSemanticTokens.swift | 2 +- .../MockTheme+TypographySemanticTokens.swift | 56 +++----- ...ThemeOverrideOfSpacingSemanticTokens.swift | 2 +- ...meOverrideOfTypographySemanticTokens.swift | 128 ++++++------------ .../MultipleFontLetterSpacingTokens.swift | 50 +++++++ .../Multiples/MultipleTypographyTokens.swift | 2 +- .../Values/SpacingSemanticTokens.swift | 6 +- .../Values/TypographySemanticTokens.swift | 53 +++----- ...MultipleFontLetterSpacingTokensTests.swift | 57 ++++++++ .../MultipleFontLineHeightTokensTests.swift | 2 +- .../MultipleTypographyTokensTests.swift | 2 +- 13 files changed, 214 insertions(+), 202 deletions(-) create mode 100644 OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleFontLetterSpacingTokens.swift create mode 100644 OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLetterSpacingTokensTests.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 9476f10333..ba9b8ce019 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- [Library] `fontLetterSpacingMobile*` and `fontLetterSpacingTablet*` merged in `MultipleFontLetterSpacingTokens` objects - [Library] `fontLineHeightMobile*` and `fontLineHeightTablet*` merged in `MultipleFontLineHeightTokens` objects - [Library] `fontSizeMobile*` and `fontSizeTablet*` merged in `MultipleFontSizeTokens` objects - [Library] Update semantic and raw tokens for fonts ([#155](https://github.com/Orange-OpenSource/ouds-ios/issues/155)) @@ -23,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed -- [Library] `fontSizeMobile*`, `fontSizeTablet*`, `fontLineHeightMobile*`, `fontLineHeightTablet*` removed +- [Library] `fontSizeMobile*`, `fontSizeTablet*`, `fontLineHeightMobile*`, `fontLineHeightTablet*`, `fontLetterSpacingMobile*`, `fontLetterSpacingTablet*` removed (update of October 4th) - [Library] `spaceRowGapWithIconTaller`, `spaceColumnGapWithIconTaller` removed (update of October 7th) ## [0.3.0](https://github.com/Orange-OpenSource/ouds-ios/compare/0.2.0...0.3.0) - 2024-10-04 diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift index 26ed3e73a0..cb88a12c81 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift @@ -86,40 +86,25 @@ extension OUDSTheme: TypographySemanticTokens { @objc open var fontLineHeightCodeMedium: MultipleFontLineHeightTokens { MultipleFontLineHeightTokens(TypographyRawTokens.fontLineHeight350) } @objc open var fontLineHeightCodeSmall: MultipleFontLineHeightTokens { MultipleFontLineHeightTokens(TypographyRawTokens.fontLineHeight250) } - // MARK: - Semantic token - Typography - Font - Letter spacing - Mobile (extra-compact/compact) - - @objc open var fontLetterSpacingMobileDisplayLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing850 } - @objc open var fontLetterSpacingMobileDisplayMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing750 } - @objc open var fontLetterSpacingMobileDisplaySmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing650 } - @objc open var fontLetterSpacingMobileHeadingXLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing550 } - @objc open var fontLetterSpacingMobileHeadingLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing450 } - @objc open var fontLetterSpacingMobileHeadingMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing350 } - @objc open var fontLetterSpacingMobileHeadingSmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing300 } - @objc open var fontLetterSpacingMobileBodyLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing250 } - @objc open var fontLetterSpacingMobileBodyMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing200 } - @objc open var fontLetterSpacingMobileBodySmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing150 } - - // MARK: - Semantic token - Typography - Font - Letter spacing - Tablet (regular/medium) - - @objc open var fontLetterSpacingTabletDisplayLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing1450 } - @objc open var fontLetterSpacingTabletDisplayMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing1050 } - @objc open var fontLetterSpacingTabletDisplaySmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing850 } - @objc open var fontLetterSpacingTabletHeadingXLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing750 } - @objc open var fontLetterSpacingTabletHeadingLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing550 } - @objc open var fontLetterSpacingTabletHeadingMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing450 } - @objc open var fontLetterSpacingTabletHeadingSmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing350 } - @objc open var fontLetterSpacingTabletBodyLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing250 } - @objc open var fontLetterSpacingTabletBodyMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing200 } - @objc open var fontLetterSpacingTabletBodySmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing150 } - - // MARK: - Semantic token - Typography - Font - Letter spacing - Others - - @objc open var fontLetterSpacingLabelXLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing300 } - @objc open var fontLetterSpacingLabelLarge: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing250 } - @objc open var fontLetterSpacingLabelMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing200 } - @objc open var fontLetterSpacingLabelSmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing150 } - @objc open var fontLetterSpacingCodeMedium: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing200 } - @objc open var fontLetterSpacingCodeSmall: TypographyFontLetterSpacingSemanticToken { TypographyRawTokens.fontLetterSpacing150 } + // MARK: - Semantic token - Typography - Font - Letter spacing + + @objc open var fontLetterSpacingDisplayLarge: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing850, regular: TypographyRawTokens.fontLetterSpacing1450) } + @objc open var fontLetterSpacingDisplayMedium: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing750, regular: TypographyRawTokens.fontLetterSpacing1050) } + @objc open var fontLetterSpacingDisplaySmall: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing650, regular: TypographyRawTokens.fontLetterSpacing850 ) } + @objc open var fontLetterSpacingHeadingXLarge: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing550, regular: TypographyRawTokens.fontLetterSpacing750) } + @objc open var fontLetterSpacingHeadingLarge: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing450, regular: TypographyRawTokens.fontLetterSpacing750) } + @objc open var fontLetterSpacingHeadingMedium: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing350, regular: TypographyRawTokens.fontLetterSpacing450) } + @objc open var fontLetterSpacingHeadingSmall: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing300, regular: TypographyRawTokens.fontLetterSpacing350 ) } + @objc open var fontLetterSpacingBodyLarge: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing150, regular: TypographyRawTokens.fontLetterSpacing150) } + @objc open var fontLetterSpacingBodyMedium: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing200, regular: TypographyRawTokens.fontLetterSpacing200) } + @objc open var fontLetterSpacingBodySmall: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing150, regular: TypographyRawTokens.fontLetterSpacing150) } + + @objc open var fontLetterSpacingLabelXLarge: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(TypographyRawTokens.fontLetterSpacing300) } + @objc open var fontLetterSpacingLabelLarge: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(TypographyRawTokens.fontLetterSpacing250) } + @objc open var fontLetterSpacingLabelMedium: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(TypographyRawTokens.fontLetterSpacing200) } + @objc open var fontLetterSpacingLabelSmall: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(TypographyRawTokens.fontLetterSpacing150) } + @objc open var fontLetterSpacingCodeMedium: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(TypographyRawTokens.fontLineHeight350) } + @objc open var fontLetterSpacingCodeSmall: MultipleFontLetterSpacingTokens { MultipleFontLetterSpacingTokens(TypographyRawTokens.fontLineHeight250) } // MARK: - Semantic tokens - Typography - Composites - Display diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SpacingSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SpacingSemanticTokens.swift index 0d9a780284..afaebf0f7a 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SpacingSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SpacingSemanticTokens.swift @@ -82,7 +82,7 @@ extension MockTheme { override var spacePaddingBlockMedium: SpacingPaddingInlineSemanticToken { Self.mockThemeSpaceRawToken } override var spacePaddingBlockTall: SpacingPaddingInlineSemanticToken { Self.mockThemeSpaceRawToken } override var spacePaddingBlockTaller: SpacingPaddingInlineSemanticToken { Self.mockThemeSpaceRawToken } - + override var spacePaddingBlockWithIconNone: SpacingPaddingInlineSemanticToken { Self.mockThemeSpaceRawToken } override var spacePaddingBlockWithIconShortest: SpacingPaddingInlineSemanticToken { Self.mockThemeSpaceRawToken } override var spacePaddingBlockWithIconShorter: SpacingPaddingInlineSemanticToken { Self.mockThemeSpaceRawToken } diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+TypographySemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+TypographySemanticTokens.swift index c7d6323e09..a0886fd8f1 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+TypographySemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+TypographySemanticTokens.swift @@ -24,6 +24,7 @@ extension MockTheme { static let mockThemeMultipleTypographyTokens = MultipleTypographyTokens(TypographyRawTokens.typeBold1850) static let mockThemeMultipleTypographyFontSizeTokens = MultipleFontSizeTokens(mockThemeTypographyFontSizeRawToken) static let mockThemeMultipleTypographyLineHeightTokens = MultipleFontLineHeightTokens(mockThemeTypographyFontLineHeightRawToken) + static let mockThemeMultipleTypographyLetterSpacingTokens = MultipleFontLetterSpacingTokens(mockThemeTypographyFontLetterSpacingRawToken) // MARK: Semantic token - Typography - Font - Family @@ -45,7 +46,7 @@ extension MockTheme { override var fontWeightCode: TypographyFontWeightSemanticToken { Self.mockThemeTypographyFontWeightRawToken } // MARK: Semantic token - Typography - Font - Size - + override var fontSizeDisplayLarge: MultipleFontSizeTokens { Self.mockThemeMultipleTypographyFontSizeTokens } override var fontSizeDisplayMedium: MultipleFontSizeTokens { Self.mockThemeMultipleTypographyFontSizeTokens } override var fontSizeDisplaySmall: MultipleFontSizeTokens { Self.mockThemeMultipleTypographyFontSizeTokens } @@ -85,40 +86,25 @@ extension MockTheme { override var fontLineHeightCodeMedium: MultipleFontLineHeightTokens { Self.mockThemeMultipleTypographyLineHeightTokens } override var fontLineHeightCodeSmall: MultipleFontLineHeightTokens { Self.mockThemeMultipleTypographyLineHeightTokens } - // MARK: - Semantic token - Typography - Font - Letter spacing - Mobile (extra-compact/compact) - - override var fontLetterSpacingMobileDisplayLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileDisplayMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileDisplaySmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileHeadingXLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileHeadingLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileHeadingMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileHeadingSmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileBodyLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileBodyMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingMobileBodySmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - - // MARK: - Semantic token - Typography - Font - Letter spacing - Tablet (regular/medium) - - override var fontLetterSpacingTabletDisplayLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletDisplayMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletDisplaySmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletHeadingXLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletHeadingLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletHeadingMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletHeadingSmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletBodyLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletBodyMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingTabletBodySmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - - // MARK: - Semantic token - Typography - Font - Letter spacing - Others - - override var fontLetterSpacingLabelXLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingLabelLarge: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingLabelMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingLabelSmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingCodeMedium: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } - override var fontLetterSpacingCodeSmall: TypographyFontLetterSpacingSemanticToken { Self.mockThemeTypographyFontLetterSpacingRawToken } + // MARK: - Semantic token - Typography - Font - Letter spacing + + override var fontLetterSpacingDisplayLarge: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingDisplayMedium: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingDisplaySmall: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingHeadingXLarge: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingHeadingLarge: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingHeadingMedium: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingHeadingSmall: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingBodyLarge: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingBodyMedium: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingBodySmall: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + + override var fontLetterSpacingLabelXLarge: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingLabelLarge: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingLabelMedium: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingLabelSmall: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingCodeMedium: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } + override var fontLetterSpacingCodeSmall: MultipleFontLetterSpacingTokens { Self.mockThemeMultipleTypographyLetterSpacingTokens } // MARK: - Semantic tokens - Typography - Composites - Display diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpacingSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpacingSemanticTokens.swift index 502046954f..06c546f74d 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpacingSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpacingSemanticTokens.swift @@ -299,7 +299,7 @@ final class TestThemeOverrideOfSpacingSemanticTokens: XCTestCase { XCTAssertNotEqual(inheritedTheme.spacePaddingBlockWithIconShortest, abstractTheme.spacePaddingBlockWithIconShortest) XCTAssertTrue(inheritedTheme.spacePaddingBlockWithIconShortest == MockTheme.mockThemeSpaceRawToken) } - + func testInheritedThemeCanOverrideSemanticTokenSpacePaddingBlockWithIconShorter() throws { XCTAssertNotEqual(inheritedTheme.spacePaddingBlockWithIconShorter, abstractTheme.spacePaddingBlockWithIconShorter) XCTAssertTrue(inheritedTheme.spacePaddingBlockWithIconShorter == MockTheme.mockThemeSpaceRawToken) diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfTypographySemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfTypographySemanticTokens.swift index 79944347e9..70768c39e7 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfTypographySemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfTypographySemanticTokens.swift @@ -185,141 +185,89 @@ final class TestThemeOverrideOfTypographySemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.fontSizeCodeSmall == MockTheme.mockThemeTypographyFontSizeRawToken) } - // MARK: - Semantic token - Typography - Font - Letter spacing - Mobile + // MARK: - Semantic token - Typography - Font - Letter spacing - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileDisplayLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileDisplayLarge, abstractTheme.fontLetterSpacingMobileDisplayLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileDisplayLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenfontLetterSpacingDisplayLarge() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingDisplayLarge, abstractTheme.fontLetterSpacingDisplayLarge) + XCTAssertTrue(inheritedTheme.fontLetterSpacingDisplayLarge == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileDisplayMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileDisplayMedium, abstractTheme.fontLetterSpacingMobileDisplayMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileDisplayMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingDisplayMedium() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingDisplayMedium, abstractTheme.fontLetterSpacingDisplayMedium) + XCTAssertTrue(inheritedTheme.fontLetterSpacingDisplayMedium == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileDisplaySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileDisplaySmall, abstractTheme.fontLetterSpacingMobileDisplaySmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileDisplaySmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingDisplaySmall() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingDisplaySmall, abstractTheme.fontLetterSpacingDisplaySmall) + XCTAssertTrue(inheritedTheme.fontLetterSpacingDisplaySmall == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileHeadingXLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileHeadingXLarge, abstractTheme.fontLetterSpacingMobileHeadingXLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileHeadingXLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingHeadingXLarge() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingHeadingXLarge, abstractTheme.fontLetterSpacingHeadingXLarge) + XCTAssertTrue(inheritedTheme.fontLetterSpacingHeadingXLarge == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileHeadingLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileHeadingLarge, abstractTheme.fontLetterSpacingMobileHeadingLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileHeadingLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingHeadingLarge() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingHeadingLarge, abstractTheme.fontLetterSpacingHeadingLarge) + XCTAssertTrue(inheritedTheme.fontLetterSpacingHeadingLarge == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileHeadingMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileHeadingMedium, abstractTheme.fontLetterSpacingMobileHeadingMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileHeadingMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingHeadingMedium() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingHeadingMedium, abstractTheme.fontLetterSpacingHeadingMedium) + XCTAssertTrue(inheritedTheme.fontLetterSpacingHeadingMedium == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileHeadingSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileHeadingSmall, abstractTheme.fontLetterSpacingMobileHeadingSmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileHeadingSmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingHeadingSmall() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingHeadingSmall, abstractTheme.fontLetterSpacingHeadingSmall) + XCTAssertTrue(inheritedTheme.fontLetterSpacingHeadingSmall == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileBodyLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileBodyLarge, abstractTheme.fontLetterSpacingMobileBodyLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileBodyLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingBodyLarge() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingBodyLarge, abstractTheme.fontLetterSpacingBodyLarge) + XCTAssertTrue(inheritedTheme.fontLetterSpacingBodyLarge == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileBodyMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileBodyMedium, abstractTheme.fontLetterSpacingMobileBodyMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileBodyMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingBodyMedium() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingBodyMedium, abstractTheme.fontLetterSpacingBodyMedium) + XCTAssertTrue(inheritedTheme.fontLetterSpacingBodyMedium == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingMobileBodySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingMobileBodySmall, abstractTheme.fontLetterSpacingMobileBodySmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingMobileBodySmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - // MARK: - Semantic token - Typography - Font - Letter spacing - Tablet - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletDisplayLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletDisplayLarge, abstractTheme.fontLetterSpacingTabletDisplayLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletDisplayLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletDisplayMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletDisplayMedium, abstractTheme.fontLetterSpacingTabletDisplayMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletDisplayMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletDisplaySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletDisplaySmall, abstractTheme.fontLetterSpacingTabletDisplaySmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletDisplaySmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletHeadingXLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletHeadingXLarge, abstractTheme.fontLetterSpacingTabletHeadingXLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletHeadingXLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletHeadingLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletHeadingLarge, abstractTheme.fontLetterSpacingTabletHeadingLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletHeadingLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletHeadingMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletHeadingMedium, abstractTheme.fontLetterSpacingTabletHeadingMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletHeadingMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletHeadingSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletHeadingSmall, abstractTheme.fontLetterSpacingTabletHeadingSmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletHeadingSmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletBodyLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletBodyLarge, abstractTheme.fontLetterSpacingTabletBodyLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletBodyLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletBodyMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletBodyMedium, abstractTheme.fontLetterSpacingTabletBodyMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletBodyMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingTabletBodySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLetterSpacingTabletBodySmall, abstractTheme.fontLetterSpacingTabletBodySmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingTabletBodySmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingBodySmall() throws { + XCTAssertNotEqual(inheritedTheme.fontLetterSpacingBodySmall, abstractTheme.fontLetterSpacingBodySmall) + XCTAssertTrue(inheritedTheme.fontLetterSpacingBodySmall == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingLabelXLarge() throws { XCTAssertNotEqual(inheritedTheme.fontLetterSpacingLabelXLarge, abstractTheme.fontLetterSpacingLabelXLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelXLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelXLarge == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingLabelLarge() throws { XCTAssertNotEqual(inheritedTheme.fontLetterSpacingLabelLarge, abstractTheme.fontLetterSpacingLabelLarge) - XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelLarge == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelLarge == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingLabelMedium() throws { XCTAssertNotEqual(inheritedTheme.fontLetterSpacingLabelMedium, abstractTheme.fontLetterSpacingLabelMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelMedium == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingLabelSmall() throws { XCTAssertNotEqual(inheritedTheme.fontLetterSpacingLabelSmall, abstractTheme.fontLetterSpacingLabelSmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelSmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + XCTAssertTrue(inheritedTheme.fontLetterSpacingLabelSmall == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingCodeMedium() throws { XCTAssertNotEqual(inheritedTheme.fontLetterSpacingCodeMedium, abstractTheme.fontLetterSpacingCodeMedium) - XCTAssertTrue(inheritedTheme.fontLetterSpacingCodeMedium == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + XCTAssertTrue(inheritedTheme.fontLetterSpacingCodeMedium == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } func testInheritedThemeCanOverrideSemanticTokenFontLetterSpacingCodeSmall() throws { XCTAssertNotEqual(inheritedTheme.fontLetterSpacingCodeSmall, abstractTheme.fontLetterSpacingCodeSmall) - XCTAssertTrue(inheritedTheme.fontLetterSpacingCodeSmall == MockTheme.mockThemeTypographyFontLetterSpacingRawToken) + XCTAssertTrue(inheritedTheme.fontLetterSpacingCodeSmall == MockTheme.mockThemeMultipleTypographyLetterSpacingTokens) } - // MARK: - Semantic token - Typography - Font - Line heigh + // MARK: - Semantic token - Typography - Font - Line height func testInheritedThemeCanOverrideSemanticTokenFontLineHeightDisplayLarge() throws { XCTAssertNotEqual(inheritedTheme.fontLineHeightDisplayLarge, abstractTheme.fontLineHeightDisplayLarge) diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleFontLetterSpacingTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleFontLetterSpacingTokens.swift new file mode 100644 index 0000000000..3a9b751c7a --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleFontLetterSpacingTokens.swift @@ -0,0 +1,50 @@ +// +// Software Name: OUDS iOS +// SPDX-FileCopyrightText: Copyright (c) Orange SA +// SPDX-License-Identifier: MIT +// +// This software is distributed under the MIT license, +// the text of which is available at https://opensource.org/license/MIT/ +// or see the "LICENSE" file for more details. +// +// Authors: See CONTRIBUTORS.txt +// Software description: A SwiftUI components library with code examples for Orange Unified Design System +// + +import Foundation +import OUDSTokensRaw + +/// Kind of semantic tokens which will wrap a combination of `MultipleFontLetterSpacingTokens` depending to size classes. +/// Allows to gather the multiple-value tokens from Figma inside one object. +public final class MultipleFontLetterSpacingTokens: NSObject { + + /// For **extra-compact** and **compact** viewports + public let compact: TypographyFontLetterSpacingSemanticToken + + /// For **regular** and **medium** viewports + public let regular: TypographyFontLetterSpacingSemanticToken + + /// Initializes a new multiple font token with the same value for both *compact* and *regular* size classes + /// - Parameter value: The `TypographyFontLetterSpacingSemanticToken` to apply if device in *compact* mode + public init(_ value: TypographyFontLetterSpacingSemanticToken) { + self.compact = value + self.regular = value + } + + /// Initializes a new multiple font token. + /// - Parameters: + /// - compact: The `TypographyFontLetterSpacingSemanticToken` to apply if device in *compact* mode + /// - regular: The `TypographyFontLetterSpacingSemanticToken` to apply if device in *regular* mode + public init(compact: TypographyFontLetterSpacingSemanticToken, regular: TypographyFontLetterSpacingSemanticToken) { + self.compact = compact + self.regular = regular + } + + /// Returns `true` if `self` and `object` has the same `compact` and `regular` values and with `object` + /// as a `MultipleFontTokens`. Otherwise returns `false`. + /// `isEqual` override is preferred for `NSObject`. + public override func isEqual(_ object: Any?) -> Bool { + guard let object = object as? MultipleFontLetterSpacingTokens else { return false } + return self.compact == object.compact && self.regular == object.regular + } +} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleTypographyTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleTypographyTokens.swift index b2d6f544ff..60eca7f02a 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleTypographyTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Multiples/MultipleTypographyTokens.swift @@ -31,7 +31,7 @@ public final class MultipleTypographyTokens: NSObject { self.compact = unique self.regular = unique } - + /// Initializes a new typography composite semantic token. /// - Parameters: /// - compact: The `TypographyCompositeRawToken` to apply if device in *compact* mode diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SpacingSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SpacingSemanticTokens.swift index 5d783665c9..a7c09c51c6 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SpacingSemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SpacingSemanticTokens.swift @@ -83,7 +83,7 @@ public protocol SpacingSemanticTokens { var spacePaddingBlockMedium: SpacingPaddingInlineSemanticToken { get } var spacePaddingBlockTall: SpacingPaddingInlineSemanticToken { get } var spacePaddingBlockTaller: SpacingPaddingInlineSemanticToken { get } - + var spacePaddingBlockWithIconNone: SpacingPaddingInlineSemanticToken { get } var spacePaddingBlockWithIconShortest: SpacingPaddingInlineSemanticToken { get } var spacePaddingBlockWithIconShorter: SpacingPaddingInlineSemanticToken { get } @@ -112,14 +112,14 @@ public protocol SpacingSemanticTokens { var spaceColumnGapShort: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapMedium: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapTall: SpacingPaddingInlineSemanticToken { get } - + var spaceColumnGapWithIconNone: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapWithIconShortest: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapWithIconShorter: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapWithIconShort: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapWithIconMedium: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapWithIconTall: SpacingPaddingInlineSemanticToken { get } - + var spaceColumnGapWithArrowNone: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapWithArrowShorter: SpacingPaddingInlineSemanticToken { get } var spaceColumnGapWithArrowShort: SpacingPaddingInlineSemanticToken { get } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Values/TypographySemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/TypographySemanticTokens.swift index 031d2f4b63..730be1a78c 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/Values/TypographySemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/TypographySemanticTokens.swift @@ -85,40 +85,25 @@ public protocol TypographySemanticTokens { var fontLineHeightCodeMedium: MultipleFontLineHeightTokens { get } var fontLineHeightCodeSmall: MultipleFontLineHeightTokens { get } - // MARK: - Semantic token - Typography - Font - Letter spacing - Mobile (extra-compact/compact) - - var fontLetterSpacingMobileDisplayLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileDisplayMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileDisplaySmall: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileHeadingXLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileHeadingLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileHeadingMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileHeadingSmall: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileBodyLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileBodyMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingMobileBodySmall: TypographyFontLetterSpacingSemanticToken { get } - - // MARK: - Semantic token - Typography - Font - Letter spacing - Tablet (regular/medium) - - var fontLetterSpacingTabletDisplayLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletDisplayMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletDisplaySmall: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletHeadingXLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletHeadingLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletHeadingMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletHeadingSmall: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletBodyLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletBodyMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingTabletBodySmall: TypographyFontLetterSpacingSemanticToken { get } - - // MARK: - Semantic token - Typography - Font - Letter spacing - Others - - var fontLetterSpacingLabelXLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingLabelLarge: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingLabelMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingLabelSmall: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingCodeMedium: TypographyFontLetterSpacingSemanticToken { get } - var fontLetterSpacingCodeSmall: TypographyFontLetterSpacingSemanticToken { get } + // MARK: - Semantic token - Typography - Font - Letter spacing + + var fontLetterSpacingDisplayLarge: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingDisplayMedium: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingDisplaySmall: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingHeadingXLarge: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingHeadingLarge: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingHeadingMedium: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingHeadingSmall: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingBodyLarge: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingBodyMedium: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingBodySmall: MultipleFontLetterSpacingTokens { get } + + var fontLetterSpacingLabelXLarge: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingLabelLarge: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingLabelMedium: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingLabelSmall: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingCodeMedium: MultipleFontLetterSpacingTokens { get } + var fontLetterSpacingCodeSmall: MultipleFontLetterSpacingTokens { get } // MARK: - Semantic tokens - Typography - Composites - Display diff --git a/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLetterSpacingTokensTests.swift b/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLetterSpacingTokensTests.swift new file mode 100644 index 0000000000..c53112329a --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLetterSpacingTokensTests.swift @@ -0,0 +1,57 @@ +// +// Software Name: OUDS iOS +// SPDX-FileCopyrightText: Copyright (c) Orange SA +// SPDX-License-Identifier: MIT +// +// This software is distributed under the MIT license, +// the text of which is available at https://opensource.org/license/MIT/ +// or see the "LICENSE" file for more details. +// +// Authors: See CONTRIBUTORS.txt +// Software description: A SwiftUI components library with code examples for Orange Unified Design System +// + +import XCTest +import OUDSTokensRaw +import OUDSTokensSemantic + +/// To ensure the `MultipleFontLetterSpacingTokens` is tested as a wrapper of semantic tokens for compact and regular size classes. +final class MultipleFontLetterSpacingTokensTests: XCTestCase { + + /// Tests if the unique value is applied for light and dark modes + func testInitWithOneValue() { + let unique: TypographyFontLetterSpacingSemanticToken = TypographyRawTokens.fontLetterSpacing250 + let token = MultipleFontLetterSpacingTokens(unique) + + XCTAssertTrue(token.compact == unique) + XCTAssertTrue(token.regular == unique) + } + + /// Tests if compact and regular values are preserved when defined with two assigned non nil values + func testInitWithTwoValues() { + let compact: TypographyFontLetterSpacingSemanticToken = TypographyRawTokens.fontLetterSpacing300 + let regular: TypographyFontLetterSpacingSemanticToken = TypographyRawTokens.fontLetterSpacing650 + let token = MultipleFontLetterSpacingTokens(compact: compact, regular: regular) + + XCTAssertTrue(token.compact == compact) + XCTAssertTrue(token.regular == regular) + } + + /// Tests comparisons between two `MultipleFontLetterSpacingTokens` to ensure tokens are considered as equal + /// if an only if they have the same compact and regular values and have the same types. + func testIsEqual() { + let first = MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing300, regular: TypographyRawTokens.fontLetterSpacing300) + let second = MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing650, regular: TypographyRawTokens.fontLineHeight250) + let third = MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing300, regular: TypographyRawTokens.fontLineHeight250) + let fourth = MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing650, regular: TypographyRawTokens.fontLineHeight850) + let fifth = MultipleFontLetterSpacingTokens(compact: TypographyRawTokens.fontLetterSpacing300, regular: TypographyRawTokens.fontLetterSpacing300) + let sixth = MultipleSizingTokens(compact: 12, regular: 12) + + XCTAssertTrue(first.isEqual(first)) + XCTAssertFalse(first.isEqual(second)) + XCTAssertFalse(first.isEqual(third)) + XCTAssertFalse(first.isEqual(fourth)) + XCTAssertTrue(first.isEqual(fifth)) + XCTAssertFalse(first.isEqual(sixth)) + } +} diff --git a/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLineHeightTokensTests.swift b/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLineHeightTokensTests.swift index ccb12f8cc2..fe9373bd0c 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLineHeightTokensTests.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleFontLineHeightTokensTests.swift @@ -44,7 +44,7 @@ final class MultipleFontLineHeightTokensTests: XCTestCase { let second = MultipleFontLineHeightTokens(compact: TypographyRawTokens.fontLineHeight650, regular: TypographyRawTokens.fontLineHeight550) let third = MultipleFontLineHeightTokens(compact: TypographyRawTokens.fontLineHeight450, regular: TypographyRawTokens.fontLineHeight550) let fourth = MultipleFontLineHeightTokens(compact: TypographyRawTokens.fontLineHeight650, regular: TypographyRawTokens.fontLineHeight750) - let fifth = MultipleFontLineHeightTokens(compact: TypographyRawTokens.fontLineHeight450, regular: TypographyRawTokens.fontLineHeight750) + let fifth = MultipleFontLineHeightTokens(compact: TypographyRawTokens.fontLineHeight450, regular: TypographyRawTokens.fontLineHeight450) let sixth = MultipleSizingTokens(compact: 12, regular: 12) XCTAssertTrue(first.isEqual(first)) diff --git a/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleTypographyTokensTests.swift b/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleTypographyTokensTests.swift index e866791070..5695e8262c 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleTypographyTokensTests.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Tests/Multiples/MultipleTypographyTokensTests.swift @@ -26,7 +26,7 @@ final class MultipleTypographyTokensTests: XCTestCase { XCTAssertTrue(token.compact == unique) XCTAssertTrue(token.regular == unique) } - + /// Tests if compact and regular values are preserved when defined func testInitWithTwoValues() { let compact = TypographyRawTokens.typeRegular150