From 37891afbf9eae677a7c1fa93a1622d446c46d6f0 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Lapersonne Date: Wed, 25 Sep 2024 20:02:55 +0200 Subject: [PATCH] refactor: add factor base in raw tokens, code cleanup (#132) (#133) Ddd back factor base in raw tokens to be aligned with parser output, code cleanup Signed-off-by: Pierre-Yves Lapersonne --- CHANGELOG.md | 7 +- ...DSTheme+FormsTextInputComponentToken.swift | 1 + .../Tests/TestInverseThemeElevation.swift | 8 +++ .../Values/BorderRawTokens+Values.swift | 41 ++++++----- .../Values/DimensionRawTokens+Values.swift | 69 +++++++++--------- .../Sources/Values/GridRawTokens+Values.swift | 39 +++++----- .../Tests/BorderRawTokensTests.swift | 43 +++++------ .../Tests/DimensionRawTokensTests.swift | 71 +++++++++---------- .../RawTokens/Tests/GridRawTokensTests.swift | 35 ++++----- .../OUDSTokensSemantic.md | 2 + .../TestsUtils/XCTestCase+extensions.swift | 6 +- Showcase/Showcase/Pages/About/AboutPage.swift | 6 -- .../Resources/en.lproj/Localizable.strings | 4 -- .../Showcase/Utils/Bundle+extension.swift | 4 -- Showcase/Showcase/Utils/WebView.swift | 6 -- 15 files changed, 167 insertions(+), 175 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c7670bdd..c986c6130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Library] Rename `SizingCompositeSemanticToken` to `MultipleSizingTokens` to keep "composite" word for *Figma* design system - [Library] Rename `ColorCompositeSemanticToken` to `MultipleColorTokens` to keep "composite" word for *Figma* design system - [Library] Elevation colors have been merged into "multiple" objects colors to have less variables and manage color schemes +- [Library] Rename `ColorCompositeSemanticToken` to `MultipleColorSemanticToken` to keep "composite" word for *Figma* design system +- [Library] Elevation colors have been merged into composite colors to have less variables and manage color schemes +- [Library] Rename `SpacingCompositeSemanticToken` to `MultipleSpacingTokens` to keep "composite" word for *Figma* design system +- [Library] Rename `SizingCompositeSemanticToken` to `MultipleSizingTokens` to keep "composite" word for *Figma* design system +- [Library] Rename `ColorCompositeSemanticToken` to `MultipleColorTokens` to keep "composite" word for *Figma* design system +- [Library] Elevation colors have been merged into "multiple" objects colors to have less variables and manage color schemes - [Library] Update color semantic tokens to better manage light and dark modes values - [Library] Update elevation colors focus light and dark - [Library] Rename space padding inline component tokens by removing "component" word @@ -38,7 +44,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed -- [Library] Remove some base multiplier factor from raw tokens - [Library] Remove raw tokens `elevationZIndex` ([#119](https://github.com/Orange-OpenSource/ouds-ios/issues/119)) ### Fixed diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift index 65826983a..27aa6491c 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift @@ -24,6 +24,7 @@ extension OUDSTheme: FormsTextInputComponentTokens { @objc open var ftiTitleFontWeight: TypographyFontWeightSemanticToken { fontWeightHeading } @objc open var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelLarge } + @objc open var ftiTitleColor: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalLightGray80, dark: ColorRawTokens.colorFunctionalDarkGray640) } @objc open var ftiSubtitleFontWeight: TypographyFontWeightSemanticToken { fontWeightDisplay } diff --git a/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift b/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift index aba5f4bbd..c9f9e3e23 100644 --- a/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift +++ b/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift @@ -26,6 +26,14 @@ final class TestInverseThemeElevationColors: XCTestCase { } func testElevationColorsEquality() throws { + XCTAssertEqual(inverseTheme.elevationColorNone.light, inverseTheme.elevationColorNone.dark) + XCTAssertEqual(inverseTheme.elevationColorRaised.light, inverseTheme.elevationColorRaised.dark) + XCTAssertEqual(inverseTheme.elevationColorDrag.light, inverseTheme.elevationColorDrag.dark) + XCTAssertEqual(inverseTheme.elevationColorOverlayDefault.light, inverseTheme.elevationColorOverlayDefault.dark) + XCTAssertEqual(inverseTheme.elevationColorOverlayEmphasized.light, inverseTheme.elevationColorOverlayEmphasized.dark) + XCTAssertEqual(inverseTheme.elevationColorStickyDefault.light, inverseTheme.elevationColorStickyDefault.dark) + XCTAssertEqual(inverseTheme.elevationColorStickyEmphasized.light, inverseTheme.elevationColorStickyEmphasized.dark) + XCTAssertEqual(inverseTheme.elevationColorStickyNavigationScrolled.light, inverseTheme.elevationColorStickyNavigationScrolled.dark) XCTAssertEqual(inverseTheme.elevationColorFocus.light, inverseTheme.elevationColorFocus.dark) } diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Values/BorderRawTokens+Values.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/BorderRawTokens+Values.swift index de1da47b3..f6ca8f694 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/Values/BorderRawTokens+Values.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/BorderRawTokens+Values.swift @@ -17,30 +17,33 @@ /// Extracted in this separated file to help the *Figma* JSON to Swift parser to generate files to include easily. extension BorderRawTokens { + /// Double type because used below for computations with Double values, output of the parser + public static let borderBase: Double = 4 + // MARK: Primitive token - Border - Width - public static let borderWidth0: BorderWidthRawToken = 4 * 0 - public static let borderWidth25: BorderWidthRawToken = 4 * 0.25 - public static let borderWidth50: BorderWidthRawToken = 4 * 0.5 - public static let borderWidth75: BorderWidthRawToken = 4 * 0.75 - public static let borderWidth100: BorderWidthRawToken = 4 * 1 - public static let borderWidth150: BorderWidthRawToken = 4 * 1.5 - public static let borderWidth200: BorderWidthRawToken = 4 * 2 + public static let borderWidth0: BorderWidthRawToken = borderBase * 0 + public static let borderWidth25: BorderWidthRawToken = borderBase * 0.25 + public static let borderWidth50: BorderWidthRawToken = borderBase * 0.5 + public static let borderWidth75: BorderWidthRawToken = borderBase * 0.75 + public static let borderWidth100: BorderWidthRawToken = borderBase * 1 + public static let borderWidth150: BorderWidthRawToken = borderBase * 1.5 + public static let borderWidth200: BorderWidthRawToken = borderBase * 2 // MARK: Primitive token - Border - Radius - public static let borderRadius0: BorderRadiusRawToken = 4 * 0 - public static let borderRadius25: BorderRadiusRawToken = 4 * 0.25 - public static let borderRadius50: BorderRadiusRawToken = 4 * 0.5 - public static let borderRadius75: BorderRadiusRawToken = 4 * 0.75 - public static let borderRadius100: BorderRadiusRawToken = 4 * 1 - public static let borderRadius150: BorderRadiusRawToken = 4 * 1.5 - public static let borderRadius200: BorderRadiusRawToken = 4 * 2 - public static let borderRadius300: BorderRadiusRawToken = 4 * 3 - public static let borderRadius400: BorderRadiusRawToken = 4 * 4 - public static let borderRadius500: BorderRadiusRawToken = 4 * 5 - public static let borderRadius600: BorderRadiusRawToken = 4 * 6 - public static let borderRadius800: BorderRadiusRawToken = 4 * 8 + public static let borderRadius0: BorderRadiusRawToken = borderBase * 0 + public static let borderRadius25: BorderRadiusRawToken = borderBase * 0.25 + public static let borderRadius50: BorderRadiusRawToken = borderBase * 0.5 + public static let borderRadius75: BorderRadiusRawToken = borderBase * 0.75 + public static let borderRadius100: BorderRadiusRawToken = borderBase * 1 + public static let borderRadius150: BorderRadiusRawToken = borderBase * 1.5 + public static let borderRadius200: BorderRadiusRawToken = borderBase * 2 + public static let borderRadius300: BorderRadiusRawToken = borderBase * 3 + public static let borderRadius400: BorderRadiusRawToken = borderBase * 4 + public static let borderRadius500: BorderRadiusRawToken = borderBase * 5 + public static let borderRadius600: BorderRadiusRawToken = borderBase * 6 + public static let borderRadius800: BorderRadiusRawToken = borderBase * 8 // MARK: Primitive token - Border - Style diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Values/DimensionRawTokens+Values.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/DimensionRawTokens+Values.swift index ddc7558a7..0a009bbf3 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/Values/DimensionRawTokens+Values.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/DimensionRawTokens+Values.swift @@ -17,39 +17,42 @@ /// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. extension DimensionRawTokens { + /// Double type because used below for computations with Double values, output of the parser + public static let dimensionBase: Double = 4 + // MARK: Primitive token - Dimension - public static let dimension0: DimensionRawToken = 4 * 0 - public static let dimension25: DimensionRawToken = 4 * 0.5 - public static let dimension50: DimensionRawToken = 4 * 1 - public static let dimension75: DimensionRawToken = 4 * 1.5 - public static let dimension100: DimensionRawToken = 4 * 2 - public static let dimension150: DimensionRawToken = 4 * 3 - public static let dimension200: DimensionRawToken = 4 * 4 - public static let dimension250: DimensionRawToken = 4 * 5 - public static let dimension300: DimensionRawToken = 4 * 6 - public static let dimension350: DimensionRawToken = 4 * 7 - public static let dimension400: DimensionRawToken = 4 * 8 - public static let dimension450: DimensionRawToken = 4 * 9 - public static let dimension500: DimensionRawToken = 4 * 10 - public static let dimension550: DimensionRawToken = 4 * 11 - public static let dimension600: DimensionRawToken = 4 * 12 - public static let dimension650: DimensionRawToken = 4 * 13 - public static let dimension700: DimensionRawToken = 4 * 14 - public static let dimension750: DimensionRawToken = 4 * 15 - public static let dimension800: DimensionRawToken = 4 * 16 - public static let dimension900: DimensionRawToken = 4 * 18 - public static let dimension1000: DimensionRawToken = 4 * 20 - public static let dimension1200: DimensionRawToken = 4 * 24 - public static let dimension1400: DimensionRawToken = 4 * 28 - public static let dimension1600: DimensionRawToken = 4 * 32 - public static let dimension1800: DimensionRawToken = 4 * 36 - public static let dimension2000: DimensionRawToken = 4 * 40 - public static let dimension3000: DimensionRawToken = 4 * 80 - public static let dimension4000: DimensionRawToken = 4 * 120 - public static let dimension5000: DimensionRawToken = 4 * 140 - public static let dimension6000: DimensionRawToken = 4 * 160 - public static let dimension7000: DimensionRawToken = 4 * 180 - public static let dimension9000: DimensionRawToken = 4 * 220 - public static let dimension11000: DimensionRawToken = 4 * 260 + public static let dimension0: DimensionRawToken = dimensionBase * 0 + public static let dimension25: DimensionRawToken = dimensionBase * 0.5 + public static let dimension50: DimensionRawToken = dimensionBase * 1 + public static let dimension75: DimensionRawToken = dimensionBase * 1.5 + public static let dimension100: DimensionRawToken = dimensionBase * 2 + public static let dimension150: DimensionRawToken = dimensionBase * 3 + public static let dimension200: DimensionRawToken = dimensionBase * 4 + public static let dimension250: DimensionRawToken = dimensionBase * 5 + public static let dimension300: DimensionRawToken = dimensionBase * 6 + public static let dimension350: DimensionRawToken = dimensionBase * 7 + public static let dimension400: DimensionRawToken = dimensionBase * 8 + public static let dimension450: DimensionRawToken = dimensionBase * 9 + public static let dimension500: DimensionRawToken = dimensionBase * 10 + public static let dimension550: DimensionRawToken = dimensionBase * 11 + public static let dimension600: DimensionRawToken = dimensionBase * 12 + public static let dimension650: DimensionRawToken = dimensionBase * 13 + public static let dimension700: DimensionRawToken = dimensionBase * 14 + public static let dimension750: DimensionRawToken = dimensionBase * 15 + public static let dimension800: DimensionRawToken = dimensionBase * 16 + public static let dimension900: DimensionRawToken = dimensionBase * 18 + public static let dimension1000: DimensionRawToken = dimensionBase * 20 + public static let dimension1200: DimensionRawToken = dimensionBase * 24 + public static let dimension1400: DimensionRawToken = dimensionBase * 28 + public static let dimension1600: DimensionRawToken = dimensionBase * 32 + public static let dimension1800: DimensionRawToken = dimensionBase * 36 + public static let dimension2000: DimensionRawToken = dimensionBase * 40 + public static let dimension3000: DimensionRawToken = dimensionBase * 80 + public static let dimension4000: DimensionRawToken = dimensionBase * 120 + public static let dimension5000: DimensionRawToken = dimensionBase * 140 + public static let dimension6000: DimensionRawToken = dimensionBase * 160 + public static let dimension7000: DimensionRawToken = dimensionBase * 180 + public static let dimension9000: DimensionRawToken = dimensionBase * 220 + public static let dimension11000: DimensionRawToken = dimensionBase * 260 } diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Values/GridRawTokens+Values.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/GridRawTokens+Values.swift index 614cdcd0e..a25883e0c 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/Values/GridRawTokens+Values.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/GridRawTokens+Values.swift @@ -17,6 +17,9 @@ /// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. extension GridRawTokens { + /// Double type because used below for computations with Double values, output of the parser + public static let dimensionBase: Double = 4 + // MARK: Primitive token - Grid - Design width public static let gridWidth100: GridRawToken = 320 @@ -59,27 +62,27 @@ extension GridRawTokens { // MARK: Primitive token - Grid - Margin - public static let gridMargin100: GridRawToken = 4 * 4 - public static let gridMargin300: GridRawToken = 4 * 6 - public static let gridMargin400: GridRawToken = 4 * 7 - public static let gridMargin500: GridRawToken = 4 * 8 - public static let gridMargin600: GridRawToken = 4 * 9 - public static let gridMargin700: GridRawToken = 4 * 10 - public static let gridMargin900: GridRawToken = 4 * 12 - public static let gridMargin1000: GridRawToken = 4 * 13 - public static let gridMargin1100: GridRawToken = 4 * 14 - public static let gridMargin1700: GridRawToken = 4 * 20 - public static let gridMargin2500: GridRawToken = 4 * 28 + public static let gridMargin100: GridRawToken = dimensionBase * 4 + public static let gridMargin300: GridRawToken = dimensionBase * 6 + public static let gridMargin400: GridRawToken = dimensionBase * 7 + public static let gridMargin500: GridRawToken = dimensionBase * 8 + public static let gridMargin600: GridRawToken = dimensionBase * 9 + public static let gridMargin700: GridRawToken = dimensionBase * 10 + public static let gridMargin900: GridRawToken = dimensionBase * 12 + public static let gridMargin1000: GridRawToken = dimensionBase * 13 + public static let gridMargin1100: GridRawToken = dimensionBase * 14 + public static let gridMargin1700: GridRawToken = dimensionBase * 20 + public static let gridMargin2500: GridRawToken = dimensionBase * 28 // MARK: Primitive token - Grid - Column gap - public static let gridColumnGap10: GridRawToken = 4 * 0.25 - public static let gridColumnGap100: GridRawToken = 4 * 2 - public static let gridColumnGap200: GridRawToken = 4 * 4 - public static let gridColumnGap300: GridRawToken = 4 * 5 - public static let gridColumnGap400: GridRawToken = 4 * 6 - public static let gridColumnGap600: GridRawToken = 4 * 8 - public static let gridColumnGap700: GridRawToken = 4 * 10 + public static let gridColumnGap10: GridRawToken = dimensionBase * 0.25 + public static let gridColumnGap100: GridRawToken = dimensionBase * 2 + public static let gridColumnGap200: GridRawToken = dimensionBase * 4 + public static let gridColumnGap300: GridRawToken = dimensionBase * 5 + public static let gridColumnGap400: GridRawToken = dimensionBase * 6 + public static let gridColumnGap600: GridRawToken = dimensionBase * 8 + public static let gridColumnGap700: GridRawToken = dimensionBase * 10 // MARK: Primitive token - Grid - Column count diff --git a/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift index 4678d486d..327f0b816 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift @@ -21,11 +21,6 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class BorderRawTokensTests: XCTestCase { - // In the global design system, there is a "border base" defined as 4 as a factor of any other token value. - // This value does not appear in the Swift code generated by the parser from Figma JSON. - // But we can still check this truth is still applied. - private static let borderRawTokensBorderBase = 4 - // MARK: - Primitive token - Border - Width func testBorderWidthRawToken0LessThan25() throws { @@ -33,7 +28,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderWidthRawToken0MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderWidth0, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderWidth0, factor: BorderRawTokens.borderBase) } func testBorderWidthRawToken25LessThan50() throws { @@ -41,7 +36,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderWidthRawToken25MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderWidth25, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderWidth25, factor: BorderRawTokens.borderBase) } func testBorderWidthRawToken50LessThan75() throws { @@ -49,7 +44,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderWidthRawToken50MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderWidth50, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderWidth50, factor: BorderRawTokens.borderBase) } func testBorderWidthRawToken75LessThan100() throws { @@ -57,7 +52,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderWidthRawToken75MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderWidth75, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderWidth75, factor: BorderRawTokens.borderBase) } func testBorderWidthRawToken100LessThan150() throws { @@ -65,7 +60,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderWidthRawToken100MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderWidth100, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderWidth100, factor: BorderRawTokens.borderBase) } func testBorderWidthRawToken150LessThan200() throws { @@ -73,11 +68,11 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderWidthRawToken150MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderWidth150, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderWidth150, factor: BorderRawTokens.borderBase) } func testBorderWidthRawToken200MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderWidth200, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderWidth200, factor: BorderRawTokens.borderBase) } // MARK: - Primitive token - Border - Radius @@ -87,7 +82,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken0MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius0, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius0, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken25LessThan50() throws { @@ -95,7 +90,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken25MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius25, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius25, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken50LessThan75() throws { @@ -103,7 +98,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken50MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius50, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius50, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken75LessThan100() throws { @@ -111,7 +106,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken75MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius75, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius75, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken100LessThan150() throws { @@ -119,7 +114,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken100MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius100, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius100, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken150LessThan200() throws { @@ -127,7 +122,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken150MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius150, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius150, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken200LessThan300() throws { @@ -135,7 +130,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken200MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius200, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius200, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken300LessThan400() throws { @@ -143,7 +138,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken300MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius300, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius300, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken400LessThan500() throws { @@ -151,7 +146,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken400MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius400, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius400, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken500LessThan600() throws { @@ -159,7 +154,7 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken500MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius500, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius500, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken600LessThan800() throws { @@ -167,11 +162,11 @@ final class BorderRawTokensTests: XCTestCase { } func testBorderRadiusRawToken600MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius600, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius600, factor: BorderRawTokens.borderBase) } func testBorderRadiusRawToken800MultipleOfBase() throws { - XCTAssertMultipleOf(BorderRawTokens.borderRadius800, factor: Self.borderRawTokensBorderBase) + XCTAssertMultipleOf(BorderRawTokens.borderRadius800, factor: BorderRawTokens.borderBase) } // MARK: - Primitive token - Border - Style diff --git a/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift index 68a9d52bc..8850c42c2 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift @@ -21,17 +21,12 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class DimensionRawTokensTests: XCTestCase { - // In the global design system, there is a "dimension base" defined as 4 as a factor of any other token value. - // This value does not appear in the Swift code generated by the parser from Figma JSON. - // But we can still check this truth is still applied. - private static let dimensionRawTokensDimensionBase = 4 - func testDimensionRawToken0LessThan25() throws { XCTAssertLessThan(DimensionRawTokens.dimension0, DimensionRawTokens.dimension25) } func testDimensionRawToken0MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension0, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension0, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken25LessThan50() throws { @@ -39,7 +34,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken25MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension25, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension25, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken50LessThan75() throws { @@ -47,7 +42,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken50MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension50, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension50, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken75LessThan100() throws { @@ -55,7 +50,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken75MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension75, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension75, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken100LessThan150() throws { @@ -63,7 +58,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken100MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension100, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension100, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken150LessThan200() throws { @@ -71,7 +66,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken150MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension150, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension150, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken200LessThan250() throws { @@ -79,7 +74,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken200MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension200, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension200, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken250LessThan300() throws { @@ -87,7 +82,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken250MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension250, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension250, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken300LessThan350() throws { @@ -95,7 +90,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken300MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension300, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension300, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken350LessThan400() throws { @@ -103,7 +98,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken350MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension350, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension350, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken400LessThan450() throws { @@ -111,7 +106,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken400MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension400, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension400, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken450LessThan500() throws { @@ -119,7 +114,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken450MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension450, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension450, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken500LessThan550() throws { @@ -127,7 +122,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken500MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension500, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension500, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken550LessThan600() throws { @@ -135,7 +130,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken550MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension550, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension550, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken600LessThan650() throws { @@ -143,7 +138,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken600MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension600, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension600, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken650LessThan700() throws { @@ -151,7 +146,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken650MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension650, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension650, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken700LessThan750() throws { @@ -159,7 +154,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken700MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension700, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension700, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken750LessThan800() throws { @@ -167,7 +162,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken750MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension750, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension750, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken800LessThan900() throws { @@ -175,7 +170,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken800MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension800, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension800, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken900LessThan1000() throws { @@ -183,7 +178,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken900MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension900, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension900, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken1000LessThan1200() throws { @@ -191,7 +186,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken1000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension1000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension1000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken1200LessThan1400() throws { @@ -199,7 +194,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken1200MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension1200, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension1200, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken1400LessThan1600() throws { @@ -207,7 +202,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken1400MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension1400, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension1400, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken1600LessThan1800() throws { @@ -215,7 +210,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken1600MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension1600, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension1600, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken1800LessThan2000() throws { @@ -223,7 +218,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken1800MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension1800, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension1800, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken2000LessThan3000() throws { @@ -231,7 +226,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken2000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension2000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension2000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken3000LessThan4000() throws { @@ -239,7 +234,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken3000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension3000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension3000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken4000LessThan5000() throws { @@ -247,7 +242,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken4000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension4000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension4000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken5000LessThan6000() throws { @@ -255,7 +250,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken5000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension5000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension5000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken6000LessThan7000() throws { @@ -263,7 +258,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken6000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension6000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension6000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken7000LessThan9000() throws { @@ -271,7 +266,7 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken7000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension7000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension7000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken9000LessThan11000() throws { @@ -279,10 +274,10 @@ final class DimensionRawTokensTests: XCTestCase { } func testDimensionRawToken9000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension9000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension9000, factor: DimensionRawTokens.dimensionBase) } func testDimensionRawToken11000MultipleOfBase() throws { - XCTAssertMultipleOf(DimensionRawTokens.dimension11000, factor: Self.dimensionRawTokensDimensionBase) + XCTAssertMultipleOf(DimensionRawTokens.dimension11000, factor: DimensionRawTokens.dimensionBase) } } diff --git a/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift index 0d6cc7475..85a72ee26 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift @@ -21,11 +21,6 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class GridRawTokensTests: XCTestCase { - // In the global design system, there is a "dimension base" defined as 4 as a factor of any other token value. - // This value does not appear in the Swift code generated by the parser from Figma JSON. - // But we can still check this truth is still applied. - private static let gridRawTokensDimensionBase = 4 - // MARK: - Primitive token - Grid - Design Width func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth200() throws { @@ -175,7 +170,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin100MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin100, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin100, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin300LessThanGridMargin400() throws { @@ -183,7 +178,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin300MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin300, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin300, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin400LessThanGridMargin500() throws { @@ -191,7 +186,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin400MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin400, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin400, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin500LessThanGridMargin600() throws { @@ -199,7 +194,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin500MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin500, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin500, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin600LessThanGridMargin700() throws { @@ -207,7 +202,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin600MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin600, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin600, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin700LessThanGridMargin900() throws { @@ -215,7 +210,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin700MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin700, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin700, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin900LessThanGridMargin1000() throws { @@ -223,7 +218,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin900MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin900, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin900, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin1000LessThanGridMargin1100() throws { @@ -231,7 +226,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin1000MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin1000, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin1000, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin1100LessThanGridMargin1700() throws { @@ -239,7 +234,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin1700MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin1700, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin1700, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridMargin1700LessThanGridMargin2500() throws { @@ -247,7 +242,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenMargin2500MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridMargin2500, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridMargin2500, factor: GridRawTokens.dimensionBase) } // MARK: - Primitive token - Grid - Column gap @@ -257,7 +252,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenColumnGap10MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridColumnGap10, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridColumnGap10, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridColumnGap100LessThanGridColumnGap200() throws { @@ -265,7 +260,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenColumnGap100MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridColumnGap100, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridColumnGap100, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridColumnGap200LessThanGridColumnGap300() throws { @@ -273,7 +268,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenColumnGap200MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridColumnGap200, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridColumnGap200, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridColumnGap300LessThanGridColumnGap500() throws { @@ -281,7 +276,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenColumnGap300MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridColumnGap300, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridColumnGap300, factor: GridRawTokens.dimensionBase) } func testGridRawTokenGridColumnGap600LessThanGridColumnGap700() throws { @@ -289,7 +284,7 @@ final class GridRawTokensTests: XCTestCase { } func testGridRawTokenColumnGap700MultipleOfBase() throws { - XCTAssertMultipleOf(GridRawTokens.gridColumnGap700, factor: Self.gridRawTokensDimensionBase) + XCTAssertMultipleOf(GridRawTokens.gridColumnGap700, factor: GridRawTokens.dimensionBase) } // MARK: - Primitive token - Grid - Column count diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md b/OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md index 6c9a2c7e7..425ca4437 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md @@ -34,6 +34,8 @@ The *Multiples* folder contains some _composite class_ defined to pack double va Such *composites* are not the same as the ones defined in the *Figma* design system, they are just utilities to handle tuple of values, without the syntaxe of tuples and with some helper functions. We would like to define one class for all combinations of things depending to light and dark modes, and another for regular and compact modes. However, it implies to use _Swift generics_ and it is not compatible with Objective-C runtime (we use through `@objc` keyword). +We would like to define one class for all combinations of things depending to light and dark modes, and another for regular and compact modes. However, it implies to use _Swift generics_ and it is not compatible with Objective-C runtime (we use through `@objc` keyword). + The *TypeAliases* folder contains all the *typealias* values used for the semantic tokens. Indeed these aliases are here to bring clarity and meanings in the library, and also to help users (i.e. developers) to know what kind of objects they handle with the same vocabulary as the one used in *Figma*, and in general, in the whole design system. They can be seen as a ligh level of abstraction with meanings, without having to define real types with `struct` or `class`. Type aliases here point to raw tokens aliases, thus by transition they point to real types. diff --git a/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift b/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift index bc1412038..e9310d46c 100644 --- a/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift +++ b/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift @@ -22,8 +22,10 @@ extension XCTestCase { } /// Checks if the `value` is a multiple of `factor` - public func XCTAssertMultipleOf(_ value: Double, factor: Int, file: StaticString = #file, line: UInt = #line) { - let remaining = Int(value) % factor + public func XCTAssertMultipleOf(_ value: Double, factor: Double, file: StaticString = #file, line: UInt = #line) { + let value = Int(value) + let factor = Int(factor) + let remaining = value % factor // If multiple, remaining will be 0 OR between 0 and factor if value less than factor XCTAssertTrue(remaining == 0 || remaining < factor, "Current value: \(value) % \(factor) = \(remaining)") } diff --git a/Showcase/Showcase/Pages/About/AboutPage.swift b/Showcase/Showcase/Pages/About/AboutPage.swift index dd9e8f15e..2d9706138 100644 --- a/Showcase/Showcase/Pages/About/AboutPage.swift +++ b/Showcase/Showcase/Pages/About/AboutPage.swift @@ -15,16 +15,12 @@ import SwiftUI struct AboutPage: View { - // ======================= // MARK: Stored properties - // ======================= let privacyPolicyUrl: URL let legalInformationUrl: URL - // ================= // MARK: Initializer - // ================= init() { guard let privacyNoticeUrl = Bundle.main.url(forResource: "about_privacy_policy", withExtension: "html") else { @@ -38,9 +34,7 @@ struct AboutPage: View { self.legalInformationUrl = legalInformationUrl } - // ========== // MARK: Body - // ========== var body: some View { NavigationView { diff --git a/Showcase/Showcase/Resources/en.lproj/Localizable.strings b/Showcase/Showcase/Resources/en.lproj/Localizable.strings index 529253196..eb5734d16 100644 --- a/Showcase/Showcase/Resources/en.lproj/Localizable.strings +++ b/Showcase/Showcase/Resources/en.lproj/Localizable.strings @@ -11,17 +11,13 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -// ================= // MARK: - bottomBar -// ================= "app_bottomBar_components" = "Components"; "app_bottomBar_guidelines" = "Guidelines"; "app_bottomBar_about" = "About"; -// ==================== // MARK: - About Screen -// ==================== "app_about_label_legalInformation" = "Legal information"; "app_about_label_privacyPolicy" = "Privacy policy"; diff --git a/Showcase/Showcase/Utils/Bundle+extension.swift b/Showcase/Showcase/Utils/Bundle+extension.swift index 7340cf679..756ed57e7 100644 --- a/Showcase/Showcase/Utils/Bundle+extension.swift +++ b/Showcase/Showcase/Utils/Bundle+extension.swift @@ -15,9 +15,7 @@ import Foundation extension Bundle { - // ========= // MARK: API - // ========= /// Marketing version in semantic versioning var marketingVersion: String { @@ -69,9 +67,7 @@ extension Bundle { return "\(type)\(tag)" } - // ============================ // MARK: Private Implementation - // ============================ private func string(forInfoDictionaryKey key: String) -> String? { object(forInfoDictionaryKey: key) as? String diff --git a/Showcase/Showcase/Utils/WebView.swift b/Showcase/Showcase/Utils/WebView.swift index cab77a735..7f5b5cc50 100644 --- a/Showcase/Showcase/Utils/WebView.swift +++ b/Showcase/Showcase/Utils/WebView.swift @@ -21,15 +21,11 @@ struct WebView: UIViewRepresentable { case html(String) } - // ======================= // MARK: Stored properties - // ======================= let source: ContentSource - // ================= // MARK: Initializer - // ================= init(from url: URL) { self.source = .url(url) @@ -39,9 +35,7 @@ struct WebView: UIViewRepresentable { self.source = .html(htmlContent) } - // ========================= // MARK: UIViewRepresentable - // ========================= @MainActor func makeUIView(context: Context) -> WKWebView {