-
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.
Browse files
Browse the repository at this point in the history
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
- Loading branch information
Showing
11 changed files
with
256 additions
and
8 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
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
85 changes: 85 additions & 0 deletions
85
...Orange/Sources/Providers/ComponentTokens/OrangeThemeSkeletonComponentTokensProvider.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,85 @@ | ||
// | ||
// 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 OUDSFoundations | ||
import OUDSTokensSemantic | ||
|
||
// swiftlint:disable type_name | ||
|
||
/// A class which wraps all **component tokens of skeleton** for skeleton objects like `OUDSSkeleton`. | ||
/// Contains also references to semantic tokens providers so as to be able to use them to define the component tokens. | ||
/// This provider should be integrated as a `AllSkeletonComponentTokensProvider` implementation inside `OUDSTheme` so as to provide | ||
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use. | ||
/// Custom themes can use subclass of ``OrangeThemeSkeletonComponentTokensProvider`` and apply the provider they need. | ||
/// It implements also the protocol `SkeletonComponentTokens` so as to expose the component tokens for links through any `OUDSTheme`. | ||
/// Skeleton components tokens are defined with semantic tokens of colors (from `AllColorSemanticTokensProvider`). | ||
/// | ||
/// ```swift | ||
/// // Define your own provider for skeleton component tokens | ||
/// // by inheriting from existing provider | ||
/// class CustomSkeletonComponentTokensProvider: OrangeThemeSkeletonComponentTokensProvider { | ||
/// | ||
/// // Then override the skeleton component tokens you want. | ||
/// | ||
/// override var skeletonColorGradientMiddle: MultipleColorSemanticTokens { colors.colorRepositoryOpacityBlackHigher } | ||
/// | ||
/// // ... | ||
/// } | ||
/// | ||
/// // Or define your own provider from scratch | ||
/// class CustomSkeletonComponentTokensProvider: SkeletonComponentTokens { | ||
/// | ||
/// // And implement maybe hundreds of tokens. | ||
/// // You are allowed to use semantic tokens providers if you want to define values. | ||
/// } | ||
/// ``` | ||
/// | ||
/// Then, you can give this `CustomSkeletonComponentTokensProvider` to your own theme implementation: | ||
/// | ||
/// ```swift | ||
/// class LocalTheme: OrangeTheme { | ||
/// | ||
/// override init() { | ||
/// super.init(skeleton: CustomSkeletonComponentTokensProvider()) | ||
/// } | ||
/// } | ||
/// ``` | ||
/// | ||
/// or to an already existing theme for example: | ||
/// | ||
/// ```swift | ||
/// OrangeTheme(skeleton: CustomSkeletonComponentTokensProvider()) | ||
/// ``` | ||
/// | ||
/// - Since: 0.9.0 | ||
open class OrangeThemeSkeletonComponentTokensProvider { | ||
|
||
/// Provider of color semantic tokens to use for link colors | ||
public let colors: AllColorSemanticTokensProvider | ||
|
||
/// Defines a provider of component tokens dedicated to `OUDSSkeleton` | ||
/// - Parameter colors: Provider for color semantic tokens | ||
public init(colors: AllColorSemanticTokensProvider) { | ||
OUDSLogger.debug("Init of OrangeThemeSkeletonComponentTokensProvider") | ||
self.colors = colors | ||
} | ||
|
||
deinit { } | ||
|
||
// ଘ( ・ω・)_/゚・:*:・。☆ | ||
// Note: So as to help the integration of generated code produced by the tokenator | ||
// the implemention of SkeletonComponentTokens is not here but in Core/Themes/Orange/Values/ComponentTokens/OrangeTheme+SkeletonComponentTokens.swift | ||
// This declaration of OrangeThemeSkeletonComponentTokensProvider is here also to allow to write documentation. | ||
} | ||
|
||
// swiftlint:enable type_name |
22 changes: 22 additions & 0 deletions
22
...re/Themes/Orange/Sources/Values/ComponentTokens/OrangeTheme+SkeletonComponentTokens.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,22 @@ | ||
// | ||
// 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 OUDSTokensComponent | ||
import OUDSTokensSemantic | ||
|
||
extension OrangeThemeSkeletonComponentTokensProvider: SkeletonComponentTokens { | ||
@objc open var skeletonColorBg: MultipleColorSemanticTokens { colors.colorOpacityLowest } | ||
@objc open var skeletonColorGradientMiddle: MultipleColorSemanticTokens { colors.colorOpacityLower } | ||
@objc open var skeletonColorGradientStartEnd: MultipleColorSemanticTokens { colors.colorOpacityTransparent } | ||
} |
39 changes: 39 additions & 0 deletions
39
.../Orange/Tests/Values/ComponentTokens/MockTheme/MockTheme+AllSkeletonComponentTokens.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,39 @@ | ||
// | ||
// 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 OUDSThemesOrange | ||
import OUDSTokensComponent | ||
import OUDSTokensRaw | ||
import OUDSTokensSemantic | ||
|
||
// swiftlint:disable required_deinit | ||
|
||
final class MockThemeSkeletonComponentTokenProvider: OrangeThemeSkeletonComponentTokensProvider { | ||
|
||
// MARK: - Mocks and setup | ||
|
||
static let mockThemeSkeletonColor = MultipleColorSemanticTokens("#00FF00") | ||
|
||
override public init(colors: AllColorSemanticTokensProvider) { | ||
super.init(colors: colors) | ||
} | ||
|
||
// MARK: - Skeleton component tokens | ||
|
||
override public var skeletonColorBg: MultipleColorSemanticTokens { Self.mockThemeSkeletonColor } | ||
override public var skeletonColorGradientMiddle: MultipleColorSemanticTokens { Self.mockThemeSkeletonColor } | ||
override public var skeletonColorGradientStartEnd: MultipleColorSemanticTokens { Self.mockThemeSkeletonColor } | ||
} | ||
|
||
// swiftlint:enable required_deinit |
50 changes: 50 additions & 0 deletions
50
...emes/Orange/Tests/Values/ComponentTokens/TestThemeOverrideOfSkeletonComponentTokens.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,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 OUDS | ||
import OUDSThemesOrange | ||
import XCTest | ||
|
||
// swiftlint:disable required_deinit | ||
// swiftlint:disable implicitly_unwrapped_optional | ||
// swiftlint:disable type_name | ||
|
||
final class TestThemeOverrideOfSkeletonComponentTokens: XCTestCase { | ||
|
||
private var abstractTheme: OUDSTheme! | ||
private var inheritedTheme: OUDSTheme! | ||
|
||
override func setUp() async throws { | ||
abstractTheme = OrangeTheme() | ||
inheritedTheme = MockTheme() | ||
} | ||
|
||
func testInheritedThemeCanOverrideSkeletonComponentTokenColorBg() throws { | ||
XCTAssertNotEqual(inheritedTheme.skeleton.skeletonColorBg, abstractTheme.skeleton.skeletonColorBg) | ||
XCTAssertTrue(inheritedTheme.skeleton.skeletonColorBg == MockThemeSkeletonComponentTokenProvider.mockThemeSkeletonColor) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSkeletonComponentTokenColorGradientMiddle() throws { | ||
XCTAssertNotEqual(inheritedTheme.skeleton.skeletonColorGradientMiddle, abstractTheme.skeleton.skeletonColorGradientMiddle) | ||
XCTAssertTrue(inheritedTheme.skeleton.skeletonColorGradientMiddle == MockThemeSkeletonComponentTokenProvider.mockThemeSkeletonColor) | ||
} | ||
|
||
func testInheritedThemeCanOverrideSkeletonComponentTokenColorGradientStartEnd() throws { | ||
XCTAssertNotEqual(inheritedTheme.skeleton.skeletonColorGradientStartEnd, abstractTheme.skeleton.skeletonColorGradientStartEnd) | ||
XCTAssertTrue(inheritedTheme.skeleton.skeletonColorGradientStartEnd == MockThemeSkeletonComponentTokenProvider.mockThemeSkeletonColor) | ||
} | ||
} | ||
|
||
// swiftlint:enable required_deinit | ||
// swiftlint:enable implicitly_unwrapped_optional | ||
// swiftlint:enable type_name |
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
35 changes: 35 additions & 0 deletions
35
OUDS/Core/Tokens/ComponentTokens/Sources/Values/SkeletonComponentTokens.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,35 @@ | ||
// | ||
// 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 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 | ||
|
||
// swiftlint:disable missing_docs | ||
|
||
/// Declares all component tokens for links components like `OUDSSkeleton` | ||
/// Use for tokens providers like `OrangeThemeSkeletonComponentTokensProvider`. | ||
/// | ||
/// - Since: 0.10.0 | ||
public protocol SkeletonComponentTokens { | ||
|
||
// MARK: - Color | ||
|
||
var skeletonColorBg: MultipleColorSemanticTokens { get } | ||
var skeletonColorGradientMiddle: MultipleColorSemanticTokens { get } | ||
var skeletonColorGradientStartEnd: MultipleColorSemanticTokens { get } | ||
} | ||
|
||
// swiftlint:enable missing_docs |
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