-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use of multiple type for space semantic tokens (#279)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
- Loading branch information
Showing
11 changed files
with
351 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...DS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceMultipleSemanticTokens.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// 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 | ||
import OUDSTokensSemantic | ||
|
||
// [File not generated by the tokenator] | ||
// WARNING: Not synchronized with the Figjam / Figma by developers team | ||
// Create an issue for update https://github.com/Orange-OpenSource/ouds-ios/issues/new?template=token_update.yml | ||
|
||
/// Defines wrapper objects for space semantic tokens (i.e. in the end `DimensionRawToken`). | ||
/// These values can be overriden inside `OUDSTheme` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination. | ||
extension OUDSTheme: SpaceMultipleSemanticTokens { | ||
|
||
// MARK: Semantic token - Spacing - Layout fluid | ||
|
||
@objc open var spaceScaledNone: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledNoneMobile, regular: spaceScaledNoneTablet) } | ||
@objc open var spaceScaledSmash: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledSmashMobile, regular: spaceScaledSmashTablet) } | ||
@objc open var spaceScaledShortest: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledShortestMobile, regular: spaceScaledShortestTablet) } | ||
@objc open var spaceScaledShorter: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledShorterMobile, regular: spaceScaledShorterTablet) } | ||
@objc open var spaceScaledShort: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledShortMobile, regular: spaceScaledShortTablet) } | ||
@objc open var spaceScaledMedium: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledMediumMobile, regular: spaceScaledMediumTablet) } | ||
@objc open var spaceScaledTall: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledTallMobile, regular: spaceScaledTallTablet) } | ||
@objc open var spaceScaledTaller: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledTallerMobile, regular: spaceScaledTallerTablet) } | ||
@objc open var spaceScaledTallest: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledTallestMobile, regular: spaceScaledTallerTablet) } | ||
@objc open var spaceScaledSpacious: MultipleSpaceTokens { MultipleSpaceTokens(compact: spaceScaledSpaciousMobile, regular: spaceScaledSpaciousTablet) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpaceMultipleSemanticTokens.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// 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 OUDS | ||
import XCTest | ||
|
||
// swiftlint:disable required_deinit | ||
// swiftlint:disable implicitly_unwrapped_optional | ||
// swiftlint:disable type_name | ||
|
||
/// The architecture of _OUDS iOS_ _Swift package_ library is based on _object oriented paradigm_ and overriding of classes. | ||
/// In factn the `OUDSTheme` object is a class, which can be seens as an _asbtract class_, exposing through its extensions and protocols _spacing semantic tokens_. | ||
/// These semantic tokens should be overriden by subclass like the `OrangeTheme` default theme. | ||
|
||
/// **These tests checks if any _space multiple semantic tokens_ can be surcharged by a child theme** | ||
/// **Also, it can help to find removed or renamed tokens by having tests no more compilable** | ||
final class TestThemeOverrideOfSpaceMultipleSemanticTokens: XCTestCase { | ||
|
||
private var abstractTheme: OUDSTheme! | ||
private var inheritedTheme: OUDSTheme! | ||
|
||
override func setUp() async throws { | ||
abstractTheme = OUDSTheme() | ||
inheritedTheme = MockTheme() | ||
} | ||
|
||
// MARK: - Semantic token - Spacing - Layout fluid | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledNone() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledNone, abstractTheme.spaceScaledNone) | ||
XCTAssertTrue(inheritedTheme.spaceScaledNone.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledSmash() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledSmash, abstractTheme.spaceScaledSmash) | ||
XCTAssertTrue(inheritedTheme.spaceScaledSmash.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledShortest() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledShortest, abstractTheme.spaceScaledShortest) | ||
XCTAssertTrue(inheritedTheme.spaceScaledShortest.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledShorter() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledShorter, abstractTheme.spaceScaledShorter) | ||
XCTAssertTrue(inheritedTheme.spaceScaledShorter.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledShort() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledShort, abstractTheme.spaceScaledShort) | ||
XCTAssertTrue(inheritedTheme.spaceScaledShort.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledMedium() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledMedium, abstractTheme.spaceScaledMedium) | ||
XCTAssertTrue(inheritedTheme.spaceScaledMedium.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledTall() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledTall, abstractTheme.spaceScaledTall) | ||
XCTAssertTrue(inheritedTheme.spaceScaledTall.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledTaller() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledTaller, abstractTheme.spaceScaledTaller) | ||
XCTAssertTrue(inheritedTheme.spaceScaledTaller.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledTallest() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledTallest, abstractTheme.spaceScaledTallest) | ||
XCTAssertTrue(inheritedTheme.spaceScaledTallest.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenSpaceScaledSpacious() throws { | ||
XCTAssertNotEqual(inheritedTheme.spaceScaledSpacious, abstractTheme.spaceScaledSpacious) | ||
XCTAssertTrue(inheritedTheme.spaceScaledSpacious.isEqual(MockTheme.mockThemeSpaceSemanticToken)) | ||
} | ||
} | ||
|
||
// swiftlint:enable required_deinit | ||
// swiftlint:enable implicitly_unwrapped_optional | ||
// swiftlint:enable type_name |
Oops, something went wrong.