|
| 1 | +// |
| 2 | +// Software Name: OUDS iOS |
| 3 | +// SPDX-FileCopyrightText: Copyright (c) Orange SA |
| 4 | +// SPDX-License-Identifier: MIT |
| 5 | +// |
| 6 | +// This software is distributed under the MIT license, |
| 7 | +// the text of which is available at https://opensource.org/license/MIT/ |
| 8 | +// or see the "LICENSE" file for more details. |
| 9 | +// |
| 10 | +// Authors: See CONTRIBUTORS.txt |
| 11 | +// Software description: A SwiftUI components library with code examples for Orange Unified Design System |
| 12 | +// |
| 13 | + |
| 14 | +import OUDSFoundations |
| 15 | +import OUDSTokensSemantic |
| 16 | + |
| 17 | +// swiftlint:disable type_name |
| 18 | + |
| 19 | +/// A class which wraps all **component tokens of skeleton** for skeleton objects like `OUDSSkeleton`. |
| 20 | +/// Contains also references to semantic tokens providers so as to be able to use them to define the component tokens. |
| 21 | +/// This provider should be integrated as a `AllSkeletonComponentTokensProvider` implementation inside `OUDSTheme` so as to provide |
| 22 | +/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use. |
| 23 | +/// Custom themes can use subclass of ``OrangeThemeSkeletonComponentTokensProvider`` and apply the provider they need. |
| 24 | +/// It implements also the protocol `SkeletonComponentTokens` so as to expose the component tokens for links through any `OUDSTheme`. |
| 25 | +/// Skeleton components tokens are defined with semantic tokens of colors (from `AllColorSemanticTokensProvider`). |
| 26 | +/// |
| 27 | +/// ```swift |
| 28 | +/// // Define your own provider for skeleton component tokens |
| 29 | +/// // by inheriting from existing provider |
| 30 | +/// class CustomSkeletonComponentTokensProvider: OrangeThemeSkeletonComponentTokensProvider { |
| 31 | +/// |
| 32 | +/// // Then override the skeleton component tokens you want. |
| 33 | +/// |
| 34 | +/// override var skeletonColorGradientMiddle: MultipleColorSemanticTokens { colors.colorRepositoryOpacityBlackHigher } |
| 35 | +/// |
| 36 | +/// // ... |
| 37 | +/// } |
| 38 | +/// |
| 39 | +/// // Or define your own provider from scratch |
| 40 | +/// class CustomSkeletonComponentTokensProvider: SkeletonComponentTokens { |
| 41 | +/// |
| 42 | +/// // And implement maybe hundreds of tokens. |
| 43 | +/// // You are allowed to use semantic tokens providers if you want to define values. |
| 44 | +/// } |
| 45 | +/// ``` |
| 46 | +/// |
| 47 | +/// Then, you can give this `CustomSkeletonComponentTokensProvider` to your own theme implementation: |
| 48 | +/// |
| 49 | +/// ```swift |
| 50 | +/// class LocalTheme: OrangeTheme { |
| 51 | +/// |
| 52 | +/// override init() { |
| 53 | +/// super.init(skeleton: CustomSkeletonComponentTokensProvider()) |
| 54 | +/// } |
| 55 | +/// } |
| 56 | +/// ``` |
| 57 | +/// |
| 58 | +/// or to an already existing theme for example: |
| 59 | +/// |
| 60 | +/// ```swift |
| 61 | +/// OrangeTheme(skeleton: CustomSkeletonComponentTokensProvider()) |
| 62 | +/// ``` |
| 63 | +/// |
| 64 | +/// - Since: 0.9.0 |
| 65 | +open class OrangeThemeSkeletonComponentTokensProvider { |
| 66 | + |
| 67 | + /// Provider of color semantic tokens to use for link colors |
| 68 | + public let colors: AllColorSemanticTokensProvider |
| 69 | + |
| 70 | + /// Defines a provider of component tokens dedicated to `OUDSSkeleton` |
| 71 | + /// - Parameter colors: Provider for color semantic tokens |
| 72 | + public init(colors: AllColorSemanticTokensProvider) { |
| 73 | + OUDSLogger.debug("Init of OrangeThemeSkeletonComponentTokensProvider") |
| 74 | + self.colors = colors |
| 75 | + } |
| 76 | + |
| 77 | + deinit { } |
| 78 | + |
| 79 | + // ଘ( ・ω・)_/゚・:*:・。☆ |
| 80 | + // Note: So as to help the integration of generated code produced by the tokenator |
| 81 | + // the implemention of SkeletonComponentTokens is not here but in Core/Themes/Orange/Values/ComponentTokens/OrangeTheme+SkeletonComponentTokens.swift |
| 82 | + // This declaration of OrangeThemeSkeletonComponentTokensProvider is here also to allow to write documentation. |
| 83 | +} |
| 84 | + |
| 85 | +// swiftlint:enable type_name |
0 commit comments