-
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 elevation semantic tokens (#279)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
- Loading branch information
Showing
10 changed files
with
303 additions
and
102 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
34 changes: 34 additions & 0 deletions
34
...ources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ElevationMultipleSemanticTokens.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,34 @@ | ||
// | ||
// 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 anymore 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 eelvation color semantic tokens. | ||
/// 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: ElevationMultipleSemanticTokens { | ||
|
||
@objc open var elevationColorDrag: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack500) } | ||
@objc open var elevationColorNone: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack0) } | ||
@objc open var elevationColorOverlayDefault: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack400) } | ||
@objc open var elevationColorOverlayEmphasized: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack300) } | ||
@objc open var elevationColorRaised: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack500) } | ||
@objc open var elevationColorStickyDefault: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack300) } | ||
@objc open var elevationColorStickyEmphasized: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack300) } | ||
@objc open var elevationColorStickyNavigationScrolled: MultipleColorTokens { MultipleColorTokens(ColorRawTokens.colorTransparentBlack300) } | ||
} |
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
80 changes: 80 additions & 0 deletions
80
OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfElevationMultipleSemanticTokens.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,80 @@ | ||
// | ||
// 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 fact, the `OUDSTheme` object is a class, which can be seen as an _asbtract class_, exposing through its extensions and protocols _elevation semantic tokens_. | ||
/// These semantic tokens should be overriden by subclass like the `OrangeTheme` default theme. | ||
/// **These tests checks if any _elevation semantic tokens_ can be surcharged by a child theme** | ||
final class TestThemeOverrideOfElevationMultipleSemanticTokens: XCTestCase { | ||
|
||
private var abstractTheme: OUDSTheme! | ||
private var inheritedTheme: OUDSTheme! | ||
|
||
override func setUp() async throws { | ||
abstractTheme = OUDSTheme() | ||
inheritedTheme = MockTheme() | ||
} | ||
|
||
// MARK: - Semantic token - Elevation - Colors | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorNone() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorNone, abstractTheme.elevationColorNone) | ||
XCTAssertTrue(inheritedTheme.elevationColorNone.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorRaised() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorRaised, abstractTheme.elevationColorRaised) | ||
XCTAssertTrue(inheritedTheme.elevationColorRaised.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorDrag() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorDrag, abstractTheme.elevationColorDrag) | ||
XCTAssertTrue(inheritedTheme.elevationColorDrag.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorOverlayDefault() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorOverlayDefault, abstractTheme.elevationColorOverlayDefault) | ||
XCTAssertTrue(inheritedTheme.elevationColorOverlayDefault.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorOverlayEmphasized() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorOverlayEmphasized, abstractTheme.elevationColorOverlayEmphasized) | ||
XCTAssertTrue(inheritedTheme.elevationColorOverlayEmphasized.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyDefault() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorStickyDefault, abstractTheme.elevationColorStickyDefault) | ||
XCTAssertTrue(inheritedTheme.elevationColorStickyDefault.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyEmphasized() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorStickyEmphasized, abstractTheme.elevationColorStickyEmphasized) | ||
XCTAssertTrue(inheritedTheme.elevationColorStickyEmphasized.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyNavigationScrolled() throws { | ||
XCTAssertNotEqual(inheritedTheme.elevationColorStickyNavigationScrolled, abstractTheme.elevationColorStickyNavigationScrolled) | ||
XCTAssertTrue(inheritedTheme.elevationColorStickyNavigationScrolled.isEqual(MockTheme.mockThemeElevationMultipleColorSemanticToken)) | ||
} | ||
} | ||
|
||
// swiftlint:enable required_deinit | ||
// swiftlint:enable implicitly_unwrapped_optional | ||
// swiftlint:enable type_name |
Oops, something went wrong.