diff --git a/.github/DEVELOP.md b/.github/DEVELOP.md index 9dde712c2..9f3341c74 100644 --- a/.github/DEVELOP.md +++ b/.github/DEVELOP.md @@ -3,6 +3,9 @@ - [Technical preconditions](#technical-preconditions) - [Build showcase demo app](#build-showcase-demo-app) - [Documentation](#documentation) +- [Run tests](#run-tests) + * [Unit tests for OUDS Swift package](#unit-tests-for-ouds-swift-package) + * [UI tests in demo app](#ui-tests-in-demo-app) - [Build phases](#build-phases) - [Targets](#targets) - [Certificates, profiles and identifiers](#certificates-profiles-and-identifiers) @@ -20,12 +23,12 @@ You should check wether or not you have the tools in use in the project like _Fastlane_, _SwiftLint_, _SwiftFormat_, etc. You can have a look for example in thr **THIRD\_PARTY.md** file which lists any dependencies and tools we use are different levels (SDK, showcase app, projects). -If some tools are missing, pick the suitable command line bellow: +If some tools are missing, pick the suitable command line below: ```bash # Use Bundler to install a major part of dependencies (thanks to Gemfile and Gemfile.lock files) bundle install -# Use CocoaPods to install other dependencies not avaialble as rubygems (thanks to Podfile and Podfile.lock files) +# Use CocoaPods to install other dependencies not available as rubygems (thanks to Podfile and Podfile.lock files) bundle exec pod install # Some dependencies must be downloaded by hand: @@ -49,7 +52,53 @@ To build the demo application follow those steps: ## Documentation -_To be defined soon_ +The documentation is based on the Swift documentation with [DocC](https://www.swift.org/documentation/docc/). +We use here the [swift-docc-plugin](https://github.com/swiftlang/swift-docc-plugin) to build the HTML documentations using the documentation catalogs +and any _DocC_ comments in the source code. + +The documentation can be built from Xcode with _Product > Build Documentation_. + +The `generateDoc.sh` script helps to build the HTML version of documentation and compress it in ZIP file, and also can update +the online version based on [_GitHub Pages_](https://pages.github.com/), this version is hosted in the [*gh-pages* GitHub branch](https://github.com/Orange-OpenSource/ouds-ios/tree/gh-pages). + +## Run tests + +### Unit tests for OUDS Swift package + +To run these unit tests follow some steps: + +1. `cd Showcase` +2. `bundle exec pod install` +3. Open *Showcase.xcworkspace* +4. Select *Showcase* scheme +5. Run tests (Product -> Test) + +Unit tests care have been implemented for several reasons. + +First, we don't have too much control on the raw tokens values. We rely on the _Figma_ design tool which outputs the tokens in a JSON file. +And this file will be parsed to as to generate Swift files. But if there are inconsistencies in the _Figma_ side or in the parser side, the inconsistencies will be spread in our code base. +It is not useful to define unit tests for raw tokens to test their values ; in fact they exist here to be updated. +But we wan still check other things like the relationship between them. For example a _grid100_ should always be less or equal than a _grid100_. Some _color100_ should be always lighter than a _color200_, etc, etc. A small typo should be always smaller or with the sale size has a one-step-bigger typo. + +Then, we want to know when tokens have been removed so as to warn our users and keep release notes and changelog clean. If we don't spot such changes, maybe some users will be impacted. + +Finally, we ensure our themes can override any semantic tokens. Themes are in fact a set of values for the whole universe of semantic tokens, and if a theme cannot override a semantic token, there could be an issue. Unit tests also help us to find if some tokens have been removed before releasing the library. + +### UI tests in demo app + +To run these UI tests follow some steps: + +1. `cd Showcase` +2. `bundle exec pod install` +3. Open *Showcase.xcworkspace* +4. Select *ShowcaseTests* scheme +5. Select some simulator (tests designed for *iPhone 13 Pro Max* and *iPhone 14 Pro Max* but works elsewhere) +6. Run tests (Product -> Test) + +Beware, if you add new UI tests using [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing) library, you may have new tests which fail at first time. +Indeed for new tests the tool makes snapshots of the views, thus for the first run no preview exist making the tests fail. You should run the tests twice for new tests. + +Such tests here are used to as to be sure the look and feel of any components and tokens rendering remaing the expected ones. ## Build phases @@ -65,11 +114,12 @@ The Xcode project contains two targets: 1. _Showcase_ for the demo application 2. _Periphery_ to look for dead code in the source code +3. _ShowcaseTests_ for UI tests in demo app ## Certificates, profiles and identifiers We choose to use Xcode automatic signing for debug builds of the app so as to make easier onboarding of newcomers in development team, and also to prevent to update provisioning profiles with individual developers certificates each team someone wants to build the app and also to prevent to register each new build device). You may need to be part of our team if you want to build in debug mode. -Note the bundle identifier here for lcoal builds is **com.orange.ouds.demoapp-debug**, with a **-debug** suffix so as to prevent any local build to be replaced by TestFlight builds which have **com.orange.ouds.demoapp** identifiers. +Note the bundle identifier here for local builds is **com.orange.ouds.demoapp-debug**, with a **-debug** suffix so as to prevent any local build to be replaced by TestFlight builds which have **com.orange.ouds.demoapp** identifiers. However for release builds we use a dedicated _provisioning profile_ built with of course a _distribution certificate_(.p12 format with private key, not .cer) and the _bundle identifier_ `com.orange.ouds.demoapp` for our _Apple Team_ `France Telecom (MG2LSJNJB6)`. Thus you won't be able to build and sign in release mode without this provisioning profile and this distribution certificate. These elements are stored in our local GitLab CI runners and must not be available outside. @@ -166,7 +216,7 @@ exit 0 We try also to apply [keep a changelog](https://keepachangelog.com/en/1.0.0/), and [semantic versioning](https://semver.org/spec/v2.0.0.html) both with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). You can generate a `RELEASE_NOTE.md` file using your Git history and [git cliff](https://git-cliff.org/) tool. -Define first a `cliff.toml` configuration file containing the code bellow. +Define first a `cliff.toml` configuration file containing the code below. ```toml # git-cliff ~ configuration file @@ -176,7 +226,7 @@ Define first a `cliff.toml` configuration file containing the code bellow. # changelog header header = """ # Release Note\n -All notable changes for this version are here and blablbla.\n +All notable changes for this version are here and blablabla.\n """ # template for the changelog body # https://keats.github.io/tera/docs/#introduction @@ -353,9 +403,9 @@ sort_commits = "oldest" A [GitHub Action](https://github.com/gitleaks/gitleaks-action) has been integrated to the repository with a configuration file defined in _/github/workflows_ named _gitleaks-action.yaml_. It will launch the _Gitleaks_ tool automatically. -Howevere this tool does not detect plain API key mixed in URL, that is a reason why _Gitleaks_ can be called in a pre-commit hook, using the _giteaks.toml_ at the root of the prokect. +However this tool does not detect plain API key mixed in URL, that is a reason why _Gitleaks_ can be called in a pre-commit hook, using the _giteaks.toml_ at the root of the project. To call _Gitleaks_ in pre-commit hooks, create a file named **pre-commit** inside _.git/hooks_ (then run `chmod u+x` in the file). -Then place the bash code bellow in this file: +Then place the bash code below in this file: ```bash # Run Gitleaks before commits diff --git a/.gitignore b/.gitignore index 2bd1c0ed8..4d60e5181 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ /Showcase/Showcase.xcworkspace/xcuserdata/ /DerivedData/ +# Produced by generateDoc.sh +.build + # Produced by Swift Package Manager /.swiftpm/xcode/xcshareddata/ /.swiftpm/xcode/xcuserdata/ diff --git a/CHANGELOG.md b/CHANGELOG.md index b047e48a3..8b28307e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,27 +4,73 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.0](https://github.com/Orange-OpenSource/ouds-ios/compare/0.1.0...0.2.0) - 2024-09-19 + +### Added + +- [Tests] Add UI regression tests using snapshot comparisons with *swift-snapshot-testing* tool ([#78](https://github.com/Orange-OpenSource/ouds-ios/issues/78)) +- [DemoApp] Display fake components for elevation rendering tests +- [Library] A theme can now override the custom font family +- [Tests] Add more unit tests for theme overriding and raw tokens controls +- [Library] Add and update raw and semantic grid tokens ([#40](https://github.com/Orange-OpenSource/ouds-ios/issues/40)) +- [Library] Manage regular and compact layouts for sizing and spacing tokens +- [Library] "Box shadow 0" has been defined and "elevation drag" changed +- [Doc] Create the basics of a documentation ([#9](https://github.com/Orange-OpenSource/ouds-ios/issues/9)) +- [Library] Add more semanttic and raw tokens for typography +- [Library] Add more semantic and raw tokens for typography, and SwiftUI API to apply them +- [Library] Computation of SwiftUI radius from Figma blur and spread values for elevation tokens +- [Library] Add elevation tokens ([#32](https://github.com/Orange-OpenSource/ouds-ios/issues/32)) + +### Changed + +- [Library] Split raws, semantics and components tokens definitions and also values, composites and type aliases +- [Showcase] Improve Fastlane alpha build notifications +- [Library] Do not store blur value in elevation semantic tokens +- [Library] Change type aliases for X and Y offsets of elevations tokens +- [Library] Update border semantic tokens values ([#106](https://github.com/Orange-OpenSource/ouds-ios/issues/106)) +- [Showcase] Add fake components for demo and tokens tests +- [Library] Remove spread value for elevation tokens +- [Library] Remove paragraph spacing tokens for typography +- [Library] Term "fluid" has been replaced by "adaptable" in spacing semantic tokens +- [Doc] Improve DocC documentation about tokens and views extensions +- [Doc] Add more details in release documentation +- [Library] Rename semantic token "opacityEmphasized" to "opacityStrong" ([#94](https://github.com/Orange-OpenSource/ouds-ios/issues/94)) +- [Library] Update value of opacity raw token "opacity800" from 0.88 to 0.80 ([#87](https://github.com/Orange-OpenSource/ouds-ios/issues/87)) +- [Tests] Add missing unit tests for opacity raw tokens +- [Library] "OUDSThemesCommons" product has been renamed to "OUDS" + +### Removed + +- [Library] Remove Z Index tokens for elevations ([#109](https://github.com/Orange-OpenSource/ouds-ios/issues/109)) +- [Library] Remove token "borderRadiusPill" and "borderRadiusCircle" ([#58](https://github.com/Orange-OpenSource/ouds-ios/issues/58)) +- [Library] "Emphasis" words have been replaced by "emphasized" +- [Library] "Box shadow" words have been removed in elevation semantic and raw tokens + +### Fixed + +- [Library] Fix some typos in documentation ([#89](https://github.com/Orange-OpenSource/ouds-ios/issues/89)) + ## [0.1.0](https://github.com/Orange-OpenSource/ouds-ios/compare/0.0.0...0.1.0) - 2024-08-08 ### Added - [Library] Add simple logger for console outputs -- [Library] Add unit tests for Sosh brand colors raw tokens -- [Library] Add unit tests for Orange brand colors raw tokens -- [Library] Add unit tests for foundations -- [Library] Add unit tests for raw tokens and semantic tokens for colors +- [Tests] Add unit tests for Sosh brand colors raw tokens +- [Tests] Add unit tests for Orange brand colors raw tokens +- [Tests] Add unit tests for foundations +- [Tests] Add unit tests for raw tokens and semantic tokens for colors - [Library] Add draft of raw tokens and semantic tokens for grids ### Changed - [Library] Redefine Swift Package with clearer path for sources, tests cases and test plan - [Library] Expose product "OUDSThemesCommons" instead of "OUDSThemesShared" -- [Library] Improve unit tests for elevation semantic tokens -- [Library] Improve unit tests for typography raw tokens -- [Library] Improve unit tests for opacity raw tokens -- [Library] Improve unit tests for elevations raw tokens -- [Library] Improve unit tests for dimensions raw tokens -- [Library] Improve unit tests for borders raw tokens +- [Tests] Improve unit tests for elevation semantic tokens +- [Tests] Improve unit tests for typography raw tokens +- [Tests] Improve unit tests for opacity raw tokens +- [Tests] Improve unit tests for elevations raw tokens +- [Tests] Improve unit tests for dimensions raw tokens +- [Tests] Improve unit tests for borders raw tokens ### Fixed @@ -43,7 +89,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Library] Add raw tokens and semantic tokens for border ([#30](https://github.com/Orange-OpenSource/ouds-ios/issues/30)) - [Library] Define Swift Package architecture of library and tokens (raw and semantic) ([#33](https://github.com/Orange-OpenSource/ouds-ios/issues/33)) - [Library] Define Swift Package library for OUDS ([#46](https://github.com/Orange-OpenSource/ouds-ios/issues/46)) - - [Showcase] Publication of comment on issues about new alpha build upload on TestFlight ([#56](https://github.com/Orange-OpenSource/ouds-ios/issues/56)) - [Showcase] Distribute demo app development version ([#12](https://github.com/Orange-OpenSource/ouds-ios/issues/12)) - [Showcase] Distribute demo app for feature validation ([#13](https://github.com/Orange-OpenSource/ouds-ios/issues/13)) diff --git a/Gemfile.lock b/Gemfile.lock index 6b4178e4e..fc6cbfc20 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -322,4 +322,4 @@ DEPENDENCIES xcode-install (= 2.8.1) BUNDLED WITH - 2.5.11 + 2.5.17 diff --git a/OUDS/Core/Components/Sources/Buttons/OUDSButton.swift b/OUDS/Core/Components/Sources/Buttons/OUDSButton.swift new file mode 100644 index 000000000..3776286de --- /dev/null +++ b/OUDS/Core/Components/Sources/Buttons/OUDSButton.swift @@ -0,0 +1,73 @@ +// +// 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 OUDSFoundations +import OUDSTokensSemantic +import SwiftUI + +/// An OUDS component for buttons. +/// __Warning: This is a draft component__. +/// +/// This component is created to illustrate the mecanism of theme and tokens and for tests. +public struct OUDSButton: View { + + // MARK: - Properties + + /// The text to display inside the button + private let text: String + + /// The action to process when the button is activated by a user interaction like a tap + private let action: () -> Void + + /// To get tokens to customize the component + @Environment(\.theme) private var theme + + /// To choose if ight or dark color must be used + @Environment(\.colorScheme) private var colorScheme + + /// To get programatically and on the fly the horizontal layout size + @Environment(\.horizontalSizeClass) private var sizeClass + + // MARK: - Init + + /// Initializes the button. + /// + /// - Parameters: + /// - text: Text displayed in the button. + /// - action: Will be called when the user clicks the button. + public init(text: String, action: @escaping () -> Void) { + self.text = text + self.action = action + } + + // MARK: - Body + + public var body: some View { + Button { + action() + } label: { + Text(text) + .systemFont(typography: theme.buttonTypography) + .padding(theme.buttonInternalSpacing) + .foregroundColor(colorScheme == .light + ? theme.buttonForegroundColorLight.color + : theme.buttonForegroundColorDark.color) + .modifier(BorderStyleModifier(theme.buttonBorderStyle, + theme.buttonBorderWidth, + theme.buttonBorderRadius, + theme.buttonBorderColorLight, + theme.buttonBorderColorDark)) + }.frame(width: theme.buttonWidth, height: theme.buttonHeight) + } +} diff --git a/OUDS/Core/Components/Sources/Extensions/View+Font.swift b/OUDS/Core/Components/Sources/Extensions/View+Font.swift new file mode 100644 index 000000000..ab6ee5d65 --- /dev/null +++ b/OUDS/Core/Components/Sources/Extensions/View+Font.swift @@ -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 Foundation +import OUDSTokensSemantic +import SwiftUI + +extension View { + + /// Applies a `CustomFontModifier` on the current `View` so as to add a specific `Font`. + /// - Parameters: + /// - familyName: The font family name to load later (e.g. "Luciole") + /// - token: The typography token to use to get useful values for `compact` or `regular` mode + /// - Returns: The `View` with the custom font applied + func customFont(familyName: String, typography token: TypographyCompositeSemanticToken) -> some View { + self.modifier(CustomFontModifier(token: token, fontFamilyName: familyName)) + } + + /// Applies a `FontModifier` to use the system font on the current `View` with a specific token + /// - Parameter token: The typography token to use to get useful values for `compact` or `regular` mode + /// - Returns: The `View` with the custom font applied + func systemFont(typography token: TypographyCompositeSemanticToken) -> some View { + self.modifier(FontModifier(token: token)) + } +} diff --git a/OUDS/Core/Components/Sources/Extensions/View+Shadows.swift b/OUDS/Core/Components/Sources/Extensions/View+Shadows.swift new file mode 100644 index 000000000..989587d75 --- /dev/null +++ b/OUDS/Core/Components/Sources/Extensions/View+Shadows.swift @@ -0,0 +1,31 @@ +// +// 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 OUDSTokensSemantic +import SwiftUI + +extension View { + + /// Wraps the *SwiftUI* `shadow(color:radius:x:y)` method so as to use as `radius` value + /// the computed `radius` value of the given `ElevationCompositeSemanticToken`. + /// - Parameter elevation: The token to give for the shadow / elevation effect + /// - Returns `View`: The current `View` with the shadow / elevation effect + public func shadow(elevation: ElevationCompositeSemanticToken) -> some View { + return self + .shadow(color: elevation.color.color, + radius: elevation.radius, + x: CGFloat(elevation.x), + y: CGFloat(elevation.y)) + } +} diff --git a/OUDS/Core/Components/Sources/Extensions/View+Typography.swift b/OUDS/Core/Components/Sources/Extensions/View+Typography.swift new file mode 100644 index 000000000..d45982290 --- /dev/null +++ b/OUDS/Core/Components/Sources/Extensions/View+Typography.swift @@ -0,0 +1,205 @@ +// +// 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 OUDS +import SwiftUI + +// MARK: - View extensions for typography + +extension View { + + /// Modifies the current `View` to apply a *display large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeDisplayLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeDisplayLarge)) + } + + /// Modifies the current `View` to apply a *display medium* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeDisplayMedium(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeDisplayMedium)) + } + + /// Modifies the current `View` to apply a *display small* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeDisplaySmall(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeDisplaySmall)) + } + + /// Modifies the current `View` to apply a *heading x large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeHeadingXLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeHeadingXLarge)) + } + + /// Modifies the current `View` to apply a *heading large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeHeadingLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeHeadingLarge)) + } + + /// Modifies the current `View` to apply a *heading medium* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeHeadingMedium(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeHeadingMedium)) + } + + /// Modifies the current `View` to apply a *heading small* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeHeadingSmall(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeHeadingSmall)) + } + + /// Modifies the current `View` to apply a *body default large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeBodyDefaultLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyDefaultLarge)) + } + + /// Modifies the current `View` to apply a *body default medium* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeBodyDefaultMedium(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyDefaultMedium)) + } + + /// Modifies the current `View` to apply a *body default small* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeBodyDefaultSmall(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyDefaultSmall)) + } + + /// Modifies the current `View` to apply a *body strong large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeBodyStrongLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyStrongLarge)) + } + + /// Modifies the current `View` to apply a *body strong medium* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeBodyStrongMedium(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyStrongMedium)) + } + + /// Modifies the current `View` to apply a *body strong small* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeBodyStrongSmall(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyStrongSmall)) + } + + /// Modifies the current `View` to apply a *label default x large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelDefaultXLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeLabelDefaultXLarge)) + } + + /// Modifies the current `View` to apply a *label default large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelDefaultLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyDefaultLarge)) + } + + /// Modifies the current `View` to apply a *label default medium* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelDefaultMedium(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyDefaultMedium)) + } + + /// Modifies the current `View` to apply a *label default small* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelDefaultSmall(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeBodyDefaultSmall)) + } + + /// Modifies the current `View` to apply a *label strong x large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelStrongXLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeLabelStrongXLarge)) + } + + /// Modifies the current `View` to apply a *label strong large* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelStrongLarge(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeLabelStrongLarge)) + } + + /// Modifies the current `View` to apply a *label strong medium* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelStrongMedium(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeLabelStrongMedium)) + } + + /// Modifies the current `View` to apply a *label strong small* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelStrongSmall(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeLabelStrongSmall)) + } + + /// Modifies the current `View` to apply a *code medium* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelCodeMedium(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeCodeMedium)) + } + + /// Modifies the current `View` to apply a *code small* typography. + /// The current `OUDSTheme` must be given in parameter because `@Environment` property cannot be accessed through an extension or inside a method. + /// - Parameter theme: The current `OUDSTheme` to use to load the current font family and the suitable typography semantic token. + /// - Returns some View: The current `View` but with new typography applied + public func typeLabelCodeSmall(_ theme: OUDSTheme) -> some View { + self.modifier(TypographyModifier(customFontFamily: theme.customFontFamily, typography: theme.typeCodeSmall)) + } +} diff --git a/OUDS/Core/Components/Sources/Forms/TextInput/OUDSFormsTextInput.swift b/OUDS/Core/Components/Sources/Forms/TextInput/OUDSFormsTextInput.swift index cf8fc4e7e..0a9d6f14e 100644 --- a/OUDS/Core/Components/Sources/Forms/TextInput/OUDSFormsTextInput.swift +++ b/OUDS/Core/Components/Sources/Forms/TextInput/OUDSFormsTextInput.swift @@ -11,33 +11,54 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation +import OUDS import SwiftUI -import OUDSThemesCommons // To get @Environment(\.theme) var theme /// An OUDS component for text input in formulars. -/// **Warning: This is a draft component ** +/// __Warning: This is a draft component__. +/// +/// This component is created to illustrate the mecanism of theme and tokens. public struct OUDSFormsTextInput: View { - var placeholder: String + // MARK: - Properties + + private let label: String + private let hint: String + private let placeholder: String + private let isEnabled: Bool + @Binding var value: String - var isEnabled: Bool @Environment(\.colorScheme) var colorScheme @Environment(\.theme) var theme - public init(placeholder: String, value: Binding, isEnabled: Bool = true) { + // MARK: - Initializer + + /// Use this initializer to create a text field that binds to a bound optional + /// value and propose a placeholder. + /// + /// - Parameters: + /// - label: The text to display in the top of the component + /// - hint: The text to display in above the input field + /// - placeholder: Text in placeholder + /// - value: Binding of the value + /// - isEnabled: Flag to indicate if input is enabled (_true_ by default) + public init(label: String, hint: String, placeholder: String, value: Binding, isEnabled: Bool = true) { + self.label = label + self.hint = hint self.placeholder = placeholder self._value = value self.isEnabled = isEnabled } + // MARK: - Body + public var body: some View { VStack(spacing: theme.spacePaddingBlockComponentTall) { Label( title: { - Text("Example of OUDSFormsTextInput") + Text(label) .fontWeight(theme.ftiTitleFontWeight.fontWeight) .font(.system(size: theme.ftiTitleFontSize)) .foregroundColor(theme.ftiTitleColor.color) @@ -45,7 +66,7 @@ public struct OUDSFormsTextInput: View { icon: { /*@START_MENU_TOKEN@*/Image(systemName: "42.circle")/*@END_MENU_TOKEN@*/ } ) - Text("Write bellow some awesome text!") + Text(hint) .fontWeight(theme.ftiSubtitleFontWeight.fontWeight) .font(.system(size: theme.ftiSubtitleFontSize)) .foregroundColor(theme.ftiSubtitleColor.color) diff --git a/OUDS/Core/Components/Sources/ViewModifiers/BorderStyleModifier.swift b/OUDS/Core/Components/Sources/ViewModifiers/BorderStyleModifier.swift new file mode 100644 index 000000000..23099fd58 --- /dev/null +++ b/OUDS/Core/Components/Sources/ViewModifiers/BorderStyleModifier.swift @@ -0,0 +1,114 @@ +// +// 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 OUDSTokensSemantic +import OUDSFoundations +import SwiftUI + +/// A `ViewModifier` which will apply a specific border style to a `View` using several semantic tokens. +struct BorderStyleModifier: ViewModifier { + + // MARK: - Properties + + /// The style to apply on the component + private let token: BorderStyleSemanticToken + + /// The width of the border + private let width: BorderWidthSemanticToken + + /// The radius of the border to apply + private let radius: BorderRadiusSemanticToken + + /// The color in light scheme of the border + private let colorLight: ColorSemanticToken + + /// The color in dark scheme of the border + private let colorDark: ColorSemanticToken + + /// Color to apply depending to the `colorScheme` + private var colorToApply: Color { + colorScheme == .light ? colorLight.color : colorDark.color + } + + /// To know if the device is in light mode or in dark mode + @Environment(\.colorScheme) private var colorScheme + + // MARK: - Initializer + + init(_ token: BorderStyleSemanticToken, + _ width: BorderWidthSemanticToken, + _ radius: BorderRadiusSemanticToken, + _ colorLight: ColorSemanticToken, + _ colorDark: ColorSemanticToken) { + self.token = token + self.width = width + self.radius = radius + self.colorLight = colorLight + self.colorDark = colorDark + if token != "solid" && token != "dashed" && token != "dotted" { + OUDSLogger.error("Unmanaged token: '\(token)'!") + } + } + + // MARK: - Body + + @ViewBuilder + func body(content: Content) -> some View { + if token == "solid" { + solid(content) + } else if token == "dashed" { + dashed(content) + } else if token == "dotted" { + dotted(content) + } else { // if token == "none" and unmanaged cases + none(content) + } + } + + private func none(_ content: Content) -> some View { + content + } + + private func solid(_ content: Content) -> some View { + content.background( + RoundedRectangle( + cornerRadius: radius, + style: .circular + ) + .border(colorToApply, width: width) + ) + } + + private func dashed(_ content: Content) -> some View { + content.background( + RoundedRectangle( + cornerRadius: radius, + style: .circular + ) + .stroke(style: StrokeStyle(lineWidth: width, dash: [10, 5])) + .foregroundColor(colorToApply) + ) + } + + private func dotted(_ content: Content) -> some View { + content.background( + RoundedRectangle( + cornerRadius: radius, + style: .circular + ) + .stroke(style: StrokeStyle(lineWidth: width, dash: [1, 5])) + .foregroundColor(colorToApply) + ) + } +} diff --git a/OUDS/Core/Components/Sources/ViewModifiers/CustomFontModifier.swift b/OUDS/Core/Components/Sources/ViewModifiers/CustomFontModifier.swift new file mode 100644 index 000000000..de578b385 --- /dev/null +++ b/OUDS/Core/Components/Sources/ViewModifiers/CustomFontModifier.swift @@ -0,0 +1,56 @@ +// +// 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 OUDSTokensSemantic +import SwiftUI + +/// A `ViewModifier` applying a custom font on a `View` +/// Note that `CustomFontModifier` expects to lad a custom external font and not any font embeded in the device. +struct CustomFontModifier: ViewModifier { + + // MARK: - Properties + + /// The typography style to apply + let token: TypographyCompositeSemanticToken + + /// The name of the custom font family, should be registered previously in the app, like "Luciole". + let fontFamilyName: String + + /// The size of the font to apply + private var fontSize: CGFloat { + sizeClass == .compact ? token.compact.size : token.regular.size + } + + /// The line spacing to apply line height effect + private var lineSpacing: CGFloat { + sizeClass == .compact + ? token.compact.lineHeight - token.compact.size + : token.regular.lineHeight - token.regular.size + } + + /// The weight to apply on the font, like "Bold" or "BoldItalic" + private var weight: String { + sizeClass == .compact ? token.compact.weight : token.regular.weight + } + + @Environment(\.horizontalSizeClass) private var sizeClass // TODO: reguar / comapct mode util + + // MARK: - Body + + func body(content: Content) -> some View { + content + .font(.custom(fontFamilyName.compose(withFont: weight), size: fontSize)) + .lineSpacing(lineSpacing) + } +} diff --git a/OUDS/Core/Components/Sources/ViewModifiers/FontModifier.swift b/OUDS/Core/Components/Sources/ViewModifiers/FontModifier.swift new file mode 100644 index 000000000..b59bb1239 --- /dev/null +++ b/OUDS/Core/Components/Sources/ViewModifiers/FontModifier.swift @@ -0,0 +1,54 @@ +// +// 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 OUDSTokensSemantic +import SwiftUI + +/// A `ViewModifier` which will apply the system `Font` in a component `View` using a `TypographyCompositeSemanticToken` +/// Note that `FontModifier` use default system font but nothing for others fonts embeded in device +struct FontModifier: ViewModifier { + + // MARK: - Properties + + // TODO: How to manage other fonts on device? + + let token: TypographyCompositeSemanticToken + + /// The size of the font to apply + private var fontSize: CGFloat { + sizeClass == .compact ? token.compact.size : token.regular.size + } + + /// The line spacing to apply line height effect + private var lineSpacing: CGFloat { + sizeClass == .compact + ? token.compact.lineHeight - token.compact.size + : token.regular.lineHeight - token.regular.size + } + + /// The weight to apply on the font. + private var weight: Font.Weight { + sizeClass == .compact ? token.compact.weight.fontWeight : token.regular.weight.fontWeight + } + + @Environment(\.horizontalSizeClass) private var sizeClass + + // MARK: - Body + + func body(content: Content) -> some View { + content + .font(.system(size: fontSize, weight: weight)) + .lineSpacing(lineSpacing) + } +} diff --git a/OUDS/Core/Components/Sources/ViewModifiers/TypographyModifier.swift b/OUDS/Core/Components/Sources/ViewModifiers/TypographyModifier.swift new file mode 100644 index 000000000..ddc400b62 --- /dev/null +++ b/OUDS/Core/Components/Sources/ViewModifiers/TypographyModifier.swift @@ -0,0 +1,74 @@ +// +// 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 OUDS +import OUDSFoundations +import OUDSTokensRaw +import OUDSTokensSemantic +import SwiftUI + +// swiftlint:disable line_length +/// A `ViewModifier` which will make possible to get the horizontal and vertical classes as `@Environment` values +/// so as to define the viewport and use finaly the suitable `TypographyCompositeSemanticToken`. +/// In fact _Swift extension_ does not allow to have such stored properties, and we don't want to use *UIKit* `UIScreen.main.traitCollection` to get values +/// which may be out of date. +/// For more details about layouts, see [the Apple documentation about devices dimensions](https://developer.apple.com/design/human-interface-guidelines/layout#iOS-iPadOS-device-size-classes) +struct TypographyModifier: ViewModifier { + + /// The name of a possible custom font family, or `nil` if the font is use is _system font_ + let customFontFamily: TypographyFontFamilyRawToken? + /// The typography to apply for *compact* or *regular* modes + let typography: TypographyCompositeSemanticToken + + /// To get programatically and on the fly the horizontal layout size + @Environment(\.horizontalSizeClass) private var horizontalSizeClass + /// To get programatically and on the fly the vertical layout size + @Environment(\.verticalSizeClass) private var verticalSizeClass + + /// Says wether or not the layout is in *compact mode* + private var isCompactMode: Bool { + horizontalSizeClass == .compact || verticalSizeClass == .compact + } + + /// Says wether or not the layout is in *regular mode* + private var isRegularMode: Bool { + horizontalSizeClass == .regular || verticalSizeClass == .regular + } + + /// Returns the `TypographyCompositeRawToken` to apply depending to the layour mode + private var adaptiveTypography: TypographyCompositeRawToken { + isCompactMode ? typography.compact : typography.regular + } + + /// According to the current `OUDSTheme` and if a custom font is applied or not, returns the suitable `View` + private func adaptiveFont() -> Font { + if let fontFamilyName = customFontFamily { + let composedFontFamily = fontFamilyName.compose(withFont: adaptiveTypography.weight) + let customFont: Font = .custom(composedFontFamily, size: adaptiveTypography.size) + return customFont + } else { + return .system(size: adaptiveTypography.size, weight: adaptiveTypography.weight.fontWeight) + } + } + + /// Applies to the `Content` the *adaptive font* (i.e. *font family*, *font weight*, *font size* and the *line height* + /// depending to the current `TypographyCompositeSemanticToken` + func body(content: Content) -> some View { + content + .font(adaptiveFont()) + .lineSpacing(adaptiveTypography.lineHeight) + // .tracking() for letter spacing + } +} +// swiftlint:enable line_length diff --git a/OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md b/OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md new file mode 100644 index 000000000..35d3be579 --- /dev/null +++ b/OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md @@ -0,0 +1,71 @@ +# ``OUDSComponents`` + +The catalog of all components provided by OUDS. + +@Metadata { + @TechnologyRoot + @SupportedLanguage(objc) +} + +## Overview + +Comming soon + +## Topics + +### Apply shadow effect + +The unified design system implemented by OUDS iOS library allows to apply *elevation effets* on a `View`, i.e. a shadow under the component. +Because the design tool in use is _Figma_ which defines such shadow with a _blur_ and a _spread_ radiuses, and because _SwfitUI_ uses only its own _radius_ definition, an extension of `View` has been implemented to let users apply some effect using an [`ElevationCompositeSemanticToken`](https://ios.unified-design-system.orange.com/documentation/oudstokenssemantic/elevationcompositesemantictoken) from the [OUDSTokensSemantic](https://ios.unified-design-system.orange.com/documentation/oudstokenssemantic/) library thanks to the method `shadow(elevation: ElevationCompositeSemanticToken)`. + +```swift +// For example, apply the elevation effect "elevationDragLight" from your theme: +myView.shadow(elevation: theme.elevationDragLight) + +// And in the theme this "elevationDragLight" has been defined for example like: +@objc open var elevationDragLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_500 } +ColorRawTokens.colorTransparentBlack400) + +// And if you look deeper, the raw token "elevationBottom_3_500" can be like: +public static let elevationBottom_3_500 = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack500) + +// Blur will be used to compute the radius value +``` + +### Apply a specific typography + +Your application identity can be strongly based on the *typography* you use, i.e. the font family you choose and other configuration details like the font size or the font weight. + +With OUDS, typography depends to the class size, i.e. wether or not the application is in _compact mode_ or in _regular mode_, and is defined with a [`TypographyCompositeSemanticToken`](https://ios.unified-design-system.orange.com/documentation/oudstokenssemantic/typographycompositesemantictoken). defined in the [`OUDSTkensSemantic` `TypographySemanticTokens`](https://ios.unified-design-system.orange.com/documentation/oudstokenssemantic/typographysemantictokens/). + +The _theme_ contains lots of `TypographyCompositeSemanticToken` listing all the combinations of typography you can apply, and these *composite semantic tokens* use *composite raw tokens*. For example: + +```swift +// Here is a definition of a semantic token inside the theme for typography "typeDisplayMedium": +@objc open var typeDisplayMedium: TypographyCompositeSemanticToken { + TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold750, regular: TypographyRawTokens.typeBold1050) +} + +// And here are the raw tokebs definitions: +public static let typeBold750 = TypographyCompositeRawToken(size: fontSize750, lineHeight: fontLineHeight850, weight: fontWeight700) + +public static let typeBold1050 = TypographyCompositeRawToken(size: fontSize1050, lineHeight: fontLineHeight1150, weight: fontWeight700) +``` + +However the _theme_ must know which _font family_ to apply, and this font family can be a _custom one_ or the _system one_. +Thus, we let the users define the font family they want by overriding the `customFontFamily` property. This value will be used to compute the typography, if not defined the systme font will be used. + +Thus, if you want to apply a specific typography to a `View`, supposing you defined previously the semantic tokens, just call the method you want and gives as parameter the theme (to get the custom font if defined): + +```swift +// Apply typography "type body default small" +myView.typeBodyDefaultSmall(theme) + +// Apply typography "type label strong X large" +myView.typeLabelStrongXLarge(theme) + +// Etc. +``` +### Group + +- ``OUDSFormsTextInput`` diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+ButtonsComponentTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+ButtonsComponentTokens.swift new file mode 100644 index 000000000..1c691cf95 --- /dev/null +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+ButtonsComponentTokens.swift @@ -0,0 +1,40 @@ +// +// 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 OUDSTokensRaw +import OUDSTokensSemantic + +/// Defines for `OUDSButton` the basic configuration which can be overriden in subthemes / subclasses of this theme. +/// **Warning: These are random and dumb values** +extension OUDSTheme: ButtonsComponentTokens { + + @objc open var buttonInternalSpacing: SpacingPaddingInlineSemanticToken { spacePaddingInlineComponentShort } + + @objc open var buttonBorderStyle: BorderStyleSemanticToken { borderStyleDefault } + @objc open var buttonBorderColorLight: ColorSemanticToken { colorBorderDefaultLight! } + @objc open var buttonBorderColorDark: ColorSemanticToken { colorBorderDefaultDark! } + @objc open var buttonBorderWidth: BorderWidthSemanticToken { borderWidthDefault } + @objc open var buttonBorderRadius: BorderRadiusSemanticToken { borderRadiusShort } + + @objc open var buttonForegroundColorLight: ColorSemanticToken { colorContentBrandPrimaryLight! } + @objc open var buttonForegroundColorDark: ColorSemanticToken { colorContentBrandPrimaryDark! } + @objc open var buttonBackgroundColorLight: ColorSemanticToken { colorBackgroundBrandPrimaryLight! } + @objc open var buttonBackgroundColorDark: ColorSemanticToken { colorBackgroundBrandPrimaryDark! } + + @objc open var buttonWidth: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension3000 } + @objc open var buttonHeight: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension1000 } + + @objc open var buttonTypography: TypographyCompositeSemanticToken { typeDisplayMedium } +} diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift similarity index 86% rename from OUDS/Core/Themes/Commons/Sources/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift index bce0985f4..a6a674050 100644 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+ComponentTokens/OUDSTheme+FormsTextInputComponentToken.swift @@ -16,11 +16,12 @@ import OUDSTokensRaw import OUDSTokensSemantic import OUDSTokensComponent -/// Defines for `FormsTextInputComponentToken` the basic configuration which can be overriden in subthemes / subclasses of this theme. +/// Defines for `FormsTextInputComponentTokens` the basic configuration which can be overriden in subthemes / subclasses of this theme. /// **Warning: These are random and dumb values** -extension OUDSTheme: FormsTextInputComponentToken { +extension OUDSTheme: FormsTextInputComponentTokens { + + // NOTE: What should we done if missing value? E.g. missing color or alias with empty values in the end - // TODO: What should we done if missing value? E.g. missing color or alias with empty values in the end private static let defaultBlack: ColorSemanticToken = ColorRawTokens.colorFunctionalBlack private static let defaultWhite: ColorSemanticToken = ColorRawTokens.colorFunctionalWhite @@ -35,7 +36,7 @@ extension OUDSTheme: FormsTextInputComponentToken { @objc open var ftiBackgroundColorLight: ColorSemanticToken { colorBackgroundDefaultPrimaryLight ?? Self.defaultWhite } @objc open var ftiBackgroundColorDark: ColorSemanticToken { colorBackgroundDefaultPrimaryDark ?? Self.defaultBlack } - @objc open var ftiBorderColor: ColorSemanticToken { colorBorderEmphasisLight ?? Self.defaultBlack } + @objc open var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedLight ?? Self.defaultBlack } @objc open var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDefault } diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+BorderSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+BorderSemanticTokens.swift similarity index 83% rename from OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+BorderSemanticTokens.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+BorderSemanticTokens.swift index f549df97c..598c96909 100644 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+BorderSemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+BorderSemanticTokens.swift @@ -26,10 +26,10 @@ extension OUDSTheme: BorderSemanticTokens { @objc open var borderWidthNone: BorderWidthSemanticToken { BorderRawTokens.borderWidth0 } @objc open var borderWidthDefault: BorderWidthSemanticToken { BorderRawTokens.borderWidth25 } @objc open var borderWidthThin: BorderWidthSemanticToken { BorderRawTokens.borderWidth25 } - @objc open var borderWidthThick: BorderWidthSemanticToken { BorderRawTokens.borderWidth50 } - @objc open var borderWidthThicker: BorderWidthSemanticToken { BorderRawTokens.borderWidth75 } - @objc open var borderWidthThickest: BorderWidthSemanticToken { BorderRawTokens.borderWidth100 } - @objc open var borderWidthInterfactivePrimaryFocus: BorderWidthSemanticToken { BorderRawTokens.borderWidth100 } + @objc open var borderWidthMedium: BorderWidthSemanticToken { BorderRawTokens.borderWidth50 } + @objc open var borderWidthThick: BorderWidthSemanticToken { BorderRawTokens.borderWidth75 } + @objc open var borderWidthThicker: BorderWidthSemanticToken { BorderRawTokens.borderWidth100 } + @objc open var borderWidthOutsideFocus: BorderWidthSemanticToken { BorderRawTokens.borderWidth50 } // MARK: Semantic token - Border - Radius @@ -38,8 +38,6 @@ extension OUDSTheme: BorderSemanticTokens { @objc open var borderRadiusShort: BorderRadiusSemanticToken { BorderRawTokens.borderRadius75 } @objc open var borderRadiusMedium: BorderRadiusSemanticToken { BorderRawTokens.borderRadius150 } @objc open var borderRadiusTall: BorderRadiusSemanticToken { BorderRawTokens.borderRadius300 } - @objc open var borderRadiusPill: BorderRadiusSemanticToken { BorderRawTokens.borderRadius9999 } - // TODO: How to deal with "border-radius-circle : 50%"? // MARK: Semantic token - Border - Style diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift similarity index 71% rename from OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift index bfb004b11..a7505afc3 100644 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift @@ -61,16 +61,16 @@ extension OUDSTheme: ColorSemanticTokens { @objc open var sysColorBrandNeutralMutedHigher: ColorAliasSemanticToken? { nil } @objc open var sysColorBrandNeutralMutedHighest: ColorAliasSemanticToken? { nil } - // MARK: Semantic token - Colors - Alias - Neutral - Emphasis + // MARK: Semantic token - Colors - Alias - Neutral - Emphasized - @objc open var sysColorBrandNeutralEmphasisLowest: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray400 } - @objc open var sysColorBrandNeutralEmphasisLower: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray480 } - @objc open var sysColorBrandNeutralEmphasisLow: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray560 } - @objc open var sysColorBrandNeutralEmphasisMedium: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray640 } - @objc open var sysColorBrandNeutralEmphasisHigh: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray720 } - @objc open var sysColorBrandNeutralEmphasisHigher: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray800 } - @objc open var sysColorBrandNeutralEmphasisHighest: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray880 } - @objc open var sysColorBrandNeutralEmphasisBlack: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalBlack } + @objc open var sysColorBrandNeutralEmphasizedLowest: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray400 } + @objc open var sysColorBrandNeutralEmphasizedLower: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray480 } + @objc open var sysColorBrandNeutralEmphasizedLow: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray560 } + @objc open var sysColorBrandNeutralEmphasizedMedium: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray640 } + @objc open var sysColorBrandNeutralEmphasizedHigh: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray720 } + @objc open var sysColorBrandNeutralEmphasizedHigher: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray800 } + @objc open var sysColorBrandNeutralEmphasizedHighest: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalDarkGray880 } + @objc open var sysColorBrandNeutralEmphasizedBlack: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalBlack } // MARK: Semantic token - Colors - Alias - Positive @@ -125,27 +125,27 @@ extension OUDSTheme: ColorSemanticTokens { // MARK: Semantic token - Colors - Background - Default - Primary @objc open var colorBackgroundDefaultPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - @objc open var colorBackgroundDefaultPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHighest } + @objc open var colorBackgroundDefaultPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHighest } // MARK: Semantic token - Colors - Background - Default - Secondary @objc open var colorBackgroundDefaultSecondaryLight: ColorSemanticToken? { sysColorBrandNeutralMutedLowest } - @objc open var colorBackgroundDefaultSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHigher } + @objc open var colorBackgroundDefaultSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHigher } // MARK: Semantic token - Colors - Background - Default - Tertiary @objc open var colorBackgroundDefaultTertiaryLight: ColorSemanticToken? { sysColorBrandAttractiveLowest } @objc open var colorBackgroundDefaultTertiaryDark: ColorSemanticToken? { sysColorBrandAttractiveHighest } - // MARK: Semantic token - Colors - Background - Emphasis - Primary + // MARK: Semantic token - Colors - Background - Emphasized - Primary - @objc open var colorBackgroundEmphasisPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - @objc open var colorBackgroundEmphasisPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisMedium } + @objc open var colorBackgroundEmphasizedPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + @objc open var colorBackgroundEmphasizedPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedMedium } - // MARK: Semantic token - Colors - Background - Emphasis - Secondary + // MARK: Semantic token - Colors - Background - Emphasized - Secondary - @objc open var colorBackgroundEmphasisSecondaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisMedium } - @objc open var colorBackgroundEmphasisSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHigh } + @objc open var colorBackgroundEmphasizedSecondaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedMedium } + @objc open var colorBackgroundEmphasizedSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHigh } // MARK: Semantic token - Colors - Background - Brand - Primary @@ -165,81 +165,81 @@ extension OUDSTheme: ColorSemanticTokens { @objc open var colorBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { sysColorBrandAttractiveLowest } @objc open var colorBackgroundStatusAttractiveMutedDark: ColorSemanticToken? { sysColorBrandAttractiveHighest } - // MARK: Semantic token - Colors - Background - Status - Attractive - Emphasis + // MARK: Semantic token - Colors - Background - Status - Attractive - Emphasized - @objc open var colorBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken? { sysColorBrandWarningDefault } - @objc open var colorBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken? { sysColorBrandWarningHighest } + @objc open var colorBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken? { sysColorBrandWarningDefault } + @objc open var colorBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken? { sysColorBrandWarningHighest } // MARK: Semantic token - Colors - Background - Status - Warning - Muted @objc open var colorBackgroundStatusWarningMutedLight: ColorSemanticToken? { sysColorBrandWarningLowest } - @objc open var colorBackgroundStatusWarningMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHigh } + @objc open var colorBackgroundStatusWarningMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHigh } - // MARK: Semantic token - Colors - Background - Status - Warning - Emphasis + // MARK: Semantic token - Colors - Background - Status - Warning - Emphasized - @objc open var colorBackgroundStatusWarningEmphasisLight: ColorSemanticToken? { sysColorBrandWarningDefault } - @objc open var colorBackgroundStatusWarningEmphasisDark: ColorSemanticToken? { sysColorBrandWarningHighest } + @objc open var colorBackgroundStatusWarningEmphasizedLight: ColorSemanticToken? { sysColorBrandWarningDefault } + @objc open var colorBackgroundStatusWarningEmphasizedDark: ColorSemanticToken? { sysColorBrandWarningHighest } // MARK: Semantic token - Colors - Background - Status - Negative - Muted @objc open var colorBackgroundStatusNegativeMutedLight: ColorSemanticToken? { sysColorBrandNegativeLowest } - @objc open var colorBackgroundStatusNegativeMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHigh } + @objc open var colorBackgroundStatusNegativeMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHigh } - // MARK: Semantic token - Colors - Background - Status - Negative - Emphasis + // MARK: Semantic token - Colors - Background - Status - Negative - Emphasized - @objc open var colorBackgroundStatusNegativeEmphasisLight: ColorSemanticToken? { sysColorBrandNegativeDefault } - @objc open var colorBackgroundStatusNegativeEmphasisDark: ColorSemanticToken? { sysColorBrandNegativeHighest } + @objc open var colorBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken? { sysColorBrandNegativeDefault } + @objc open var colorBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken? { sysColorBrandNegativeHighest } // MARK: Semantic token - Colors - Background - Status - Positive - Muted @objc open var colorBackgroundStatusPositiveMutedLight: ColorSemanticToken? { sysColorBrandPositiveLowest } @objc open var colorBackgroundStatusPositiveMutedInverse: ColorSemanticToken? { sysColorBrandPositiveLowest } - @objc open var colorBackgroundStatusPositiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHigh } + @objc open var colorBackgroundStatusPositiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHigh } - // MARK: Semantic token - Colors - Background - Status - Positive - Emphasis + // MARK: Semantic token - Colors - Background - Status - Positive - Emphasized - @objc open var colorBackgroundStatusPositiveEmphasisLight: ColorSemanticToken? { sysColorBrandPositiveDefault } - @objc open var colorBackgroundStatusPositiveEmphasisDark: ColorSemanticToken? { sysColorBrandPositiveHighest } + @objc open var colorBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken? { sysColorBrandPositiveDefault } + @objc open var colorBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken? { sysColorBrandPositiveHighest } // MARK: Semantic token - Colors - Background - Status - Information - Muted @objc open var colorBackgroundStatusInformationMutedLight: ColorSemanticToken? { sysColorBrandInformationLowest } - @objc open var colorBackgroundStatusInformationMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHigh } + @objc open var colorBackgroundStatusInformationMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHigh } - // MARK: Semantic token - Colors - Background - Status - Information - Emphasis + // MARK: Semantic token - Colors - Background - Status - Information - Emphasized - @objc open var colorBackgroundStatusInformationEmphasisLight: ColorSemanticToken? { sysColorBrandInformationDefault } - @objc open var colorBackgroundStatusInformationEmphasisDark: ColorSemanticToken? { sysColorBrandInformationHighest } + @objc open var colorBackgroundStatusInformationEmphasizedLight: ColorSemanticToken? { sysColorBrandInformationDefault } + @objc open var colorBackgroundStatusInformationEmphasizedDark: ColorSemanticToken? { sysColorBrandInformationHighest } // MARK: Semantic token - Colors - Content - Default - @objc open var colorContentDefaultLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + @objc open var colorContentDefaultLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } @objc open var colorContentDefaultDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } - // MARK: Semantic token - Colors - Content - Default - On background emphasis + // MARK: Semantic token - Colors - Content - Default - On background emphasized - @objc open var colorContentDefaultOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - @objc open var colorContentDefaultOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorContentDefaultOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + @objc open var colorContentDefaultOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } // MARK: Semantic token - Colors - Content - Muted - @objc open var colorContentMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } - @objc open var colorContentMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHigh } + @objc open var colorContentMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } + @objc open var colorContentMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHigh } - // MARK: Semantic token - Colors - Content - Muted - On background emphasis + // MARK: Semantic token - Colors - Content - Muted - On background emphasized - @objc open var colorContentMutedOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralMutedMedium } - @objc open var colorContentMutedOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedHigh } + @objc open var colorContentMutedOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralMutedMedium } + @objc open var colorContentMutedOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedHigh } // MARK: Semantic token - Colors - Content - Brand - Primary @objc open var colorContentBrandPrimaryLight: ColorSemanticToken? { sysColorBrandPrimaryDefault } @objc open var colorContentBrandPrimaryDark: ColorSemanticToken? { sysColorBrandPrimaryLow } - // MARK: Semantic token - Colors - Content - Brand - Primary - On background emphasis + // MARK: Semantic token - Colors - Content - Brand - Primary - On background emphasized - @objc open var colorContentBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandPrimaryLow } - @objc open var colorContentBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandPrimaryLow } + @objc open var colorContentBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandPrimaryLow } + @objc open var colorContentBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandPrimaryLow } // MARK: Semantic token - Colors - Content - Brand - Secondary @@ -275,32 +275,32 @@ extension OUDSTheme: ColorSemanticTokens { // MARK: Semantic token - Colors - Border - Default @objc open var colorBorderDefaultLight: ColorSemanticToken? { sysColorBrandNeutralMutedMedium } - @objc open var colorBorderDefaultDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } + @objc open var colorBorderDefaultDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } - // MARK: Semantic token - Colors - Border - Default - On background emphasis + // MARK: Semantic token - Colors - Border - Default - On background emphasized - @objc open var colorBorderDefaultOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } - @objc open var colorBorderDefaultOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } + @objc open var colorBorderDefaultOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } + @objc open var colorBorderDefaultOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } - // MARK: Semantic token - Colors - Border - Emphasis + // MARK: Semantic token - Colors - Border - Emphasized - @objc open var colorBorderEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - @objc open var colorBorderEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorBorderEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + @objc open var colorBorderEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } - // MARK: Semantic token - Colors - Border - Emphasis - On background emphasis + // MARK: Semantic token - Colors - Border - Emphasized - On background emphasized - @objc open var colorBorderEmphasisOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - @objc open var colorBorderEmphasisOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorBorderEmphasizedOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + @objc open var colorBorderEmphasizedOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } // MARK: Semantic token - Colors - Border - Brand - Primary @objc open var colorBorderBrandPrimaryLight: ColorSemanticToken? { sysColorBrandPrimaryDefault } @objc open var colorBorderBrandPrimaryDark: ColorSemanticToken? { sysColorBrandPrimaryLow } - // MARK: Semantic token - Colors - Border - Brand - Primary - On background emphasis + // MARK: Semantic token - Colors - Border - Brand - Primary - On background emphasized - @objc open var colorBorderBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandPrimaryLow } - @objc open var colorBorderBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandPrimaryLow } + @objc open var colorBorderBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandPrimaryLow } + @objc open var colorBorderBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandPrimaryLow } // MARK: Semantic token - Colors - Border - Brand - Secondary @@ -340,7 +340,7 @@ extension OUDSTheme: ColorSemanticTokens { // MARK: Semantic token - Colors - On background - Primary @objc open var colorOnBackgroundPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - @objc open var colorOnBackgroundPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisHighest } + @objc open var colorOnBackgroundPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedHighest } // MARK: Semantic token - Colors - On background - Secondary @@ -354,52 +354,52 @@ extension OUDSTheme: ColorSemanticTokens { // MARK: Semantic token - Colors - On background - Status - Attrative - Muted - @objc open var colorOnBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + @objc open var colorOnBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } @objc open var colorOnBackgroundStatusAttractiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } - // MARK: Semantic token - Colors - On background - Status - Attrative - Emphasis + // MARK: Semantic token - Colors - On background - Status - Attrative - Emphasized - @objc open var colorOnBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - @objc open var colorOnBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorOnBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + @objc open var colorOnBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } // MARK: Semantic token - Colors - On background - Status - Warning - Muted - @objc open var colorOnBackgroundStatusWarningMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + @objc open var colorOnBackgroundStatusWarningMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } @objc open var colorOnBackgroundStatusWarningMutedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } - // MARK: Semantic token - Colors - On background - Status - Warning - Emphasis + // MARK: Semantic token - Colors - On background - Status - Warning - Emphasized - @objc open var colorOnBackgroundStatusWarningEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - @objc open var colorOnBackgroundStatusWarningEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorOnBackgroundStatusWarningEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + @objc open var colorOnBackgroundStatusWarningEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } // MARK: Semantic token - Colors - On background - Status - Negative - Muted - @objc open var colorOnBackgroundStatusNegativeMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + @objc open var colorOnBackgroundStatusNegativeMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } @objc open var colorOnBackgroundStatusNegativeMutedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } - // MARK: Semantic token - Colors - On background - Status - Negative - Emphasis + // MARK: Semantic token - Colors - On background - Status - Negative - Emphasized - @objc open var colorOnBackgroundStatusNegativeEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - @objc open var colorOnBackgroundStatusNegativeEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorOnBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + @objc open var colorOnBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } // MARK: Semantic token - Colors - On background - Status - Positive - Muted - @objc open var colorOnBackgroundStatusPositiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + @objc open var colorOnBackgroundStatusPositiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } @objc open var colorOnBackgroundStatusPositiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } - // MARK: Semantic token - Colors - On background - Status - Positive - Emphasis + // MARK: Semantic token - Colors - On background - Status - Positive - Emphasized - @objc open var colorOnBackgroundStatusPositiveEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - @objc open var colorOnBackgroundStatusPositiveEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorOnBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + @objc open var colorOnBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } // MARK: Semantic token - Colors - On background - Status - Information - Muted - @objc open var colorOnBackgroundStatusInformationMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + @objc open var colorOnBackgroundStatusInformationMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } @objc open var colorOnBackgroundStatusInformationMutedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } - // MARK: Semantic token - Colors - On background - Status - Information - Emphasis + // MARK: Semantic token - Colors - On background - Status - Information - Emphasized - @objc open var colorOnBackgroundStatusInformationEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - @objc open var colorOnBackgroundStatusInformationEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } + @objc open var colorOnBackgroundStatusInformationEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + @objc open var colorOnBackgroundStatusInformationEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedLower } } diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+DimensionSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+DimensionSemanticTokens.swift similarity index 100% rename from OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+DimensionSemanticTokens.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+DimensionSemanticTokens.swift diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ElevationSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ElevationSemanticTokens.swift new file mode 100644 index 000000000..a779ced96 --- /dev/null +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ElevationSemanticTokens.swift @@ -0,0 +1,130 @@ +// +// 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 + +/// Defines basic values common to all themes for `ElevationSemanticTokenss`. +/// These values can be overriden inside `OUDSTheme` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination. +/// The aim of this extensions is to make relationships between all semantic tokens for elevations and associated raw tokens. +/// `OUDSTheme` can be seen as a kind of "abstract class" in _object oriented paradigm_. +extension OUDSTheme: ElevationSemanticTokens { + + // MARK: Semantic token - Elevation - X + + @objc open var elevationXNone: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXRaised: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXDrag: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXOverlayDefault: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXOverlayEmphasized: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXStickyDefault: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXStickyEmphasized: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXStickyNavigationScrolled: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + @objc open var elevationXFocus: ElevationXSemanticToken { ElevationRawTokens.elevationX0 } + + // MARK: Semantic token - Elevation - Y + + @objc open var elevationYNone: ElevationYSemanticToken { ElevationRawTokens.elevationY0 } + @objc open var elevationYRaised: ElevationYSemanticToken { ElevationRawTokens.elevationY100 } + @objc open var elevationYDrag: ElevationYSemanticToken { ElevationRawTokens.elevationY300 } + @objc open var elevationYOverlayDefault: ElevationYSemanticToken { ElevationRawTokens.elevationY200 } + @objc open var elevationYOverlayEmphasized: ElevationYSemanticToken { ElevationRawTokens.elevationY500 } + @objc open var elevationYStickyDefault: ElevationYSemanticToken { ElevationRawTokens.elevationY300 } + @objc open var elevationYStickyEmphasized: ElevationYSemanticToken { ElevationRawTokens.elevationY300 } + @objc open var elevationYStickyNavigationScrolled: ElevationYSemanticToken { ElevationRawTokens.elevationY300 } + @objc open var elevationYFocus: ElevationYSemanticToken { ElevationRawTokens.elevationY0 } + + // MARK: Semantic token - Elevation - Blur + + @objc open var elevationBlurNone: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur0 } + @objc open var elevationBlurRaised: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur200 } + @objc open var elevationBlurDrag: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } + @objc open var elevationBlurOverlayDefault: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur300 } + @objc open var elevationBlurOverlayEmphasized: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur600 } + @objc open var elevationBlurStickyDefault: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } + @objc open var elevationBlurStickyEmphasized: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } + @objc open var elevationBlurStickyNavigationScrolled: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } + @objc open var elevationBlurFocus: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur0 } + + // MARK: Semantic token - Elevation - Color - None + + @objc open var elevationColorNoneLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack0 } + @objc open var elevationColorNoneDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack0 } + + // MARK: Semantic token - Elevation - Color - Raised + + @objc open var elevationColorRaisedLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack500 } + @objc open var elevationColorRaisedDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack500 } + + // MARK: Semantic token - Elevation - Color - Drag + + @objc open var elevationColorDragLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack600 } + @objc open var elevationColorDragDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack600 } + + // MARK: Semantic token - Elevation - Color - Overlay - Default + + @objc open var elevationColorOverlayDefaultLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack400 } + @objc open var elevationColorOverlayDefaultDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack400 } + + // MARK: Semantic token - Elevation - Color - Overlay - Emphasized + + @objc open var elevationColorOverlayEmphasizedLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + @objc open var elevationColorOverlayEmphasizedDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + + // MARK: Semantic token - Elevation - Color - Sticky - Default + + @objc open var elevationColorStickyDefaultLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + @objc open var elevationColorStickyDefaultDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + + // MARK: Semantic token - Elevation - Color - Sticky - Emphasized + + @objc open var elevationColorStickyEmphasizedLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + @objc open var elevationColorStickyEmphasizedDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + + // MARK: Semantic token - Elevation - Color - Sticky - Navigation scrolled + + @objc open var elevationColorStickyNavigationScrolledLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + @objc open var elevationColorStickyNavigationScrolledDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + + // MARK: Semantic token - Elevation - Color - Focus + + @objc open var elevationColorFocusLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentWhite900 } + @objc open var elevationColorFocusDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentWhite900 } + + // MARK: Semantic token - Elevation - Box shadow + + @objc open var elevationRaisedLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } + @objc open var elevationRaisedDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } + + @objc open var elevationDragLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_500 } + @objc open var elevationDragDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_500 } + + @objc open var elevationOverlayDefaultLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_2_400 } + @objc open var elevationOverlayDefaultDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_2_400 } + + @objc open var elevationOverlayEmphasizedLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_5_300 } + @objc open var elevationOverlayEmphasizedDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_5_300 } + + @objc open var elevationStickyDefaultLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } + @objc open var elevationStickyDefaultDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } + + @objc open var elevationStickyEmphasizedLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } + @objc open var elevationStickyEmphasizedDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } + + @objc open var elevationStickyNavigationScrolledLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } + @objc open var elevationStickyNavigationScrolledDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } + + @objc open var elevationFocusLight: ElevationCompositeSemanticToken { ElevationCompositeRawToken(x: 0, y: 0, blur: 0, color: ColorRawTokens.colorTransparentWhite900) } + @objc open var elevationFocusDark: ElevationCompositeSemanticToken { ElevationCompositeRawToken(x: 0, y: 0, blur: 0, color: ColorRawTokens.colorTransparentWhite900) } +} diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift new file mode 100644 index 000000000..39f43bbb3 --- /dev/null +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift @@ -0,0 +1,48 @@ +// +// 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 + +/// Defines basic values common to all themes for `DimensionSemanticTokens`. +/// 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: GridSemanticTokens { + + // MARK: Semantic token - Grid - iOS Extra compact + + @objc open var gridExtraCompactWidth: GridExtraCompactSemanticToken { GridRawTokens.gridWidth100 } + @objc open var gridExtraCompactMinWidth: GridExtraCompactSemanticToken { GridRawTokens.gridMinWidthExtraCompact } + @objc open var gridExtraCompactMaxWidth: GridExtraCompactSemanticToken { GridRawTokens.gridMaxWidthExtraCompact } + @objc open var gridExtraCompactMargin: GridExtraCompactSemanticToken { GridRawTokens.gridMargin100 } + @objc open var gridExtraCompactColumnGap: GridExtraCompactSemanticToken { GridRawTokens.gridColumnGap100 } + @objc open var gridExtraCompactColumnCount: GridExtraCompactSemanticToken { GridRawTokens.gridColumnCount100 } + + // MARK: Semantic token - Grid - iOS Compact + + @objc open var gridCompactWidth: GridExtraCompactSemanticToken { GridRawTokens.gridWidth200 } + @objc open var gridCompactMinWidth: GridCompactSemanticToken { GridRawTokens.gridMinWidthCompact } + @objc open var gridCompactMaxWidth: GridCompactSemanticToken { GridRawTokens.gridMaxWidthCompact } + @objc open var gridCompactMargin: GridCompactSemanticToken { GridRawTokens.gridMargin300 } + @objc open var gridCompactColumnGap: GridCompactSemanticToken { GridRawTokens.gridColumnGap100 } + @objc open var gridCompactColumnCount: GridCompactSemanticToken { GridRawTokens.gridColumnCount400 } + + // MARK: Semantic token - Grid - iOS Regular + + @objc open var gridRegularWidth: GridExtraCompactSemanticToken { GridRawTokens.gridWidth400 } + @objc open var gridRegularMinWidth: GridRegularSemanticToken { GridRawTokens.gridMinWidthRegular } + @objc open var gridRegularMaxWidth: GridRegularSemanticToken { GridRawTokens.gridMaxWidthRegular } + @objc open var gridRegularMargin: GridRegularSemanticToken { GridRawTokens.gridMargin500 } + @objc open var gridRegularColumnGap: GridRegularSemanticToken { GridRawTokens.gridColumnGap300 } + @objc open var gridRegularColumnCount: GridRegularSemanticToken { GridRawTokens.gridColumnCount600 } +} diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+OpacitySemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+OpacitySemanticTokens.swift similarity index 93% rename from OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+OpacitySemanticTokens.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+OpacitySemanticTokens.swift index c7eb5fa4d..caa49027c 100644 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+OpacitySemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+OpacitySemanticTokens.swift @@ -23,6 +23,6 @@ extension OUDSTheme: OpacitySemanticTokens { @objc open var opacityWeaker: OpacitySemanticToken { OpacityRawTokens.opacity100 } @objc open var opacityWeak: OpacitySemanticToken { OpacityRawTokens.opacity300 } @objc open var opacityMedium: OpacitySemanticToken { OpacityRawTokens.opacity500 } - @objc open var opacityEmphasis: OpacitySemanticToken { OpacityRawTokens.opacity700 } + @objc open var opacityStrong: OpacitySemanticToken { OpacityRawTokens.opacity700 } @objc open var opacityOpaque: OpacitySemanticToken { OpacityRawTokens.opacity900 } } diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SizingSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SizingSemanticTokens.swift new file mode 100644 index 000000000..dfeea7377 --- /dev/null +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SizingSemanticTokens.swift @@ -0,0 +1,90 @@ +// +// 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 + +// swiftlint:disable line_length +/// Defines basic values common to all themes for `SizingSemanticTokens`. +/// 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: SizingSemanticTokens { + + // MARK: Semantic token - Sizing - Width height - Icon decorative + + @objc open var sizeWidthHeightIconShortest: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension200 } + @objc open var sizeWidthHeightIconShorter: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } + @objc open var sizeWidthHeightIconShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension400 } + @objc open var sizeWidthHeightIconMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension500 } + @objc open var sizeWidthHeightIconTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension600 } + @objc open var sizeWidthHeightIconTaller: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension700 } + @objc open var sizeWidthHeightIconTallest: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension900 } + + // MARK: Semantic token - Sizing - Width height - Icon component + + @objc open var sizeWidthHeightIsLabelSmallShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension150 } + @objc open var sizeWidthHeightIsLabelSmallMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension200 } + @objc open var sizeWidthHeightIsLabelSmallTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } + @objc open var sizeWidthHeightIsLabelMediumShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension200 } + @objc open var sizeWidthHeightIsLabelMediumMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } + @objc open var sizeWidthHeightIsLabelMediumTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } + @objc open var sizeWidthHeightIsLabelLargeShorter: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } + @objc open var sizeWidthHeightIsLabelLargeShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } + @objc open var sizeWidthHeightIsLabelLargeMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension350 } + @objc open var sizeWidthHeightIsLabelLargeTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension400 } + @objc open var sizeWidthHeightIsLabelLargeTaller: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension550 } + @objc open var sizeWidthHeightIsLabelXLargeShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension400 } + @objc open var sizeWidthHeightIsLabelXLargeMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension500 } + @objc open var sizeWidthHeightIsLabelXLargeTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension550 } + + // MARK: Semantic token - Sizing - Width height - Icon typography - Heading + + @objc open var sizeWidthHeightIconIsHeadingSmallShort: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension400, regular: DimensionRawTokens.dimension400) } + @objc open var sizeWidthHeightIconIsHeadingSmallMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension500, regular: DimensionRawTokens.dimension500 ) } + @objc open var sizeWidthHeightIconIsHeadingSmallTall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension550, regular: DimensionRawTokens.dimension550 ) } + @objc open var sizeWidthHeightIconIsHeadingMediumShort: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension400, regular: DimensionRawTokens.dimension500 ) } + @objc open var sizeWidthHeightIconIsHeadingMediumMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension500, regular: DimensionRawTokens.dimension550 ) } + @objc open var sizeWidthHeightIconIsHeadingMediumTall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension550, regular: DimensionRawTokens.dimension600 ) } + @objc open var sizeWidthHeightIconIsHeadingLargeShort: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension500, regular: DimensionRawTokens.dimension550 ) } + @objc open var sizeWidthHeightIconIsHeadingLargeMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension550, regular: DimensionRawTokens.dimension600 ) } + @objc open var sizeWidthHeightIconIsHeadingLargeTall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension600, regular: DimensionRawTokens.dimension650 ) } + @objc open var sizeWidthHeightIconIsHeadingXLargeShort: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension550, regular: DimensionRawTokens.dimension650 ) } + @objc open var sizeWidthHeightIconIsHeadingXLargeMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension600, regular: DimensionRawTokens.dimension700 ) } + @objc open var sizeWidthHeightIconIsHeadingXLargeTall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension650, regular: DimensionRawTokens.dimension800 ) } + + // MARK: Semantic token - Sizing - Width height - Icon typography - Body + + @objc open var sizeWidthHeightIconIsBodySmallShort: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension150, regular: DimensionRawTokens.dimension150 ) } + @objc open var sizeWidthHeightIconIsBodySmallMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension200, regular: DimensionRawTokens.dimension200 ) } + @objc open var sizeWidthHeightIconIsBodySmallTall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension250, regular: DimensionRawTokens.dimension250 ) } + @objc open var sizeWidthHeightIconIsBodyMediumShort: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension200, regular: DimensionRawTokens.dimension200 ) } + @objc open var sizeWidthHeightIconIsBodyMediumMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension250, regular: DimensionRawTokens.dimension250 ) } + @objc open var sizeWidthHeightIconIsBodyMediumTall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension300, regular: DimensionRawTokens.dimension300 ) } + @objc open var sizeWidthHeightIconIsBodyLargeShort: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension250, regular: DimensionRawTokens.dimension250 ) } + @objc open var sizeWidthHeightIconIsBodyLargeMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension300, regular: DimensionRawTokens.dimension300 ) } + @objc open var sizeWidthHeightIconIsBodyLargeTall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension350, regular: DimensionRawTokens.dimension350 ) } + + // MARK: Semantic token - Sizing - Max width + + @objc open var sizeMaxWidthTypographyDisplaySmall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension9000, regular: DimensionRawTokens.dimension9000 ) } + @objc open var sizeMaxWidthTypographyDisplayMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension9000, regular: DimensionRawTokens.dimension9000 ) } + @objc open var sizeMaxWidthTypographyDisplayLarge: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension9000, regular: DimensionRawTokens.dimension9000 ) } + @objc open var sizeMaxWidthTypographyHeadingSmall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension6000, regular: DimensionRawTokens.dimension6000 ) } + @objc open var sizeMaxWidthTypographyHeadingMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension9000, regular: DimensionRawTokens.dimension9000 ) } + @objc open var sizeMaxWidthTypographyHeadingLarge: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension9000, regular: DimensionRawTokens.dimension9000 ) } + @objc open var sizeMaxWidthTypographyHeadingXLarge: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension9000, regular: DimensionRawTokens.dimension9000 ) } + @objc open var sizeMaxWidthTypographyBodySmall: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension6000, regular: DimensionRawTokens.dimension6000 ) } + @objc open var sizeMaxWidthTypographyBodyMedium: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension6000, regular: DimensionRawTokens.dimension6000 ) } + @objc open var sizeMaxWidthTypographyBodyLarge: SizingCompositeSemanticToken { SizingCompositeSemanticToken(compact: DimensionRawTokens.dimension6000, regular: DimensionRawTokens.dimension6000 ) } +} +// swiftlint:enable line_length diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+SpacingSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpacingSemanticTokens.swift similarity index 84% rename from OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+SpacingSemanticTokens.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpacingSemanticTokens.swift index 41aa97c57..e38b6606c 100644 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+SpacingSemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpacingSemanticTokens.swift @@ -15,6 +15,7 @@ import Foundation import OUDSTokensRaw import OUDSTokensSemantic +// swiftlint:disable line_length /// Defines basic values common to all themes for `SpacingSemanticTokens`. /// 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: SpacingSemanticTokens { @@ -34,17 +35,16 @@ extension OUDSTheme: SpacingSemanticTokens { // MARK: Semantic token - Spacing - Layout fluid - // TODO: What should we do? In issue #36 there are 3 possible values (web paradigm ?), selected here the xl-2xl-3xl case - @objc open var spaceLayoutFluidNone: SpacingLayoutSemanticToken { DimensionRawTokens.dimension0 } - @objc open var spaceLayoutFluidSmash: SpacingLayoutSemanticToken { DimensionRawTokens.dimension50 } - @objc open var spaceLayoutFluidShortest: SpacingLayoutSemanticToken { DimensionRawTokens.dimension100 } - @objc open var spaceLayoutFluidShorter: SpacingLayoutSemanticToken { DimensionRawTokens.dimension200 } - @objc open var spaceLayoutFluidShort: SpacingLayoutSemanticToken { DimensionRawTokens.dimension300 } - @objc open var spaceLayoutFluidMedium: SpacingLayoutSemanticToken { DimensionRawTokens.dimension400 } - @objc open var spaceLayoutFluidTall: SpacingLayoutSemanticToken { DimensionRawTokens.dimension500 } - @objc open var spaceLayoutFluidTaller: SpacingLayoutSemanticToken { DimensionRawTokens.dimension600 } - @objc open var spaceLayoutFluidTallest: SpacingLayoutSemanticToken { DimensionRawTokens.dimension700 } - @objc open var spaceLayoutFluidSpacious: SpacingLayoutSemanticToken { DimensionRawTokens.dimension800 } + @objc open var spaceLayoutAdaptableNone: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension0, regular: DimensionRawTokens.dimension0) } + @objc open var spaceLayoutAdaptableSmash: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension25, regular: DimensionRawTokens.dimension50) } + @objc open var spaceLayoutAdaptableShortest: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension50, regular: DimensionRawTokens.dimension100) } + @objc open var spaceLayoutAdaptableShorter: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension100, regular: DimensionRawTokens.dimension150) } + @objc open var spaceLayoutAdaptableShort: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension150, regular: DimensionRawTokens.dimension200) } + @objc open var spaceLayoutAdaptableMedium: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension200, regular: DimensionRawTokens.dimension300) } + @objc open var spaceLayoutAdaptableTall: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension300, regular: DimensionRawTokens.dimension400) } + @objc open var spaceLayoutAdaptableTaller: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension400, regular: DimensionRawTokens.dimension500) } + @objc open var spaceLayoutAdaptableTallest: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension500, regular: DimensionRawTokens.dimension600) } + @objc open var spaceLayoutAdaptableSpacious: SpacingCompositeSemanticToken { SpacingCompositeSemanticToken(compact: DimensionRawTokens.dimension600, regular: DimensionRawTokens.dimension700) } // MARK: Semantic token - Spacing - Padding - Padding inline @@ -137,3 +137,4 @@ extension OUDSTheme: SpacingSemanticTokens { @objc open var spaceRowGapComponentIsIconTall: SpacingGapStackSemanticToken { DimensionRawTokens.dimension100 } @objc open var spaceRowGapComponentIsIconTaller: SpacingGapStackSemanticToken { DimensionRawTokens.dimension200 } } +// swiftlint:enable line_length diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift similarity index 60% rename from OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift index 2a8ad7fef..0a24b780d 100644 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+TypographySemanticTokens.swift @@ -15,21 +15,24 @@ import Foundation import OUDSTokensRaw import OUDSTokensSemantic +// swiftlint:disable line_length /// Defines basic values common to all themes for `TypographySemanticTokens`. /// 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: TypographySemanticTokens { // MARK: Semantic token - Typography - Font - Family - @objc open var fontFamily: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilySystem } - @objc open var fontFamilyDisplay: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilySystem } - @objc open var fontFamilyHeading: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilySystem } - @objc open var fontFamilyBody: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilySystem } - @objc open var fontFamilyLabel: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilySystem } - @objc open var fontFamilyCode: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilySystem } + @objc open var fontFamily: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilyBrandDefault } + @objc open var fontFamilyDisplay: TypographyFontFamilySemanticToken { fontFamily } + @objc open var fontFamilyHeading: TypographyFontFamilySemanticToken { fontFamily } + @objc open var fontFamilyBody: TypographyFontFamilySemanticToken { fontFamily } + @objc open var fontFamilyLabel: TypographyFontFamilySemanticToken { fontFamily } + @objc open var fontFamilyCode: TypographyFontFamilySemanticToken { TypographyRawTokens.fontFamilyMonospaceMenlo } // MARK: Semantic token - Typography - Font - Weight + @objc open var fontWeightDefault: TypographyFontWeightSemanticToken { TypographyRawTokens.fontWeight400 } + @objc open var fontWeightStrong: TypographyFontWeightSemanticToken { TypographyRawTokens.fontWeight700 } @objc open var fontWeightDisplay: TypographyFontWeightSemanticToken { TypographyRawTokens.fontWeight700 } @objc open var fontWeightHeading: TypographyFontWeightSemanticToken { TypographyRawTokens.fontWeight700 } @objc open var fontWeightBodyDefault: TypographyFontWeightSemanticToken { TypographyRawTokens.fontWeight400 } @@ -50,8 +53,6 @@ extension OUDSTheme: TypographySemanticTokens { @objc open var fontSizeMobileBodyLarge: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize250 } @objc open var fontSizeMobileBodyMedium: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize200 } @objc open var fontSizeMobileBodySmall: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize100 } - @objc open var fontSizeMobileCodeMedium: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize200 } - @objc open var fontSizeMobileCodeSmall: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize100 } // MARK: Semantic token - Typography - Font - Size - Tablet @@ -65,8 +66,6 @@ extension OUDSTheme: TypographySemanticTokens { @objc open var fontSizeTabletBodyLarge: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize250 } @objc open var fontSizeTabletBodyMedium: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize200 } @objc open var fontSizeTabletBodySmall: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize150 } - @objc open var fontSizeTabletCodeMedium: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize200 } - @objc open var fontSizeTabletCodeSmall: TypographyFontSizeSemanticToken { TypographyRawTokens.fontSize150 } // MARK: Semantic token - Typography - Font - Size - Others @@ -89,8 +88,6 @@ extension OUDSTheme: TypographySemanticTokens { @objc open var fontLineHeightMobileBodyLarge: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight450 } @objc open var fontLineHeightMobileBodyMedium: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight350 } @objc open var fontLineHeightMobileBodySmall: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight250 } - @objc open var fontLineHeightMobileCodeMedium: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight350 } - @objc open var fontLineHeightMobileCodeSmall: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight250 } // MARK: Semantic token - Typography - Font - Light height - Tablet @@ -104,8 +101,6 @@ extension OUDSTheme: TypographySemanticTokens { @objc open var fontLineHeightTabletBodyLarge: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight450 } @objc open var fontLineHeightTabletBodyMedium: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight350 } @objc open var fontLineHeightTabletBodySmall: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight250 } - @objc open var fontLineHeightTabletCodeMedium: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight350 } - @objc open var fontLineHeightTabletCodeSmall: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight250 } // MARK: Semantic token - Typography - Font - Light height - Others @@ -116,42 +111,42 @@ extension OUDSTheme: TypographySemanticTokens { @objc open var fontLineHeightCodeMedium: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight350 } @objc open var fontLineHeightCodeSmall: TypographyFontLineHeightSemanticToken { TypographyRawTokens.fontLineHeight250 } - // MARK: Semantic token - Typography - Font - Paragraph spacing - Mobile - - @objc open var fontParagraphSpacingMobileDisplayLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileDisplayMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileDisplaySmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileHeadingXLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileHeadingLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileHeadingMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileHeadingSmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileBodyLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileBodyMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileBodySmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileCodeMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingMobileCodeSmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - - // MARK: Semantic token - Typography - Font - Paragraph spacing - Tablet - - @objc open var fontParagraphSpacingTabletDisplayLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletDisplayMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletDisplaySmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletHeadingXLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletHeadingLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletHeadingMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletHeadingSmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletBodyLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletBodyMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletBodySmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletCodeMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingTabletCodeSmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - - // MARK: Semantic token - Typography - Font - Paragraph spacing - Others - - @objc open var fontParagraphSpacingLabelXLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingLabelLarge: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingLabelMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingLabelSmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingCodeMedium: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } - @objc open var fontParagraphSpacingCodeSmall: TypographyFontParagraphSpacingRawToken { TypographyRawTokens.fontParagraphSpacing100 } + // MARK: - Semantic tokens - Typography - Composites - Display + + @objc open var typeDisplayLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold850, regular: TypographyRawTokens.typeBold1450) } + @objc open var typeDisplayMedium: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold750, regular: TypographyRawTokens.typeBold1050) } + @objc open var typeDisplaySmall: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold650, regular: TypographyRawTokens.typeBold850) } + + // MARK: - Semantic tokens - Typography - Composites - Heading + + @objc open var typeHeadingXLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold550, regular: TypographyRawTokens.typeBold750) } + @objc open var typeHeadingLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold450, regular: TypographyRawTokens.typeBold550) } + @objc open var typeHeadingMedium: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold350, regular: TypographyRawTokens.typeBold450) } + @objc open var typeHeadingSmall: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold300, regular: TypographyRawTokens.typeBold350) } + + // MARK: - Semantic tokens - Typography - Composites - Body + + @objc open var typeBodyDefaultLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold250, regular: TypographyRawTokens.typeBold250) } + @objc open var typeBodyDefaultMedium: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold200, regular: TypographyRawTokens.typeBold200) } + @objc open var typeBodyDefaultSmall: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold150, regular: TypographyRawTokens.typeBold150) } + @objc open var typeBodyStrongLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold250, regular: TypographyRawTokens.typeBold250) } + @objc open var typeBodyStrongMedium: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold200, regular: TypographyRawTokens.typeBold200) } + @objc open var typeBodyStrongSmall: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold150, regular: TypographyRawTokens.typeBold150) } + + // MARK: - Semantic tokens - Typography - Composites - Label + + @objc open var typeLabelDefaultXLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold300, regular: TypographyRawTokens.typeBold300) } + @objc open var typeLabelDefaultLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold250, regular: TypographyRawTokens.typeBold250) } + @objc open var typeLabelDefaultMedium: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold200, regular: TypographyRawTokens.typeBold200) } + @objc open var typeLabelDefaultSmall: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold150, regular: TypographyRawTokens.typeBold150) } + @objc open var typeLabelStrongXLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold300, regular: TypographyRawTokens.typeBold300) } + @objc open var typeLabelStrongLarge: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold250, regular: TypographyRawTokens.typeBold250) } + @objc open var typeLabelStrongMedium: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold200, regular: TypographyRawTokens.typeBold200) } + @objc open var typeLabelStrongSmall: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold150, regular: TypographyRawTokens.typeBold150) } + + // MARK: - Semantic tokens - Typography - Composites - Code + + @objc open var typeCodeMedium: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold200, regular: TypographyRawTokens.typeBold200) } + @objc open var typeCodeSmall: TypographyCompositeSemanticToken { TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold150, regular: TypographyRawTokens.typeBold150) } } +// swiftlint:enable line_length diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift new file mode 100644 index 000000000..9548b86af --- /dev/null +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift @@ -0,0 +1,44 @@ +// +// 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 OUDSTokensSemantic + +/// This is a basic theme any theme must be a subclass off, or all themes must have as ancestor. +/// A Swift `class` has been used so as to allow to easily override some attributes and have inheritance, without having for developers +/// to implement all tokens. +/// Any properties of an overridable theme should be defined so as to provide defaults values. +/// We allow this theme to be derivated and be overriden. +/// +/// `OUDSTheme` can be seen as a kind of "abstract class" in _object oriented paradigm_. +/// **Warning: You are not supposed to use this abstract default theme directly. Please prefer `OrangeTheme` instead** +open class OUDSTheme { + + /// A theme can have a custom font which is not the system font + public let customFontFamily: TypographyFontFamilySemanticToken? + + /// Defines a basic kind of abstract theme to subclass then. + /// No custom font family will be used. + public convenience init() { + self.init(customFontFamily: nil) + } + + /// Defines a basic kind of abstract theme to subclass then. + /// - Parameters: + /// - customFontFamily: Set `nil` if system font to use, otherwise use the `TypographyFontFamilySemanticToken` you want to apply + public init(customFontFamily: TypographyFontFamilySemanticToken?) { + self.customFontFamily = customFontFamily + } + + // Please refer to extensions for properties, it will be more clear +} diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSThemeableView.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSThemeableView.swift similarity index 91% rename from OUDS/Core/Themes/Commons/Sources/OUDSThemeableView.swift rename to OUDS/Core/OUDS/Sources/OUDSTheme/OUDSThemeableView.swift index 6e08ecac9..67e280734 100644 --- a/OUDS/Core/Themes/Commons/Sources/OUDSThemeableView.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSThemeableView.swift @@ -36,8 +36,8 @@ extension EnvironmentValues { // MARK: - Themeable View /// This is a kind of root `SwiftUI.View` to add at the top level of your views tree so as to define -/// as an environement varable the theme which will be applied. -/// Any theme to apply must be a child of `OUDSTheme` +/// as an environement variable the theme which will be applied. +/// Any theme to apply must be a child of `OUDSTheme`, direct or not. public struct OUDSThemeableView: View where Content: View { private let theme: OUDSTheme diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/Components.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/Components.md new file mode 100644 index 000000000..4110613e8 --- /dev/null +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/Components.md @@ -0,0 +1,31 @@ +# Components + +_Components_ are defined in the [OUDSComponents](https://ios.unified-design-system.orange.com/documentation/oudstokenscomponent/) target and can be integrated in applications. + +❗**More details coming soon.**❗ + +## How to use components + +Import the target of components, and use the component you want: + +```swift +import OUDSComponents // To get the components + +struct YourView: View { + + @State private var writtenText: String = "" + + var body: some View { + OUDSFormsTextInput(placeholder: "Some placeholder to display", value: $writtenText) + } +} +``` + +Of course you must use in your root view the with the suitable theme: + +```swift + // The theme can be OrangeTheme or your own + OUDSThemeableView(theme: theTheme) { + + } +``` diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/GettingStarted.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/GettingStarted.md new file mode 100644 index 000000000..16c2840dc --- /dev/null +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/GettingStarted.md @@ -0,0 +1,27 @@ +# Getting Started with OUDS + +How to add the package as dependency, and import libraries + +❗**More details coming soon.**❗ + +## Integrate OUDS + +### Use Swift Package Manager + +If you want to add the iOS library of **Orange Unified Design System**, you need to add our _Swift Package_ into your project. +To do that, add a new _package dependency_ to your _Xcode_ project by refering to it with `https://github.com/Orange-OpenSource/ouds-ios`. +You are free to choose wether or not you want a branch or a specific tag, pick the solution you want. + +### Import the library you need + +You should use one (or several) of the following imports for your needs, which are basically _Swift Package_ products. + +```swift +import OUDS // If you want to define your theme or use OUDSThemeableView +import OUDSModules // To use modules +import OUDSComponents // To use components +import OUDSThemesOrange // To use the default theme +import OUDSTokensComponent // If you need to override or use directly components tokens +import OUDSTokenSemantic // If you need to override or use directly semantic tokens +import OUDSTokensRaw // If you need to override or use directly raw tokens +``` diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/Modules.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/Modules.md new file mode 100644 index 000000000..6116b234d --- /dev/null +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/Modules.md @@ -0,0 +1,6 @@ +# Modules + +A _module_ can be seen as a set of features and components to fill a need. +There is not module yet. + +❗**More details coming soon.**❗ diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md new file mode 100644 index 000000000..faa17d189 --- /dev/null +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md @@ -0,0 +1,127 @@ +# Themes + +_Themes_ are applications of specific values for _components tokens_ and _semantic tokens_ using in the end _raw tokens_. +A _theme_ contains any relevant _semantic tokens_ and _component tokens_ which can be used for components rendering. +A _theme_ has also _raw tokens_ associated to primitive types so as to give to _components_, written with _SwiftUI_, the needed values in the suitable type. A _theme_ can add for itself any new _tokens_. + +This library exposes today up to three themes: +1. [Orange Theme](https://ios.unified-design-system.orange.com/documentation/oudsthemesorange/) which can be seen as the default _theme_ ; +2. [Sosh Theme](https://ios.unified-design-system.orange.com/documentation/oudsthemessosh/) for *Sosh* ; +3. [Inverse Theme](https://ios.unified-design-system.orange.com/documentation/oudsthemesinverse/) for other use cases. +They both are based on an `OUDSTheme` defining default values. + +_Themes_ can be defined thanks to `open class` in Swift. It allows inheritance and derivation. + +_Themes_ have Swift _extensions_ so as to get the _tokens_ to define. These tokens are overriden thanks to `@objc open` combination so as to make possible to override these values in extensions (thanks to `@objc`) and from objects outside the module (thanks to `open`). Thus we can split values and responsabilities in different _Swift Package Manager_ targets and keep overriding and inheritance possible. + + +## Use themeable view + +```swift +// Make imports +import OUDS +import OUDSThemesOrange + +// Add themeable view to your root view +OUDSThemeableView(theme: OrangeTheme()) { + YourRootView() +} +``` + +## Define a custom theme if needed + +```swift +class YourCustomTheme: OrangeTheme { } + +extension YourCustomTheme { + + // Override components tokens if needed + override var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDrag } + override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThick } + + // Override colors semantic tokens if needed + override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun500 } + override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun800 } + + // Etc. +} +``` + +## How to create your own theme + +It is quite simple, you have to follow several steps. + +First, create a _Swift class_ which will inherit from `OrangeTheme` or `OUDSTheme`. +You can see `OrangeTheme` as more specified and less abtract as `OUDSTheme` which is the base of all themes. We do not recommend to sue directly the `OUDSTheme` as is. +Then, you should override the _semantic tokens_ and _components tokens_ you want ; we recommend to use _Swift extensions_ for clarity reasons. +If your theme needs to define its own _raw tokens_, you can also define them using a `enum` and the _raw tokens types_. + +For example: + +```swift +import Foundation +import SwiftUI +import OUDSTokensRaw // To get raw tokens +import OUDSTokensSemantic // To get semantic tokens +import OUDSTokensComponent // To get component tokens +import OUDSThemesOrange // To override OrangeTheme (which is default theme) + +// Can be for example a country theme +class OrangeCustomTheme: OrangeTheme { } + +extension OrangeCustomTheme { // For FormsTextInputComponentTokens, used in component FormsTextInputComponent + + public override var ftiTitleFontWeight: TypographyFontWeightSemanticToken { fontWeightLabelStrong } + public override var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelXLarge } + public override var ftiTitleColor: ColorSemanticToken { ColorRawTokens.colorFunctionalDodgerBlue500 } + + public override var ftiSubtitleFontWeight: TypographyFontWeightSemanticToken { fontWeightBodyDefault } + public override var ftiSubtitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelMedium } + public override var ftiSubtitleColor: ColorSemanticToken { ColorRawTokens.colorFunctionalMalachite500 } + + public override var ftiBackgroundColorLight: ColorSemanticToken { colorBackgroundDefaultPrimaryLight } + public override var ftiBackgroundColorDark: ColorSemanticToken { colorBackgroundDefaultPrimaryDark } + + public override var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedDark ?? MyThemeColorRawTokens.someAwesomeThemeExclusiveColor } + + public override var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDrag } + + public override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThick } +} + +extension OrangeCustomTheme { // For ColorSemanticTokens using anywhere + + override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun500 } + override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun800 } +} +``` + +And your own theme colors _raw tokens_: + +```swift + +public typealias MyThemeColorRawToken = ColorRawToken // Refer to type ColorRawToken for consistency + +public enum MyThemeColorRawTokens { + + public static let someAwesomeThemeExclusiveColor: MyThemeColorRawToken = "#12345600" + +} +``` + +Then for your root view: + +```swift +import SwiftUI +import OUDS // To get ``OUDSThemeableView`` + +struct MyAppRootView: View { + + var body: some View { + OUDSThemeableView(theme: OrangeCustomTheme()) { + // ... + } + } +} +``` + diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/Tokens.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/Tokens.md new file mode 100644 index 000000000..dd1c9b193 --- /dev/null +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/Tokens.md @@ -0,0 +1,179 @@ +# Tokens + +Design tokens represent the small, repeated design decisions that make up a design system's visual style. Tokens replace hard-coded static values, such as hexadecimal codes for color, with self-explanatory names. + +About responsabilities: +```mermaid +flowchart TD + A(Raw token) --> |Contains primitive type SwiftUI value| B(Semantic token) + B --> |Brings higher logic and functional meanings|C(Component token) + C --> |Helps to make match between View and semantics|D(Component) +``` + +Example: +```mermaid +flowchart TD + A(colorFunctionalDodgerBlue500) --> |#26B2FF| B(sysColorBrandInformationDefault) + B --> C(.informationIconbackgroundColor) + C --> D(InformationModalView) +``` + +*You can have the graphical rendering of this _Mermaid_ charts in the [README markdown](https://github.com/Orange-OpenSource/ouds-ios/blob/develop/OUDS/README.md).* +*Frustrated? Boost [the issue we submitted](https://github.com/swiftlang/swift-docc/issues/1026)* + +## Component tokens + +These _tokens_ ([OUDSTokensComponent](https://ios.unified-design-system.orange.com/documentation/oudstokenscomponent/)) can be used to apply some style and configuration values to _components_. +Thus if a component needs to change for example its _background color_, and if a _component token_ is used for it, then only the value of this _token_ should be changed without any modification on the _component_ definition. +_Components_ use _component tokens_ exposed through the _theme_ to get their style values. + +Example with a fake component `FormsTextInputComponentTokens`: + +```swift +// Declare the component tokens +public protocol FormsTextInputComponentTokens { + var ftiTitleFontWeight: TypographyFontWeightSemanticToken { get } + var ftiTitleFontSize: TypographyFontSizeSemanticToken { get } + var ftiTitleColor: ColorSemanticToken { get } + + var ftiBorderColor: ColorSemanticToken { get } + var ftiBorderStyle: BorderStyleSemanticToken { get } + var ftiBorderWidth: BorderWidthSemanticToken { get } +} + +// Define the component tokens +extension OUDSTheme: FormsTextInputComponentTokens { + private static let defaultBlack: ColorSemanticToken = ColorRawTokens.colorFunctionalBlack + private static let defaultWhite: ColorSemanticToken = ColorRawTokens.colorFunctionalWhite + + @objc open var ftiTitleFontWeight: TypographyFontWeightSemanticToken { fontWeightHeading } + @objc open var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelLarge } + @objc open var ftiTitleColor: ColorSemanticToken { colorContentBrandPrimaryLight ?? Self.defaultBlack } + + @objc open var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedLight ?? Self.defaultBlack } + @objc open var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDefault } + @objc open var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThin } +} + +// Then in the definition of the component FormsTextInput component, the theme will be called and the component tokens +// stored inside will be applied +// The View + +struct OUDSFormsTextInput: View { + + // ... + @Environment(\.theme) var theme + + public var body: some View { + VStack(spacing: theme.spacePaddingBlockComponentTall) { + Label( + title: { + Text("Example of OUDSFormsTextInput") + .fontWeight(theme.ftiTitleFontWeight.fontWeight) + .font(.system(size: theme.ftiTitleFontSize)) + .foregroundColor(theme.ftiTitleColor.color) + }, + icon: { /*@START_MENU_TOKEN@*/Image(systemName: "42.circle")/*@END_MENU_TOKEN@*/ } + ) + Text("Write bellow some awesome text!") + .fontWeight(theme.ftiSubtitleFontWeight.fontWeight) + .font(.system(size: theme.ftiSubtitleFontSize)) + .foregroundColor(theme.ftiSubtitleColor.color) + TextField(placeholder, text: $value) + } + .padding(theme.spacePaddingBlockComponentTall) + .background(colorScheme == .light ? theme.ftiBackgroundColorLight.color : theme.ftiBackgroundColorDark.color) + .border(theme.ftiBorderColor.color, width: theme.ftiBorderWidth) + } +} +``` + +## Semantic tokens + +These _tokens_ ([OUDSTokensSemantic](https://ios.unified-design-system.orange.com/documentation/oudstokenssemantic/)) can be used mainly for _component tokens_ to apply some style and configuration values. +They can be seen as an high level of usage with functional meanings. +Thus if we need for example to change a warning color, supposing this color is defined as a _semantic token_, we only have to change its assigned value and all components using the _semantic token_ won't be impacted in their definition. + +In addition, there are hundreds of _semantics tokens_ and we needed to add them to the abstract root theme using extensions for clarity reasons to prevent to have a _Swift class_ with thousands of lines. Each _raw token_ "family" is then declared in its dedicated _Swift protocol_ any root theme must implement. Because we choose to split responsabilities and objects into their own modules, we faced troubles to make possible for children themes to override properties declared in _protocols_ and defined in _extensions_. + +That is the reason why tokens are exposed as `@objc open` to be available and overridable anywhere. + +To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are avaialble for those who want too make their own theme. It's only syntaxic sugar to bring _design words_ in our product. + +Example with [OUDSTokensComponent/ColorSemanticTokens](https://ios.unified-design-system.orange.com/documentation/oudstokenssemantic/colorsemantictokens): + +```swift +// Declare a semantic token for color +protocol ColorSemanticTokens { + var sysColorBrandNeutralMutedWhite: ColorAliasSemanticToken? { get } +} + +// Define the semantic token +extension OUDSTheme: ColorSemanticTokens { + + @objc open var sysColorBrandNeutralMutedWhite: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalWhite } +} + +// Then any component and view can use the theme and get the stored colors, only manipulating them by their variable names. +``` + +## Raw tokens + +_Raw tokens_ ([OUDSTokensRaw](https://ios.unified-design-system.orange.com/documentation/oudstokensraw/)) are smallest _tokens_ possible. They are associated to raw values and will be finaly the values assigned to the _components_ properties. + +In fact, we choose to use as most as possible primitive types for raw values, like `Int`, `Double`, `CGFloat` or `String` so as to handle the smallest types with few impacts on the memory for ecodesign principles. Indeed with hundreds of raw tokens, it will be more efficient to store primitive small types than *structs* or *classes*. + +So we expose also in higher level some properties so as to convert when needed some of these types to `SwiftUI` types (like `Font.Weight` and `Color`). + +To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are available for those who want too make their own theme. + +Using more simple and primitive types will help also to test the library. With also type aliases we force users to use our types and not higher level types like _SwiftUI_ types. + +We also choose to add in _extension_ all the tokens values in a separated file so as to help the *Figma*-JSON-to-Swift parser to build files to copy and past easily in the project and keeping all the other objects. + +Example for [ColorRawTokens](https://ios.unified-design-system.orange.com/documentation/oudstokensraw/colorrawtokens): + +```swift +// Define type alias for color raw tokens, we don't care in higher level their real type, just use aliases +public typealias ColorRawToken = String + +public enum ColorRawTokens { } + +extension ColorRawTokens { // Gathers all color raw tokens, use enums for namespace optimization with static let + + public static let colorFunctionalWhite: ColorRawToken = "#FFFFFF" + public static let colorFunctionalScarlet400: ColorRawToken = "#FF4D4E" + public static let colorTransparentBlack0: ColorRawToken = apply(opacity: OpacityRawTokens.opacity0, on: colorFunctionalBlack) + ... +} + +extension String { // The OUDS library still exposes this comptuer property + public var color: Color { + Color(hexadecimalCode: self) + } +} +``` + +## Add, edit or remove tokens + +If you need to add, edit or remove tokens, you will have to follow some simple steps. +You may need to [create an issue](https://github.com/Orange-OpenSource/ouds-ios/issues) or [a pull request](https://github.com/Orange-OpenSource/ouds-ios/pulls) to submit the evolutions you want. + +### For raw tokens + +First, find the file containing the tokens you target. For example, _raw tokens_ are listed and gathered in dedicated files (one file for elevation tokens, one file for dimensions tokens, etc.). +Then, in the _enum_, add as _static let_ the new raw rotken you want, or update or remove the one you target. Beware, some of them are not *raw types* but *composite types* because they wrap severla values. + +Do not forget to update the unit tests. Indeed we don't want to test realy the values of each raw token, because for each update of values the unit tests will have to be updated, and it is time wasting. Thus we only test relationship between tokens. For exemple, for a color palette we ensure the colors are lighter and lighter (or darker and darker). For sizes we check if a variable remains lower than the next one, etc. + +Beware, if you want remove tokens and if the raw tokens you want to remove are shared to others, prefer keeping the old value until the next release and flag it as deprecated so as to avoid to break the backward compatibility. + +### For semantic tokens + +Semantic tokens are declared in dedicated protocols, i.e. each semantic token family is gathered in its own protocol definition. It allows to not spread tokens everywhere, keep things clean, and will force themes to implement them so as to be sure the tokens will always been defined. +You may need thus to add the semantic tokens you want in the suitable protocol, then update the theme which defines the vavlues by implementing the protocol. +You can declare a semantic token (or several) in a protocol, and define them in your theme assigning in the end a raw token as value. + +Do not forget to update the unit tests. Indeed we don't tests the real values of the semantic tokens which can change a lot, but we test if the semantic tokens can be overriden, i.e. if a theme which is a subclass of an higher level them can change the value for each semantic token. It will ensure that tokens remain overridable. + +Beware, if you want remove tokens and if the semantic tokens you want to remove are shared to others, prefer keeping the old value until the next release and flag it as deprecated so as to avoid to break the backward compatibility. diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/_OUDS.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/_OUDS.md new file mode 100644 index 000000000..5036e165e --- /dev/null +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/_OUDS.md @@ -0,0 +1,33 @@ +# ``OUDS`` + +The iOS library of *Orange Unified Design System Design System*, the new design system unified and cohesive across all platforms to build Orange mobile applications. + +@Metadata { + @TechnologyRoot + @SupportedLanguage(objc) +} + +## Overview + +Orange is providing a full design system to build Orange mobile aplications. The objective of *Orange Unified Design System* (OUDS) is to propose a set of guidelines about how to apply the Orange brand on mobile applications. *Orange Unified Design System* also provides series of components and modules that show in details how to use this in the Orange apps. + +*Orange Unified Design System* has been implemented in a code library exposed as a _Swift Package_ that provides: + +- a SwiftUI code library +- a showcase application that can be launched to show the guidelines, components and modules + +This demo app also shows how to use the library or to style existing components. +Using these resources will allow you to create Orange branded applications faster and will inherit all the work that was done to make sure that all presented codes are fully tested regarding the brand, the ecodesign, the open source and the accessibility compliances. + +*Orange Unified Design System* framework supports iOS 15 and later. + +## Topics + +### Essentials + +- +- +- +- +- + diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+BorderSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+BorderSemanticTokens.swift similarity index 86% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+BorderSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+BorderSemanticTokens.swift index 54afa5492..12bc89111 100644 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+BorderSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+BorderSemanticTokens.swift @@ -26,10 +26,10 @@ extension MockTheme { override var borderWidthNone: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken } override var borderWidthDefault: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} override var borderWidthThin: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} + override var borderWidthMedium: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} override var borderWidthThick: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} override var borderWidthThicker: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} - override var borderWidthThickest: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} - override var borderWidthInterfactivePrimaryFocus: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} + override var borderWidthOutsideFocus: BorderWidthSemanticToken { Self.mockThemeBorderWidthRawToken} // MARK: Semantic token - Border - Radius @@ -38,7 +38,6 @@ extension MockTheme { override var borderRadiusShort: BorderRadiusSemanticToken { Self.mockThemeBorderRadiusRawToken } override var borderRadiusMedium: BorderRadiusSemanticToken { Self.mockThemeBorderRadiusRawToken } override var borderRadiusTall: BorderRadiusSemanticToken { Self.mockThemeBorderRadiusRawToken } - override var borderRadiusPill: BorderRadiusSemanticToken { Self.mockThemeBorderRadiusRawToken } // MARK: Semantic token - Border - Style diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+ColorSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+ColorSemanticTokens.swift similarity index 81% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+ColorSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+ColorSemanticTokens.swift index 9baf9b206..f3d3d20bf 100644 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+ColorSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+ColorSemanticTokens.swift @@ -60,16 +60,16 @@ extension MockTheme { override var sysColorBrandNeutralMutedHigher: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } override var sysColorBrandNeutralMutedHighest: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Alias - Neutral - Emphasis + // MARK: Semantic token - Colors - Alias - Neutral - Emphasized - override var sysColorBrandNeutralEmphasisLowest: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } - override var sysColorBrandNeutralEmphasisLower: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } - override var sysColorBrandNeutralEmphasisLow: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } - override var sysColorBrandNeutralEmphasisMedium: ColorAliasSemanticToken { Self.mockThemeColorRawToken } - override var sysColorBrandNeutralEmphasisHigh: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } - override var sysColorBrandNeutralEmphasisHigher: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } - override var sysColorBrandNeutralEmphasisHighest: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } - override var sysColorBrandNeutralEmphasisBlack: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedLowest: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedLower: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedLow: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedMedium: ColorAliasSemanticToken { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedHigh: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedHigher: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedHighest: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } + override var sysColorBrandNeutralEmphasizedBlack: ColorAliasSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Alias - Positive @@ -129,22 +129,22 @@ extension MockTheme { // MARK: Semantic token - Colors - Background - Default - Secondary override var colorBackgroundDefaultSecondaryLight: ColorSemanticToken! { sysColorBrandNeutralMutedLowest } - override var colorBackgroundDefaultSecondaryDark: ColorSemanticToken! { sysColorBrandNeutralEmphasisHigher } + override var colorBackgroundDefaultSecondaryDark: ColorSemanticToken! { sysColorBrandNeutralEmphasizedHigher } // MARK: Semantic token - Colors - Background - Default - Tertiary override var colorBackgroundDefaultTertiaryLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBackgroundDefaultTertiaryDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Background - Emphasis - Primary + // MARK: Semantic token - Colors - Background - Emphasized - Primary - override var colorBackgroundEmphasisPrimaryLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBackgroundEmphasisPrimaryDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundEmphasizedPrimaryLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundEmphasizedPrimaryDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Background - Emphasis - Secondary + // MARK: Semantic token - Colors - Background - Emphasized - Secondary - override var colorBackgroundEmphasisSecondaryLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBackgroundEmphasisSecondaryDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundEmphasizedSecondaryLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundEmphasizedSecondaryDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Background - Brand - Primary @@ -164,30 +164,30 @@ extension MockTheme { override var colorBackgroundStatusAttractiveMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBackgroundStatusAttractiveMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Background - Status - Attractive - Emphasis + // MARK: Semantic token - Colors - Background - Status - Attractive - Emphasized - override var colorBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Background - Status - Warning - Muted override var colorBackgroundStatusWarningMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBackgroundStatusWarningMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Background - Status - Warning - Emphasis + // MARK: Semantic token - Colors - Background - Status - Warning - Emphasized - override var colorBackgroundStatusWarningEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBackgroundStatusWarningEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusWarningEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusWarningEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Background - Status - Negative - Muted override var colorBackgroundStatusNegativeMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBackgroundStatusNegativeMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Background - Status - Negative - Emphasis + // MARK: Semantic token - Colors - Background - Status - Negative - Emphasized - override var colorBackgroundStatusNegativeEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBackgroundStatusNegativeEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Background - Status - Positive - Muted @@ -195,50 +195,50 @@ extension MockTheme { override var colorBackgroundStatusPositiveMutedInverse: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBackgroundStatusPositiveMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Background - Status - Positive - Emphasis + // MARK: Semantic token - Colors - Background - Status - Positive - Emphasized - override var colorBackgroundStatusPositiveEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBackgroundStatusPositiveEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Background - Status - Information - Muted override var colorBackgroundStatusInformationMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBackgroundStatusInformationMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Background - Status - Information - Emphasis + // MARK: Semantic token - Colors - Background - Status - Information - Emphasized - override var colorBackgroundStatusInformationEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBackgroundStatusInformationEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusInformationEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBackgroundStatusInformationEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Content - Default override var colorContentDefaultLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorContentDefaultDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Content - Default - On background emphasis + // MARK: Semantic token - Colors - Content - Default - On background emphasized - override var colorContentDefaultOnBackgroundEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorContentDefaultOnBackgroundEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorContentDefaultOnBackgroundEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorContentDefaultOnBackgroundEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Content - Muted override var colorContentMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorContentMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Content - Muted - On background emphasis + // MARK: Semantic token - Colors - Content - Muted - On background emphasized - override var colorContentMutedOnBackgroundEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorContentMutedOnBackgroundEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorContentMutedOnBackgroundEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorContentMutedOnBackgroundEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Content - Brand - Primary override var colorContentBrandPrimaryLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorContentBrandPrimaryDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Content - Brand - Primary - On background emphasis + // MARK: Semantic token - Colors - Content - Brand - Primary - On background emphasized - override var colorContentBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorContentBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorContentBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorContentBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Content - Brand - Secondary @@ -276,30 +276,30 @@ extension MockTheme { override var colorBorderDefaultLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBorderDefaultDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Border - Default - On background emphasis + // MARK: Semantic token - Colors - Border - Default - On background emphasized - override var colorBorderDefaultOnBackgroundEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBorderDefaultOnBackgroundEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderDefaultOnBackgroundEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderDefaultOnBackgroundEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Border - Emphasis + // MARK: Semantic token - Colors - Border - Emphasized - override var colorBorderEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBorderEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Border - Emphasis - On background emphasis + // MARK: Semantic token - Colors - Border - Emphasized - On background emphasized - override var colorBorderEmphasisOnBackgroundEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBorderEmphasisOnBackgroundEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderEmphasizedOnBackgroundEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderEmphasizedOnBackgroundEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Border - Brand - Primary override var colorBorderBrandPrimaryLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorBorderBrandPrimaryDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - Border - Brand - Primary - On background emphasis + // MARK: Semantic token - Colors - Border - Brand - Primary - On background emphasized - override var colorBorderBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorBorderBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorBorderBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - Border - Brand - Secondary @@ -356,48 +356,48 @@ extension MockTheme { override var colorOnBackgroundStatusAttractiveMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorOnBackgroundStatusAttractiveMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - On background - Status - Attrative - Emphasis + // MARK: Semantic token - Colors - On background - Status - Attrative - Emphasized - override var colorOnBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorOnBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - On background - Status - Warning - Muted override var colorOnBackgroundStatusWarningMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorOnBackgroundStatusWarningMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - On background - Status - Warning - Emphasis + // MARK: Semantic token - Colors - On background - Status - Warning - Emphasized - override var colorOnBackgroundStatusWarningEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorOnBackgroundStatusWarningEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusWarningEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusWarningEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - On background - Status - Negative - Muted override var colorOnBackgroundStatusNegativeMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorOnBackgroundStatusNegativeMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - On background - Status - Negative - Emphasis + // MARK: Semantic token - Colors - On background - Status - Negative - Emphasized - override var colorOnBackgroundStatusNegativeEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorOnBackgroundStatusNegativeEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - On background - Status - Positive - Muted override var colorOnBackgroundStatusPositiveMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorOnBackgroundStatusPositiveMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - On background - Status - Positive - Emphasis + // MARK: Semantic token - Colors - On background - Status - Positive - Emphasized - override var colorOnBackgroundStatusPositiveEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorOnBackgroundStatusPositiveEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } // MARK: Semantic token - Colors - On background - Status - Information - Muted override var colorOnBackgroundStatusInformationMutedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } override var colorOnBackgroundStatusInformationMutedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } - // MARK: Semantic token - Colors - On background - Status - Information - Emphasis + // MARK: Semantic token - Colors - On background - Status - Information - Emphasized - override var colorOnBackgroundStatusInformationEmphasisLight: ColorSemanticToken! { Self.mockThemeColorRawToken } - override var colorOnBackgroundStatusInformationEmphasisDark: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusInformationEmphasizedLight: ColorSemanticToken! { Self.mockThemeColorRawToken } + override var colorOnBackgroundStatusInformationEmphasizedDark: ColorSemanticToken! { Self.mockThemeColorRawToken } } diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+DimensionSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+DimensionSemanticTokens.swift similarity index 100% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+DimensionSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+DimensionSemanticTokens.swift diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+ElevationSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+ElevationSemanticTokens.swift new file mode 100644 index 000000000..a5a6c4afd --- /dev/null +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+ElevationSemanticTokens.swift @@ -0,0 +1,135 @@ +// +// 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 + +extension MockTheme { + + static let mockThemeXRawToken: ElevationRawToken = 711 + static let mockThemeYRawToken: ElevationRawToken = 713 + static let mockThemeBlurRawToken: ElevationRawToken = 816 + static let mockThemeElevationColorRawToken: ColorRawToken = ColorRawTokens.colorFunctionalMalachite500 + static let mockThemeCompositeRawToken: ElevationCompositeRawToken = ElevationCompositeRawToken(x: 118, + y: 712, + blur: 118, + color: ColorRawTokens.colorFunctionalDodgerBlue800) + + // MARK: Semantic token - Elevation - X + + override var elevationXNone: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXRaised: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXDrag: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXOverlayDefault: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXOverlayEmphasized: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXStickyDefault: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXStickyEmphasized: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXStickyNavigationScrolled: ElevationYSemanticToken { Self.mockThemeXRawToken } + override var elevationXFocus: ElevationYSemanticToken { Self.mockThemeXRawToken } + + // MARK: Semantic token - Elevation - Y + + override var elevationYNone: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYRaised: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYDrag: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYOverlayDefault: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYOverlayEmphasized: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYStickyDefault: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYStickyEmphasized: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYStickyNavigationScrolled: ElevationYSemanticToken { Self.mockThemeYRawToken } + override var elevationYFocus: ElevationYSemanticToken { Self.mockThemeYRawToken } + + // MARK: Semantic token - Elevation - Blur + + override var elevationBlurNone: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurRaised: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurDrag: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurOverlayDefault: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurOverlayEmphasized: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurStickyDefault: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurStickyEmphasized: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurStickyNavigationScrolled: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + override var elevationBlurFocus: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } + + // MARK: Semantic token - Elevation - Color - None + + override var elevationColorNoneLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorNoneDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Raised + + override var elevationColorRaisedLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorRaisedDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Drag + + override var elevationColorDragLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorDragDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Overlay - Default + + override var elevationColorOverlayDefaultLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorOverlayDefaultDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Overlay - Emphasized + + override var elevationColorOverlayEmphasizedLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorOverlayEmphasizedDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Sticky - Default + + override var elevationColorStickyDefaultLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorStickyDefaultDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Sticky - Emphasized + + override var elevationColorStickyEmphasizedLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorStickyEmphasizedDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Sticky - Navigation scrolled + + override var elevationColorStickyNavigationScrolledLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorStickyNavigationScrolledDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Color - Focus + + override var elevationColorFocusLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + override var elevationColorFocusDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } + + // MARK: Semantic token - Elevation - Box shadow + + override var elevationRaisedLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationRaisedDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + + override var elevationDragLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationDragDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + + override var elevationOverlayDefaultLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationOverlayDefaultDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + + override var elevationOverlayEmphasizedLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationOverlayEmphasizedDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + + override var elevationStickyDefaultLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationStickyDefaultDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + + override var elevationStickyEmphasizedLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationStickyEmphasizedDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + + override var elevationStickyNavigationScrolledLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationStickyNavigationScrolledDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + + override var elevationFocusLight: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } + override var elevationFocusDark: ElevationCompositeSemanticToken { Self.mockThemeCompositeRawToken } +} diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+GridSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+GridSemanticTokens.swift new file mode 100644 index 000000000..de11c5db0 --- /dev/null +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+GridSemanticTokens.swift @@ -0,0 +1,42 @@ +// +// 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 + +extension MockTheme { + + static let mockThemeGridRawToken: GridRawToken = 3630 + + override var gridExtraCompactWidth: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridExtraCompactMinWidth: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridExtraCompactMaxWidth: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridExtraCompactMargin: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridExtraCompactColumnGap: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridExtraCompactColumnCount: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + + override var gridCompactWidth: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridCompactMinWidth: GridCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridCompactMaxWidth: GridCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridCompactMargin: GridCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridCompactColumnGap: GridCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridCompactColumnCount: GridCompactSemanticToken { Self.mockThemeGridRawToken } + + override var gridRegularWidth: GridExtraCompactSemanticToken { Self.mockThemeGridRawToken } + override var gridRegularMinWidth: GridRegularSemanticToken { Self.mockThemeGridRawToken } + override var gridRegularMaxWidth: GridRegularSemanticToken { Self.mockThemeGridRawToken } + override var gridRegularMargin: GridRegularSemanticToken { Self.mockThemeGridRawToken } + override var gridRegularColumnGap: GridRegularSemanticToken { Self.mockThemeGridRawToken } + override var gridRegularColumnCount: GridRegularSemanticToken { Self.mockThemeGridRawToken } +} diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+OpacitySemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+OpacitySemanticTokens.swift similarity index 92% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+OpacitySemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+OpacitySemanticTokens.swift index 680ea5f90..012c5c743 100644 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+OpacitySemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+OpacitySemanticTokens.swift @@ -23,6 +23,6 @@ extension MockTheme { override var opacityWeaker: OpacitySemanticToken { Self.mockThemeOpacityRawToken } override var opacityWeak: OpacitySemanticToken { Self.mockThemeOpacityRawToken } override var opacityMedium: OpacitySemanticToken { Self.mockThemeOpacityRawToken } - override var opacityEmphasis: OpacitySemanticToken { Self.mockThemeOpacityRawToken } + override var opacityStrong: OpacitySemanticToken { Self.mockThemeOpacityRawToken } override var opacityOpaque: OpacitySemanticToken { Self.mockThemeOpacityRawToken } } diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+SizingSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SizingSemanticTokens.swift similarity index 51% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+SizingSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SizingSemanticTokens.swift index 14d6bbe0f..1abbfb2c4 100644 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+SizingSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SizingSemanticTokens.swift @@ -18,6 +18,7 @@ import OUDSTokensSemantic extension MockTheme { static let mockThemeSizeRawToken: DimensionRawToken = 118_000 + static let mockThemeSizeCompositeToken: SizingCompositeSemanticToken = SizingCompositeSemanticToken(compact: 1, regular: 151) // MARK: Semantic token - Sizing - Width height - Icon decorative @@ -48,41 +49,41 @@ extension MockTheme { // MARK: Semantic token - Sizing - Width height - Icon typography - Heading - override var sizeWidthHeightIconIsHeadingSmallShort: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingSmallMedium: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingSmallTall: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingMediumShort: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingMediumMedium: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingMediumTall: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingLargeShort: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingLargeMedium: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingLargeTall: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingXLargeShort: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingXLargeMedium: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsHeadingXLargeTall: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } + override var sizeWidthHeightIconIsHeadingSmallShort: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingSmallMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingSmallTall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingMediumShort: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingMediumMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingMediumTall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingLargeShort: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingLargeMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingLargeTall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingXLargeShort: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingXLargeMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsHeadingXLargeTall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } // MARK: Semantic token - Sizing - Width height - Icon typography - Body - override var sizeWidthHeightIconIsBodySmallShort: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodySmallMedium: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodySmallTall: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodyMediumShort: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodyMediumMedium: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodyMediumTall: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodyLargeShort: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodyLargeMedium: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } - override var sizeWidthHeightIconIsBodyLargeTall: SizingWidthHeightSemanticToken { Self.mockThemeSizeRawToken } + override var sizeWidthHeightIconIsBodySmallShort: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodySmallMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodySmallTall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodyMediumShort: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodyMediumMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodyMediumTall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodyLargeShort: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodyLargeMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeWidthHeightIconIsBodyLargeTall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } // MARK: Semantic token - Sizing - Max width - override var sizeMaxWidthTypographyDisplaySmall: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyDisplayMedium: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyDisplayLarge: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyHeadingSmall: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyHeadingMedium: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyHeadingLarge: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyHeadingXLarge: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyBodySmall: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyBodyMedium: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } - override var sizeMaxWidthTypographyBodyLarge: SizingMaxWidthSemanticToken { Self.mockThemeSizeRawToken } + override var sizeMaxWidthTypographyDisplaySmall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyDisplayMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyDisplayLarge: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyHeadingSmall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyHeadingMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyHeadingLarge: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyHeadingXLarge: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyBodySmall: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyBodyMedium: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } + override var sizeMaxWidthTypographyBodyLarge: SizingCompositeSemanticToken { Self.mockThemeSizeCompositeToken } } diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+SpacingSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SpacingSemanticTokens.swift similarity index 88% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+SpacingSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SpacingSemanticTokens.swift index 3b20de33e..a12f04a33 100644 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+SpacingSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+SpacingSemanticTokens.swift @@ -18,6 +18,7 @@ import OUDSTokensSemantic extension MockTheme { static let mockThemeSpaceRawToken: DimensionRawToken = 911 + static let mockThemeSpaceSemanticToken: SpacingCompositeSemanticToken = SpacingCompositeSemanticToken(compact: 1, regular: 151) // MARK: Semantic token - Spacing - Layout fix @@ -34,16 +35,16 @@ extension MockTheme { // MARK: Semantic token - Spacing - Layout fluid - override var spaceLayoutFluidNone: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidSmash: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidShortest: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidShorter: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidShort: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidMedium: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidTall: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidTaller: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidTallest: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } - override var spaceLayoutFluidSpacious: SpacingLayoutSemanticToken { Self.mockThemeSpaceRawToken } + override var spaceLayoutAdaptableNone: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableSmash: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableShortest: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableShorter: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableShort: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableMedium: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableTall: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableTaller: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableTallest: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } + override var spaceLayoutAdaptableSpacious: SpacingCompositeSemanticToken { Self.mockThemeSpaceSemanticToken } // MARK: Semantic token - Spacing - Padding - Padding inline diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+TypographySemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+TypographySemanticTokens.swift similarity index 62% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+TypographySemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+TypographySemanticTokens.swift index 3538f2e90..0b48e91a5 100644 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+TypographySemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme+TypographySemanticTokens.swift @@ -15,13 +15,14 @@ import Foundation import OUDSTokensRaw import OUDSTokensSemantic +// swiftlint:disable line_length extension MockTheme { static let mockThemeFontFamilyRawToken: TypographyFontFamilyRawToken = "oΒ°xXSkyBl0GF0ntxXxΒ°o" static let mockThemeFontWeightRawToken: TypographyFontWeightRawToken = "stiicckkyyyy" static let mockThemeFontSizeRawToken: TypographyFontSizeRawToken = 666 static let mockThemeFontLineHeightRawToken: TypographyFontLineHeightRawToken = 321 - static let mockThemeFontParagraphSpacingRawToken: TypographyFontParagraphSpacingRawToken = 0x911 + static let mockThemeTypographyCompositeSemanticToken: TypographyCompositeSemanticToken = TypographyCompositeSemanticToken(compact: TypographyRawTokens.typeBold1850, regular: TypographyRawTokens.typeBold1850) // MARK: Semantic token - Typography - Font - Family @@ -54,8 +55,6 @@ extension MockTheme { override var fontSizeMobileBodyLarge: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } override var fontSizeMobileBodyMedium: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } override var fontSizeMobileBodySmall: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } - override var fontSizeMobileCodeMedium: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } - override var fontSizeMobileCodeSmall: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } // MARK: Semantic token - Typography - Font - Size - Tablet @@ -69,8 +68,6 @@ extension MockTheme { override var fontSizeTabletBodyLarge: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } override var fontSizeTabletBodyMedium: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } override var fontSizeTabletBodySmall: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } - override var fontSizeTabletCodeMedium: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } - override var fontSizeTabletCodeSmall: TypographyFontSizeSemanticToken { Self.mockThemeFontSizeRawToken } // MARK: Semantic token - Typography - Font - Size - Others @@ -93,8 +90,6 @@ extension MockTheme { override var fontLineHeightMobileBodyLarge: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } override var fontLineHeightMobileBodyMedium: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } override var fontLineHeightMobileBodySmall: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } - override var fontLineHeightMobileCodeMedium: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } - override var fontLineHeightMobileCodeSmall: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } // MARK: Semantic token - Typography - Font - Line height - Tablet @@ -108,8 +103,6 @@ extension MockTheme { override var fontLineHeightTabletBodyLarge: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } override var fontLineHeightTabletBodyMedium: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } override var fontLineHeightTabletBodySmall: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } - override var fontLineHeightTabletCodeMedium: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } - override var fontLineHeightTabletCodeSmall: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } // MARK: Semantic token - Typography - Font - Light height - Others @@ -120,42 +113,42 @@ extension MockTheme { override var fontLineHeightCodeMedium: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } override var fontLineHeightCodeSmall: TypographyFontLineHeightSemanticToken { Self.mockThemeFontLineHeightRawToken } - // MARK: Semantic token - Typography - Font - Paragraph spacing - Mobile - - override var fontParagraphSpacingMobileDisplayLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileDisplayMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileDisplaySmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileHeadingXLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileHeadingLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileHeadingMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileHeadingSmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileBodyLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileBodyMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileBodySmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileCodeMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingMobileCodeSmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - - // MARK: Semantic token - Typography - Font - Paragraph spacing - Tablet - - override var fontParagraphSpacingTabletDisplayLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletDisplayMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletDisplaySmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletHeadingXLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletHeadingLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletHeadingMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletHeadingSmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletBodyLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletBodyMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletBodySmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletCodeMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingTabletCodeSmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - - // MARK: Semantic token - Typography - Font - Paragraph spacing - Others - - override var fontParagraphSpacingLabelXLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingLabelLarge: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingLabelMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingLabelSmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingCodeMedium: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } - override var fontParagraphSpacingCodeSmall: TypographyFontParagraphSpacingRawToken { Self.mockThemeFontParagraphSpacingRawToken } + // MARK: - Semantic tokens - Typography - Composites - Display + + override var typeDisplayLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeDisplayMedium: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeDisplaySmall: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + + // MARK: - Semantic tokens - Typography - Composites - Heading + + override var typeHeadingXLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeHeadingLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeHeadingMedium: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeHeadingSmall: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + + // MARK: - Semantic tokens - Typography - Composites - Body + + override var typeBodyDefaultLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeBodyDefaultMedium: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeBodyDefaultSmall: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeBodyStrongLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeBodyStrongMedium: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeBodyStrongSmall: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + + // MARK: - Semantic tokens - Typography - Composites - Label + + override var typeLabelDefaultXLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeLabelDefaultLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeLabelDefaultMedium: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeLabelDefaultSmall: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeLabelStrongXLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeLabelStrongLarge: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeLabelStrongMedium: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeLabelStrongSmall: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + + // MARK: - Semantic tokens - Typography - Composites - Code + + override var typeCodeMedium: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } + override var typeCodeSmall: TypographyCompositeSemanticToken { Self.mockThemeTypographyCompositeSemanticToken } } +// swiftlint:enable line_length diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme.swift similarity index 69% rename from OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme.swift index 619fd73b3..fda7e8039 100644 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockTheme/MockTheme.swift @@ -12,10 +12,19 @@ // import Foundation -import OUDSThemesCommons +import OUDS +import OUDSTokensSemantic /// A mock theme for tests -class MockTheme: OUDSTheme { +final class MockTheme: OUDSTheme { + + convenience init() { + self.init(customFont: nil) + } + + init(customFont: String?) { + super.init(customFontFamily: customFont) + } // Please refer to extensions } diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfBorderSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfBorderSemanticTokens.swift similarity index 83% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfBorderSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfBorderSemanticTokens.swift index c5ceb3aa7..28705bc62 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfBorderSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfBorderSemanticTokens.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS /// 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 seens as an _asbtract class_, exposing through its extensions and protocols _border semantic tokens_. @@ -45,6 +45,11 @@ final class TestThemeOverrideOfBorderSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.borderWidthThin == MockTheme.mockThemeBorderWidthRawToken) } + func testInheritedThemeCanOverrideSemanticTokenBorderWidthMedium() throws { + XCTAssertNotEqual(inheritedTheme.borderWidthMedium, abstractTheme.borderWidthMedium) + XCTAssertTrue(inheritedTheme.borderWidthMedium == MockTheme.mockThemeBorderWidthRawToken) + } + func testInheritedThemeCanOverrideSemanticTokenBorderWidthThick() throws { XCTAssertNotEqual(inheritedTheme.borderWidthThick, abstractTheme.borderWidthThick) XCTAssertTrue(inheritedTheme.borderWidthThick == MockTheme.mockThemeBorderWidthRawToken) @@ -55,14 +60,9 @@ final class TestThemeOverrideOfBorderSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.borderWidthThicker == MockTheme.mockThemeBorderWidthRawToken) } - func testInheritedThemeCanOverrideSemanticTokenBorderWidthThickest() throws { - XCTAssertNotEqual(inheritedTheme.borderWidthThickest, abstractTheme.borderWidthThickest) - XCTAssertTrue(inheritedTheme.borderWidthThickest == MockTheme.mockThemeBorderWidthRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenBorderWidthInterfactivePrimaryFocus() throws { - XCTAssertNotEqual(inheritedTheme.borderWidthInterfactivePrimaryFocus, abstractTheme.borderWidthInterfactivePrimaryFocus) - XCTAssertTrue(inheritedTheme.borderWidthInterfactivePrimaryFocus == MockTheme.mockThemeBorderWidthRawToken) + func testInheritedThemeCanOverrideSemanticTokenBorderWidthOutsideFocus() throws { + XCTAssertNotEqual(inheritedTheme.borderWidthOutsideFocus, abstractTheme.borderWidthOutsideFocus) + XCTAssertTrue(inheritedTheme.borderWidthOutsideFocus == MockTheme.mockThemeBorderWidthRawToken) } // MARK: - Semantic token - Border - Radius @@ -92,11 +92,6 @@ final class TestThemeOverrideOfBorderSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.borderRadiusTall == MockTheme.mockThemeBorderRadiusRawToken) } - func testInheritedThemeCanOverrideSemanticTokenBorderRadiusPill() throws { - XCTAssertNotEqual(inheritedTheme.borderRadiusPill, abstractTheme.borderRadiusPill) - XCTAssertTrue(inheritedTheme.borderRadiusPill == MockTheme.mockThemeBorderRadiusRawToken) - } - // MARK: - Semantic token - Border - Style func testInheritedThemeCanOverrideSemanticTokenBorderStyleDefault() throws { diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfColorSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfColorSemanticTokens.swift similarity index 85% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfColorSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfColorSemanticTokens.swift index 7a0f57fbb..16a5f1c8a 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfColorSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfColorSemanticTokens.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS // swiftlint:disable type_body_length // swiftlint:disable file_length @@ -184,46 +184,46 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.sysColorBrandNeutralMutedHighest == MockTheme.mockThemeColorRawToken) } - // MARK: - Semantic token - Colors - Alias - Neutral - Emphasis + // MARK: - Semantic token - Colors - Alias - Neutral - Emphasized - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisLowest() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisLowest, abstractTheme.sysColorBrandNeutralEmphasisLowest) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisLowest == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedLowest() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedLowest, abstractTheme.sysColorBrandNeutralEmphasizedLowest) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedLowest == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisLower() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisLower, abstractTheme.sysColorBrandNeutralEmphasisLower) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisLower == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedLower() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedLower, abstractTheme.sysColorBrandNeutralEmphasizedLower) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedLower == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisLow() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisLow, abstractTheme.sysColorBrandNeutralEmphasisLow) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisLow == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedLow() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedLow, abstractTheme.sysColorBrandNeutralEmphasizedLow) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedLow == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisMedium() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisMedium, abstractTheme.sysColorBrandNeutralEmphasisMedium) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisMedium == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedMedium() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedMedium, abstractTheme.sysColorBrandNeutralEmphasizedMedium) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedMedium == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisHigh() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisHigh, abstractTheme.sysColorBrandNeutralEmphasisHigh) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisHigh == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedHigh() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedHigh, abstractTheme.sysColorBrandNeutralEmphasizedHigh) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedHigh == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisHigher() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisHigher, abstractTheme.sysColorBrandNeutralEmphasisHigher) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisHigher == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedHigher() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedHigher, abstractTheme.sysColorBrandNeutralEmphasizedHigher) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedHigher == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisHighest() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisHighest, abstractTheme.sysColorBrandNeutralEmphasisHighest) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisHighest == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedHighest() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedHighest, abstractTheme.sysColorBrandNeutralEmphasizedHighest) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedHighest == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasisBlack() throws { - XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasisBlack, abstractTheme.sysColorBrandNeutralEmphasisBlack) - XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasisBlack == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenSysColorBrandNeutralEmphasizedBlack() throws { + XCTAssertNotEqual(inheritedTheme.sysColorBrandNeutralEmphasizedBlack, abstractTheme.sysColorBrandNeutralEmphasizedBlack) + XCTAssertTrue(inheritedTheme.sysColorBrandNeutralEmphasizedBlack == MockTheme.mockThemeColorRawToken) } // MARK: - Semantic token - Colors - Alias - Positive @@ -443,24 +443,24 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBackgroundDefaultTertiaryDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasisPrimaryLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasisPrimaryLight, abstractTheme.colorBackgroundEmphasisPrimaryLight) - XCTAssertTrue(inheritedTheme.colorBackgroundEmphasisPrimaryLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasizedPrimaryLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasizedPrimaryLight, abstractTheme.colorBackgroundEmphasizedPrimaryLight) + XCTAssertTrue(inheritedTheme.colorBackgroundEmphasizedPrimaryLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasisPrimaryDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasisPrimaryDark, abstractTheme.colorBackgroundEmphasisPrimaryDark) - XCTAssertTrue(inheritedTheme.colorBackgroundEmphasisPrimaryDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasizedPrimaryDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasizedPrimaryDark, abstractTheme.colorBackgroundEmphasizedPrimaryDark) + XCTAssertTrue(inheritedTheme.colorBackgroundEmphasizedPrimaryDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasisSecondaryLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasisSecondaryLight, abstractTheme.colorBackgroundEmphasisSecondaryLight) - XCTAssertTrue(inheritedTheme.colorBackgroundEmphasisSecondaryLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasizedSecondaryLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasizedSecondaryLight, abstractTheme.colorBackgroundEmphasizedSecondaryLight) + XCTAssertTrue(inheritedTheme.colorBackgroundEmphasizedSecondaryLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasisSecondaryDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasisSecondaryDark, abstractTheme.colorBackgroundEmphasisSecondaryDark) - XCTAssertTrue(inheritedTheme.colorBackgroundEmphasisSecondaryDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundEmphasizedSecondaryDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundEmphasizedSecondaryDark, abstractTheme.colorBackgroundEmphasizedSecondaryDark) + XCTAssertTrue(inheritedTheme.colorBackgroundEmphasizedSecondaryDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorBackgroundBrandPrimaryLight() throws { @@ -493,14 +493,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBackgroundStatusAttractiveMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusAttractiveEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusAttractiveEmphasisLight, abstractTheme.colorBackgroundStatusAttractiveEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusAttractiveEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusAttractiveEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusAttractiveEmphasizedLight, abstractTheme.colorBackgroundStatusAttractiveEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusAttractiveEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusAttractiveEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusAttractiveEmphasisDark, abstractTheme.colorBackgroundStatusAttractiveEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusAttractiveEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusAttractiveEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusAttractiveEmphasizedDark, abstractTheme.colorBackgroundStatusAttractiveEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusAttractiveEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusWarningMutedLight() throws { @@ -513,14 +513,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBackgroundStatusWarningMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusWarningEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusWarningEmphasisLight, abstractTheme.colorBackgroundStatusWarningEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusWarningEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusWarningEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusWarningEmphasizedLight, abstractTheme.colorBackgroundStatusWarningEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusWarningEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusWarningEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusWarningEmphasisDark, abstractTheme.colorBackgroundStatusWarningEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusWarningEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusWarningEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusWarningEmphasizedDark, abstractTheme.colorBackgroundStatusWarningEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusWarningEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusNegativeMutedLight() throws { @@ -533,14 +533,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBackgroundStatusNegativeMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusNegativeEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusNegativeEmphasisLight, abstractTheme.colorBackgroundStatusNegativeEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusNegativeEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusNegativeEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusNegativeEmphasizedLight, abstractTheme.colorBackgroundStatusNegativeEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusNegativeEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusNegativeEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusNegativeEmphasisDark, abstractTheme.colorBackgroundStatusNegativeEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusNegativeEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusNegativeEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusNegativeEmphasizedDark, abstractTheme.colorBackgroundStatusNegativeEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusNegativeEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusPositiveMutedLight() throws { @@ -553,14 +553,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBackgroundStatusPositiveMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusPositiveEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusPositiveEmphasisLight, abstractTheme.colorBackgroundStatusPositiveEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusPositiveEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusPositiveEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusPositiveEmphasizedLight, abstractTheme.colorBackgroundStatusPositiveEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusPositiveEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusPositiveEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusPositiveEmphasisDark, abstractTheme.colorBackgroundStatusPositiveEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusPositiveEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusPositiveEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusPositiveEmphasizedDark, abstractTheme.colorBackgroundStatusPositiveEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusPositiveEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusInformationMutedLight() throws { @@ -573,14 +573,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBackgroundStatusInformationMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusInformationEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusInformationEmphasisLight, abstractTheme.colorBackgroundStatusInformationEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusInformationEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusInformationEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusInformationEmphasizedLight, abstractTheme.colorBackgroundStatusInformationEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusInformationEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusInformationEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusInformationEmphasisDark, abstractTheme.colorBackgroundStatusInformationEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBackgroundStatusInformationEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBackgroundStatusInformationEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBackgroundStatusInformationEmphasizedDark, abstractTheme.colorBackgroundStatusInformationEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBackgroundStatusInformationEmphasizedDark == MockTheme.mockThemeColorRawToken) } // MARK: - Semantic token - Colors - Content @@ -595,14 +595,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorContentDefaultDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorContentDefaultOnBackgroundEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorContentDefaultOnBackgroundEmphasisLight, abstractTheme.colorContentDefaultOnBackgroundEmphasisLight) - XCTAssertTrue(inheritedTheme.colorContentDefaultOnBackgroundEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorContentDefaultOnBackgroundEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorContentDefaultOnBackgroundEmphasizedLight, abstractTheme.colorContentDefaultOnBackgroundEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorContentDefaultOnBackgroundEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorContentDefaultOnBackgroundEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorContentDefaultOnBackgroundEmphasisDark, abstractTheme.colorContentDefaultOnBackgroundEmphasisDark) - XCTAssertTrue(inheritedTheme.colorContentDefaultOnBackgroundEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorContentDefaultOnBackgroundEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorContentDefaultOnBackgroundEmphasizedDark, abstractTheme.colorContentDefaultOnBackgroundEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorContentDefaultOnBackgroundEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorContentMutedLight() throws { @@ -615,14 +615,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorContentMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorContentMutedOnBackgroundEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorContentMutedOnBackgroundEmphasisLight, abstractTheme.colorContentMutedOnBackgroundEmphasisLight) - XCTAssertTrue(inheritedTheme.colorContentMutedOnBackgroundEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorContentMutedOnBackgroundEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorContentMutedOnBackgroundEmphasizedLight, abstractTheme.colorContentMutedOnBackgroundEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorContentMutedOnBackgroundEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorContentMutedOnBackgroundEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorContentMutedOnBackgroundEmphasisDark, abstractTheme.colorContentMutedOnBackgroundEmphasisDark) - XCTAssertTrue(inheritedTheme.colorContentMutedOnBackgroundEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorContentMutedOnBackgroundEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorContentMutedOnBackgroundEmphasizedDark, abstractTheme.colorContentMutedOnBackgroundEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorContentMutedOnBackgroundEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorContentBrandPrimaryLight() throws { @@ -635,14 +635,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorContentBrandPrimaryDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorContentBrandPrimaryOnBackgroundEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasisLight, abstractTheme.colorContentBrandPrimaryOnBackgroundEmphasisLight) - XCTAssertTrue(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorContentBrandPrimaryOnBackgroundEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasizedLight, abstractTheme.colorContentBrandPrimaryOnBackgroundEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorContentBrandPrimaryOnBackgroundEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasisDark, abstractTheme.colorContentBrandPrimaryOnBackgroundEmphasisDark) - XCTAssertTrue(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorContentBrandPrimaryOnBackgroundEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasizedDark, abstractTheme.colorContentBrandPrimaryOnBackgroundEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorContentBrandPrimaryOnBackgroundEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorContentBrandSecondaryLight() throws { @@ -717,34 +717,34 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBorderDefaultDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderDefaultOnBackgroundEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderDefaultOnBackgroundEmphasisLight, abstractTheme.colorBorderDefaultOnBackgroundEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBorderDefaultOnBackgroundEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderDefaultOnBackgroundEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderDefaultOnBackgroundEmphasizedLight, abstractTheme.colorBorderDefaultOnBackgroundEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBorderDefaultOnBackgroundEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderDefaultOnBackgroundEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderDefaultOnBackgroundEmphasisDark, abstractTheme.colorBorderDefaultOnBackgroundEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBorderDefaultOnBackgroundEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderDefaultOnBackgroundEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderDefaultOnBackgroundEmphasizedDark, abstractTheme.colorBorderDefaultOnBackgroundEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBorderDefaultOnBackgroundEmphasizedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderEmphasisLight, abstractTheme.colorBorderEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBorderEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderEmphasizedLight, abstractTheme.colorBorderEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBorderEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderEmphasisDark, abstractTheme.colorBorderEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBorderEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderEmphasizedDark, abstractTheme.colorBorderEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBorderEmphasizedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasisOnBackgroundEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderEmphasisOnBackgroundEmphasisLight, abstractTheme.colorBorderEmphasisOnBackgroundEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBorderEmphasisOnBackgroundEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasizedOnBackgroundEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderEmphasizedOnBackgroundEmphasizedLight, abstractTheme.colorBorderEmphasizedOnBackgroundEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBorderEmphasizedOnBackgroundEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasisOnBackgroundEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderEmphasisOnBackgroundEmphasisDark, abstractTheme.colorBorderEmphasisOnBackgroundEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBorderEmphasisOnBackgroundEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderEmphasizedOnBackgroundEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderEmphasizedOnBackgroundEmphasizedDark, abstractTheme.colorBorderEmphasizedOnBackgroundEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBorderEmphasizedOnBackgroundEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorBorderBrandPrimaryLight() throws { @@ -757,14 +757,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorBorderBrandPrimaryDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderBrandPrimaryOnBackgroundEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasisLight, abstractTheme.colorBorderBrandPrimaryOnBackgroundEmphasisLight) - XCTAssertTrue(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderBrandPrimaryOnBackgroundEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedLight, abstractTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorBorderBrandPrimaryOnBackgroundEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasisDark, abstractTheme.colorBorderBrandPrimaryOnBackgroundEmphasisDark) - XCTAssertTrue(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorBorderBrandPrimaryOnBackgroundEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedDark, abstractTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorBorderBrandSecondaryLight() throws { @@ -879,14 +879,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusAttractiveMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusAttractiveEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasisLight, abstractTheme.colorOnBackgroundStatusAttractiveEmphasisLight) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusAttractiveEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasizedLight, abstractTheme.colorOnBackgroundStatusAttractiveEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusAttractiveEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasisDark, abstractTheme.colorOnBackgroundStatusAttractiveEmphasisDark) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusAttractiveEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasizedDark, abstractTheme.colorOnBackgroundStatusAttractiveEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusAttractiveEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusWarningMutedLight() throws { @@ -899,14 +899,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusWarningMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusWarningEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusWarningEmphasisLight, abstractTheme.colorOnBackgroundStatusWarningEmphasisLight) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusWarningEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusWarningEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusWarningEmphasizedLight, abstractTheme.colorOnBackgroundStatusWarningEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusWarningEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusWarningEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusWarningEmphasisDark, abstractTheme.colorOnBackgroundStatusWarningEmphasisDark) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusWarningEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusWarningEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusWarningEmphasizedDark, abstractTheme.colorOnBackgroundStatusWarningEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusWarningEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusNegativeMutedLight() throws { @@ -919,14 +919,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusNegativeMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusNegativeEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusNegativeEmphasisLight, abstractTheme.colorOnBackgroundStatusNegativeEmphasisLight) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusNegativeEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusNegativeEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusNegativeEmphasizedLight, abstractTheme.colorOnBackgroundStatusNegativeEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusNegativeEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusNegativeEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusNegativeEmphasisDark, abstractTheme.colorOnBackgroundStatusNegativeEmphasisDark) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusNegativeEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusNegativeEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusNegativeEmphasizedDark, abstractTheme.colorOnBackgroundStatusNegativeEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusNegativeEmphasizedDark == MockTheme.mockThemeColorRawToken) } func ttestInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusPositiveMutedLight() throws { @@ -939,14 +939,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusPositiveMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusPositiveEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusPositiveEmphasisLight, abstractTheme.colorOnBackgroundStatusPositiveEmphasisLight) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusPositiveEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusPositiveEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusPositiveEmphasizedLight, abstractTheme.colorOnBackgroundStatusPositiveEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusPositiveEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusPositiveEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusPositiveEmphasisDark, abstractTheme.colorOnBackgroundStatusPositiveEmphasisDark) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusPositiveEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusPositiveEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusPositiveEmphasizedDark, abstractTheme.colorOnBackgroundStatusPositiveEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusPositiveEmphasizedDark == MockTheme.mockThemeColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusInformationMutedLight() throws { @@ -959,14 +959,14 @@ final class TestThemeOverrideOfColorSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusInformationMutedDark == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusInformationEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusInformationEmphasisLight, abstractTheme.colorOnBackgroundStatusInformationEmphasisLight) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusInformationEmphasisLight == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusInformationEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusInformationEmphasizedLight, abstractTheme.colorOnBackgroundStatusInformationEmphasizedLight) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusInformationEmphasizedLight == MockTheme.mockThemeColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusInformationEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusInformationEmphasisDark, abstractTheme.colorOnBackgroundStatusInformationEmphasisDark) - XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusInformationEmphasisDark == MockTheme.mockThemeColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenColorOnBackgroundStatusInformationEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.colorOnBackgroundStatusInformationEmphasizedDark, abstractTheme.colorOnBackgroundStatusInformationEmphasizedDark) + XCTAssertTrue(inheritedTheme.colorOnBackgroundStatusInformationEmphasizedDark == MockTheme.mockThemeColorRawToken) } } diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfDimensionSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfDimensionSemanticTokens.swift similarity index 98% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfDimensionSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfDimensionSemanticTokens.swift index b25d7a696..19e3dcce5 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfDimensionSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfDimensionSemanticTokens.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS /// 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 _dimension semantic tokens_. diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfElevationSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfElevationSemanticTokens.swift similarity index 50% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfElevationSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfElevationSemanticTokens.swift index 36590326b..187273b7a 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfElevationSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfElevationSemanticTokens.swift @@ -12,9 +12,7 @@ // import XCTest -import OUDSThemesCommons - -// swiftlint:disable type_body_length +import OUDS /// 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_. @@ -30,78 +28,6 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { inheritedTheme = MockTheme() } - // MARK: - Semantic token - Elevation - Z index - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexDeep() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexDeep, abstractTheme.elevationZIndexDeep) - XCTAssertTrue(inheritedTheme.elevationZIndexDeep == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexDefault() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexDefault, abstractTheme.elevationZIndexDefault) - XCTAssertTrue(inheritedTheme.elevationZIndexDefault == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexDropdown() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexDropdown, abstractTheme.elevationZIndexDropdown) - XCTAssertTrue(inheritedTheme.elevationZIndexDropdown == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexSticky() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexSticky, abstractTheme.elevationZIndexSticky) - XCTAssertTrue(inheritedTheme.elevationZIndexSticky == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexFixed() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexFixed, abstractTheme.elevationZIndexFixed) - XCTAssertTrue(inheritedTheme.elevationZIndexFixed == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexBackToTop() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexBackToTop, abstractTheme.elevationZIndexBackToTop) - XCTAssertTrue(inheritedTheme.elevationZIndexBackToTop == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexSpinner() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexSpinner, abstractTheme.elevationZIndexSpinner) - XCTAssertTrue(inheritedTheme.elevationZIndexSpinner == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexOffCanvasBackdrop() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexOffCanvasBackdrop, abstractTheme.elevationZIndexOffCanvasBackdrop) - XCTAssertTrue(inheritedTheme.elevationZIndexOffCanvasBackdrop == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexOffCanvas() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexOffCanvas, abstractTheme.elevationZIndexOffCanvas) - XCTAssertTrue(inheritedTheme.elevationZIndexOffCanvas == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexModalBackdrop() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexModalBackdrop, abstractTheme.elevationZIndexModalBackdrop) - XCTAssertTrue(inheritedTheme.elevationZIndexModalBackdrop == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexModal() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexModal, abstractTheme.elevationZIndexModal) - XCTAssertTrue(inheritedTheme.elevationZIndexModal == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexPopover() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexPopover, abstractTheme.elevationZIndexPopover) - XCTAssertTrue(inheritedTheme.elevationZIndexPopover == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexTooltip() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexTooltip, abstractTheme.elevationZIndexTooltip) - XCTAssertTrue(inheritedTheme.elevationZIndexTooltip == MockTheme.mockThemeZIndexRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationZIndexToast() throws { - XCTAssertNotEqual(inheritedTheme.elevationZIndexToast, abstractTheme.elevationZIndexToast) - XCTAssertTrue(inheritedTheme.elevationZIndexToast == MockTheme.mockThemeZIndexRawToken) - } - // MARK: - Semantic token - Elevation - X func testInheritedThemeCanOverrideSemanticTokenElevationXNone() throws { @@ -124,9 +50,9 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationXOverlayDefault == MockTheme.mockThemeXRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationXOverlayEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationXOverlayEmphasis, abstractTheme.elevationXOverlayEmphasis) - XCTAssertTrue(inheritedTheme.elevationXOverlayEmphasis == MockTheme.mockThemeXRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationXOverlayEmphasized() throws { + XCTAssertNotEqual(inheritedTheme.elevationXOverlayEmphasized, abstractTheme.elevationXOverlayEmphasized) + XCTAssertTrue(inheritedTheme.elevationXOverlayEmphasized == MockTheme.mockThemeXRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationXStickyDefault() throws { @@ -134,9 +60,9 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationXStickyDefault == MockTheme.mockThemeXRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationXStickyEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationXStickyEmphasis, abstractTheme.elevationXStickyEmphasis) - XCTAssertTrue(inheritedTheme.elevationXStickyEmphasis == MockTheme.mockThemeXRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationXStickyEmphasized() throws { + XCTAssertNotEqual(inheritedTheme.elevationXStickyEmphasized, abstractTheme.elevationXStickyEmphasized) + XCTAssertTrue(inheritedTheme.elevationXStickyEmphasized == MockTheme.mockThemeXRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationXStickyNavigationScrolled() throws { @@ -171,9 +97,9 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationYOverlayDefault == MockTheme.mockThemeYRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationYOverlayEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationYOverlayEmphasis, abstractTheme.elevationYOverlayEmphasis) - XCTAssertTrue(inheritedTheme.elevationYOverlayEmphasis == MockTheme.mockThemeYRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationYOverlayEmphasized() throws { + XCTAssertNotEqual(inheritedTheme.elevationYOverlayEmphasized, abstractTheme.elevationYOverlayEmphasized) + XCTAssertTrue(inheritedTheme.elevationYOverlayEmphasized == MockTheme.mockThemeYRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationYStickyDefault() throws { @@ -181,9 +107,9 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationYStickyDefault == MockTheme.mockThemeYRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationYStickyEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationYStickyEmphasis, abstractTheme.elevationYStickyEmphasis) - XCTAssertTrue(inheritedTheme.elevationYStickyEmphasis == MockTheme.mockThemeYRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationYStickyEmphasized() throws { + XCTAssertNotEqual(inheritedTheme.elevationYStickyEmphasized, abstractTheme.elevationYStickyEmphasized) + XCTAssertTrue(inheritedTheme.elevationYStickyEmphasized == MockTheme.mockThemeYRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationYStickyNavigationScrolled() throws { @@ -218,9 +144,9 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationBlurOverlayDefault == MockTheme.mockThemeBlurRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBlurOverlayEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationBlurOverlayEmphasis, abstractTheme.elevationBlurOverlayEmphasis) - XCTAssertTrue(inheritedTheme.elevationBlurOverlayEmphasis == MockTheme.mockThemeBlurRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationBlurOverlayEmphasized() throws { + XCTAssertNotEqual(inheritedTheme.elevationBlurOverlayEmphasized, abstractTheme.elevationBlurOverlayEmphasized) + XCTAssertTrue(inheritedTheme.elevationBlurOverlayEmphasized == MockTheme.mockThemeBlurRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationBlurStickyDefault() throws { @@ -228,9 +154,9 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationBlurStickyDefault == MockTheme.mockThemeBlurRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBlurStickyEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationBlurStickyEmphasis, abstractTheme.elevationBlurStickyEmphasis) - XCTAssertTrue(inheritedTheme.elevationBlurStickyEmphasis == MockTheme.mockThemeBlurRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationBlurStickyEmphasized() throws { + XCTAssertNotEqual(inheritedTheme.elevationBlurStickyEmphasized, abstractTheme.elevationBlurStickyEmphasized) + XCTAssertTrue(inheritedTheme.elevationBlurStickyEmphasized == MockTheme.mockThemeBlurRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationBlurStickyNavigationScrolled() throws { @@ -243,53 +169,6 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationBlurFocus == MockTheme.mockThemeBlurRawToken) } - // MARK: - Semantic token - Elevation - Spread - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadNone() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadNone, abstractTheme.elevationSpreadNone) - XCTAssertTrue(inheritedTheme.elevationSpreadNone == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadRaised() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadRaised, abstractTheme.elevationSpreadRaised) - XCTAssertTrue(inheritedTheme.elevationSpreadRaised == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadDrag() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadDrag, abstractTheme.elevationSpreadDrag) - XCTAssertTrue(inheritedTheme.elevationSpreadDrag == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadOverlayDefault() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadOverlayDefault, abstractTheme.elevationSpreadOverlayDefault) - XCTAssertTrue(inheritedTheme.elevationSpreadOverlayDefault == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadOverlayEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadOverlayEmphasis, abstractTheme.elevationSpreadOverlayEmphasis) - XCTAssertTrue(inheritedTheme.elevationSpreadOverlayEmphasis == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadStickyDefault() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadStickyDefault, abstractTheme.elevationSpreadStickyDefault) - XCTAssertTrue(inheritedTheme.elevationSpreadStickyDefault == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadStickyEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadStickyEmphasis, abstractTheme.elevationSpreadStickyEmphasis) - XCTAssertTrue(inheritedTheme.elevationSpreadStickyEmphasis == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadStickyNavigationScrolled() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadStickyNavigationScrolled, abstractTheme.elevationSpreadStickyNavigationScrolled) - XCTAssertTrue(inheritedTheme.elevationSpreadStickyNavigationScrolled == MockTheme.mockThemeSpreadRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenElevationSpreadFocus() throws { - XCTAssertNotEqual(inheritedTheme.elevationSpreadFocus, abstractTheme.elevationSpreadFocus) - XCTAssertTrue(inheritedTheme.elevationSpreadFocus == MockTheme.mockThemeSpreadRawToken) - } - // MARK: - Semantic token - Elevation - Color - None func testInheritedThemeCanOverrideSemanticTokenElevationColorNoneLight() throws { @@ -332,14 +211,14 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationColorOverlayDefaultDark == MockTheme.mockThemeElevationColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationColorOverlayEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationColorOverlayEmphasisLight, abstractTheme.elevationColorOverlayEmphasisLight) - XCTAssertTrue(inheritedTheme.elevationColorOverlayEmphasisLight == MockTheme.mockThemeElevationColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationColorOverlayEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationColorOverlayEmphasizedLight, abstractTheme.elevationColorOverlayEmphasizedLight) + XCTAssertTrue(inheritedTheme.elevationColorOverlayEmphasizedLight == MockTheme.mockThemeElevationColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationColorOverlayEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationColorOverlayEmphasisDark, abstractTheme.elevationColorOverlayEmphasisDark) - XCTAssertTrue(inheritedTheme.elevationColorOverlayEmphasisDark == MockTheme.mockThemeElevationColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationColorOverlayEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationColorOverlayEmphasizedDark, abstractTheme.elevationColorOverlayEmphasizedDark) + XCTAssertTrue(inheritedTheme.elevationColorOverlayEmphasizedDark == MockTheme.mockThemeElevationColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyDefaultLight() throws { @@ -352,14 +231,14 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationColorStickyDefaultDark == MockTheme.mockThemeElevationColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationColorStickyEmphasisLight, abstractTheme.elevationColorStickyEmphasisLight) - XCTAssertTrue(inheritedTheme.elevationColorStickyEmphasisLight == MockTheme.mockThemeElevationColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationColorStickyEmphasizedLight, abstractTheme.elevationColorStickyEmphasizedLight) + XCTAssertTrue(inheritedTheme.elevationColorStickyEmphasizedLight == MockTheme.mockThemeElevationColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationColorStickyEmphasisDark, abstractTheme.elevationColorStickyEmphasisDark) - XCTAssertTrue(inheritedTheme.elevationColorStickyEmphasisDark == MockTheme.mockThemeElevationColorRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationColorStickyEmphasizedDark, abstractTheme.elevationColorStickyEmphasizedDark) + XCTAssertTrue(inheritedTheme.elevationColorStickyEmphasizedDark == MockTheme.mockThemeElevationColorRawToken) } func testInheritedThemeCanOverrideSemanticTokenElevationColorStickyNavigationScrolledLight() throws { @@ -382,80 +261,78 @@ final class TestThemeOverrideOfElevationSemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.elevationColorFocusDark == MockTheme.mockThemeElevationColorRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowRaisedDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowRaisedDark, abstractTheme.elevationBoxShadowRaisedDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowRaisedDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeRaisedDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationRaisedDark, abstractTheme.elevationRaisedDark) + XCTAssertTrue(inheritedTheme.elevationRaisedDark == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowDragLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowDragLight, abstractTheme.elevationBoxShadowDragLight) - XCTAssertTrue(inheritedTheme.elevationBoxShadowDragLight == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeDragLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationDragLight, abstractTheme.elevationDragLight) + XCTAssertTrue(inheritedTheme.elevationDragLight == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowDragDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowDragDark, abstractTheme.elevationBoxShadowDragDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowDragDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeDragDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationDragDark, abstractTheme.elevationDragDark) + XCTAssertTrue(inheritedTheme.elevationDragDark == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowOverlayDefaultLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowOverlayDefaultLight, abstractTheme.elevationBoxShadowOverlayDefaultLight) - XCTAssertTrue(inheritedTheme.elevationBoxShadowOverlayDefaultLight == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeOverlayDefaultLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationOverlayDefaultLight, abstractTheme.elevationOverlayDefaultLight) + XCTAssertTrue(inheritedTheme.elevationOverlayDefaultLight == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowOverlayDefaultDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowOverlayDefaultDark, abstractTheme.elevationBoxShadowOverlayDefaultDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowOverlayDefaultDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeOverlayDefaultDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationOverlayDefaultDark, abstractTheme.elevationOverlayDefaultDark) + XCTAssertTrue(inheritedTheme.elevationOverlayDefaultDark == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowOverlayEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowOverlayEmphasisLight, abstractTheme.elevationBoxShadowOverlayEmphasisLight) - XCTAssertTrue(inheritedTheme.elevationBoxShadowOverlayEmphasisLight == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeOverlayEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationOverlayEmphasizedLight, abstractTheme.elevationOverlayEmphasizedLight) + XCTAssertTrue(inheritedTheme.elevationOverlayEmphasizedLight == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowOverlayEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowOverlayEmphasisDark, abstractTheme.elevationBoxShadowOverlayEmphasisDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowOverlayEmphasisDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeOverlayEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationOverlayEmphasizedDark, abstractTheme.elevationOverlayEmphasizedDark) + XCTAssertTrue(inheritedTheme.elevationOverlayEmphasizedDark == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowStickyDefaultLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowStickyDefaultLight, abstractTheme.elevationBoxShadowStickyDefaultLight) - XCTAssertTrue(inheritedTheme.elevationBoxShadowStickyDefaultLight == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeStickyDefaultLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationStickyDefaultLight, abstractTheme.elevationStickyDefaultLight) + XCTAssertTrue(inheritedTheme.elevationStickyDefaultLight == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowStickyDefaultDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowStickyDefaultDark, abstractTheme.elevationBoxShadowStickyDefaultDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowStickyDefaultDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeStickyDefaultDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationStickyDefaultDark, abstractTheme.elevationStickyDefaultDark) + XCTAssertTrue(inheritedTheme.elevationStickyDefaultDark == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowStickyEmphasisLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowStickyEmphasisLight, abstractTheme.elevationBoxShadowStickyEmphasisLight) - XCTAssertTrue(inheritedTheme.elevationBoxShadowStickyEmphasisLight == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeStickyEmphasizedLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationStickyEmphasizedLight, abstractTheme.elevationStickyEmphasizedLight) + XCTAssertTrue(inheritedTheme.elevationStickyEmphasizedLight == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowStickyEmphasisDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowStickyEmphasisDark, abstractTheme.elevationBoxShadowStickyEmphasisDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowStickyEmphasisDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeStickyEmphasizedDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationStickyEmphasizedDark, abstractTheme.elevationStickyEmphasizedDark) + XCTAssertTrue(inheritedTheme.elevationStickyEmphasizedDark == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowStickyNavigationScrolledLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowStickyNavigationScrolledLight, abstractTheme.elevationBoxShadowStickyNavigationScrolledLight) - XCTAssertTrue(inheritedTheme.elevationBoxShadowStickyNavigationScrolledLight == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeStickyNavigationScrolledLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationStickyNavigationScrolledLight, abstractTheme.elevationStickyNavigationScrolledLight) + XCTAssertTrue(inheritedTheme.elevationStickyNavigationScrolledLight == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowStickyNavigationScrolledDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowStickyNavigationScrolledDark, abstractTheme.elevationBoxShadowStickyNavigationScrolledDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowStickyNavigationScrolledDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeStickyNavigationScrolledDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationStickyNavigationScrolledDark, abstractTheme.elevationStickyNavigationScrolledDark) + XCTAssertTrue(inheritedTheme.elevationStickyNavigationScrolledDark == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowFocusLight() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowFocusLight, abstractTheme.elevationBoxShadowFocusLight) - XCTAssertTrue(inheritedTheme.elevationBoxShadowFocusLight == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeFocusLight() throws { + XCTAssertNotEqual(inheritedTheme.elevationFocusLight, abstractTheme.elevationFocusLight) + XCTAssertTrue(inheritedTheme.elevationFocusLight == MockTheme.mockThemeCompositeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenElevationBoxShadowFocusDark() throws { - XCTAssertNotEqual(inheritedTheme.elevationBoxShadowFocusDark, abstractTheme.elevationBoxShadowFocusDark) - XCTAssertTrue(inheritedTheme.elevationBoxShadowFocusDark == MockTheme.mockThemeBoxShadowRawToken) + func testInheritedThemeCanOverrideSemanticTokenElevationCompositeFocusDark() throws { + XCTAssertNotEqual(inheritedTheme.elevationFocusDark, abstractTheme.elevationFocusDark) + XCTAssertTrue(inheritedTheme.elevationFocusDark == MockTheme.mockThemeCompositeRawToken) } } - -// swiftlint:enable type_body_length diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfGridSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfGridSemanticTokens.swift new file mode 100644 index 000000000..ea0eb5e7b --- /dev/null +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfGridSemanticTokens.swift @@ -0,0 +1,120 @@ +// +// 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 XCTest +import OUDS + +/// 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 _grid semantic tokens_. +/// These semantic tokens should be overriden by subclass like the `OrangeTheme` default theme. +/// **These tests checks if any _grid semantic tokens_ can be surcharged by a child theme** +final class TestThemeOverrideOfGridSemanticTokens: XCTestCase { + + private var abstractTheme: OUDSTheme! + private var inheritedTheme: OUDSTheme! + + override func setUp() async throws { + abstractTheme = OUDSTheme() + inheritedTheme = MockTheme() + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactDesignWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridExtraCompactWidth, abstractTheme.gridExtraCompactWidth) + XCTAssertTrue(inheritedTheme.gridExtraCompactWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactMinWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridExtraCompactMinWidth, abstractTheme.gridExtraCompactMinWidth) + XCTAssertTrue(inheritedTheme.gridExtraCompactMinWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactMaxWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridExtraCompactMaxWidth, abstractTheme.gridExtraCompactMaxWidth) + XCTAssertTrue(inheritedTheme.gridExtraCompactMaxWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactMargin() throws { + XCTAssertNotEqual(inheritedTheme.gridExtraCompactMargin, abstractTheme.gridExtraCompactMargin) + XCTAssertTrue(inheritedTheme.gridExtraCompactMargin == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactColumnGap() throws { + XCTAssertNotEqual(inheritedTheme.gridExtraCompactColumnGap, abstractTheme.gridExtraCompactColumnGap) + XCTAssertTrue(inheritedTheme.gridExtraCompactColumnGap == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactColumnCount() throws { + XCTAssertNotEqual(inheritedTheme.gridExtraCompactColumnCount, abstractTheme.gridExtraCompactColumnCount) + XCTAssertTrue(inheritedTheme.gridExtraCompactColumnCount == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactDesignWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridCompactWidth, abstractTheme.gridCompactWidth) + XCTAssertTrue(inheritedTheme.gridCompactWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactMinWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridCompactMinWidth, abstractTheme.gridCompactMinWidth) + XCTAssertTrue(inheritedTheme.gridCompactMinWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactMaxWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridCompactMaxWidth, abstractTheme.gridCompactMaxWidth) + XCTAssertTrue(inheritedTheme.gridCompactMaxWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactMargin() throws { + XCTAssertNotEqual(inheritedTheme.gridCompactMargin, abstractTheme.gridCompactMargin) + XCTAssertTrue(inheritedTheme.gridCompactMargin == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactColumnGap() throws { + XCTAssertNotEqual(inheritedTheme.gridCompactColumnGap, abstractTheme.gridCompactColumnGap) + XCTAssertTrue(inheritedTheme.gridCompactColumnGap == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactColumnCount() throws { + XCTAssertNotEqual(inheritedTheme.gridCompactColumnCount, abstractTheme.gridCompactColumnCount) + XCTAssertTrue(inheritedTheme.gridCompactColumnCount == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularDesignWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridRegularWidth, abstractTheme.gridRegularWidth) + XCTAssertTrue(inheritedTheme.gridRegularWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularMinWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridRegularMinWidth, abstractTheme.gridRegularMinWidth) + XCTAssertTrue(inheritedTheme.gridRegularMinWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularMaxWidth() throws { + XCTAssertNotEqual(inheritedTheme.gridRegularMaxWidth, abstractTheme.gridRegularMaxWidth) + XCTAssertTrue(inheritedTheme.gridRegularMaxWidth == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularMargin() throws { + XCTAssertNotEqual(inheritedTheme.gridRegularMargin, abstractTheme.gridRegularMargin) + XCTAssertTrue(inheritedTheme.gridRegularMargin == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularColumnGap() throws { + XCTAssertNotEqual(inheritedTheme.gridRegularColumnGap, abstractTheme.gridRegularColumnGap) + XCTAssertTrue(inheritedTheme.gridRegularColumnGap == MockTheme.mockThemeGridRawToken) + } + + func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularColumnCount() throws { + XCTAssertNotEqual(inheritedTheme.gridRegularColumnCount, abstractTheme.gridRegularColumnCount) + XCTAssertTrue(inheritedTheme.gridRegularColumnCount == MockTheme.mockThemeGridRawToken) + } +} diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfOpacitySemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfOpacitySemanticTokens.swift similarity index 92% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfOpacitySemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfOpacitySemanticTokens.swift index b805ff023..36cbc916c 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfOpacitySemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfOpacitySemanticTokens.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS /// 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 _opacity semantic tokens_. @@ -48,9 +48,9 @@ final class TestThemeOverrideOfOpacitySemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.opacityMedium == MockTheme.mockThemeOpacityRawToken) } - func testInheritedThemeCanOverrideSemanticTokenOpacityEmphasis() throws { - XCTAssertNotEqual(inheritedTheme.opacityEmphasis, abstractTheme.opacityEmphasis) - XCTAssertTrue(inheritedTheme.opacityEmphasis == MockTheme.mockThemeOpacityRawToken) + func testInheritedThemeCanOverrideSemanticTokenOpacityEmphasized() throws { + XCTAssertNotEqual(inheritedTheme.opacityStrong, abstractTheme.opacityStrong) + XCTAssertTrue(inheritedTheme.opacityStrong == MockTheme.mockThemeOpacityRawToken) } func testInheritedThemeCanOverrideSemanticTokenOpacityOpaque() throws { diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfSizingSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSizingSemanticTokens.swift similarity index 90% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfSizingSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSizingSemanticTokens.swift index a27e943aa..2c181e6bb 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfSizingSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSizingSemanticTokens.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS /// 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 _sizing semantic tokens_. @@ -141,160 +141,160 @@ final class TestThemeOverrideOfSizingSemanticTokens: XCTestCase { func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingSmallShort() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingSmallShort, abstractTheme.sizeWidthHeightIconIsHeadingSmallShort) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingSmallShort == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingSmallShort.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingSmallMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingSmallMedium, abstractTheme.sizeWidthHeightIconIsHeadingSmallMedium) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingSmallMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingSmallMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingSmallTall() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingSmallTall, abstractTheme.sizeWidthHeightIconIsHeadingSmallTall) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingSmallTall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingSmallTall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingMediumShort() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingMediumShort, abstractTheme.sizeWidthHeightIconIsHeadingMediumShort) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingMediumShort == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingMediumShort.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingMediumMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingMediumMedium, abstractTheme.sizeWidthHeightIconIsHeadingMediumMedium) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingMediumMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingMediumMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingMediumTall() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingMediumTall, abstractTheme.sizeWidthHeightIconIsHeadingMediumTall) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingMediumTall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingMediumTall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingLargeShort() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingLargeShort, abstractTheme.sizeWidthHeightIconIsHeadingLargeShort) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingLargeShort == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingLargeShort.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingLargeMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingLargeMedium, abstractTheme.sizeWidthHeightIconIsHeadingLargeMedium) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingLargeMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingLargeMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingLargeTall() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingLargeTall, abstractTheme.sizeWidthHeightIconIsHeadingLargeTall) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingLargeTall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingLargeTall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingXLargeShort() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeShort, abstractTheme.sizeWidthHeightIconIsHeadingXLargeShort) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeShort == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeShort.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingXLargeMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeMedium, abstractTheme.sizeWidthHeightIconIsHeadingXLargeMedium) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsHeadingXLargeTall() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeTall, abstractTheme.sizeWidthHeightIconIsHeadingXLargeTall) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeTall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsHeadingXLargeTall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } // MARK: - Semantic token - Sizing - Width height - Icon typography - Body func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodySmallShort() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodySmallShort, abstractTheme.sizeWidthHeightIconIsBodySmallShort) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodySmallShort == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodySmallShort.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodySmallMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodySmallMedium, abstractTheme.sizeWidthHeightIconIsBodySmallMedium) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodySmallMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodySmallMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodySmallTall() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodySmallTall, abstractTheme.sizeWidthHeightIconIsBodySmallTall) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodySmallTall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodySmallTall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodyMediumShort() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodyMediumShort, abstractTheme.sizeWidthHeightIconIsBodyMediumShort) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyMediumShort == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyMediumShort.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodyMediumMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodyMediumMedium, abstractTheme.sizeWidthHeightIconIsBodyMediumMedium) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyMediumMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyMediumMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodyMediumTall() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodyMediumTall, abstractTheme.sizeWidthHeightIconIsBodyMediumTall) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyMediumTall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyMediumTall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodyLargeShort() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodyLargeShort, abstractTheme.sizeWidthHeightIconIsBodyLargeShort) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyLargeShort == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyLargeShort.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodyLargeMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodyLargeMedium, abstractTheme.sizeWidthHeightIconIsBodyLargeMedium) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyLargeMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyLargeMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeWidthHeightIconIsBodyLargeTall() throws { XCTAssertNotEqual(inheritedTheme.sizeWidthHeightIconIsBodyLargeTall, abstractTheme.sizeWidthHeightIconIsBodyLargeTall) - XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyLargeTall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeWidthHeightIconIsBodyLargeTall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } // MARK: - Semantic token - Sizing - Max width func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyDisplaySmall() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyDisplaySmall, abstractTheme.sizeMaxWidthTypographyDisplaySmall) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyDisplaySmall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyDisplaySmall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyDisplayMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyDisplayMedium, abstractTheme.sizeMaxWidthTypographyDisplayMedium) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyDisplayMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyDisplayMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyDisplayLarge() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyDisplayLarge, abstractTheme.sizeMaxWidthTypographyDisplayLarge) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyDisplayLarge == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyDisplayLarge.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyHeadingSmall() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyHeadingSmall, abstractTheme.sizeMaxWidthTypographyHeadingSmall) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingSmall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingSmall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyHeadingMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyHeadingMedium, abstractTheme.sizeMaxWidthTypographyHeadingMedium) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyHeadingLarge() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyHeadingLarge, abstractTheme.sizeMaxWidthTypographyHeadingLarge) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingLarge == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingLarge.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyHeadingXLarge() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyHeadingXLarge, abstractTheme.sizeMaxWidthTypographyHeadingXLarge) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingXLarge == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyHeadingXLarge.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyBodySmall() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyBodySmall, abstractTheme.sizeMaxWidthTypographyBodySmall) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyBodySmall == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyBodySmall.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyBodyMedium() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyBodyMedium, abstractTheme.sizeMaxWidthTypographyBodyMedium) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyBodyMedium == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyBodyMedium.isEqual(MockTheme.mockThemeSizeCompositeToken)) } func testInheritedThemeCanOverrideSemanticTokenSizeMaxWidthTypographyBodyLarge() throws { XCTAssertNotEqual(inheritedTheme.sizeMaxWidthTypographyBodyLarge, abstractTheme.sizeMaxWidthTypographyBodyLarge) - XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyBodyLarge == MockTheme.mockThemeSizeRawToken) + XCTAssertTrue(inheritedTheme.sizeMaxWidthTypographyBodyLarge.isEqual(MockTheme.mockThemeSizeCompositeToken)) } } diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfSpacingSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpacingSemanticTokens.swift similarity index 89% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfSpacingSemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpacingSemanticTokens.swift index cadba65a0..b9f9ce23a 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfSpacingSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfSpacingSemanticTokens.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS // swiftlint:disable type_body_length @@ -84,54 +84,54 @@ final class TestThemeOverrideOfSpacingSemanticTokens: XCTestCase { // MARK: - Semantic token - Spacing - Layout fluid - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidNone() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidNone, abstractTheme.spaceLayoutFluidNone) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidNone == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableNone() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableNone, abstractTheme.spaceLayoutAdaptableNone) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableNone.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidSmash() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidSmash, abstractTheme.spaceLayoutFluidSmash) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidSmash == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableSmash() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableSmash, abstractTheme.spaceLayoutAdaptableSmash) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableSmash.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidShortest() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidShortest, abstractTheme.spaceLayoutFluidShortest) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidShortest == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableShortest() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableShortest, abstractTheme.spaceLayoutAdaptableShortest) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableShortest.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidShorter() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidShorter, abstractTheme.spaceLayoutFluidShorter) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidShorter == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableShorter() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableShorter, abstractTheme.spaceLayoutAdaptableShorter) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableShorter.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidShort() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidShort, abstractTheme.spaceLayoutFluidShort) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidShort == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableShort() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableShort, abstractTheme.spaceLayoutAdaptableShort) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableShort.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidMedium() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidMedium, abstractTheme.spaceLayoutFluidMedium) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidMedium == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableMedium() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableMedium, abstractTheme.spaceLayoutAdaptableMedium) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableMedium.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidTall() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidTall, abstractTheme.spaceLayoutFluidTall) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidTall == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableTall() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableTall, abstractTheme.spaceLayoutAdaptableTall) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableTall.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidTaller() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidTaller, abstractTheme.spaceLayoutFluidTaller) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidTaller == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableTaller() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableTaller, abstractTheme.spaceLayoutAdaptableTaller) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableTaller.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidTallest() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidTallest, abstractTheme.spaceLayoutFluidTallest) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidTallest == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableTallest() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableTallest, abstractTheme.spaceLayoutAdaptableTallest) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableTallest.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } - func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutFluidSpacious() throws { - XCTAssertNotEqual(inheritedTheme.spaceLayoutFluidSpacious, abstractTheme.spaceLayoutFluidSpacious) - XCTAssertTrue(inheritedTheme.spaceLayoutFluidSpacious == MockTheme.mockThemeSpaceRawToken) + func testInheritedThemeCanOverrideSemanticTokenSpaceLayoutAdaptableSpacious() throws { + XCTAssertNotEqual(inheritedTheme.spaceLayoutAdaptableSpacious, abstractTheme.spaceLayoutAdaptableSpacious) + XCTAssertTrue(inheritedTheme.spaceLayoutAdaptableSpacious.isEqual(MockTheme.mockThemeSpaceSemanticToken)) } // MARK: - Semantic token - Spacing - Padding - Padding inline diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfThemeProperties.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfThemeProperties.swift new file mode 100644 index 000000000..193dbfb04 --- /dev/null +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfThemeProperties.swift @@ -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 OUDS +import XCTest + +/// 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 some properties. +/// These properties should be overridable by subclasses like the `OrangeTheme` default theme. +/// **These tests checks if any _non token properties_ can be surcharged by a child theme** +final class TestThemeOverrideOfThemeProperties: XCTestCase { + + private var abstractTheme: OUDSTheme! + private var inheritedTheme: OUDSTheme! + + override func setUp() async throws { + abstractTheme = OUDSTheme() + inheritedTheme = MockTheme(customFont: "Mr R08ΓΈT") + } + + func testInheritedThemeCanOverrideCustomFontFamily() throws { + XCTAssertNotEqual(inheritedTheme.customFontFamily, abstractTheme.customFontFamily) + XCTAssertTrue(inheritedTheme.customFontFamily == "Mr R08ΓΈT") + } +} diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfTypographySemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfTypographySemanticTokens.swift similarity index 62% rename from OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfTypographySemanticTokens.swift rename to OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfTypographySemanticTokens.swift index e82c93478..c25f5f11d 100644 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfTypographySemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/TestThemeOverrideOfTypographySemanticTokens.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS // swiftlint:disable type_body_length @@ -151,16 +151,6 @@ final class TestThemeOverrideOfTypographySemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.fontSizeMobileBodySmall == MockTheme.mockThemeFontSizeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenFontSizeMobileCodeMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontSizeMobileCodeMedium, abstractTheme.fontSizeMobileCodeMedium) - XCTAssertTrue(inheritedTheme.fontSizeMobileCodeMedium == MockTheme.mockThemeFontSizeRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontSizeMobileCodeSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontSizeMobileCodeSmall, abstractTheme.fontSizeMobileCodeSmall) - XCTAssertTrue(inheritedTheme.fontSizeMobileCodeSmall == MockTheme.mockThemeFontSizeRawToken) - } - // MARK: - Semantic token - Typography - Font - Size - Tablet func testInheritedThemeCanOverrideSemanticTokenFontSizeTabletDisplayLarge() throws { @@ -213,16 +203,6 @@ final class TestThemeOverrideOfTypographySemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.fontSizeTabletBodySmall == MockTheme.mockThemeFontSizeRawToken) } - func testInheritedThemeCanOverrideSemanticTokenFontSizeTabletCodeMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontSizeTabletCodeMedium, abstractTheme.fontSizeTabletCodeMedium) - XCTAssertTrue(inheritedTheme.fontSizeTabletCodeMedium == MockTheme.mockThemeFontSizeRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontSizeTabletCodeSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontSizeTabletCodeSmall, abstractTheme.fontSizeTabletCodeSmall) - XCTAssertTrue(inheritedTheme.fontSizeTabletCodeSmall == MockTheme.mockThemeFontSizeRawToken) - } - // MARK: - Semantic token - Typography - Font - Size - Others func testInheritedThemeCanOverrideSemanticTokenFontSizeLabelXLarge() throws { @@ -307,16 +287,6 @@ final class TestThemeOverrideOfTypographySemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.fontLineHeightMobileBodySmall == MockTheme.mockThemeFontLineHeightRawToken) } - func testInheritedThemeCanOverrideSemanticTokenFontLineHeightMobileCodeMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLineHeightMobileCodeMedium, abstractTheme.fontLineHeightMobileCodeMedium) - XCTAssertTrue(inheritedTheme.fontLineHeightMobileCodeMedium == MockTheme.mockThemeFontLineHeightRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLineHeightMobileCodeSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLineHeightMobileCodeSmall, abstractTheme.fontLineHeightMobileCodeSmall) - XCTAssertTrue(inheritedTheme.fontLineHeightMobileCodeSmall == MockTheme.mockThemeFontLineHeightRawToken) - } - // MARK: - Semantic token - Typography - Font - Line height - Tablet func testInheritedThemeCanOverrideSemanticTokenFontLineHeightTabletDisplayLarge() throws { @@ -369,16 +339,6 @@ final class TestThemeOverrideOfTypographySemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.fontLineHeightTabletBodySmall == MockTheme.mockThemeFontLineHeightRawToken) } - func testInheritedThemeCanOverrideSemanticTokenFontLineHeightTabletCodeMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontLineHeightTabletCodeMedium, abstractTheme.fontLineHeightTabletCodeMedium) - XCTAssertTrue(inheritedTheme.fontLineHeightTabletCodeMedium == MockTheme.mockThemeFontLineHeightRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontLineHeightTabletCodeSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontLineHeightTabletCodeSmall, abstractTheme.fontLineHeightTabletCodeSmall) - XCTAssertTrue(inheritedTheme.fontLineHeightTabletCodeSmall == MockTheme.mockThemeFontLineHeightRawToken) - } - // MARK: - Semantic token - Typography - Font - Line height - Others func testInheritedThemeCanOverrideSemanticTokenFontLineHeightLabelXLarge() throws { @@ -411,160 +371,129 @@ final class TestThemeOverrideOfTypographySemanticTokens: XCTestCase { XCTAssertTrue(inheritedTheme.fontLineHeightCodeSmall == MockTheme.mockThemeFontLineHeightRawToken) } - // MARK: Semantic token - Typography - Font - Paragraph spacing - Mobile - - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileDisplayLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileDisplayLarge, abstractTheme.fontParagraphSpacingMobileDisplayLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileDisplayLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileDisplayMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileDisplayMedium, abstractTheme.fontParagraphSpacingMobileDisplayMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileDisplayMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileDisplaySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileDisplaySmall, abstractTheme.fontParagraphSpacingMobileDisplaySmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileDisplaySmall == MockTheme.mockThemeFontParagraphSpacingRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileHeadingXLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileHeadingXLarge, abstractTheme.fontParagraphSpacingMobileHeadingXLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileHeadingXLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) - } + // MARK: - Semantic tokens - Typography - Composites - Display - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileHeadingLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileHeadingLarge, abstractTheme.fontParagraphSpacingMobileHeadingLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileHeadingLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeDisplayLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeDisplayLarge, abstractTheme.typeDisplayLarge) + XCTAssertTrue(inheritedTheme.typeDisplayLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileHeadingMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileHeadingMedium, abstractTheme.fontParagraphSpacingMobileHeadingMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileHeadingMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeDisplayMedium() throws { + XCTAssertNotEqual(inheritedTheme.typeDisplayMedium, abstractTheme.typeDisplayMedium) + XCTAssertTrue(inheritedTheme.typeDisplayMedium == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileHeadingSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileHeadingSmall, abstractTheme.fontParagraphSpacingMobileHeadingSmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileHeadingSmall == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeDisplaySmal() throws { + XCTAssertNotEqual(inheritedTheme.typeDisplaySmall, abstractTheme.typeDisplaySmall) + XCTAssertTrue(inheritedTheme.typeDisplaySmall == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileBodyLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileBodyLarge, abstractTheme.fontParagraphSpacingMobileBodyLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileBodyLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) - } + // MARK: - Semantic tokens - Typography - Composites - Heading - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileBodyMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileBodyMedium, abstractTheme.fontParagraphSpacingMobileBodyMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileBodyMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeHeadingXLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeHeadingXLarge, abstractTheme.typeHeadingXLarge) + XCTAssertTrue(inheritedTheme.typeHeadingXLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileBodySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileBodySmall, abstractTheme.fontParagraphSpacingMobileBodySmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileBodySmall == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeHeadingLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeHeadingLarge, abstractTheme.typeHeadingLarge) + XCTAssertTrue(inheritedTheme.typeHeadingLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileCodeMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileCodeMedium, abstractTheme.fontParagraphSpacingMobileCodeMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileCodeMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeHeadingMedium() throws { + XCTAssertNotEqual(inheritedTheme.typeHeadingMedium, abstractTheme.typeHeadingMedium) + XCTAssertTrue(inheritedTheme.typeHeadingMedium == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingMobileCodeSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingMobileCodeSmall, abstractTheme.fontParagraphSpacingMobileCodeSmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingMobileCodeSmall == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeHeadingSmall() throws { + XCTAssertNotEqual(inheritedTheme.typeHeadingSmall, abstractTheme.typeHeadingSmall) + XCTAssertTrue(inheritedTheme.typeHeadingSmall == MockTheme.mockThemeTypographyCompositeSemanticToken) } - // MARK: - Semantic token - Typography - Font - Paragraph spacing - Tablet + // MARK: - Semantic tokens - Typography - Composites - Body - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletDisplayLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletDisplayLarge, abstractTheme.fontParagraphSpacingTabletDisplayLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletDisplayLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeDefaultLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeBodyDefaultLarge, abstractTheme.typeBodyDefaultLarge) + XCTAssertTrue(inheritedTheme.typeBodyDefaultLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletDisplayMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletDisplayMedium, abstractTheme.fontParagraphSpacingTabletDisplayMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletDisplayMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeDefaultMedium() throws { + XCTAssertNotEqual(inheritedTheme.typeBodyDefaultMedium, abstractTheme.typeBodyDefaultMedium) + XCTAssertTrue(inheritedTheme.typeBodyDefaultMedium == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletDisplaySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletDisplaySmall, abstractTheme.fontParagraphSpacingTabletDisplaySmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletDisplaySmall == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeDefaultSmall() throws { + XCTAssertNotEqual(inheritedTheme.typeBodyDefaultSmall, abstractTheme.typeBodyDefaultSmall) + XCTAssertTrue(inheritedTheme.typeBodyDefaultSmall == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletHeadingXLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletHeadingXLarge, abstractTheme.fontParagraphSpacingTabletHeadingXLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletHeadingXLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeStrongLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeBodyStrongLarge, abstractTheme.typeBodyStrongLarge) + XCTAssertTrue(inheritedTheme.typeBodyStrongLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletHeadingLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletHeadingLarge, abstractTheme.fontParagraphSpacingTabletHeadingLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletHeadingLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeStrongMedium() throws { + XCTAssertNotEqual(inheritedTheme.typeBodyStrongMedium, abstractTheme.typeBodyStrongMedium) + XCTAssertTrue(inheritedTheme.typeBodyStrongMedium == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletHeadingMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletHeadingMedium, abstractTheme.fontParagraphSpacingTabletHeadingMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletHeadingMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeStrongSmall() throws { + XCTAssertNotEqual(inheritedTheme.typeBodyStrongSmall, abstractTheme.typeBodyStrongSmall) + XCTAssertTrue(inheritedTheme.typeBodyStrongSmall == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletHeadingSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletHeadingSmall, abstractTheme.fontParagraphSpacingTabletHeadingSmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletHeadingSmall == MockTheme.mockThemeFontParagraphSpacingRawToken) - } + // MARK: - Semantic tokens - Typography - Composites - Label - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletBodyLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletBodyLarge, abstractTheme.fontParagraphSpacingTabletBodyLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletBodyLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelDefaultXLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelDefaultXLarge, abstractTheme.typeLabelDefaultXLarge) + XCTAssertTrue(inheritedTheme.typeLabelDefaultXLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletBodyMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletBodyMedium, abstractTheme.fontParagraphSpacingTabletBodyMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletBodyMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelDefaultLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelDefaultLarge, abstractTheme.typeLabelDefaultLarge) + XCTAssertTrue(inheritedTheme.typeLabelDefaultLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletBodySmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletBodySmall, abstractTheme.fontParagraphSpacingTabletBodySmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletBodySmall == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelDefaultMedium() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelDefaultMedium, abstractTheme.typeLabelDefaultMedium) + XCTAssertTrue(inheritedTheme.typeLabelDefaultMedium == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletCodeMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletCodeMedium, abstractTheme.fontParagraphSpacingTabletCodeMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletCodeMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelDefaultSmall() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelDefaultSmall, abstractTheme.typeLabelDefaultSmall) + XCTAssertTrue(inheritedTheme.typeLabelDefaultSmall == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingTabletCodeSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingTabletCodeSmall, abstractTheme.fontParagraphSpacingTabletCodeSmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingTabletCodeSmall == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelStrongXLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelStrongXLarge, abstractTheme.typeLabelStrongXLarge) + XCTAssertTrue(inheritedTheme.typeLabelStrongXLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - // MARK: - Semantic token - Typography - Font - Paragraph spacing - Others - - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingLabelXLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingLabelXLarge, abstractTheme.fontParagraphSpacingLabelXLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingLabelXLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelStrongLarge() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelStrongLarge, abstractTheme.typeLabelStrongLarge) + XCTAssertTrue(inheritedTheme.typeLabelStrongLarge == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingLabelLarge() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingLabelLarge, abstractTheme.fontParagraphSpacingLabelLarge) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingLabelLarge == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelStrongMedium() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelStrongMedium, abstractTheme.typeLabelStrongMedium) + XCTAssertTrue(inheritedTheme.typeLabelStrongMedium == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingLabelMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingLabelMedium, abstractTheme.fontParagraphSpacingLabelMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingLabelMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeLabelStrongSmall() throws { + XCTAssertNotEqual(inheritedTheme.typeLabelStrongSmall, abstractTheme.typeLabelStrongSmall) + XCTAssertTrue(inheritedTheme.typeLabelStrongSmall == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingLabelSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingLabelSmall, abstractTheme.fontParagraphSpacingLabelSmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingLabelSmall == MockTheme.mockThemeFontParagraphSpacingRawToken) - } + // MARK: - Semantic tokens - Typography - Composites - Code - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingCodeMedium() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingCodeMedium, abstractTheme.fontParagraphSpacingCodeMedium) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingCodeMedium == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeCodeMedium() throws { + XCTAssertNotEqual(inheritedTheme.typeCodeMedium, abstractTheme.typeCodeMedium) + XCTAssertTrue(inheritedTheme.typeCodeMedium == MockTheme.mockThemeTypographyCompositeSemanticToken) } - func testInheritedThemeCanOverrideSemanticTokenFontParagraphSpacingCodeSmall() throws { - XCTAssertNotEqual(inheritedTheme.fontParagraphSpacingCodeSmall, abstractTheme.fontParagraphSpacingCodeSmall) - XCTAssertTrue(inheritedTheme.fontParagraphSpacingCodeSmall == MockTheme.mockThemeFontParagraphSpacingRawToken) + func testInheritedThemeCanOverrideSemanticTokenTypeCodeSmall() throws { + XCTAssertNotEqual(inheritedTheme.typeCodeSmall, abstractTheme.typeCodeSmall) + XCTAssertTrue(inheritedTheme.typeCodeSmall == MockTheme.mockThemeTypographyCompositeSemanticToken) } } diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+ElevationSemanticTokens.swift b/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+ElevationSemanticTokens.swift deleted file mode 100644 index 89c6a13cd..000000000 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+ElevationSemanticTokens.swift +++ /dev/null @@ -1,161 +0,0 @@ -// -// 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 - -// swiftlint:disable line_length -/// Defines basic values common to all themes for `ElevationSemanticTokenss`. -/// These values can be overriden inside `OUDSTheme` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination. -/// The aim of this extensions is to make relationships between all semantic tokens for elevations and associated raw tokens. -/// `OUDSTheme` can be seen as a kind of "abstract class" in _object oriented paradigm_. -extension OUDSTheme: ElevationSemanticTokens { - - // MARK: Semantic token - Elevation - Z index - - @objc open var elevationZIndexDeep: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndexMinus9999 } - @objc open var elevationZIndexDefault: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex0 } - @objc open var elevationZIndexDropdown: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1000 } - @objc open var elevationZIndexSticky: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1020 } - @objc open var elevationZIndexFixed: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1030 } - @objc open var elevationZIndexBackToTop: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1035 } - @objc open var elevationZIndexSpinner: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1038 } - @objc open var elevationZIndexOffCanvasBackdrop: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1040 } - @objc open var elevationZIndexOffCanvas: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1045 } - @objc open var elevationZIndexModalBackdrop: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1050 } - @objc open var elevationZIndexModal: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1060 } - @objc open var elevationZIndexPopover: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1070 } - @objc open var elevationZIndexTooltip: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1080 } - @objc open var elevationZIndexToast: ElevationZIndexSemanticToken { ElevationRawTokens.elevationZIndex1090 } - - // MARK: Semantic token - Elevation - X - - @objc open var elevationXNone: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXRaised: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXDrag: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXOverlayDefault: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXOverlayEmphasis: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXStickyDefault: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXStickyEmphasis: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXStickyNavigationScrolled: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - @objc open var elevationXFocus: ElevationZIndexSemanticToken { ElevationRawTokens.elevationX0 } - - // MARK: Semantic token - Elevation - Y - - @objc open var elevationYNone: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY0 } - @objc open var elevationYRaised: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY100 } - @objc open var elevationYDrag: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY300 } - @objc open var elevationYOverlayDefault: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY200 } - @objc open var elevationYOverlayEmphasis: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY500 } - @objc open var elevationYStickyDefault: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY300 } - @objc open var elevationYStickyEmphasis: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY300 } - @objc open var elevationYStickyNavigationScrolled: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY300 } - @objc open var elevationYFocus: ElevationZIndexSemanticToken { ElevationRawTokens.elevationY0 } - - // MARK: Semantic token - Elevation - Blur - - @objc open var elevationBlurNone: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur0 } - @objc open var elevationBlurRaised: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur200 } - @objc open var elevationBlurDrag: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } - @objc open var elevationBlurOverlayDefault: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur300 } - @objc open var elevationBlurOverlayEmphasis: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur600 } - @objc open var elevationBlurStickyDefault: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } - @objc open var elevationBlurStickyEmphasis: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } - @objc open var elevationBlurStickyNavigationScrolled: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur400 } - @objc open var elevationBlurFocus: ElevationBlurSemanticToken { ElevationRawTokens.elevationBlur0 } - - // MARK: Semantic token - Elevation - Spread - - @objc open var elevationSpreadNone: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpread0 } - @objc open var elevationSpreadRaised: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpread0 } - @objc open var elevationSpreadDrag: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpreadMinus100 } - @objc open var elevationSpreadOverlayDefault: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpreadMinus100 } - @objc open var elevationSpreadOverlayEmphasis: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpreadMinus300 } - @objc open var elevationSpreadStickyDefault: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpreadMinus100 } - @objc open var elevationSpreadStickyEmphasis: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpreadMinus100 } - @objc open var elevationSpreadStickyNavigationScrolled: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpreadMinus100 } - @objc open var elevationSpreadFocus: ElevationSpreadSemanticToken { ElevationRawTokens.elevationSpread300 } - - // MARK: Semantic token - Elevation - Color - None - - @objc open var elevationColorNoneLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack0 } - @objc open var elevationColorNoneDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack0 } - - // MARK: Semantic token - Elevation - Color - Raised - - @objc open var elevationColorRaisedLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack500 } - @objc open var elevationColorRaisedDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack500 } - - // MARK: Semantic token - Elevation - Color - Drag - - @objc open var elevationColorDragLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack600 } - @objc open var elevationColorDragDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack600 } - - // MARK: Semantic token - Elevation - Color - Overlay - Default - - @objc open var elevationColorOverlayDefaultLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack400 } - @objc open var elevationColorOverlayDefaultDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack400 } - - // MARK: Semantic token - Elevation - Color - Overlay - Emphasis - - @objc open var elevationColorOverlayEmphasisLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - @objc open var elevationColorOverlayEmphasisDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - - // MARK: Semantic token - Elevation - Color - Sticky - Default - - @objc open var elevationColorStickyDefaultLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - @objc open var elevationColorStickyDefaultDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - - // MARK: Semantic token - Elevation - Color - Sticky - Emphasis - - @objc open var elevationColorStickyEmphasisLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - @objc open var elevationColorStickyEmphasisDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - - // MARK: Semantic token - Elevation - Color - Sticky - Navigation scrolled - - @objc open var elevationColorStickyNavigationScrolledLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - @objc open var elevationColorStickyNavigationScrolledDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - - // MARK: Semantic token - Elevation - Color - Focus - - @objc open var elevationColorFocusLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentWhite900 } - @objc open var elevationColorFocusDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentWhite900 } - - // MARK: Semantic token - Elevation - Box shadow - - @objc open var elevationBoxShadowRaisedLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } - @objc open var elevationBoxShadowRaisedDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } - - @objc open var elevationBoxShadowDragLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_600 } - @objc open var elevationBoxShadowDragDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_600 } - - @objc open var elevationBoxShadowOverlayDefaultLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_2_400 } - @objc open var elevationBoxShadowOverlayDefaultDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_2_400 } - - @objc open var elevationBoxShadowOverlayEmphasisLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_5_300 } - @objc open var elevationBoxShadowOverlayEmphasisDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_5_300 } - - @objc open var elevationBoxShadowStickyDefaultLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } - @objc open var elevationBoxShadowStickyDefaultDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } - - @objc open var elevationBoxShadowStickyEmphasisLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } - @objc open var elevationBoxShadowStickyEmphasisDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } - - @objc open var elevationBoxShadowStickyNavigationScrolledLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } - @objc open var elevationBoxShadowStickyNavigationScrolledDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } - - @objc open var elevationBoxShadowFocusLight: ElevationBoxShadowSemanticToken { ElevationBoxShadowRawToken(x: 0, y: 0, blur: 0, spread: 3, color: ColorRawTokens.colorTransparentWhite900) } - @objc open var elevationBoxShadowFocusDark: ElevationBoxShadowSemanticToken { ElevationBoxShadowRawToken(x: 0, y: 0, blur: 0, spread: 3, color: ColorRawTokens.colorTransparentWhite900) } -} -// swiftlint:enable line_length diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift b/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift deleted file mode 100644 index 2cc935b01..000000000 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokens.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// 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 - -/// Defines basic values common to all themes for `DimensionSemanticTokens`. -/// 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: GridSemanticTokens { - - // MARK: Semantic token - Grid - iOS Extra compact - - @objc open var gridIOSExtraCompactDesignWidth: GridIOSExtraCompactSemanticToken { GridRawTokens.gridDesignWidth100 } - @objc open var gridIOSExtraCompactMinWidth: GridIOSExtraCompactSemanticToken { GridRawTokens.gridMinWidthIOSExtraCompact } - @objc open var gridIOSExtraCompactMaxWidth: GridIOSExtraCompactSemanticToken { GridRawTokens.gridMaxWidthIOSExtraCompact } - @objc open var gridIOSExtraCompactMargin: GridIOSExtraCompactSemanticToken { GridRawTokens.gridMargin100 } - @objc open var gridIOSExtraCompactColumnGap: GridIOSExtraCompactSemanticToken { GridRawTokens.gridColumnGap100 } - @objc open var gridIOSExtraCompactColumnCount: GridIOSExtraCompactSemanticToken { GridRawTokens.gridColumnCount100 } - - // MARK: Semantic token - Grid - iOS Compact - - @objc open var gridIOSCompactDesignWidth: GridIOSExtraCompactSemanticToken { GridRawTokens.gridDesignWidth200 } - @objc open var gridIOSCompactMinWidth: GridIOSCompactSemanticToken { GridRawTokens.gridMinWidthIOSCompact } - @objc open var gridIOSCompactMaxWidth: GridIOSCompactSemanticToken { GridRawTokens.gridMaxWidthIOSCompact } - @objc open var gridIOSCompactMargin: GridIOSCompactSemanticToken { GridRawTokens.gridMargin300 } - @objc open var gridIOSCompactColumnGap: GridIOSCompactSemanticToken { GridRawTokens.gridColumnGap100 } - @objc open var gridIOSCompactColumnCount: GridIOSCompactSemanticToken { GridRawTokens.gridColumnCount400 } - - // MARK: Semantic token - Grid - iOS Regular - - @objc open var gridIOSRegularDesignWidth: GridIOSExtraCompactSemanticToken { GridRawTokens.gridDesignWidth400 } - @objc open var gridIOSRegularMinWidth: GridIOSRegularSemanticToken { GridRawTokens.gridMinWidthIOSRegular } - @objc open var gridIOSRegularMaxWidth: GridIOSRegularSemanticToken { GridRawTokens.gridMaxWidthIOSRegular } - @objc open var gridIOSRegularMargin: GridIOSRegularSemanticToken { GridRawTokens.gridMargin500 } - @objc open var gridIOSRegularColumnGap: GridIOSRegularSemanticToken { GridRawTokens.gridColumnGap300 } - @objc open var gridIOSRegularColumnCount: GridIOSRegularSemanticToken { GridRawTokens.gridColumnCount600 } -} diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+SizingSemanticTokens.swift b/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+SizingSemanticTokens.swift deleted file mode 100644 index 4ea5c1bbc..000000000 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme+SemanticTokens/OUDSTheme+SizingSemanticTokens.swift +++ /dev/null @@ -1,91 +0,0 @@ -// -// 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 - -/// Defines basic values common to all themes for `SizingSemanticTokens`. -/// 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: SizingSemanticTokens { - - // MARK: Semantic token - Sizing - Width height - Icon decorative - - @objc open var sizeWidthHeightIconShortest: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension200 } - @objc open var sizeWidthHeightIconShorter: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } - @objc open var sizeWidthHeightIconShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension400 } - @objc open var sizeWidthHeightIconMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension500 } - @objc open var sizeWidthHeightIconTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension600 } - @objc open var sizeWidthHeightIconTaller: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension700 } - @objc open var sizeWidthHeightIconTallest: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension900 } - - // MARK: Semantic token - Sizing - Width height - Icon component - - @objc open var sizeWidthHeightIsLabelSmallShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension150 } - @objc open var sizeWidthHeightIsLabelSmallMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension200 } - @objc open var sizeWidthHeightIsLabelSmallTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } - @objc open var sizeWidthHeightIsLabelMediumShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension200 } - @objc open var sizeWidthHeightIsLabelMediumMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } - @objc open var sizeWidthHeightIsLabelMediumTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } - @objc open var sizeWidthHeightIsLabelLargeShorter: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } - @objc open var sizeWidthHeightIsLabelLargeShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } - @objc open var sizeWidthHeightIsLabelLargeMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension350 } - @objc open var sizeWidthHeightIsLabelLargeTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension400 } - @objc open var sizeWidthHeightIsLabelLargeTaller: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension550 } - @objc open var sizeWidthHeightIsLabelXLargeShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension400 } - @objc open var sizeWidthHeightIsLabelXLargeMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension500 } - @objc open var sizeWidthHeightIsLabelXLargeTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension550 } - - // MARK: Semantic token - Sizing - Width height - Icon typography - Heading - - // TODO: What should we do? In issue #36 there are 3 possible values (web paradigm ?), selected here the xl-2xl-3xl case - @objc open var sizeWidthHeightIconIsHeadingSmallShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension500 } - @objc open var sizeWidthHeightIconIsHeadingSmallMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension550 } - @objc open var sizeWidthHeightIconIsHeadingSmallTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension600 } - @objc open var sizeWidthHeightIconIsHeadingMediumShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension550 } - @objc open var sizeWidthHeightIconIsHeadingMediumMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension600 } - @objc open var sizeWidthHeightIconIsHeadingMediumTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension650 } - @objc open var sizeWidthHeightIconIsHeadingLargeShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension600 } - @objc open var sizeWidthHeightIconIsHeadingLargeMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension650 } - @objc open var sizeWidthHeightIconIsHeadingLargeTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension700 } - @objc open var sizeWidthHeightIconIsHeadingXLargeShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension700 } - @objc open var sizeWidthHeightIconIsHeadingXLargeMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension750 } - @objc open var sizeWidthHeightIconIsHeadingXLargeTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension800 } - - // MARK: Semantic token - Sizing - Width height - Icon typography - Body - - // TODO: What should we do? In issue #36 there are 3 possible values (web paradigm ?), selected here the xl-2xl-3xl case - @objc open var sizeWidthHeightIconIsBodySmallShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension200 } - @objc open var sizeWidthHeightIconIsBodySmallMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } - @objc open var sizeWidthHeightIconIsBodySmallTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } - @objc open var sizeWidthHeightIconIsBodyMediumShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension250 } - @objc open var sizeWidthHeightIconIsBodyMediumMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension300 } - @objc open var sizeWidthHeightIconIsBodyMediumTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension350 } - @objc open var sizeWidthHeightIconIsBodyLargeShort: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension400 } - @objc open var sizeWidthHeightIconIsBodyLargeMedium: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension500 } - @objc open var sizeWidthHeightIconIsBodyLargeTall: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension550 } - - // MARK: Semantic token - Sizing - Max width - - // TODO: What should we do? In issue #36 there are 3 possible values (web paradigm ?), selected here the xl-2xl-3xl case - @objc open var sizeMaxWidthTypographyDisplaySmall: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension11000 } - @objc open var sizeMaxWidthTypographyDisplayMedium: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension11000 } - @objc open var sizeMaxWidthTypographyDisplayLarge: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension11000 } - @objc open var sizeMaxWidthTypographyHeadingSmall: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension7000 } - @objc open var sizeMaxWidthTypographyHeadingMedium: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension11000 } - @objc open var sizeMaxWidthTypographyHeadingLarge: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension11000 } - @objc open var sizeMaxWidthTypographyHeadingXLarge: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension11000 } - @objc open var sizeMaxWidthTypographyBodySmall: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension6000 } - @objc open var sizeMaxWidthTypographyBodyMedium: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension7000 } - @objc open var sizeMaxWidthTypographyBodyLarge: SizingMaxWidthSemanticToken { DimensionRawTokens.dimension7000 } -} diff --git a/OUDS/Core/Themes/Commons/Sources/OUDSTheme.swift b/OUDS/Core/Themes/Commons/Sources/OUDSTheme.swift deleted file mode 100644 index 6237f6d82..000000000 --- a/OUDS/Core/Themes/Commons/Sources/OUDSTheme.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// 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 - -/// This is a basic theme any themes must be a subclass off. -/// A Swift `class` has been used to as to allow to easily override some attributes and have inheritance, without having for developers -/// to implement all tokens. -/// Any properties of an overridable theme should be defined so as to provide defaults values. -/// We allow this theme to be derivated / be overriden. -/// -/// **Warning: You are not supposed to use this abstract default theme directly. Please prefer `OrangeTheme` instead** -/// `OUDSTheme` can be seen as a kid of "abstract class" in _object oriented paradigm_. -open class OUDSTheme { - - public init() { } - - // Please refer to extensions for properties, it will be more clear -} diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+ElevationSemanticTokens.swift b/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+ElevationSemanticTokens.swift deleted file mode 100644 index d7718ec46..000000000 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+ElevationSemanticTokens.swift +++ /dev/null @@ -1,167 +0,0 @@ -// -// 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 - -extension MockTheme { - - static let mockThemeZIndexRawToken: ElevationRawToken = 687 - static let mockThemeXRawToken: ElevationRawToken = 711 - static let mockThemeYRawToken: ElevationRawToken = 713 - static let mockThemeBlurRawToken: ElevationRawToken = 816 - static let mockThemeSpreadRawToken: ElevationRawToken = 80085 - static let mockThemeElevationColorRawToken: ColorRawToken = ColorRawTokens.colorFunctionalMalachite500 - static let mockThemeBoxShadowRawToken: ElevationBoxShadowRawToken = ElevationBoxShadowRawToken(x: 118, - y: 712, - blur: 118, - spread: 218, - color: ColorRawTokens.colorFunctionalDodgerBlue800) - - // MARK: Semantic token - Elevation - Z index - - override var elevationZIndexDeep: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexDefault: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexDropdown: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexSticky: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexFixed: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexBackToTop: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexSpinner: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexOffCanvasBackdrop: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexOffCanvas: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexModalBackdrop: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexModal: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexPopover: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexTooltip: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - override var elevationZIndexToast: ElevationZIndexSemanticToken { Self.mockThemeZIndexRawToken } - - // MARK: Semantic token - Elevation - X - - override var elevationXNone: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXRaised: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXDrag: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXOverlayDefault: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXOverlayEmphasis: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXStickyDefault: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXStickyEmphasis: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXStickyNavigationScrolled: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - override var elevationXFocus: ElevationZIndexSemanticToken { Self.mockThemeXRawToken } - - // MARK: Semantic token - Elevation - Y - - override var elevationYNone: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYRaised: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYDrag: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYOverlayDefault: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYOverlayEmphasis: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYStickyDefault: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYStickyEmphasis: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYStickyNavigationScrolled: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - override var elevationYFocus: ElevationZIndexSemanticToken { Self.mockThemeYRawToken } - - // MARK: Semantic token - Elevation - Blur - - override var elevationBlurNone: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurRaised: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurDrag: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurOverlayDefault: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurOverlayEmphasis: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurStickyDefault: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurStickyEmphasis: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurStickyNavigationScrolled: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - override var elevationBlurFocus: ElevationBlurSemanticToken { Self.mockThemeBlurRawToken } - - // MARK: Semantic token - Elevation - Spread - - override var elevationSpreadNone: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadRaised: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadDrag: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadOverlayDefault: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadOverlayEmphasis: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadStickyDefault: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadStickyEmphasis: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadStickyNavigationScrolled: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - override var elevationSpreadFocus: ElevationSpreadSemanticToken { Self.mockThemeSpreadRawToken } - - // MARK: Semantic token - Elevation - Color - None - - override var elevationColorNoneLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorNoneDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Raised - - override var elevationColorRaisedLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorRaisedDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Drag - - override var elevationColorDragLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorDragDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Overlay - Default - - override var elevationColorOverlayDefaultLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorOverlayDefaultDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Overlay - Emphasis - - override var elevationColorOverlayEmphasisLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorOverlayEmphasisDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Sticky - Default - - override var elevationColorStickyDefaultLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorStickyDefaultDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Sticky - Emphasis - - override var elevationColorStickyEmphasisLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorStickyEmphasisDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Sticky - Navigation scrolled - - override var elevationColorStickyNavigationScrolledLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorStickyNavigationScrolledDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Color - Focus - - override var elevationColorFocusLight: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - override var elevationColorFocusDark: ElevationColorSemanticToken { Self.mockThemeElevationColorRawToken } - - // MARK: Semantic token - Elevation - Box shadow - - override var elevationBoxShadowRaisedLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowRaisedDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - - override var elevationBoxShadowDragLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowDragDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - - override var elevationBoxShadowOverlayDefaultLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowOverlayDefaultDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - - override var elevationBoxShadowOverlayEmphasisLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowOverlayEmphasisDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - - override var elevationBoxShadowStickyDefaultLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowStickyDefaultDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - - override var elevationBoxShadowStickyEmphasisLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowStickyEmphasisDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - - override var elevationBoxShadowStickyNavigationScrolledLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowStickyNavigationScrolledDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - - override var elevationBoxShadowFocusLight: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } - override var elevationBoxShadowFocusDark: ElevationBoxShadowSemanticToken { Self.mockThemeBoxShadowRawToken } -} diff --git a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+GridSemanticTokens.swift b/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+GridSemanticTokens.swift deleted file mode 100644 index 90c856455..000000000 --- a/OUDS/Core/Themes/Commons/Tests/MockTheme/MockTheme+GridSemanticTokens.swift +++ /dev/null @@ -1,42 +0,0 @@ -// -// 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 - -extension MockTheme { - - static let mockThemeGridRawToken: GridRawToken = 3630 - - override var gridIOSExtraCompactDesignWidth: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSExtraCompactMinWidth: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSExtraCompactMaxWidth: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSExtraCompactMargin: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSExtraCompactColumnGap: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSExtraCompactColumnCount: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - - override var gridIOSCompactDesignWidth: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSCompactMinWidth: GridIOSCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSCompactMaxWidth: GridIOSCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSCompactMargin: GridIOSCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSCompactColumnGap: GridIOSCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSCompactColumnCount: GridIOSCompactSemanticToken { Self.mockThemeGridRawToken } - - override var gridIOSRegularDesignWidth: GridIOSExtraCompactSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSRegularMinWidth: GridIOSRegularSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSRegularMaxWidth: GridIOSRegularSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSRegularMargin: GridIOSRegularSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSRegularColumnGap: GridIOSRegularSemanticToken { Self.mockThemeGridRawToken } - override var gridIOSRegularColumnCount: GridIOSRegularSemanticToken { Self.mockThemeGridRawToken } -} diff --git a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfGridSemanticTokens.swift b/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfGridSemanticTokens.swift deleted file mode 100644 index c82ce75f8..000000000 --- a/OUDS/Core/Themes/Commons/Tests/TestThemeOverrideOfGridSemanticTokens.swift +++ /dev/null @@ -1,120 +0,0 @@ -// -// 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 XCTest -import OUDSThemesCommons - -/// 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 _grid semantic tokens_. -/// These semantic tokens should be overriden by subclass like the `OrangeTheme` default theme. -/// **These tests checks if any _grid semantic tokens_ can be surcharged by a child theme** -final class TestThemeOverrideOfGridSemanticTokens: XCTestCase { - - private var abstractTheme: OUDSTheme! - private var inheritedTheme: OUDSTheme! - - override func setUp() async throws { - abstractTheme = OUDSTheme() - inheritedTheme = MockTheme() - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactDesignWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSExtraCompactDesignWidth, abstractTheme.gridIOSExtraCompactDesignWidth) - XCTAssertTrue(inheritedTheme.gridIOSExtraCompactDesignWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactMinWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSExtraCompactMinWidth, abstractTheme.gridIOSExtraCompactMinWidth) - XCTAssertTrue(inheritedTheme.gridIOSExtraCompactMinWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactMaxWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSExtraCompactMaxWidth, abstractTheme.gridIOSExtraCompactMaxWidth) - XCTAssertTrue(inheritedTheme.gridIOSExtraCompactMaxWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactMargin() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSExtraCompactMargin, abstractTheme.gridIOSExtraCompactMargin) - XCTAssertTrue(inheritedTheme.gridIOSExtraCompactMargin == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactColumnGap() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSExtraCompactColumnGap, abstractTheme.gridIOSExtraCompactColumnGap) - XCTAssertTrue(inheritedTheme.gridIOSExtraCompactColumnGap == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSExtraCompactColumnCount() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSExtraCompactColumnCount, abstractTheme.gridIOSExtraCompactColumnCount) - XCTAssertTrue(inheritedTheme.gridIOSExtraCompactColumnCount == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactDesignWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSCompactDesignWidth, abstractTheme.gridIOSCompactDesignWidth) - XCTAssertTrue(inheritedTheme.gridIOSCompactDesignWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactMinWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSCompactMinWidth, abstractTheme.gridIOSCompactMinWidth) - XCTAssertTrue(inheritedTheme.gridIOSCompactMinWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactMaxWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSCompactMaxWidth, abstractTheme.gridIOSCompactMaxWidth) - XCTAssertTrue(inheritedTheme.gridIOSCompactMaxWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactMargin() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSCompactMargin, abstractTheme.gridIOSCompactMargin) - XCTAssertTrue(inheritedTheme.gridIOSCompactMargin == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactColumnGap() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSCompactColumnGap, abstractTheme.gridIOSCompactColumnGap) - XCTAssertTrue(inheritedTheme.gridIOSCompactColumnGap == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSCompactColumnCount() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSCompactColumnCount, abstractTheme.gridIOSCompactColumnCount) - XCTAssertTrue(inheritedTheme.gridIOSCompactColumnCount == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularDesignWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSRegularDesignWidth, abstractTheme.gridIOSRegularDesignWidth) - XCTAssertTrue(inheritedTheme.gridIOSRegularDesignWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularMinWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSRegularMinWidth, abstractTheme.gridIOSRegularMinWidth) - XCTAssertTrue(inheritedTheme.gridIOSRegularMinWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularMaxWidth() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSRegularMaxWidth, abstractTheme.gridIOSRegularMaxWidth) - XCTAssertTrue(inheritedTheme.gridIOSRegularMaxWidth == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularMargin() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSRegularMargin, abstractTheme.gridIOSRegularMargin) - XCTAssertTrue(inheritedTheme.gridIOSRegularMargin == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularColumnGap() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSRegularColumnGap, abstractTheme.gridIOSRegularColumnGap) - XCTAssertTrue(inheritedTheme.gridIOSRegularColumnGap == MockTheme.mockThemeGridRawToken) - } - - func testInheritedThemeCanOverrideSemanticTokenGridIOSRegularColumnCount() throws { - XCTAssertNotEqual(inheritedTheme.gridIOSRegularColumnCount, abstractTheme.gridIOSRegularColumnCount) - XCTAssertTrue(inheritedTheme.gridIOSRegularColumnCount == MockTheme.mockThemeGridRawToken) - } -} diff --git a/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ColorSemanticTokens.swift b/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ColorSemanticTokens.swift index 53390aff6..adb6098ba 100644 --- a/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ColorSemanticTokens.swift +++ b/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ColorSemanticTokens.swift @@ -17,20 +17,20 @@ import OUDSTokensSemantic /// Overrides some colors using values defined in extension of `ColorRawTokens` in this current module. extension InverseTheme { - public override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorBackgroundDefaultSecondaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisMedium } - public override var colorBackgroundDefaultSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisMedium } + public override var colorBackgroundDefaultSecondaryLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedMedium } + public override var colorBackgroundDefaultSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedMedium } public override var colorBackgroundDefaultTertiaryLight: ColorSemanticToken? { sysColorBrandAttractiveHighest } public override var colorBackgroundDefaultTertiaryDark: ColorSemanticToken? { sysColorBrandAttractiveHighest } - public override var colorBackgroundEmphasisPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - public override var colorBackgroundEmphasisPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + public override var colorBackgroundEmphasizedPrimaryLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + public override var colorBackgroundEmphasizedPrimaryDark: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - public override var colorBackgroundEmphasisSecondaryLight: ColorSemanticToken? { sysColorBrandNeutralMutedLowest } - public override var colorBackgroundEmphasisSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralMutedLowest } + public override var colorBackgroundEmphasizedSecondaryLight: ColorSemanticToken? { sysColorBrandNeutralMutedLowest } + public override var colorBackgroundEmphasizedSecondaryDark: ColorSemanticToken? { sysColorBrandNeutralMutedLowest } public override var colorBackgroundBrandPrimaryLight: ColorSemanticToken? { sysColorBrandPrimaryDefault } public override var colorBackgroundBrandPrimaryDark: ColorSemanticToken? { sysColorBrandPrimaryDefault } @@ -38,50 +38,50 @@ extension InverseTheme { public override var colorBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { sysColorBrandAttractiveLowest } public override var colorBackgroundStatusAttractiveMutedDark: ColorSemanticToken? { sysColorBrandAttractiveLowest } - public override var colorBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken? { sysColorBrandWarningDefault } - public override var colorBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken? { sysColorBrandWarningDefault } + public override var colorBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken? { sysColorBrandWarningDefault } + public override var colorBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken? { sysColorBrandWarningDefault } public override var colorBackgroundStatusWarningMutedLight: ColorSemanticToken? { sysColorBrandWarningLowest } public override var colorBackgroundStatusWarningMutedDark: ColorSemanticToken? { sysColorBrandWarningLowest } - public override var colorBackgroundStatusWarningEmphasisLight: ColorSemanticToken? { sysColorBrandWarningDefault } - public override var colorBackgroundStatusWarningEmphasisDark: ColorSemanticToken? { sysColorBrandWarningDefault } + public override var colorBackgroundStatusWarningEmphasizedLight: ColorSemanticToken? { sysColorBrandWarningDefault } + public override var colorBackgroundStatusWarningEmphasizedDark: ColorSemanticToken? { sysColorBrandWarningDefault } public override var colorBackgroundStatusNegativeMutedLight: ColorSemanticToken? { sysColorBrandNegativeLowest } public override var colorBackgroundStatusNegativeMutedDark: ColorSemanticToken? { sysColorBrandNegativeLowest } - public override var colorBackgroundStatusNegativeEmphasisLight: ColorSemanticToken? { sysColorBrandNegativeDefault } - public override var colorBackgroundStatusNegativeEmphasisDark: ColorSemanticToken? { sysColorBrandNegativeDefault } + public override var colorBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken? { sysColorBrandNegativeDefault } + public override var colorBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken? { sysColorBrandNegativeDefault } public override var colorBackgroundStatusPositiveMutedLight: ColorSemanticToken? { sysColorBrandPositiveLowest } public override var colorBackgroundStatusPositiveMutedDark: ColorSemanticToken? { sysColorBrandPositiveLowest } - public override var colorBackgroundStatusPositiveEmphasisLight: ColorSemanticToken? { sysColorBrandPositiveDefault } - public override var colorBackgroundStatusPositiveEmphasisDark: ColorSemanticToken? { sysColorBrandPositiveDefault } + public override var colorBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken? { sysColorBrandPositiveDefault } + public override var colorBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken? { sysColorBrandPositiveDefault } public override var colorBackgroundStatusInformationMutedLight: ColorSemanticToken? { sysColorBrandInformationLowest } public override var colorBackgroundStatusInformationMutedDark: ColorSemanticToken? { sysColorBrandInformationLowest } - public override var colorBackgroundStatusInformationEmphasisLight: ColorSemanticToken? { sysColorBrandPositiveLowest } - public override var colorBackgroundStatusInformationEmphasisDark: ColorSemanticToken? { sysColorBrandPositiveLowest } + public override var colorBackgroundStatusInformationEmphasizedLight: ColorSemanticToken? { sysColorBrandPositiveLowest } + public override var colorBackgroundStatusInformationEmphasizedDark: ColorSemanticToken? { sysColorBrandPositiveLowest } public override var colorContentDefaultLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } public override var colorContentDefaultDark: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - public override var colorContentDefaultOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorContentDefaultOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorContentDefaultOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorContentDefaultOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorContentMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisMedium } - public override var colorContentMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisMedium } + public override var colorContentMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedMedium } + public override var colorContentMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedMedium } - public override var colorContentMutedOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } - public override var colorContentMutedOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } + public override var colorContentMutedOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } + public override var colorContentMutedOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } public override var colorContentBrandPrimaryLight: ColorSemanticToken? { sysColorBrandPrimaryLow } public override var colorContentBrandPrimaryDark: ColorSemanticToken? { sysColorBrandPrimaryLow } - public override var colorContentBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandPrimaryDefault } - public override var colorContentBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandPrimaryDefault } + public override var colorContentBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandPrimaryDefault } + public override var colorContentBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandPrimaryDefault } public override var colorContentBrandSecondaryLight: ColorSemanticToken? { nil } public override var colorContentBrandSecondaryDark: ColorSemanticToken? { nil } @@ -101,23 +101,23 @@ extension InverseTheme { public override var colorContentStatusInformationLight: ColorSemanticToken? { sysColorBrandInformationDefault } public override var colorContentStatusInformationDark: ColorSemanticToken? { sysColorBrandInformationDefault } - public override var colorBorderDefaultLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } - public override var colorBorderDefaultDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisLowest } + public override var colorBorderDefaultLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } + public override var colorBorderDefaultDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedLowest } - public override var colorBorderDefaultOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralMutedMedium } - public override var colorBorderDefaultOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedMedium } + public override var colorBorderDefaultOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralMutedMedium } + public override var colorBorderDefaultOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedMedium } - public override var colorBorderEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - public override var colorBorderEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + public override var colorBorderEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + public override var colorBorderEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - public override var colorBorderEmphasisOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorBorderEmphasisOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorBorderEmphasizedOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorBorderEmphasizedOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } public override var colorBorderBrandPrimaryLight: ColorSemanticToken? { sysColorBrandPrimaryLow } public override var colorBorderBrandPrimaryDark: ColorSemanticToken? { sysColorBrandPrimaryLow } - public override var colorBorderBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken? { sysColorBrandPrimaryDefault } - public override var colorBorderBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken? { sysColorBrandPrimaryDefault } + public override var colorBorderBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken? { sysColorBrandPrimaryDefault } + public override var colorBorderBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken? { sysColorBrandPrimaryDefault } public override var colorBorderBrandSecondaryLight: ColorSemanticToken? { nil } public override var colorBorderBrandSecondaryDark: ColorSemanticToken? { nil } @@ -149,33 +149,33 @@ extension InverseTheme { public override var colorOnBackgroundTertiaryLight: ColorSemanticToken? { nil } public override var colorOnBackgroundTertiaryDark: ColorSemanticToken? { nil } - public override var colorOnBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusAttractiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusAttractiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusWarningMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusWarningMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusWarningMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusWarningMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusWarningEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusWarningEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusWarningEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusWarningEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusNegativeMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusNegativeMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusNegativeMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusNegativeMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusNegativeEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - public override var colorOnBackgroundStatusNegativeEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + public override var colorOnBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } + public override var colorOnBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralMutedWhite } - public override var colorOnBackgroundStatusPositiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusPositiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusPositiveMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusPositiveMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusPositiveEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusPositiveEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusInformationMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusInformationMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusInformationMutedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusInformationMutedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } - public override var colorOnBackgroundStatusInformationEmphasisLight: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } - public override var colorOnBackgroundStatusInformationEmphasisDark: ColorSemanticToken? { sysColorBrandNeutralEmphasisBlack } + public override var colorOnBackgroundStatusInformationEmphasizedLight: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } + public override var colorOnBackgroundStatusInformationEmphasizedDark: ColorSemanticToken? { sysColorBrandNeutralEmphasizedBlack } } diff --git a/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ElevationSemanticTokens.swift b/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ElevationSemanticTokens.swift index 8bf994d59..c8066e598 100644 --- a/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ElevationSemanticTokens.swift +++ b/OUDS/Core/Themes/Inverse/Sources/InverseTheme+ElevationSemanticTokens.swift @@ -15,7 +15,6 @@ import Foundation import OUDSTokensRaw import OUDSTokensSemantic -// swiftlint:disable line_length extension InverseTheme { // MARK: Semantic token - Elevation - Color - None @@ -38,20 +37,20 @@ extension InverseTheme { public override var elevationColorOverlayDefaultLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack400 } public override var elevationColorOverlayDefaultDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack400 } - // MARK: Semantic token - Elevation - Color - Overlay - Emphasis + // MARK: Semantic token - Elevation - Color - Overlay - Emphasized - public override var elevationColorOverlayEmphasisLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - public override var elevationColorOverlayEmphasisDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + public override var elevationColorOverlayEmphasizedLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + public override var elevationColorOverlayEmphasizedDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } // MARK: Semantic token - Elevation - Color - Sticky - Default public override var elevationColorStickyDefaultLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } public override var elevationColorStickyDefaultDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - // MARK: Semantic token - Elevation - Color - Sticky - Emphasis + // MARK: Semantic token - Elevation - Color - Sticky - Emphasized - public override var elevationColorStickyEmphasisLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } - public override var elevationColorStickyEmphasisDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + public override var elevationColorStickyEmphasizedLight: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } + public override var elevationColorStickyEmphasizedDark: ElevationColorSemanticToken { ColorRawTokens.colorTransparentBlack300 } // MARK: Semantic token - Elevation - Color - Sticky - Navigation scrolled @@ -65,28 +64,27 @@ extension InverseTheme { // MARK: Semantic token - Elevation - Box shadow - public override var elevationBoxShadowRaisedLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } - public override var elevationBoxShadowRaisedDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } + public override var elevationRaisedLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } + public override var elevationRaisedDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } - public override var elevationBoxShadowDragLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_600 } - public override var elevationBoxShadowDragDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_600 } + public override var elevationDragLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_600 } + public override var elevationDragDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_600 } - public override var elevationBoxShadowOverlayDefaultLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_2_400 } - public override var elevationBoxShadowOverlayDefaultDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_2_400 } + public override var elevationOverlayDefaultLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_2_400 } + public override var elevationOverlayDefaultDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_2_400 } - public override var elevationBoxShadowOverlayEmphasisLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_5_300 } - public override var elevationBoxShadowOverlayEmphasisDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_5_300 } + public override var elevationOverlayEmphasizedLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_5_300 } + public override var elevationOverlayEmphasizedDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_5_300 } - public override var elevationBoxShadowStickyDefaultLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } - public override var elevationBoxShadowStickyDefaultDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } + public override var elevationStickyDefaultLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } + public override var elevationStickyDefaultDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } - public override var elevationBoxShadowStickyEmphasisLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } - public override var elevationBoxShadowStickyEmphasisDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_3_300 } + public override var elevationStickyEmphasizedLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } + public override var elevationStickyEmphasizedDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_3_300 } - public override var elevationBoxShadowStickyNavigationScrolledLight: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } - public override var elevationBoxShadowStickyNavigationScrolledDark: ElevationBoxShadowSemanticToken { ElevationRawTokens.elevationBoxShadowBottom_1_500 } + public override var elevationStickyNavigationScrolledLight: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } + public override var elevationStickyNavigationScrolledDark: ElevationCompositeSemanticToken { ElevationRawTokens.elevationBottom_1_500 } - public override var elevationBoxShadowFocusLight: ElevationBoxShadowSemanticToken { ElevationBoxShadowRawToken(x: 0, y: 0, blur: 0, spread: 3, color: ColorRawTokens.colorTransparentWhite900) } - public override var elevationBoxShadowFocusDark: ElevationBoxShadowSemanticToken { ElevationBoxShadowRawToken(x: 0, y: 0, blur: 0, spread: 3, color: ColorRawTokens.colorTransparentWhite900) } + public override var elevationFocusLight: ElevationCompositeSemanticToken { ElevationCompositeRawToken(x: 0, y: 0, blur: 0, color: ColorRawTokens.colorTransparentWhite900) } + public override var elevationFocusDark: ElevationCompositeSemanticToken { ElevationCompositeRawToken(x: 0, y: 0, blur: 0, color: ColorRawTokens.colorTransparentWhite900) } } -// swiftlint:enable line_length diff --git a/OUDS/Core/Themes/Inverse/Sources/_OUDSThemesInverse.docc/OUDSThemesInverse.md b/OUDS/Core/Themes/Inverse/Sources/_OUDSThemesInverse.docc/OUDSThemesInverse.md new file mode 100644 index 000000000..9d86c628f --- /dev/null +++ b/OUDS/Core/Themes/Inverse/Sources/_OUDSThemesInverse.docc/OUDSThemesInverse.md @@ -0,0 +1,16 @@ +# ``OUDSThemesInverse`` + +This theme overrides the [Orange theme](https://ios.unified-design-system.orange.com/documentation/oudsthemesorange/) for some colors. + +## Overview + +This is an override of the [Orange theme](https://ios.unified-design-system.orange.com/documentation/oudsthemesorange/) with some inverted colors. +It can override any properties from its superclass, and can be derived too. + +❗**More details coming soon.**❗ + +## Topics + +### Group + +- ``InverseTheme`` diff --git a/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeColors.swift b/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeColors.swift index 32ef9d137..d5c198fb9 100644 --- a/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeColors.swift +++ b/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeColors.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS import OUDSThemesInverse /// `InverseTheme` is a quite particular theme with "inverse" color palette. Is it neuther a light mode theme nor a dark mode theme. @@ -29,44 +29,44 @@ final class TestInverseThemeColors: XCTestCase { XCTAssertEqual(inverseTheme.colorBackgroundDefaultPrimaryLight, inverseTheme.colorBackgroundDefaultPrimaryDark) XCTAssertEqual(inverseTheme.colorBackgroundDefaultSecondaryLight, inverseTheme.colorBackgroundDefaultSecondaryDark) XCTAssertEqual(inverseTheme.colorBackgroundDefaultTertiaryLight, inverseTheme.colorBackgroundDefaultTertiaryDark) - XCTAssertEqual(inverseTheme.colorBackgroundEmphasisPrimaryLight, inverseTheme.colorBackgroundEmphasisPrimaryDark) - XCTAssertEqual(inverseTheme.colorBackgroundEmphasisSecondaryLight, inverseTheme.colorBackgroundEmphasisSecondaryDark) + XCTAssertEqual(inverseTheme.colorBackgroundEmphasizedPrimaryLight, inverseTheme.colorBackgroundEmphasizedPrimaryDark) + XCTAssertEqual(inverseTheme.colorBackgroundEmphasizedSecondaryLight, inverseTheme.colorBackgroundEmphasizedSecondaryDark) XCTAssertEqual(inverseTheme.colorBackgroundBrandPrimaryLight, inverseTheme.colorBackgroundBrandPrimaryDark) XCTAssertEqual(inverseTheme.colorBackgroundStatusAttractiveMutedLight, inverseTheme.colorBackgroundStatusAttractiveMutedDark) - XCTAssertEqual(inverseTheme.colorBackgroundStatusAttractiveEmphasisLight, inverseTheme.colorBackgroundStatusAttractiveEmphasisDark) + XCTAssertEqual(inverseTheme.colorBackgroundStatusAttractiveEmphasizedLight, inverseTheme.colorBackgroundStatusAttractiveEmphasizedDark) XCTAssertEqual(inverseTheme.colorBackgroundStatusWarningMutedLight, inverseTheme.colorBackgroundStatusWarningMutedDark) - XCTAssertEqual(inverseTheme.colorBackgroundStatusWarningEmphasisLight, inverseTheme.colorBackgroundStatusWarningEmphasisDark) + XCTAssertEqual(inverseTheme.colorBackgroundStatusWarningEmphasizedLight, inverseTheme.colorBackgroundStatusWarningEmphasizedDark) XCTAssertEqual(inverseTheme.colorBackgroundStatusNegativeMutedLight, inverseTheme.colorBackgroundStatusNegativeMutedDark) - XCTAssertEqual(inverseTheme.colorBackgroundStatusNegativeEmphasisLight, inverseTheme.colorBackgroundStatusNegativeEmphasisDark) + XCTAssertEqual(inverseTheme.colorBackgroundStatusNegativeEmphasizedLight, inverseTheme.colorBackgroundStatusNegativeEmphasizedDark) XCTAssertEqual(inverseTheme.colorBackgroundStatusPositiveMutedLight, inverseTheme.colorBackgroundStatusPositiveMutedDark) - XCTAssertEqual(inverseTheme.colorBackgroundStatusPositiveEmphasisLight, inverseTheme.colorBackgroundStatusPositiveEmphasisDark) + XCTAssertEqual(inverseTheme.colorBackgroundStatusPositiveEmphasizedLight, inverseTheme.colorBackgroundStatusPositiveEmphasizedDark) XCTAssertEqual(inverseTheme.colorBackgroundStatusInformationMutedLight, inverseTheme.colorBackgroundStatusInformationMutedDark) - XCTAssertEqual(inverseTheme.colorBackgroundStatusInformationEmphasisLight, inverseTheme.colorBackgroundStatusInformationEmphasisDark) + XCTAssertEqual(inverseTheme.colorBackgroundStatusInformationEmphasizedLight, inverseTheme.colorBackgroundStatusInformationEmphasizedDark) XCTAssertEqual(inverseTheme.colorContentDefaultLight, inverseTheme.colorContentDefaultDark) - XCTAssertEqual(inverseTheme.colorContentDefaultOnBackgroundEmphasisLight, inverseTheme.colorContentDefaultOnBackgroundEmphasisDark) + XCTAssertEqual(inverseTheme.colorContentDefaultOnBackgroundEmphasizedLight, inverseTheme.colorContentDefaultOnBackgroundEmphasizedDark) XCTAssertEqual(inverseTheme.colorContentMutedLight, inverseTheme.colorContentMutedDark) - XCTAssertEqual(inverseTheme.colorContentMutedOnBackgroundEmphasisLight, inverseTheme.colorContentMutedOnBackgroundEmphasisDark) + XCTAssertEqual(inverseTheme.colorContentMutedOnBackgroundEmphasizedLight, inverseTheme.colorContentMutedOnBackgroundEmphasizedDark) XCTAssertEqual(inverseTheme.colorContentBrandPrimaryLight, inverseTheme.colorContentBrandPrimaryDark) - XCTAssertEqual(inverseTheme.colorContentBrandPrimaryOnBackgroundEmphasisLight, inverseTheme.colorContentBrandPrimaryOnBackgroundEmphasisDark) + XCTAssertEqual(inverseTheme.colorContentBrandPrimaryOnBackgroundEmphasizedLight, inverseTheme.colorContentBrandPrimaryOnBackgroundEmphasizedDark) XCTAssertEqual(inverseTheme.colorContentStatusNegativeLight, inverseTheme.colorContentStatusNegativeDark) XCTAssertEqual(inverseTheme.colorContentStatusPositiveLight, inverseTheme.colorContentStatusPositiveDark) XCTAssertEqual(inverseTheme.colorContentStatusInformationLight, inverseTheme.colorContentStatusInformationDark) XCTAssertEqual(inverseTheme.colorBorderDefaultLight, inverseTheme.colorBorderDefaultDark) - XCTAssertEqual(inverseTheme.colorBorderDefaultOnBackgroundEmphasisLight, inverseTheme.colorBorderDefaultOnBackgroundEmphasisDark) - XCTAssertEqual(inverseTheme.colorBorderEmphasisLight, inverseTheme.colorBorderEmphasisDark) - XCTAssertEqual(inverseTheme.colorBorderEmphasisOnBackgroundEmphasisLight, inverseTheme.colorBorderEmphasisOnBackgroundEmphasisDark) + XCTAssertEqual(inverseTheme.colorBorderDefaultOnBackgroundEmphasizedLight, inverseTheme.colorBorderDefaultOnBackgroundEmphasizedDark) + XCTAssertEqual(inverseTheme.colorBorderEmphasizedLight, inverseTheme.colorBorderEmphasizedDark) + XCTAssertEqual(inverseTheme.colorBorderEmphasizedOnBackgroundEmphasizedLight, inverseTheme.colorBorderEmphasizedOnBackgroundEmphasizedDark) XCTAssertEqual(inverseTheme.colorBorderBrandPrimaryLight, inverseTheme.colorBorderBrandPrimaryDark) - XCTAssertEqual(inverseTheme.colorBorderBrandPrimaryOnBackgroundEmphasisLight, inverseTheme.colorBorderBrandPrimaryOnBackgroundEmphasisDark) + XCTAssertEqual(inverseTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedLight, inverseTheme.colorBorderBrandPrimaryOnBackgroundEmphasizedDark) XCTAssertEqual(inverseTheme.colorOnBackgroundPrimaryLight, inverseTheme.colorOnBackgroundPrimaryDark) XCTAssertEqual(inverseTheme.colorOnBackgroundStatusAttractiveMutedLight, inverseTheme.colorOnBackgroundStatusAttractiveMutedDark) - XCTAssertEqual(inverseTheme.colorOnBackgroundStatusAttractiveEmphasisLight, inverseTheme.colorOnBackgroundStatusAttractiveEmphasisDark) + XCTAssertEqual(inverseTheme.colorOnBackgroundStatusAttractiveEmphasizedLight, inverseTheme.colorOnBackgroundStatusAttractiveEmphasizedDark) XCTAssertEqual(inverseTheme.colorOnBackgroundStatusWarningMutedLight, inverseTheme.colorOnBackgroundStatusWarningMutedDark) - XCTAssertEqual(inverseTheme.colorOnBackgroundStatusWarningEmphasisLight, inverseTheme.colorOnBackgroundStatusWarningEmphasisDark) + XCTAssertEqual(inverseTheme.colorOnBackgroundStatusWarningEmphasizedLight, inverseTheme.colorOnBackgroundStatusWarningEmphasizedDark) XCTAssertEqual(inverseTheme.colorOnBackgroundStatusNegativeMutedLight, inverseTheme.colorOnBackgroundStatusNegativeMutedDark) - XCTAssertEqual(inverseTheme.colorOnBackgroundStatusNegativeEmphasisLight, inverseTheme.colorOnBackgroundStatusNegativeEmphasisDark) + XCTAssertEqual(inverseTheme.colorOnBackgroundStatusNegativeEmphasizedLight, inverseTheme.colorOnBackgroundStatusNegativeEmphasizedDark) XCTAssertEqual(inverseTheme.colorOnBackgroundStatusPositiveMutedLight, inverseTheme.colorOnBackgroundStatusPositiveMutedDark) - XCTAssertEqual(inverseTheme.colorOnBackgroundStatusPositiveEmphasisLight, inverseTheme.colorOnBackgroundStatusPositiveEmphasisDark) + XCTAssertEqual(inverseTheme.colorOnBackgroundStatusPositiveEmphasizedLight, inverseTheme.colorOnBackgroundStatusPositiveEmphasizedDark) XCTAssertEqual(inverseTheme.colorOnBackgroundStatusInformationMutedLight, inverseTheme.colorOnBackgroundStatusInformationMutedDark) - XCTAssertEqual(inverseTheme.colorOnBackgroundStatusInformationEmphasisLight, inverseTheme.colorOnBackgroundStatusInformationEmphasisDark) + XCTAssertEqual(inverseTheme.colorOnBackgroundStatusInformationEmphasizedLight, inverseTheme.colorOnBackgroundStatusInformationEmphasizedDark) } } diff --git a/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift b/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift index 5c6e10b63..3aa3dadaf 100644 --- a/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift +++ b/OUDS/Core/Themes/Inverse/Tests/TestInverseThemeElevation.swift @@ -12,7 +12,7 @@ // import XCTest -import OUDSThemesCommons +import OUDS import OUDSThemesInverse /// `InverseTheme` is a quite particular theme with "inverse" color palette. Is it neuther a light mode theme nor a dark mode theme. @@ -30,21 +30,21 @@ final class TestInverseThemeElevationColors: XCTestCase { XCTAssertEqual(inverseTheme.elevationColorRaisedLight, inverseTheme.elevationColorRaisedDark) XCTAssertEqual(inverseTheme.elevationColorDragLight, inverseTheme.elevationColorDragDark) XCTAssertEqual(inverseTheme.elevationColorOverlayDefaultLight, inverseTheme.elevationColorOverlayDefaultDark) - XCTAssertEqual(inverseTheme.elevationColorOverlayEmphasisLight, inverseTheme.elevationColorOverlayEmphasisDark) + XCTAssertEqual(inverseTheme.elevationColorOverlayEmphasizedLight, inverseTheme.elevationColorOverlayEmphasizedDark) XCTAssertEqual(inverseTheme.elevationColorStickyDefaultLight, inverseTheme.elevationColorStickyDefaultDark) - XCTAssertEqual(inverseTheme.elevationColorStickyEmphasisLight, inverseTheme.elevationColorStickyEmphasisDark) + XCTAssertEqual(inverseTheme.elevationColorStickyEmphasizedLight, inverseTheme.elevationColorStickyEmphasizedDark) XCTAssertEqual(inverseTheme.elevationColorStickyNavigationScrolledLight, inverseTheme.elevationColorStickyNavigationScrolledDark) XCTAssertEqual(inverseTheme.elevationColorFocusLight, inverseTheme.elevationColorFocusDark) } - func testElevationBoxShadowsEquality() throws { - XCTAssertEqual(inverseTheme.elevationBoxShadowRaisedLight, inverseTheme.elevationBoxShadowRaisedDark) - XCTAssertEqual(inverseTheme.elevationBoxShadowDragLight, inverseTheme.elevationBoxShadowDragDark) - XCTAssertEqual(inverseTheme.elevationBoxShadowOverlayDefaultLight, inverseTheme.elevationBoxShadowOverlayDefaultDark) - XCTAssertEqual(inverseTheme.elevationBoxShadowOverlayEmphasisLight, inverseTheme.elevationBoxShadowOverlayEmphasisDark) - XCTAssertEqual(inverseTheme.elevationBoxShadowStickyDefaultLight, inverseTheme.elevationBoxShadowStickyDefaultDark) - XCTAssertEqual(inverseTheme.elevationBoxShadowStickyEmphasisLight, inverseTheme.elevationBoxShadowStickyEmphasisDark) - XCTAssertEqual(inverseTheme.elevationBoxShadowStickyNavigationScrolledLight, inverseTheme.elevationBoxShadowStickyNavigationScrolledDark) - XCTAssertEqual(inverseTheme.elevationBoxShadowFocusLight, inverseTheme.elevationBoxShadowFocusDark) + func testElevationEquality() throws { + XCTAssertEqual(inverseTheme.elevationRaisedLight, inverseTheme.elevationRaisedDark) + XCTAssertEqual(inverseTheme.elevationDragLight, inverseTheme.elevationDragDark) + XCTAssertEqual(inverseTheme.elevationOverlayDefaultLight, inverseTheme.elevationOverlayDefaultDark) + XCTAssertEqual(inverseTheme.elevationOverlayEmphasizedLight, inverseTheme.elevationOverlayEmphasizedDark) + XCTAssertEqual(inverseTheme.elevationStickyDefaultLight, inverseTheme.elevationStickyDefaultDark) + XCTAssertEqual(inverseTheme.elevationStickyEmphasizedLight, inverseTheme.elevationStickyEmphasizedDark) + XCTAssertEqual(inverseTheme.elevationStickyNavigationScrolledLight, inverseTheme.elevationStickyNavigationScrolledDark) + XCTAssertEqual(inverseTheme.elevationFocusLight, inverseTheme.elevationFocusDark) } } diff --git a/OUDS/Core/Themes/Orange/Sources/OrangeBrandColorRawTokens.swift b/OUDS/Core/Themes/Orange/Sources/OrangeBrandColorRawTokens.swift index 473e610d0..ce19fddaa 100644 --- a/OUDS/Core/Themes/Orange/Sources/OrangeBrandColorRawTokens.swift +++ b/OUDS/Core/Themes/Orange/Sources/OrangeBrandColorRawTokens.swift @@ -15,7 +15,10 @@ import Foundation import SwiftUI import OUDSTokensRaw +/// In the global design system tool, the verbs of "brand colors" are used, and at this level mean simply raw tokens of colors. public typealias ColorOrangeBrandRawToken = ColorRawToken + +/// In the global design system tool, the verbs of "decorative colors" are used, and at this level mean simply raw tokens of colors, but decorative ones public typealias ColorOrangeDecorativeRawToken = ColorRawToken /// This extension helps to add new raw tokens for this theme. diff --git a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift index 40d1b1aed..912120c02 100644 --- a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift +++ b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift @@ -12,7 +12,7 @@ // import Foundation -import OUDSThemesCommons +import OUDS /// This is an override of the default basic `OUDSTheme` and should be seen as the default theme for the OUDS library. /// It can overrides any properties from its superclass, and can be derived too. diff --git a/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md b/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md new file mode 100644 index 000000000..8e33c61f0 --- /dev/null +++ b/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md @@ -0,0 +1,14 @@ +# ``OUDSThemesOrange`` + +The Orange theme overrides some tokens from the basic `OUDSTheme` and should be seen as the default theme for the OUDS library. + +## Overview + +It defines its own colors and override the semantic tokens to use the right colors. This is the default theme any app should used, and can be subclassed to define for example themes dedicated to countries. It embeds also in its target the brand colors which are not shared not exposed in lower level targets. + +## Topics + +### Group + +- ``OrangeTheme`` +- ``OrangeBrandColorRawTokens`` diff --git a/OUDS/Core/Themes/Sosh/Sources/SoshBrandColorRawTokens.swift b/OUDS/Core/Themes/Sosh/Sources/SoshBrandColorRawTokens.swift index ea59b7824..8a3c01d1f 100644 --- a/OUDS/Core/Themes/Sosh/Sources/SoshBrandColorRawTokens.swift +++ b/OUDS/Core/Themes/Sosh/Sources/SoshBrandColorRawTokens.swift @@ -17,6 +17,7 @@ import OUDSTokensRaw // MARK: - Type aliases to keep grammar clear +/// In the global design system tool, the verbs of "primitive colors" are used, and at this level mean simply raw tokens of colors. public typealias ColorSoshPrimitiveToken = ColorRawToken // MARK: Primitive tokens @@ -25,6 +26,7 @@ public typealias ColorSoshPrimitiveToken = ColorRawToken /// Type aliases here are just for consistancy reasons. /// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else /// (i.e. publicly accessible from everywhere). More optimized than _struct_. +/// All colors of the Sosh brand are listed here. public enum SoshBrandColorRawTokens { // MARK: Primitive token - Colors - Sosh - Magenta diff --git a/OUDS/Core/Themes/Sosh/Sources/SoshTheme.swift b/OUDS/Core/Themes/Sosh/Sources/SoshTheme.swift index fa020ab3e..9180ecc4c 100644 --- a/OUDS/Core/Themes/Sosh/Sources/SoshTheme.swift +++ b/OUDS/Core/Themes/Sosh/Sources/SoshTheme.swift @@ -12,9 +12,10 @@ // import Foundation -import OUDSThemesCommons +import OUDS /// Overrides some colors using values defined in extension of `ColorRawTokens` in this current module. +/// This is the implementation of the Sosh brand. open class SoshTheme: OUDSTheme { // For clarity reasons, please override OUDSTheme properties in extensions diff --git a/OUDS/Core/Themes/Sosh/Sources/_OUDSThemesSosh.docc/OUDSThemesSosh.md b/OUDS/Core/Themes/Sosh/Sources/_OUDSThemesSosh.docc/OUDSThemesSosh.md new file mode 100644 index 000000000..27389b303 --- /dev/null +++ b/OUDS/Core/Themes/Sosh/Sources/_OUDSThemesSosh.docc/OUDSThemesSosh.md @@ -0,0 +1,14 @@ +# ``OUDSThemesSosh`` + +The Sosh theme overrides some tokens from the basic `OUDSTheme` and should be seen as the theme with the Sosh brand, used for Sosh apps. + +## Overview + +It defines its own colors and override the semantic tokens to use the right colors. + +## Topics + +### Group + +- ``SoshTheme`` +- ``SoshBrandColorRawTokens`` diff --git a/OUDS/Core/Tokens/ComponentTokens/Sources/Values/ButtonsComponentTokens.swift b/OUDS/Core/Tokens/ComponentTokens/Sources/Values/ButtonsComponentTokens.swift new file mode 100644 index 000000000..90fcedb7c --- /dev/null +++ b/OUDS/Core/Tokens/ComponentTokens/Sources/Values/ButtonsComponentTokens.swift @@ -0,0 +1,44 @@ +// +// 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 OUDSTokensSemantic + +/// This is a component tokens list for buttons like `OUDSButton`. +/// **Warning: This is a draft component ** +public protocol ButtonsComponentTokens { + + /* + NOTE: + 1. Maybe composite tokens for border can be useful to define several types of buttons + 2. Maybe a composite tokens should be defined and used to gather all these atomic semantic tokens + */ + + var buttonInternalSpacing: SpacingPaddingInlineSemanticToken { get } + + var buttonBorderStyle: BorderStyleSemanticToken { get } + var buttonBorderColorLight: ColorSemanticToken { get } + var buttonBorderColorDark: ColorSemanticToken { get } + var buttonBorderWidth: BorderWidthSemanticToken { get } + var buttonBorderRadius: BorderRadiusSemanticToken { get } + + var buttonForegroundColorLight: ColorSemanticToken { get } + var buttonForegroundColorDark: ColorSemanticToken { get } + var buttonBackgroundColorLight: ColorSemanticToken { get } + var buttonBackgroundColorDark: ColorSemanticToken { get } + + var buttonWidth: SizingWidthHeightSemanticToken { get } + var buttonHeight: SizingWidthHeightSemanticToken { get } + + var buttonTypography: TypographyCompositeSemanticToken { get } +} diff --git a/OUDS/Core/Tokens/ComponentTokens/Sources/FormsTextInputComponentToken.swift b/OUDS/Core/Tokens/ComponentTokens/Sources/Values/FormsTextInputComponentTokens.swift similarity index 96% rename from OUDS/Core/Tokens/ComponentTokens/Sources/FormsTextInputComponentToken.swift rename to OUDS/Core/Tokens/ComponentTokens/Sources/Values/FormsTextInputComponentTokens.swift index c70bc888d..6bf0f8040 100644 --- a/OUDS/Core/Tokens/ComponentTokens/Sources/FormsTextInputComponentToken.swift +++ b/OUDS/Core/Tokens/ComponentTokens/Sources/Values/FormsTextInputComponentTokens.swift @@ -16,7 +16,7 @@ import OUDSTokensSemantic /// This is a component token for a text input in formulars. /// **Warning: This is a draft component ** -public protocol FormsTextInputComponentToken { +public protocol FormsTextInputComponentTokens { var ftiTitleFontWeight: TypographyFontWeightSemanticToken { get } var ftiTitleFontSize: TypographyFontSizeSemanticToken { get } diff --git a/OUDS/Core/Tokens/ComponentTokens/Sources/_OUDSTokensComponent.docc/OUDSTokensComponent.md b/OUDS/Core/Tokens/ComponentTokens/Sources/_OUDSTokensComponent.docc/OUDSTokensComponent.md new file mode 100644 index 000000000..5b18ae5e0 --- /dev/null +++ b/OUDS/Core/Tokens/ComponentTokens/Sources/_OUDSTokensComponent.docc/OUDSTokensComponent.md @@ -0,0 +1,75 @@ +# ``OUDSTokensComponent`` + +These _tokens_ can be used to apply some style and configuration values to _components_. + +## Overview + +Thus if a component need to change for example its _background color_, and if a _component token_ is used for it, then only the value of this _token_ should be changed without any modification on the _component_ definition. +_Components_ use _component tokens_ exposed through the _theme_ to get their style values. + +Example with a fake component named `FormsTextInputComponent` using component tokens in `FormsTextInputComponentTokens`: + +```swift +// Declare component tokens +public protocol FormsTextInputComponentTokens { + var ftiTitleFontWeight: TypographyFontWeightSemanticToken { get } + var ftiTitleFontSize: TypographyFontSizeSemanticToken { get } + var ftiTitleColor: ColorSemanticToken { get } + + var ftiBorderColor: ColorSemanticToken { get } + var ftiBorderStyle: BorderStyleSemanticToken { get } + var ftiBorderWidth: BorderWidthSemanticToken { get } +} + +// Define the component tokens +extension OUDSTheme: FormsTextInputComponentTokens { + private static let defaultBlack: ColorSemanticToken = ColorRawTokens.colorFunctionalBlack + private static let defaultWhite: ColorSemanticToken = ColorRawTokens.colorFunctionalWhite + + @objc open var ftiTitleFontWeight: TypographyFontWeightSemanticToken { fontWeightHeading } + @objc open var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelLarge } + @objc open var ftiTitleColor: ColorSemanticToken { colorContentBrandPrimaryLight ?? Self.defaultBlack } + + @objc open var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedLight ?? Self.defaultBlack } + @objc open var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDefault } + @objc open var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThin } +} + +// In the implementation of the component, the theme will be retrieved to get these component tokens +// The View + +struct OUDSFormsTextInput: View { + + // ... + @Environment(\.theme) var theme + + public var body: some View { + VStack(spacing: theme.spacePaddingBlockComponentTall) { + Label( + title: { + Text("Example of OUDSFormsTextInput") + .fontWeight(theme.ftiTitleFontWeight.fontWeight) + .font(.system(size: theme.ftiTitleFontSize)) + .foregroundColor(theme.ftiTitleColor.color) + }, + icon: { /*@START_MENU_TOKEN@*/Image(systemName: "42.circle")/*@END_MENU_TOKEN@*/ } + ) + Text("Write bellow some awesome text!") + .fontWeight(theme.ftiSubtitleFontWeight.fontWeight) + .font(.system(size: theme.ftiSubtitleFontSize)) + .foregroundColor(theme.ftiSubtitleColor.color) + TextField(placeholder, text: $value) + } + .padding(theme.spacePaddingBlockComponentTall) + .background(colorScheme == .light ? theme.ftiBackgroundColorLight.color : theme.ftiBackgroundColorDark.color) + .border(theme.ftiBorderColor.color, width: theme.ftiBorderWidth) + } +} +``` + +## Topics + +### Group + +- ``FormsTextInputComponentTokens`` + diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Composites/ElevationRawTokens+Composites.swift b/OUDS/Core/Tokens/RawTokens/Sources/Composites/ElevationRawTokens+Composites.swift new file mode 100644 index 000000000..da82de117 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Composites/ElevationRawTokens+Composites.swift @@ -0,0 +1,57 @@ +// +// 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 + +/// In the global design system, composite tokens are defined for elevation effects. +/// It is defined as a `final class` and `NSObject` so as to be shared through `@objc` with extensions and protocols within modules. +public final class ElevationCompositeRawToken: NSObject { // For @objc compatibility + + /// The X offset for the elevation + public let x: ElevationRawToken + /// The Y offset for the elevation + public let y: ElevationRawToken + /// The color of the shadow effect + public let color: ColorRawToken + + /// The *Figma* tool uses its own implementation of shadow or elevation effect with a *blur* and a *spread* values defined in the *tokens*, inherited from web universe. + /// However *SwiftUI* for shadows effects uses only a *radius* which does not match the *Figma* *blur* and *spread* radiuses values. + public let radius: ElevationRawToken + + /// Defines a composite elevation token and computes the *SwftUI radius* from the given *Figma blur* applying formula: + /// + /// ** radius = blur / 2 ** + /// + /// - Parameters: + /// - x: The X offset for elevation + /// - y: The Y offset for elevation + /// - blur: The blur effect from *Figma*, used to compute *SwiftUI radius* + /// - color: The color to apply on the shafow + public init(x: ElevationRawToken, y: ElevationRawToken, blur: ElevationRawToken, color: ColorRawToken) { + self.x = x + self.y = y + self.color = color + radius = blur / 2 + } + + /// Compares the `self.x`, `self.y`, `self.blur` and `self.color` values between tokens. + /// If `object` is not an `ElevationCompositeRawToken`, or ahs one of its four proeprties with another value than `self`, + /// return `false`. Otherwise returns `true`. `isEqual` override is preferred for `NSObject`. + public override func isEqual(_ object: Any?) -> Bool { + guard let other = object as? ElevationCompositeRawToken else { return false } + return self.x == other.x + && self.y == other.y + && self.radius == other.radius + && self.color == other.color + } +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Composites/TypographyRawTokens+Composites.swift b/OUDS/Core/Tokens/RawTokens/Sources/Composites/TypographyRawTokens+Composites.swift new file mode 100644 index 000000000..8c8cd6670 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Composites/TypographyRawTokens+Composites.swift @@ -0,0 +1,30 @@ +// +// 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 +// + +/// Composite raw tokens are here to pack a set of specific values according to the global design system tool. +/// Here a *typography* is finaly defined by some specific values. +public struct TypographyCompositeRawToken: Equatable { + + // Font family is not included here because this is the only thing which can vary + + /// The font size to apply for the texts + public let size: TypographyFontSizeRawToken + + /// The line height to apply on texts + public let lineHeight: TypographyFontLineHeightRawToken + + /// The font weight to associated wit the font family + public let weight: TypographyFontWeightRawToken + + // TODO: How to deal "letter spacing"? +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Declarations/BorderRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/BorderRawTokens.swift new file mode 100644 index 000000000..aad05a50f --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/BorderRawTokens.swift @@ -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 +// + +/// Defined as the group of all **raw tokens** related to **borders**. +/// +/// Primitive types such as `Double` and `String` must be used to as to allow to use `@objc` keywords in _Swift extensions_ for overriding. +/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else +/// (i.e. publicly accessible from everywhere). More optimized than _struct_. +public enum BorderRawTokens { + + // Note: So as to help the Figma JSON to Swift parser the values have been added in the Values folder +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Declarations/ColorRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/ColorRawTokens.swift new file mode 100644 index 000000000..6f195ac04 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/ColorRawTokens.swift @@ -0,0 +1,57 @@ +// +// 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 +// + +/// Defined as the group of all **raw tokens** related to **colors**. +/// Primitive types such as `String` must be used to as to allow to use `@objc` keywords in extensions for overriding. +/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else +/// (i.e. publicly accessible from everywhere). More optimized than _struct_. +public enum ColorRawTokens { + + // Note: So as to help the Figma JSON to Swift parser the values have been added in the Values folder + + static func apply(opacity: OpacityRawToken, on hexColor: String) -> String { + // TODO: Improve this algorithm too much naive + // Values picked from https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 + if opacity == OpacityRawTokens.opacity0 { + return hexColor + "00" + } + if opacity == OpacityRawTokens.opacity100 { + return hexColor + "0A" + } + if opacity == OpacityRawTokens.opacity200 { + return hexColor + "14" + } + if opacity == OpacityRawTokens.opacity300 { + return hexColor + "29" + } + if opacity == OpacityRawTokens.opacity400 { + return hexColor + "3D" + } + if opacity == OpacityRawTokens.opacity500 { + return hexColor + "52" + } + if opacity == OpacityRawTokens.opacity600 { + return hexColor + "7A" + } + if opacity == OpacityRawTokens.opacity700 { + return hexColor + "A3" + } + if opacity == OpacityRawTokens.opacity800 { + return hexColor + "E0" + } + if opacity == OpacityRawTokens.opacity900 { + return hexColor + "FF" + } + return hexColor + } +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Declarations/DimensionRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/DimensionRawTokens.swift new file mode 100644 index 000000000..8213adebd --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/DimensionRawTokens.swift @@ -0,0 +1,21 @@ +// +// 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 +// + +/// Defined as the group of all **raw tokens** related to **dimensions**. +/// Primitive types such as `Double` must be used to as to allow to use `@objc` keywords in extensions for overriding. +/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else +/// (i.e. publicly accessible from everywhere). More optimized than _struct_. +public enum DimensionRawTokens { + + // Note: So as to help the Figma JSON to Swift parser the values have been added in the Values folder +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Declarations/ElevationRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/ElevationRawTokens.swift new file mode 100644 index 000000000..a03e02f86 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/ElevationRawTokens.swift @@ -0,0 +1,21 @@ +// +// 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 +// + +/// Defined as the group of all **raw tokens** related to **elevations**. +/// Primitive types such as `CGFloat` must be used to as to allow to use `@objc` keywords in extensions for overriding. +/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else +/// (i.e. publicly accessible from everywhere). More optimized than _struct_. +public enum ElevationRawTokens { + + // Note: So as to help the Figma JSON to Swift parser the values have been added in the Values folder +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Declarations/GridRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/GridRawTokens.swift new file mode 100644 index 000000000..86fcaae94 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/GridRawTokens.swift @@ -0,0 +1,21 @@ +// +// 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 +// + +/// Defined as the group of all **raw tokens** related to **grid**. +/// Primitive types such as `Int` must be used to as to allow to use `@objc` keywords in extensions for overriding. +/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else +/// (i.e. publicly accessible from everywhere). More optimized than _struct_. +public enum GridRawTokens { + + // Note: So as to help the Figma JSON to Swift parser the values have been added in the Values folder +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Declarations/OpacityRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/OpacityRawTokens.swift new file mode 100644 index 000000000..71f6c5f32 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/OpacityRawTokens.swift @@ -0,0 +1,21 @@ +// +// 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 +// + +/// Defined as the group of all **raw tokens** related to **opacity**. +/// Primitive types such as `Double` must be used to as to allow to use `@objc` keywords in extensions for overriding. +/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else +/// (i.e. publicly accessible from everywhere). More optimized than _struct_. +public enum OpacityRawTokens { + + // Note: So as to help the Figma JSON to Swift parser the values have been added in the Values folder +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Declarations/TypographyRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/TypographyRawTokens.swift new file mode 100644 index 000000000..60603f25b --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Declarations/TypographyRawTokens.swift @@ -0,0 +1,21 @@ +// +// 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 +// + +/// Defined as the group of all **raw tokens** related to **typography**. +/// Primitive types such as `Int` and `String` must be used to as to allow to use `@objc` keywords in extensions for overriding. +/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else +/// (i.e. publicly accessible from everywhere). More optimized than _struct_. +public enum TypographyRawTokens { + + // Note: So as to help the Figma JSON to Swift parser the values have been added in the Values folder +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/ElevationRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/ElevationRawTokens.swift deleted file mode 100644 index a19fa11bf..000000000 --- a/OUDS/Core/Tokens/RawTokens/Sources/ElevationRawTokens.swift +++ /dev/null @@ -1,148 +0,0 @@ -// -// 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 - -// MARK: - Type aliases to keep grammar clear - -/// Typeliases precising `Int` value are used (because used in _SwiftUI_ API) for each **elevation raw token**. -public typealias ElevationRawToken = Int - -// MARK: - Composite raw token - -public class ElevationBoxShadowRawToken: NSObject { // For @objc compatibility - - public let x: ElevationRawToken - public let y: ElevationRawToken - public let blur: ElevationRawToken - public let spread: ElevationRawToken - public let color: ColorRawToken - - public init(x: ElevationRawToken, y: ElevationRawToken, blur: ElevationRawToken, spread: ElevationRawToken, color: ColorRawToken) { - self.x = x - self.y = y - self.blur = blur - self.spread = spread - self.color = color - } - - public override func isEqual(_ object: Any?) -> Bool { - guard let other = object as? ElevationBoxShadowRawToken else { return false } - return self.x == other.x - && self.y == other.y - && self.blur == other.blur - && self.spread == other.spread - && self.color == other.color - } -} - -// MARK: - Raw tokens - -/// This is the group of all **raw tokens** related to **elevations**. -/// Primitive types such as `Int` must be used to as to allow to use `@objc` keywords in extensions for overriding. -/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else -/// (i.e. publicly accessible from everywhere). More optimized than _struct_. -public enum ElevationRawTokens { - - // MARK: Primitive token - Elevation - Z Index - - public static let elevationZIndex0: ElevationRawToken = 0 - public static let elevationZIndexMinus9999: ElevationRawToken = -9999 - public static let elevationZIndex1000: ElevationRawToken = 1000 - public static let elevationZIndex1010: ElevationRawToken = 1010 - public static let elevationZIndex1020: ElevationRawToken = 1020 - public static let elevationZIndex1030: ElevationRawToken = 1030 - public static let elevationZIndex1035: ElevationRawToken = 1035 - public static let elevationZIndex1038: ElevationRawToken = 1038 - public static let elevationZIndex1040: ElevationRawToken = 1040 - public static let elevationZIndex1045: ElevationRawToken = 1045 - public static let elevationZIndex1050: ElevationRawToken = 1050 - public static let elevationZIndex1060: ElevationRawToken = 1060 - public static let elevationZIndex1070: ElevationRawToken = 1070 - public static let elevationZIndex1080: ElevationRawToken = 1080 - public static let elevationZIndex1090: ElevationRawToken = 1090 - - // MARK: Primitive token - Elevation - X - - public static let elevationX0: ElevationRawToken = 0 - - // MARK: Primitive token - Elevation - Y - - public static let elevationY0: ElevationRawToken = 0 - public static let elevationY100: ElevationRawToken = 1 - public static let elevationY200: ElevationRawToken = 2 - public static let elevationY300: ElevationRawToken = 4 - public static let elevationY400: ElevationRawToken = 8 - public static let elevationY500: ElevationRawToken = 12 - public static let elevationY600: ElevationRawToken = 20 - - // MARK: Primitive token - Elevation - Blur - - public static let elevationBlur0: ElevationRawToken = 0 - public static let elevationBlur100: ElevationRawToken = 1 - public static let elevationBlur200: ElevationRawToken = 2 - public static let elevationBlur300: ElevationRawToken = 3 - public static let elevationBlur400: ElevationRawToken = 4 - public static let elevationBlur500: ElevationRawToken = 8 - public static let elevationBlur600: ElevationRawToken = 12 - public static let elevationBlur700: ElevationRawToken = 20 - - // MARK: Primitive token - Elevation - Spread - - public static let elevationSpreadMinus100: ElevationRawToken = -1 - public static let elevationSpreadMinus200: ElevationRawToken = -2 - public static let elevationSpreadMinus300: ElevationRawToken = -4 - public static let elevationSpreadMinus400: ElevationRawToken = -8 - public static let elevationSpread0: ElevationRawToken = 0 - public static let elevationSpread300: ElevationRawToken = 3 - - // MARK: Primitive token - Elevation - Box Shadow - - // TODO: Missing elevationBoxShadowBottom0 raw token - public static let elevationBoxShadowBottom_1_100 = ElevationBoxShadowRawToken(x: 0, y: 1, blur: 2, spread: 0, color: ColorRawTokens.colorTransparentBlack100) - public static let elevationBoxShadowBottom_1_200 = ElevationBoxShadowRawToken(x: 0, y: 1, blur: 2, spread: 0, color: ColorRawTokens.colorTransparentBlack200) - public static let elevationBoxShadowBottom_1_300 = ElevationBoxShadowRawToken(x: 0, y: 1, blur: 2, spread: 0, color: ColorRawTokens.colorTransparentBlack300) - public static let elevationBoxShadowBottom_1_400 = ElevationBoxShadowRawToken(x: 0, y: 1, blur: 2, spread: 0, color: ColorRawTokens.colorTransparentBlack400) - public static let elevationBoxShadowBottom_1_500 = ElevationBoxShadowRawToken(x: 0, y: 1, blur: 2, spread: 0, color: ColorRawTokens.colorTransparentBlack500) - public static let elevationBoxShadowBottom_1_600 = ElevationBoxShadowRawToken(x: 0, y: 1, blur: 2, spread: 0, color: ColorRawTokens.colorTransparentBlack600) - public static let elevationBoxShadowBottom_2_100 = ElevationBoxShadowRawToken(x: 0, y: 2, blur: 3, spread: 0, color: ColorRawTokens.colorTransparentBlack100) - public static let elevationBoxShadowBottom_2_200 = ElevationBoxShadowRawToken(x: 0, y: 2, blur: 3, spread: 0, color: ColorRawTokens.colorTransparentBlack200) - public static let elevationBoxShadowBottom_2_300 = ElevationBoxShadowRawToken(x: 0, y: 2, blur: 3, spread: 0, color: ColorRawTokens.colorTransparentBlack300) - public static let elevationBoxShadowBottom_2_400 = ElevationBoxShadowRawToken(x: 0, y: 2, blur: 3, spread: 0, color: ColorRawTokens.colorTransparentBlack400) - public static let elevationBoxShadowBottom_2_500 = ElevationBoxShadowRawToken(x: 0, y: 2, blur: 3, spread: 0, color: ColorRawTokens.colorTransparentBlack500) - public static let elevationBoxShadowBottom_2_600 = ElevationBoxShadowRawToken(x: 0, y: 2, blur: 3, spread: 0, color: ColorRawTokens.colorTransparentBlack600) - public static let elevationBoxShadowBottom_3_100 = ElevationBoxShadowRawToken(x: 0, y: 4, blur: 4, spread: -1, color: ColorRawTokens.colorTransparentBlack100) - public static let elevationBoxShadowBottom_3_200 = ElevationBoxShadowRawToken(x: 0, y: 4, blur: 4, spread: -1, color: ColorRawTokens.colorTransparentBlack200) - public static let elevationBoxShadowBottom_3_300 = ElevationBoxShadowRawToken(x: 0, y: 4, blur: 4, spread: -1, color: ColorRawTokens.colorTransparentBlack300) - public static let elevationBoxShadowBottom_3_400 = ElevationBoxShadowRawToken(x: 0, y: 4, blur: 4, spread: -1, color: ColorRawTokens.colorTransparentBlack400) - public static let elevationBoxShadowBottom_3_500 = ElevationBoxShadowRawToken(x: 0, y: 4, blur: 4, spread: -1, color: ColorRawTokens.colorTransparentBlack500) - public static let elevationBoxShadowBottom_3_600 = ElevationBoxShadowRawToken(x: 0, y: 4, blur: 4, spread: -1, color: ColorRawTokens.colorTransparentBlack600) - public static let elevationBoxShadowBottom_4_100 = ElevationBoxShadowRawToken(x: 0, y: 8, blur: 8, spread: -2, color: ColorRawTokens.colorTransparentBlack100) - public static let elevationBoxShadowBottom_4_200 = ElevationBoxShadowRawToken(x: 0, y: 8, blur: 8, spread: -2, color: ColorRawTokens.colorTransparentBlack200) - public static let elevationBoxShadowBottom_4_300 = ElevationBoxShadowRawToken(x: 0, y: 8, blur: 8, spread: -2, color: ColorRawTokens.colorTransparentBlack300) - public static let elevationBoxShadowBottom_4_400 = ElevationBoxShadowRawToken(x: 0, y: 8, blur: 8, spread: -2, color: ColorRawTokens.colorTransparentBlack400) - public static let elevationBoxShadowBottom_4_500 = ElevationBoxShadowRawToken(x: 0, y: 8, blur: 8, spread: -2, color: ColorRawTokens.colorTransparentBlack500) - public static let elevationBoxShadowBottom_4_600 = ElevationBoxShadowRawToken(x: 0, y: 8, blur: 8, spread: -2, color: ColorRawTokens.colorTransparentBlack600) - public static let elevationBoxShadowBottom_5_100 = ElevationBoxShadowRawToken(x: 0, y: 12, blur: 12, spread: -4, color: ColorRawTokens.colorTransparentBlack100) - public static let elevationBoxShadowBottom_5_200 = ElevationBoxShadowRawToken(x: 0, y: 12, blur: 12, spread: -4, color: ColorRawTokens.colorTransparentBlack200) - public static let elevationBoxShadowBottom_5_300 = ElevationBoxShadowRawToken(x: 0, y: 12, blur: 12, spread: -4, color: ColorRawTokens.colorTransparentBlack300) - public static let elevationBoxShadowBottom_5_400 = ElevationBoxShadowRawToken(x: 0, y: 12, blur: 12, spread: -4, color: ColorRawTokens.colorTransparentBlack400) - public static let elevationBoxShadowBottom_5_500 = ElevationBoxShadowRawToken(x: 0, y: 12, blur: 12, spread: -4, color: ColorRawTokens.colorTransparentBlack500) - public static let elevationBoxShadowBottom_5_600 = ElevationBoxShadowRawToken(x: 0, y: 12, blur: 12, spread: -4, color: ColorRawTokens.colorTransparentBlack600) - public static let elevationBoxShadowBottom_6_100 = ElevationBoxShadowRawToken(x: 0, y: 20, blur: 20, spread: -8, color: ColorRawTokens.colorTransparentBlack100) - public static let elevationBoxShadowBottom_6_200 = ElevationBoxShadowRawToken(x: 0, y: 20, blur: 20, spread: -8, color: ColorRawTokens.colorTransparentBlack200) - public static let elevationBoxShadowBottom_6_300 = ElevationBoxShadowRawToken(x: 0, y: 20, blur: 20, spread: -8, color: ColorRawTokens.colorTransparentBlack300) - public static let elevationBoxShadowBottom_6_400 = ElevationBoxShadowRawToken(x: 0, y: 20, blur: 20, spread: -8, color: ColorRawTokens.colorTransparentBlack400) - public static let elevationBoxShadowBottom_6_500 = ElevationBoxShadowRawToken(x: 0, y: 20, blur: 20, spread: -8, color: ColorRawTokens.colorTransparentBlack500) - public static let elevationBoxShadowBottom_6_600 = ElevationBoxShadowRawToken(x: 0, y: 20, blur: 20, spread: -8, color: ColorRawTokens.colorTransparentBlack600) -} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/GridRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/GridRawTokens.swift deleted file mode 100644 index 62812398c..000000000 --- a/OUDS/Core/Tokens/RawTokens/Sources/GridRawTokens.swift +++ /dev/null @@ -1,112 +0,0 @@ -// -// 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 - -// MARK: - Type aliases to keep grammar clear - -public typealias GridRawToken = DimensionRawToken - -// MARK: - Raw tokens - -/// This is the group of all **raw tokens** related to **grid**. -/// Primitive types such as `Int` must be used to as to allow to use `@objc` keywords in extensions for overriding. -/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else -/// (i.e. publicly accessible from everywhere). More optimized than _struct_. -public enum GridRawTokens { - - private static let dimensionBase: GridRawToken = 4 - - // MARK: Primitive token - Grid - Design width - - public static let gridDesignWidth100: GridRawToken = 320 - public static let gridDesignWidth200: GridRawToken = 390 - public static let gridDesignWidth300: GridRawToken = 480 - public static let gridDesignWidth400: GridRawToken = 768 - public static let gridDesignWidth500: GridRawToken = 1024 - public static let gridDesignWidth600: GridRawToken = 1440 - public static let gridDesignWidth700: GridRawToken = 1680 - public static let gridDesignWidth800: GridRawToken = 1920 - - // MARK: Primitive token - Grid - Min width - - public static let gridMinWidthIOSExtraCompact: GridRawToken = 320 - public static let gridMinWidthIOSCompact: GridRawToken = 390 - public static let gridMinWidthIOSRegular: GridRawToken = 736 - - // MARK: Primitive token - Grid - Max width - - public static let gridMaxWidthIOSExtraCompact: GridRawToken = 389 - public static let gridMaxWidthIOSCompact: GridRawToken = 852 - public static let gridMaxWidthIOSRegular: GridRawToken = 1336 - - // MARK: Primitive token - Grid - Margin - - 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 = dimensionBase * 0.25 - public static let gridColumnGap100: GridRawToken = dimensionBase * 4 - public static let gridColumnGap200: GridRawToken = dimensionBase * 5 - public static let gridColumnGap300: GridRawToken = dimensionBase * 6 - public static let gridColumnGap500: GridRawToken = dimensionBase * 8 - public static let gridColumnGap700: GridRawToken = dimensionBase * 10 - - // MARK: Primitive token - Grid - Column count - - public static let gridColumnCount100: GridRawToken = dimensionBase * 1 - public static let gridColumnCount200: GridRawToken = dimensionBase * 2 - public static let gridColumnCount400: GridRawToken = dimensionBase * 4 - public static let gridColumnCount600: GridRawToken = dimensionBase * 6 - public static let gridColumnCount800: GridRawToken = dimensionBase * 8 - public static let gridColumnCount1000: GridRawToken = dimensionBase * 10 - public static let gridColumnCount1200: GridRawToken = dimensionBase * 12 - - // MARK: Primitive token - Grid - Composite - iOS Extra Compact - - public static let gridIOSExtraCompactDesignWidth: GridRawToken = gridDesignWidth100 - public static let gridIOSExtraCompactMinWidth: GridRawToken = gridMinWidthIOSExtraCompact - public static let gridIOSExtraCompactMaxWidth: GridRawToken = gridMaxWidthIOSExtraCompact - public static let gridIOSExtraCompactMargin: GridRawToken = gridMargin100 - public static let gridIOSExtraCompactColumnGap: GridRawToken = gridColumnGap100 - public static let gridIOSExtraCompactColumnCount: GridRawToken = gridColumnCount100 - - // MARK: Primitive token - Grid - Composite - iOS Compact - - public static let gridIOSCompactDesignWidth: GridRawToken = gridDesignWidth200 - public static let gridIOSCompactMinWidth: GridRawToken = gridMinWidthIOSCompact - public static let gridIOSCompactMaxWidth: GridRawToken = gridMaxWidthIOSCompact - public static let gridIOSCompactMargin: GridRawToken = gridMargin300 - public static let gridIOSCompactColumnGap: GridRawToken = gridColumnGap100 - public static let gridIOSCompactColumnCount: GridRawToken = gridColumnCount400 - - // MARK: Primitive token - Grid - Composite - iOS Regular - - public static let gridIOSRegularDesignWidth: GridRawToken = gridDesignWidth400 - public static let gridIOSRegularMinWidth: GridRawToken = gridMinWidthIOSCompact - public static let gridIOSRegularMaxWidth: GridRawToken = gridMaxWidthIOSCompact - public static let gridIOSRegularMargin: GridRawToken = gridMargin500 - public static let gridIOSRegularColumnGap: GridRawToken = gridColumnGap300 - public static let gridIOSRegularColumnCount: GridRawToken = gridColumnCount600 -} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/BorderRawTokens+Aliases.swift b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/BorderRawTokens+Aliases.swift new file mode 100644 index 000000000..e33c20ba6 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/BorderRawTokens+Aliases.swift @@ -0,0 +1,26 @@ +// +// 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 +// + +/// Type alias precising `Double` value are used (because of multiplier factors) for a **border width raw token**, to keep grammar clean and clear with design system grammar. +public typealias BorderWidthRawToken = Double + +/// Type alias precising `Double` value are used (because of multiplier factors) for a **border radius raw token**, to keep grammar clean and clear with design system grammar. +public typealias BorderRadiusRawToken = Double + +/// Type alias for `String` so as to help users (developers) to see that raw tokens are needed and linked to `String` for **border style raw token**. +/// `String` are used here to prevent to rely on _SwiftUI_ types which are not compatible with `@objc` and are heavier than primitive types. +/// In addition, if new styles are defined in design team side (such as kind of composite styles) and need to be processed differently +/// (because not available with _SwiftUI_ because are composed of several styles), +/// such `String` values could be processed later without any API breaks. +/// Keeps grammar clean and clear with design system grammar. +public typealias BorderStyleRawToken = String diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/ColorRawTokens+Aliases.swift b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/ColorRawTokens+Aliases.swift new file mode 100644 index 000000000..7e2449d64 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/ColorRawTokens+Aliases.swift @@ -0,0 +1,15 @@ +// +// 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 +// + +/// A color raw token is finaly a `String` containing the hexadecimal code of the color, to keep grammar clean and clear with design system grammar. +public typealias ColorRawToken = String diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/DimensionRawTokens+Aliases.swift b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/DimensionRawTokens+Aliases.swift new file mode 100644 index 000000000..3299bd9d7 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/DimensionRawTokens+Aliases.swift @@ -0,0 +1,15 @@ +// +// 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 +// + +/// Raw tokens of dimensions are finaly `Double`, to keep grammar clean and clear with design system grammar. +public typealias DimensionRawToken = Double diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/ElevationRawTokens+Aliases.swift b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/ElevationRawTokens+Aliases.swift new file mode 100644 index 000000000..2a99e923f --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/ElevationRawTokens+Aliases.swift @@ -0,0 +1,17 @@ +// +// 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 + +/// Type aliases precising `CGFloat` values are used (because used in _SwiftUI_ API) for each **elevation raw token**, to keep grammar clean and clear with design system grammar. +public typealias ElevationRawToken = CGFloat diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/GridRawTokens+Aliases.swift b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/GridRawTokens+Aliases.swift new file mode 100644 index 000000000..11d727b31 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/GridRawTokens+Aliases.swift @@ -0,0 +1,16 @@ +// +// 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 +// + +/// In the global design system tool, the notion of "raw tokens of grids" exist but refers always to dimension raw tokens, +/// to keep grammar clean and clear with design system grammar. +public typealias GridRawToken = DimensionRawToken diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/OpacityRawTokens+Aliases.swift b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/OpacityRawTokens+Aliases.swift new file mode 100644 index 000000000..861ce73fe --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/OpacityRawTokens+Aliases.swift @@ -0,0 +1,15 @@ +// +// 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 +// + +/// Raw tokens of opacity are finaly `Double`, to keep grammar clean and clear with design system grammar. +public typealias OpacityRawToken = Double diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/TypographyRawTokens+Aliases.swift b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/TypographyRawTokens+Aliases.swift new file mode 100644 index 000000000..922094301 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/TypeAliases/TypographyRawTokens+Aliases.swift @@ -0,0 +1,26 @@ +// +// 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 + +/// In the global design system tool, *font family* raw tokens are basically `String` values, to keep grammar clean and clear with design system grammar. +public typealias TypographyFontFamilyRawToken = String + +/// In the global design system tool, *font weight* raw tokens are basically `String` values, to keep grammar clean and clear with design system grammar. +public typealias TypographyFontWeightRawToken = String + +/// In the global design system tool, *font size* raw tokens are basically `CGFloat` values, to keep grammar clean and clear with design system grammar. +public typealias TypographyFontSizeRawToken = CGFloat + +/// In the global design system tool, *font line height* raw tokens are basically `Int` values, to keep grammar clean and clear with design system grammar. +public typealias TypographyFontLineHeightRawToken = CGFloat diff --git a/OUDS/Core/Tokens/RawTokens/Sources/BorderRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/BorderRawTokens+Values.swift similarity index 55% rename from OUDS/Core/Tokens/RawTokens/Sources/BorderRawTokens.swift rename to OUDS/Core/Tokens/RawTokens/Sources/Values/BorderRawTokens+Values.swift index af175689d..17d25bc99 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/BorderRawTokens.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/BorderRawTokens+Values.swift @@ -11,34 +11,12 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation +/// Extracted in this separated file to help the *Figma* JSON to Swift parser to generate files to include easily. +/// Should be fully generated in the future. +extension BorderRawTokens { -// MARK: - Type aliases to keep grammar clear - -/// Typeliases precising `Double` value are used (because of multiplier factors) for a **border width raw token**. -public typealias BorderWidthRawToken = Double - -/// Typeliases precising `Double` value are used (because of multiplier factors) for a **border widthradiusraw token**. -public typealias BorderRadiusRawToken = Double - -/// Typealise for `String` so as to help users (developers) to see that raw tokens are needed and linked to `String` for **border style raw tokeb**. -/// `String` are used here to prevent to rely on _SwiftUI_ types which are not compatible with `@objc` and are heavier than primitive types. -/// In addition, if new styles are defined in design team side (such as kind of composite styles) and need to be processed differently -/// (because not available with _SwiftUI_ because are composed of several styles), -/// such `String` values could be procesed later without any API breaks. -public typealias BorderStyleRawToken = String - -// MARK: - Raw tokens - -/// This is the group of all **raw tokens** related to **borders**. -/// Primitive types such as `Double` and `String` must be used to as to allow to use `@objc` keywords in _Swift extensions_ for overriding. -/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else -/// (i.e. publicly accessible from everywhere). More optimized than _struct_. -/// -/// In the future, generating tools like _Style Dictionary_ should either follow this file template and structure or just replace values or lines. -public enum BorderRawTokens { - - private static let borderBase: Double = 4 // Double type because used bellow for computations with Double values + // Double type because used below for computations with Double values + private static let borderBase: Double = 4 // MARK: Primitive token - Border - Width @@ -64,7 +42,6 @@ public enum BorderRawTokens { public static let borderRadius500: BorderRadiusRawToken = borderBase * 5 public static let borderRadius600: BorderRadiusRawToken = borderBase * 6 public static let borderRadius800: BorderRadiusRawToken = borderBase * 8 - public static let borderRadius9999: BorderRadiusRawToken = 2000 // MARK: Primitive token - Border - Style diff --git a/OUDS/Core/Tokens/RawTokens/Sources/ColorRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/ColorRawTokens+Values.swift similarity index 81% rename from OUDS/Core/Tokens/RawTokens/Sources/ColorRawTokens.swift rename to OUDS/Core/Tokens/RawTokens/Sources/Values/ColorRawTokens+Values.swift index 11a0e1bed..93e29e5c9 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/ColorRawTokens.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/ColorRawTokens+Values.swift @@ -11,20 +11,9 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import OUDSFoundations - -// MARK: - Type aliases to keep grammar clear - -public typealias ColorRawToken = String - -// MARK: Raw tokens - -/// This is the group of all **raw tokens** related to **colors**. -/// Primitive types such as `String` must be used to as to allow to use `@objc` keywords in extensions for overriding. -/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else -/// (i.e. publicly accessible from everywhere). More optimized than _struct_. -public enum ColorRawTokens { +/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. +/// Should be fully generated in the future. +extension ColorRawTokens { // MARK: Primitive token - Colors - Black, white @@ -134,42 +123,4 @@ public enum ColorRawTokens { public static let colorTransparentWhite700: ColorRawToken = apply(opacity: OpacityRawTokens.opacity700, on: colorFunctionalWhite) public static let colorTransparentWhite800: ColorRawToken = apply(opacity: OpacityRawTokens.opacity800, on: colorFunctionalWhite) public static let colorTransparentWhite900: ColorRawToken = apply(opacity: OpacityRawTokens.opacity900, on: colorFunctionalWhite) - - // MARK: - Helpers - - private static func apply(opacity: OpacityRawToken, on hexColor: String) -> String { - // TODO: Improve this algorithm too much naive - // Values picked from https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 - if opacity == OpacityRawTokens.opacity0 { - return hexColor + "00" - } - if opacity == OpacityRawTokens.opacity100 { - return hexColor + "0A" - } - if opacity == OpacityRawTokens.opacity200 { - return hexColor + "14" - } - if opacity == OpacityRawTokens.opacity300 { - return hexColor + "29" - } - if opacity == OpacityRawTokens.opacity400 { - return hexColor + "3D" - } - if opacity == OpacityRawTokens.opacity500 { - return hexColor + "52" - } - if opacity == OpacityRawTokens.opacity600 { - return hexColor + "7A" - } - if opacity == OpacityRawTokens.opacity700 { - return hexColor + "A3" - } - if opacity == OpacityRawTokens.opacity800 { - return hexColor + "E0" - } - if opacity == OpacityRawTokens.opacity900 { - return hexColor + "FF" - } - return hexColor - } } diff --git a/OUDS/Core/Tokens/RawTokens/Sources/DimensionRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/DimenRawTokens+Values.swift similarity index 82% rename from OUDS/Core/Tokens/RawTokens/Sources/DimensionRawTokens.swift rename to OUDS/Core/Tokens/RawTokens/Sources/Values/DimenRawTokens+Values.swift index f9ed2fe48..925062f7e 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/DimensionRawTokens.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/DimenRawTokens+Values.swift @@ -2,28 +2,18 @@ // 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 +// Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation - -// MARK: - Type aliases to keep grammar clear - -public typealias DimensionRawToken = Double - -// MARK: - Raw tokens - -/// This is the group of all **raw tokens** related to **dimensions**. -/// Primitive types such as `Double` must be used to as to allow to use `@objc` keywords in extensions for overriding. -/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else -/// (i.e. publicly accessible from everywhere). More optimized than _struct_. -public enum DimensionRawTokens { +/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. +/// Should be fully generated in the future. +extension DimensionRawTokens { public static let dimensionBase: DimensionRawToken = 4 diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Values/ElevationRawTokens+Values.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/ElevationRawTokens+Values.swift new file mode 100644 index 000000000..f7d80ff52 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/ElevationRawTokens+Values.swift @@ -0,0 +1,102 @@ +// +// 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 +// + +/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. +/// Should be fully generated in the future. +extension ElevationRawTokens { + + // MARK: Primitive token - Elevation - Z Index + + public static let elevationZIndex0: ElevationRawToken = 0 + public static let elevationZIndexMinus9999: ElevationRawToken = -9999 + public static let elevationZIndex1000: ElevationRawToken = 1000 + public static let elevationZIndex1010: ElevationRawToken = 1010 + public static let elevationZIndex1020: ElevationRawToken = 1020 + public static let elevationZIndex1030: ElevationRawToken = 1030 + public static let elevationZIndex1035: ElevationRawToken = 1035 + public static let elevationZIndex1038: ElevationRawToken = 1038 + public static let elevationZIndex1040: ElevationRawToken = 1040 + public static let elevationZIndex1045: ElevationRawToken = 1045 + public static let elevationZIndex1050: ElevationRawToken = 1050 + public static let elevationZIndex1060: ElevationRawToken = 1060 + public static let elevationZIndex1070: ElevationRawToken = 1070 + public static let elevationZIndex1080: ElevationRawToken = 1080 + public static let elevationZIndex1090: ElevationRawToken = 1090 + + // MARK: Primitive token - Elevation - X + + public static let elevationX0: ElevationRawToken = 0 + + // MARK: Primitive token - Elevation - Y + + public static let elevationY0: ElevationRawToken = 0 + public static let elevationY100: ElevationRawToken = 1 + public static let elevationY200: ElevationRawToken = 2 + public static let elevationY300: ElevationRawToken = 4 + public static let elevationY400: ElevationRawToken = 8 + public static let elevationY500: ElevationRawToken = 12 + public static let elevationY600: ElevationRawToken = 20 + + // MARK: Primitive token - Elevation - Blur + + public static let elevationBlur0: ElevationRawToken = 0 + public static let elevationBlur100: ElevationRawToken = 1 + public static let elevationBlur200: ElevationRawToken = 2 + public static let elevationBlur300: ElevationRawToken = 3 + public static let elevationBlur400: ElevationRawToken = 4 + public static let elevationBlur500: ElevationRawToken = 8 + public static let elevationBlur600: ElevationRawToken = 12 + public static let elevationBlur700: ElevationRawToken = 20 + + // MARK: Primitive token - Elevation - Box Shadow + + // WARNING: Not the same syntax between CSS and Figma, maybe blur and Y and inverted, beware + + public static let elevationBottom_0 = ElevationCompositeRawToken(x: 0, y: 0, blur: 0, color: ColorRawTokens.colorTransparentBlack0) + public static let elevationBottom_1_100 = ElevationCompositeRawToken(x: 0, y: 1, blur: 2, color: ColorRawTokens.colorTransparentBlack100) + public static let elevationBottom_1_200 = ElevationCompositeRawToken(x: 0, y: 1, blur: 2, color: ColorRawTokens.colorTransparentBlack200) + public static let elevationBottom_1_300 = ElevationCompositeRawToken(x: 0, y: 1, blur: 2, color: ColorRawTokens.colorTransparentBlack300) + public static let elevationBottom_1_400 = ElevationCompositeRawToken(x: 0, y: 1, blur: 2, color: ColorRawTokens.colorTransparentBlack400) + public static let elevationBottom_1_500 = ElevationCompositeRawToken(x: 0, y: 1, blur: 2, color: ColorRawTokens.colorTransparentBlack500) + public static let elevationBottom_1_600 = ElevationCompositeRawToken(x: 0, y: 1, blur: 2, color: ColorRawTokens.colorTransparentBlack600) + public static let elevationBottom_2_100 = ElevationCompositeRawToken(x: 0, y: 2, blur: 3, color: ColorRawTokens.colorTransparentBlack100) + public static let elevationBottom_2_200 = ElevationCompositeRawToken(x: 0, y: 2, blur: 3, color: ColorRawTokens.colorTransparentBlack200) + public static let elevationBottom_2_300 = ElevationCompositeRawToken(x: 0, y: 2, blur: 3, color: ColorRawTokens.colorTransparentBlack300) + public static let elevationBottom_2_400 = ElevationCompositeRawToken(x: 0, y: 2, blur: 3, color: ColorRawTokens.colorTransparentBlack400) + public static let elevationBottom_2_500 = ElevationCompositeRawToken(x: 0, y: 2, blur: 3, color: ColorRawTokens.colorTransparentBlack500) + public static let elevationBottom_2_600 = ElevationCompositeRawToken(x: 0, y: 2, blur: 3, color: ColorRawTokens.colorTransparentBlack600) + public static let elevationBottom_3_100 = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack100) + public static let elevationBottom_3_200 = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack200) + public static let elevationBottom_3_300 = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack300) + public static let elevationBottom_3_400 = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack400) + public static let elevationBottom_3_500 = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack500) + public static let elevationBottom_3_600 = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack600) + public static let elevationBottom_4_100 = ElevationCompositeRawToken(x: 0, y: 8, blur: 8, color: ColorRawTokens.colorTransparentBlack100) + public static let elevationBottom_4_200 = ElevationCompositeRawToken(x: 0, y: 8, blur: 8, color: ColorRawTokens.colorTransparentBlack200) + public static let elevationBottom_4_300 = ElevationCompositeRawToken(x: 0, y: 8, blur: 8, color: ColorRawTokens.colorTransparentBlack300) + public static let elevationBottom_4_400 = ElevationCompositeRawToken(x: 0, y: 8, blur: 8, color: ColorRawTokens.colorTransparentBlack400) + public static let elevationBottom_4_500 = ElevationCompositeRawToken(x: 0, y: 8, blur: 8, color: ColorRawTokens.colorTransparentBlack500) + public static let elevationBottom_4_600 = ElevationCompositeRawToken(x: 0, y: 8, blur: 8, color: ColorRawTokens.colorTransparentBlack600) + public static let elevationBottom_5_100 = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack100) + public static let elevationBottom_5_200 = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack200) + public static let elevationBottom_5_300 = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack300) + public static let elevationBottom_5_400 = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack400) + public static let elevationBottom_5_500 = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack500) + public static let elevationBottom_5_600 = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack600) + public static let elevationBottom_6_100 = ElevationCompositeRawToken(x: 0, y: 20, blur: 20, color: ColorRawTokens.colorTransparentBlack100) + public static let elevationBottom_6_200 = ElevationCompositeRawToken(x: 0, y: 20, blur: 20, color: ColorRawTokens.colorTransparentBlack200) + public static let elevationBottom_6_300 = ElevationCompositeRawToken(x: 0, y: 20, blur: 20, color: ColorRawTokens.colorTransparentBlack300) + public static let elevationBottom_6_400 = ElevationCompositeRawToken(x: 0, y: 20, blur: 20, color: ColorRawTokens.colorTransparentBlack400) + public static let elevationBottom_6_500 = ElevationCompositeRawToken(x: 0, y: 20, blur: 20, color: ColorRawTokens.colorTransparentBlack500) + public static let elevationBottom_6_600 = ElevationCompositeRawToken(x: 0, y: 20, blur: 20, color: ColorRawTokens.colorTransparentBlack600) +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/Values/GridRawTokens+Values.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/GridRawTokens+Values.swift new file mode 100644 index 000000000..ab813cf82 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/GridRawTokens+Values.swift @@ -0,0 +1,115 @@ +// +// 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 +// + +/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. +/// Should be fully generated in the future. +extension GridRawTokens { + + private static let dimensionBase: GridRawToken = 4 + + // MARK: Primitive token - Grid - Design width + + public static let gridWidth100: GridRawToken = 320 + public static let gridWidth200: GridRawToken = 390 + public static let gridWidth300: GridRawToken = 480 + public static let gridWidth400: GridRawToken = 768 + public static let gridWidth500: GridRawToken = 1024 + public static let gridWidth600: GridRawToken = 1440 + public static let gridWidth700: GridRawToken = 1680 + public static let gridWidth800: GridRawToken = 1920 + + // MARK: Primitive token - Grid - Min width + + public static let gridMinWidth100: GridRawToken = 1 + public static let gridMinWidth200: GridRawToken = 390 + public static let gridMinWidth300: GridRawToken = 480 + public static let gridMinWidth400: GridRawToken = 736 + public static let gridMinWidth500: GridRawToken = 1024 + public static let gridMinWidth600: GridRawToken = 1320 + public static let gridMinWidth700: GridRawToken = 1640 + public static let gridMinWidth800: GridRawToken = 1880 + public static let gridMinWidthExtraCompact: GridRawToken = 320 + public static let gridMinWidthCompact: GridRawToken = 390 + public static let gridMinWidthRegular: GridRawToken = 736 + + // MARK: Primitive token - Grid - Max width + + public static let gridMaxWidth100: GridRawToken = 389 + public static let gridMaxWidth200: GridRawToken = 479 + public static let gridMaxWidth300: GridRawToken = 735 + public static let gridMaxWidth400: GridRawToken = 1023 + public static let gridMaxWidth500: GridRawToken = 1339 + public static let gridMaxWidth600: GridRawToken = 1639 + public static let gridMaxWidth650: GridRawToken = 1680 + public static let gridMaxWidth700: GridRawToken = 1879 + public static let gridMaxWidth800: GridRawToken = 1920 + public static let gridMaxWidthExtraCompact: GridRawToken = 389 + public static let gridMaxWidthCompact: GridRawToken = 852 + public static let gridMaxWidthRegular: GridRawToken = 1336 + + // MARK: Primitive token - Grid - Margin + + 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 = 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 + + public static let gridColumnCount100: GridRawToken = 1 + public static let gridColumnCount200: GridRawToken = 2 + public static let gridColumnCount400: GridRawToken = 4 + public static let gridColumnCount600: GridRawToken = 6 + public static let gridColumnCount800: GridRawToken = 8 + public static let gridColumnCount1000: GridRawToken = 10 + public static let gridColumnCount1200: GridRawToken = 12 + + // MARK: Primitive token - Grid - Composite - iOS Extra Compact + + public static let gridExtraCompactMinWidth: GridRawToken = gridMinWidthExtraCompact + public static let gridExtraCompactMaxWidth: GridRawToken = gridMaxWidthExtraCompact + public static let gridExtraCompactMargin: GridRawToken = gridMargin100 + public static let gridExtraCompactColumnGap: GridRawToken = gridColumnGap100 + + // MARK: Primitive token - Grid - Composite - iOS Compact + + public static let gridCompactMinWidth: GridRawToken = gridMinWidthCompact + public static let gridCompactMaxWidth: GridRawToken = gridMaxWidthCompact + public static let gridCompactMargin: GridRawToken = gridMargin300 + public static let gridCompactColumnGap: GridRawToken = gridColumnGap100 + + // MARK: Primitive token - Grid - Composite - iOS Regular + + public static let gridRegularWidth: GridRawToken = gridWidth400 + public static let gridRegularMinWidth: GridRawToken = gridMinWidthCompact + public static let gridRegularMaxWidth: GridRawToken = gridMaxWidthCompact + public static let gridRegularMargin: GridRawToken = gridMargin500 + public static let gridRegularColumnGap: GridRawToken = gridColumnGap300 +} diff --git a/OUDS/Core/Tokens/RawTokens/Sources/OpacityRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/OpacityRawTokens+Values.swift similarity index 57% rename from OUDS/Core/Tokens/RawTokens/Sources/OpacityRawTokens.swift rename to OUDS/Core/Tokens/RawTokens/Sources/Values/OpacityRawTokens+Values.swift index f92c6f465..f1567ad41 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/OpacityRawTokens.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/OpacityRawTokens+Values.swift @@ -2,28 +2,18 @@ // 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 +// Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation - -// MARK: - Type aliases to keep grammar clear - -public typealias OpacityRawToken = Double - -// MARK: - Raw tokens - -/// This is the group of all **raw tokens** related to **opacity**. -/// Primitive types such as `Double` must be used to as to allow to use `@objc` keywords in extensions for overriding. -/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else -/// (i.e. publicly accessible from everywhere). More optimized than _struct_. -public enum OpacityRawTokens { +/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. +/// Should be fully generated in the future. +extension OpacityRawTokens { // MARK: Primitive token - Opacity @@ -35,6 +25,6 @@ public enum OpacityRawTokens { public static let opacity500: OpacityRawToken = 0.32 public static let opacity600: OpacityRawToken = 0.48 public static let opacity700: OpacityRawToken = 0.64 - public static let opacity800: OpacityRawToken = 0.88 + public static let opacity800: OpacityRawToken = 0.80 public static let opacity900: OpacityRawToken = 1 } diff --git a/OUDS/Core/Tokens/RawTokens/Sources/TypographyRawTokens.swift b/OUDS/Core/Tokens/RawTokens/Sources/Values/TypographyRawTokens+Values.swift similarity index 50% rename from OUDS/Core/Tokens/RawTokens/Sources/TypographyRawTokens.swift rename to OUDS/Core/Tokens/RawTokens/Sources/Values/TypographyRawTokens+Values.swift index d529423c2..c0467a360 100644 --- a/OUDS/Core/Tokens/RawTokens/Sources/TypographyRawTokens.swift +++ b/OUDS/Core/Tokens/RawTokens/Sources/Values/TypographyRawTokens+Values.swift @@ -2,51 +2,23 @@ // 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 +// Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import SwiftUI - -// MARK: - Type aliases to keep grammar clear - -public typealias TypographyFontFamilyRawToken = String -public typealias TypographyFontWeightRawToken = String -public typealias TypographyFontSizeRawToken = CGFloat -public typealias TypographyFontLineHeightRawToken = Int -public typealias TypographyFontParagraphSpacingRawToken = Int - -// MARK: Primitive tokens - -// MARK: - Composite raw token - -public struct TypographyCompositeRawToken { - - public let family: TypographyFontFamilyRawToken - public let size: TypographyFontSizeRawToken - public let lineHeight: TypographyFontLineHeightRawToken - public let weight: TypographyFontWeightRawToken - // TODO: How to deal "letter spacing"? - public let paragraphSpacing: TypographyFontParagraphSpacingRawToken -} - -// MARK: - Raw tokens - -// swiftlint:disable line_length -/// This is the group of all **raw tokens** related to **typography**. -/// Primitive types such as `Int` and `String` must be used to as to allow to use `@objc` keywords in extensions for overriding. -/// Such tokens are packed in a _Swift enum_ so as to gather them in one object with the suitable namespace and avoid to have just constants in nothing else -/// (i.e. publicly accessible from everywhere). More optimized than _struct_. -public enum TypographyRawTokens { +/// Extracted in a separated file to help the *Figma* JSON to Swift parser to generate files to include easily. +/// Should be fully generated in the future. +extension TypographyRawTokens { // MARK: Primitive token - Typography - Font size + // Warning: values in pixels! + public static let fontSize100: TypographyFontSizeRawToken = 10 public static let fontSize150: TypographyFontSizeRawToken = 12 public static let fontSize175: TypographyFontSizeRawToken = 13 @@ -68,6 +40,8 @@ public enum TypographyRawTokens { // MARK: Primitive token - Typography - Line height + // Warning: values in pixels! + public static let fontLineHeight250: TypographyFontLineHeightRawToken = 16 public static let fontLineHeight350: TypographyFontLineHeightRawToken = 20 public static let fontLineHeight450: TypographyFontLineHeightRawToken = 24 @@ -84,17 +58,18 @@ public enum TypographyRawTokens { public static let fontLineHeight1850: TypographyFontLineHeightRawToken = 72 public static let fontLineHeight2050: TypographyFontLineHeightRawToken = 80 - // MARK: Primitive token - Typography - Paragraph spacing - - public static let fontParagraphSpacing100: TypographyFontParagraphSpacingRawToken = 0 - public static let fontParagraphSpacing200: TypographyFontParagraphSpacingRawToken = 8 - public static let fontParagraphSpacing300: TypographyFontParagraphSpacingRawToken = 16 - public static let fontParagraphSpacing400: TypographyFontParagraphSpacingRawToken = 24 - // MARK: Primitive token - Typography - Font family - public static let fontFamilySystem: TypographyFontFamilyRawToken = "SF-Pro-Text" - public static let fontFamilyMonospace: TypographyFontFamilyRawToken = "Courrier-New" + public static let fontFamilyBrandDefault: TypographyFontFamilyRawToken = "Helvetica Neue" + // TODO: How to manage font-family-brand-tv = "Helvetica Neue LT"? Not existing in iOS SwiftUI + public static let fontFamilySystemArial: TypographyFontFamilyRawToken = "Arial" + public static let fontFamilySystemHelvetica: TypographyFontFamilyRawToken = "Helvetica" + // TODO: How to manage font-family-system-noto-sans = "Noto sans"? Not existing in iOS SwiftUI + // TODO: How to manage font-family-system-sf-pro-text = "SF Pro Text"? Not existing in iOS SwiftUI + // TODO: How to manage font-family-system-roboto = "Roboto"? Not existing in iOS SwiftUI + public static let fontFamilyMonospaceMenlo: TypographyFontFamilyRawToken = "Menlo" + // TODO: How to manage font-family-system-monaco = "Monaco"? Not existing in iOS SwiftUI + public static let fontFamilyMonospaceCourierNew: TypographyFontFamilyRawToken = "Courier New" // MARK: Primitive token - Typography - Font weight @@ -105,31 +80,31 @@ public enum TypographyRawTokens { public static let fontWeight500: TypographyFontWeightRawToken = "medium" public static let fontWeight600: TypographyFontWeightRawToken = "semibold" public static let fontWeight700: TypographyFontWeightRawToken = "bold" + // TODO: How to manage fontWeight800 = "extra bold"? Not existing in iOS SwiftUI public static let fontWeight900: TypographyFontWeightRawToken = "heavy" + // TODO: How to manage fontWeight950 = "extra black"? Not existing in iOS SwiftUI // MARK: Primitive token - Typography - Composite - public static let typeRegular150 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize150, lineHeight: fontLineHeight250, weight: fontWeight400, paragraphSpacing: fontParagraphSpacing100) - public static let typeRegular175 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize175, lineHeight: fontLineHeight250, weight: fontWeight400, paragraphSpacing: fontParagraphSpacing100) - public static let typeRegular200 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize200, lineHeight: fontLineHeight250, weight: fontWeight400, paragraphSpacing: fontParagraphSpacing100) - public static let typeRegular250 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize250, lineHeight: fontLineHeight350, weight: fontWeight400, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold150 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize150, lineHeight: fontLineHeight450, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold175 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize175, lineHeight: fontLineHeight250, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold200 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize200, lineHeight: fontLineHeight250, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold250 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize250, lineHeight: fontLineHeight350, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold300 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize300, lineHeight: fontLineHeight450, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold350 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize350, lineHeight: fontLineHeight550, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold450 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize450, lineHeight: fontLineHeight550, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold550 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize550, lineHeight: fontLineHeight650, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold650 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize650, lineHeight: fontLineHeight750, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold750 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize750, lineHeight: fontLineHeight850, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold850 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize850, lineHeight: fontLineHeight950, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold950 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize950, lineHeight: fontLineHeight1050, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold1050 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize1050, lineHeight: fontLineHeight1150, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold1150 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize1150, lineHeight: fontLineHeight1250, weight: fontWeight400, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold1250 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize1250, lineHeight: fontLineHeight1350, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold1450 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize1450, lineHeight: fontLineHeight1450, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - public static let typeBold1850 = TypographyCompositeRawToken(family: fontFamilySystem, size: fontSize1850, lineHeight: fontLineHeight1850, weight: fontWeight700, paragraphSpacing: fontParagraphSpacing100) - + public static let typeRegular150 = TypographyCompositeRawToken(size: fontSize150, lineHeight: fontLineHeight250, weight: fontWeight400) + public static let typeRegular175 = TypographyCompositeRawToken(size: fontSize175, lineHeight: fontLineHeight250, weight: fontWeight400) + public static let typeRegular200 = TypographyCompositeRawToken(size: fontSize200, lineHeight: fontLineHeight250, weight: fontWeight400) + public static let typeRegular250 = TypographyCompositeRawToken(size: fontSize250, lineHeight: fontLineHeight350, weight: fontWeight400) + public static let typeBold150 = TypographyCompositeRawToken(size: fontSize150, lineHeight: fontLineHeight250, weight: fontWeight700) + public static let typeBold175 = TypographyCompositeRawToken(size: fontSize175, lineHeight: fontLineHeight250, weight: fontWeight700) + public static let typeBold200 = TypographyCompositeRawToken(size: fontSize200, lineHeight: fontLineHeight250, weight: fontWeight700) + public static let typeBold250 = TypographyCompositeRawToken(size: fontSize250, lineHeight: fontLineHeight350, weight: fontWeight700) + public static let typeBold300 = TypographyCompositeRawToken(size: fontSize300, lineHeight: fontLineHeight450, weight: fontWeight700) + public static let typeBold350 = TypographyCompositeRawToken(size: fontSize350, lineHeight: fontLineHeight550, weight: fontWeight700) + public static let typeBold450 = TypographyCompositeRawToken(size: fontSize450, lineHeight: fontLineHeight550, weight: fontWeight700) + public static let typeBold550 = TypographyCompositeRawToken(size: fontSize550, lineHeight: fontLineHeight650, weight: fontWeight700) + public static let typeBold650 = TypographyCompositeRawToken(size: fontSize650, lineHeight: fontLineHeight750, weight: fontWeight700) + public static let typeBold750 = TypographyCompositeRawToken(size: fontSize750, lineHeight: fontLineHeight850, weight: fontWeight700) + public static let typeBold850 = TypographyCompositeRawToken(size: fontSize850, lineHeight: fontLineHeight950, weight: fontWeight700) + public static let typeBold950 = TypographyCompositeRawToken(size: fontSize950, lineHeight: fontLineHeight1050, weight: fontWeight700) + public static let typeBold1050 = TypographyCompositeRawToken(size: fontSize1050, lineHeight: fontLineHeight1150, weight: fontWeight700) + public static let typeBold1150 = TypographyCompositeRawToken(size: fontSize1150, lineHeight: fontLineHeight1250, weight: fontWeight700) + public static let typeBold1250 = TypographyCompositeRawToken(size: fontSize1250, lineHeight: fontLineHeight1350, weight: fontWeight700) + public static let typeBold1450 = TypographyCompositeRawToken(size: fontSize1450, lineHeight: fontLineHeight1450, weight: fontWeight700) + public static let typeBold1850 = TypographyCompositeRawToken(size: fontSize1850, lineHeight: fontLineHeight1850, weight: fontWeight700) } -// swiftlint:enable line_length diff --git a/OUDS/Core/Tokens/RawTokens/Sources/_OUDSTokensRaw.docc/OUDSTokensRaw.md b/OUDS/Core/Tokens/RawTokens/Sources/_OUDSTokensRaw.docc/OUDSTokensRaw.md new file mode 100644 index 000000000..8898a3495 --- /dev/null +++ b/OUDS/Core/Tokens/RawTokens/Sources/_OUDSTokensRaw.docc/OUDSTokensRaw.md @@ -0,0 +1,50 @@ +# ``OUDSTokensRaw`` + +_Raw tokens_ are smallest _tokens_ possible. They are associated to raw values and will be finaly the values assigned to the _components_ properties. + +## Overview + +In fact, we choose to use as most as possible primitive types for raw values, like `Int`, `Double`, `CGFloat` or `String` so as to handle the smallest types with few impacts on the memory for ecodesign principles. Indeed with hundreds of raw tokens, it will be more efficient to store primitive small types than structs or classes. + +So we expose also in higher level some properties so as to convert when needed some of these types to `SwiftUI` types (like `Font.Weight` and `Color`). + +To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are avaialble for those who want too make their own theme. + +Using more simple and primitive types will help also to test the library. With also type aliases we force users to use our types and not higher level types like _SwiftUI_ types. + +We also choose to add in _extension_ all the tokens values in a separated file so as to help the *Figma*-JSON-to-Swift parser to build files to copy and past easily in the project and keeping all the other objects. + +Example for ``ColorRawTokens`: + +```swift +// Define types for color raw tokens +public typealias ColorRawToken = String + +public enum ColorRawTokens { } // Gathers all color raw tokens + +extension ColorRawTokens { + + public static let colorFunctionalWhite: ColorRawToken = "#FFFFFF" + public static let colorFunctionalScarlet400: ColorRawToken = "#FF4D4E" + public static let colorTransparentBlack0: ColorRawToken = apply(opacity: OpacityRawTokens.opacity0, on: colorFunctionalBlack) + ... +} + +extension String { + public var color: Color { + Color(hexadecimalCode: self) + } +} +``` + +## Topics + +### Group + +- ``BorderRawTokens`` +- ``ColorRawTokens`` +- ``DimensionRawTokens`` +- ``ElevationRawTokens`` +- ``GridRawTokens`` +- ``OpacityRawTokens`` +- ``TypographyRawTokens`` diff --git a/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift index 54b280852..932b50d9f 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift @@ -21,80 +21,155 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class BorderRawTokensTests: XCTestCase { + // Curent value of BorderRawTokens.borderBase + static let borderRawTokensBorderBase = 4 + // MARK: - Primitive token - Border - Width func testBorderWidthRawToken0LessThan25() throws { XCTAssertLessThan(BorderRawTokens.borderWidth0, BorderRawTokens.borderWidth25) } + func testBorderWidthRawToken0MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderWidth0, factor: Self.borderRawTokensBorderBase) + } + func testBorderWidthRawToken25LessThan50() throws { XCTAssertLessThan(BorderRawTokens.borderWidth25, BorderRawTokens.borderWidth50) } + func testBorderWidthRawToken25MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderWidth25, factor: Self.borderRawTokensBorderBase) + } + func testBorderWidthRawToken50LessThan75() throws { XCTAssertLessThan(BorderRawTokens.borderWidth50, BorderRawTokens.borderWidth75) } + func testBorderWidthRawToken50MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderWidth50, factor: Self.borderRawTokensBorderBase) + } + func testBorderWidthRawToken75LessThan100() throws { XCTAssertLessThan(BorderRawTokens.borderWidth75, BorderRawTokens.borderWidth100) } + func testBorderWidthRawToken75MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderWidth75, factor: Self.borderRawTokensBorderBase) + } + func testBorderWidthRawToken100LessThan150() throws { XCTAssertLessThan(BorderRawTokens.borderWidth100, BorderRawTokens.borderWidth150) } + func testBorderWidthRawToken100MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderWidth100, factor: Self.borderRawTokensBorderBase) + } + func testBorderWidthRawToken150LessThan200() throws { XCTAssertLessThan(BorderRawTokens.borderWidth150, BorderRawTokens.borderWidth200) } + func testBorderWidthRawToken150MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderWidth150, factor: Self.borderRawTokensBorderBase) + } + + func testBorderWidthRawToken200MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderWidth200, factor: Self.borderRawTokensBorderBase) + } + // MARK: - Primitive token - Border - Radius func testBorderRadiusRawToken0LessThan25() throws { XCTAssertLessThan(BorderRawTokens.borderRadius0, BorderRawTokens.borderRadius25) } + func testBorderRadiusRawToken0MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius0, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken25LessThan50() throws { XCTAssertLessThan(BorderRawTokens.borderRadius25, BorderRawTokens.borderRadius50) } + func testBorderRadiusRawToken25MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius25, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken50LessThan75() throws { XCTAssertLessThan(BorderRawTokens.borderRadius50, BorderRawTokens.borderRadius75) } + func testBorderRadiusRawToken50MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius50, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken75LessThan100() throws { XCTAssertLessThan(BorderRawTokens.borderRadius75, BorderRawTokens.borderRadius100) } + func testBorderRadiusRawToken75MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius75, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken100LessThan150() throws { XCTAssertLessThan(BorderRawTokens.borderRadius100, BorderRawTokens.borderRadius150) } + func testBorderRadiusRawToken100MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius100, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken150LessThan200() throws { XCTAssertLessThan(BorderRawTokens.borderRadius150, BorderRawTokens.borderRadius200) } + func testBorderRadiusRawToken150MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius150, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken200LessThan300() throws { XCTAssertLessThan(BorderRawTokens.borderRadius200, BorderRawTokens.borderRadius300) } + func testBorderRadiusRawToken200MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius200, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken300LessThan400() throws { XCTAssertLessThan(BorderRawTokens.borderRadius300, BorderRawTokens.borderRadius400) } + func testBorderRadiusRawToken300MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius300, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken400LessThan500() throws { XCTAssertLessThan(BorderRawTokens.borderRadius400, BorderRawTokens.borderRadius500) } + func testBorderRadiusRawToken400MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius400, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken500LessThan600() throws { XCTAssertLessThan(BorderRawTokens.borderRadius500, BorderRawTokens.borderRadius600) } + func testBorderRadiusRawToken500MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius500, factor: Self.borderRawTokensBorderBase) + } + func testBorderRadiusRawToken600LessThan800() throws { XCTAssertLessThan(BorderRawTokens.borderRadius600, BorderRawTokens.borderRadius800) } - func testBorderRadiusRawToken800LessThan9999() throws { - XCTAssertLessThan(BorderRawTokens.borderRadius800, BorderRawTokens.borderRadius9999) + func testBorderRadiusRawToken600MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius600, factor: Self.borderRawTokensBorderBase) + } + + func testBorderRadiusRawToken800MultipleOfBase() throws { + XCTAssertMultipleOf(BorderRawTokens.borderRadius800, factor: Self.borderRawTokensBorderBase) } // MARK: - Primitive token - Border - Style diff --git a/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift index c267d2fad..50874f9ac 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/DimensionRawTokensTests.swift @@ -21,131 +21,266 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class DimensionRawTokensTests: XCTestCase { + // Curent value of DimensionRawTokens.dimensionBase + static let dimensionRawTokensDimensionBase = 4 + func testDimensionRawToken0LessThan25() throws { XCTAssertLessThan(DimensionRawTokens.dimension0, DimensionRawTokens.dimension25) } + func testDimensionRawToken0MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension0, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken25LessThan50() throws { XCTAssertLessThan(DimensionRawTokens.dimension25, DimensionRawTokens.dimension50) } + func testDimensionRawToken25MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension25, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken50LessThan75() throws { XCTAssertLessThan(DimensionRawTokens.dimension50, DimensionRawTokens.dimension75) } + func testDimensionRawToken50MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension50, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken75LessThan100() throws { XCTAssertLessThan(DimensionRawTokens.dimension75, DimensionRawTokens.dimension100) } + func testDimensionRawToken75MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension75, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken100LessThan150() throws { XCTAssertLessThan(DimensionRawTokens.dimension100, DimensionRawTokens.dimension150) } + func testDimensionRawToken100MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension100, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken150LessThan200() throws { XCTAssertLessThan(DimensionRawTokens.dimension150, DimensionRawTokens.dimension200) } + func testDimensionRawToken150MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension150, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken200LessThan250() throws { XCTAssertLessThan(DimensionRawTokens.dimension200, DimensionRawTokens.dimension250) } + func testDimensionRawToken200MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension200, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken250LessThan300() throws { XCTAssertLessThan(DimensionRawTokens.dimension250, DimensionRawTokens.dimension300) } + func testDimensionRawToken250MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension250, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken300LessThan350() throws { XCTAssertLessThan(DimensionRawTokens.dimension300, DimensionRawTokens.dimension350) } + func testDimensionRawToken300MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension300, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken350LessThan400() throws { XCTAssertLessThan(DimensionRawTokens.dimension350, DimensionRawTokens.dimension400) } + func testDimensionRawToken350MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension350, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken400LessThan450() throws { XCTAssertLessThan(DimensionRawTokens.dimension400, DimensionRawTokens.dimension450) } + func testDimensionRawToken400MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension400, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken450LessThan500() throws { XCTAssertLessThan(DimensionRawTokens.dimension450, DimensionRawTokens.dimension500) } + func testDimensionRawToken450MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension450, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken500LessThan550() throws { XCTAssertLessThan(DimensionRawTokens.dimension500, DimensionRawTokens.dimension550) } + func testDimensionRawToken500MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension500, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken550LessThan600() throws { XCTAssertLessThan(DimensionRawTokens.dimension550, DimensionRawTokens.dimension600) } + func testDimensionRawToken550MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension550, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken600LessThan650() throws { XCTAssertLessThan(DimensionRawTokens.dimension600, DimensionRawTokens.dimension650) } + func testDimensionRawToken600MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension600, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken650LessThan700() throws { XCTAssertLessThan(DimensionRawTokens.dimension650, DimensionRawTokens.dimension700) } + func testDimensionRawToken650MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension650, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken700LessThan750() throws { XCTAssertLessThan(DimensionRawTokens.dimension700, DimensionRawTokens.dimension750) } + func testDimensionRawToken700MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension700, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken750LessThan800() throws { XCTAssertLessThan(DimensionRawTokens.dimension750, DimensionRawTokens.dimension800) } + func testDimensionRawToken750MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension750, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken800LessThan900() throws { XCTAssertLessThan(DimensionRawTokens.dimension800, DimensionRawTokens.dimension900) } + func testDimensionRawToken800MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension800, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken900LessThan1000() throws { XCTAssertLessThan(DimensionRawTokens.dimension900, DimensionRawTokens.dimension1000) } + func testDimensionRawToken900MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension900, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken1000LessThan1200() throws { XCTAssertLessThan(DimensionRawTokens.dimension1000, DimensionRawTokens.dimension1200) } + func testDimensionRawToken1000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension1000, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken1200LessThan1400() throws { XCTAssertLessThan(DimensionRawTokens.dimension1200, DimensionRawTokens.dimension1400) } + func testDimensionRawToken1200MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension1200, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken1400LessThan1600() throws { XCTAssertLessThan(DimensionRawTokens.dimension1400, DimensionRawTokens.dimension1600) } + func testDimensionRawToken1400MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension1400, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken1600LessThan1800() throws { XCTAssertLessThan(DimensionRawTokens.dimension1600, DimensionRawTokens.dimension1800) } + func testDimensionRawToken1600MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension1600, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken1800LessThan2000() throws { XCTAssertLessThan(DimensionRawTokens.dimension1800, DimensionRawTokens.dimension2000) } + func testDimensionRawToken1800MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension1800, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken2000LessThan3000() throws { XCTAssertLessThan(DimensionRawTokens.dimension2000, DimensionRawTokens.dimension3000) } + func testDimensionRawToken2000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension2000, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken3000LessThan4000() throws { XCTAssertLessThan(DimensionRawTokens.dimension3000, DimensionRawTokens.dimension4000) } + func testDimensionRawToken3000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension3000, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken4000LessThan5000() throws { XCTAssertLessThan(DimensionRawTokens.dimension4000, DimensionRawTokens.dimension5000) } + func testDimensionRawToken4000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension4000, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken5000LessThan6000() throws { XCTAssertLessThan(DimensionRawTokens.dimension5000, DimensionRawTokens.dimension6000) } + func testDimensionRawToken5000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension5000, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken6000LessThan7000() throws { XCTAssertLessThan(DimensionRawTokens.dimension6000, DimensionRawTokens.dimension7000) } + func testDimensionRawToken6000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension6000, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken7000LessThan9000() throws { XCTAssertLessThan(DimensionRawTokens.dimension7000, DimensionRawTokens.dimension9000) } + func testDimensionRawToken7000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension7000, factor: Self.dimensionRawTokensDimensionBase) + } + func testDimensionRawToken9000LessThan11000() throws { XCTAssertLessThan(DimensionRawTokens.dimension9000, DimensionRawTokens.dimension11000) } + + func testDimensionRawToken9000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension9000, factor: Self.dimensionRawTokensDimensionBase) + } + + func testDimensionRawToken11000MultipleOfBase() throws { + XCTAssertMultipleOf(DimensionRawTokens.dimension11000, factor: Self.dimensionRawTokensDimensionBase) + } } diff --git a/OUDS/Core/Tokens/RawTokens/Tests/ElevationRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/ElevationRawTokensTests.swift index bbc88cf08..75d4f5449 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/ElevationRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/ElevationRawTokensTests.swift @@ -14,8 +14,7 @@ import XCTest import OUDSFoundations import OUDSTokensRaw - -// swiftlint:disable type_body_length +import SwiftUI /// The aim of this tests class is to look for regressions in **elevation raw tokens**. /// Because these values will be at least generated through an external tool, is it not mandatory and relevant to test each token values. @@ -24,62 +23,43 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class ElevationRawTokensTests: XCTestCase { - // MARK: - Primitive token - Elevation - Z Index - - func testElevationZIndexRawTokenMinus9999LessThanZIndex0() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndexMinus9999, ElevationRawTokens.elevationZIndex0) - } - - func testElevationZIndexRawToken0LessThanZIndex1000() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex0, ElevationRawTokens.elevationZIndex1000) - } - - func testElevationZIndexRawToken1000LessThanZIndex1010() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1000, ElevationRawTokens.elevationZIndex1010) - } - - func testElevationZIndexRawToken1010LessThanZIndex1020() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1010, ElevationRawTokens.elevationZIndex1020) - } - - func testElevationZIndexRawToken1020LessThanZIndex1030() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1020, ElevationRawTokens.elevationZIndex1030) - } - - func testElevationZIndexRawToken1030LessThanZIndex1035() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1030, ElevationRawTokens.elevationZIndex1035) - } - - func testElevationZIndexRawToken1035LessThanZIndex1038() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1035, ElevationRawTokens.elevationZIndex1038) - } - - func testElevationZIndexRawToken1038LessThanZIndex1040() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1038, ElevationRawTokens.elevationZIndex1040) - } - - func testElevationZIndexRawToken1040LessThanZIndex1045() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1040, ElevationRawTokens.elevationZIndex1045) - } - - func testElevationZIndexRawToken1045LessThanZIndex1050() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1045, ElevationRawTokens.elevationZIndex1050) - } - - func testElevationZIndexRawToken1050LessThanZIndex1060() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1050, ElevationRawTokens.elevationZIndex1060) - } - - func testElevationZIndexRawToken1060LessThanZIndex1070() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1060, ElevationRawTokens.elevationZIndex1070) - } - - func testElevationZIndexRawToken1070LessThanZIndex1080() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1070, ElevationRawTokens.elevationZIndex1080) - } - - func testElevationZIndexRawToken1080LessThanZIndex1090() throws { - XCTAssertLessThan(ElevationRawTokens.elevationZIndex1080, ElevationRawTokens.elevationZIndex1090) + // MARK: - Computed properties + + func testRadiusComputation() throws { + // Given + var token = ElevationCompositeRawToken(x: 0, y: 0, blur: 0, color: ColorRawTokens.colorTransparentBlack500) + // When + var radius = token.radius + // Then + XCTAssertTrue(radius == 0) + + // Given + token = ElevationCompositeRawToken(x: 0, y: 2, blur: 1, color: ColorRawTokens.colorTransparentBlack400) + // When + radius = token.radius + // Then + XCTAssertTrue(radius == 0.5) + + // Given + token = ElevationCompositeRawToken(x: 0, y: 3, blur: 2, color: ColorRawTokens.colorTransparentBlack300) + // When + radius = token.radius + // Then + XCTAssertTrue(radius == 1) + + // Given + token = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack500) + // When + radius = token.radius + // Then + XCTAssertTrue(radius == 2) + + // Given + token = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack300) + // When + radius = token.radius + // Then + XCTAssertTrue(radius == 6) } // MARK: - Primitive token - Elevation - Y @@ -138,257 +118,232 @@ final class ElevationRawTokensTests: XCTestCase { XCTAssertLessThan(ElevationRawTokens.elevationBlur600, ElevationRawTokens.elevationBlur700) } - // MARK: - Primitive token - Elevation - Spread - - func testElevationSpreadMinus400LessThanMinus300() throws { - XCTAssertLessThan(ElevationRawTokens.elevationSpreadMinus400, ElevationRawTokens.elevationSpreadMinus300) - } - - func testElevationSpreadMinus300LessThanMinus200() throws { - XCTAssertLessThan(ElevationRawTokens.elevationSpreadMinus300, ElevationRawTokens.elevationSpreadMinus200) - } - - func testElevationSpreadMinus200LessThanMinus100() throws { - XCTAssertLessThan(ElevationRawTokens.elevationSpreadMinus200, ElevationRawTokens.elevationSpreadMinus100) - } - - func testElevationSpreadMinus100LessThan0() throws { - XCTAssertLessThan(ElevationRawTokens.elevationSpreadMinus100, ElevationRawTokens.elevationSpread0) - } - - func testElevationSpread0LessThan300() throws { - XCTAssertLessThan(ElevationRawTokens.elevationSpread0, ElevationRawTokens.elevationSpread300) - } - // MARK: - Primitive token - Elevation - Box Shadow - func testElevationBoxShadowBottom_1_100ColorDarkerThan_1_200() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_1_100.color, ElevationRawTokens.elevationBoxShadowBottom_1_200.color) + func testElevationBottom_1_100ColorDarkerThan_1_200() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_1_100.color, ElevationRawTokens.elevationBottom_1_200.color) } - func testElevationBoxShadowBottom_1_200ColorDarkerThan_1_300() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_1_200.color, ElevationRawTokens.elevationBoxShadowBottom_1_300.color) + func testElevationBottom_1_200ColorDarkerThan_1_300() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_1_200.color, ElevationRawTokens.elevationBottom_1_300.color) } - func testElevationBoxShadowBottom_1_300ColorDarkerThan_1_400() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_1_300.color, ElevationRawTokens.elevationBoxShadowBottom_1_400.color) + func testElevationBottom_1_300ColorDarkerThan_1_400() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_1_300.color, ElevationRawTokens.elevationBottom_1_400.color) } - func testElevationBoxShadowBottom_1_400ColorDarkerThan_1_500() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_1_400.color, ElevationRawTokens.elevationBoxShadowBottom_1_500.color) + func testElevationBottom_1_400ColorDarkerThan_1_500() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_1_400.color, ElevationRawTokens.elevationBottom_1_500.color) } - func testElevationBoxShadowBottom_1_500ColorDarkerThan_1_600() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_1_500.color, ElevationRawTokens.elevationBoxShadowBottom_1_600.color) + func testElevationBottom_1_500ColorDarkerThan_1_600() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_1_500.color, ElevationRawTokens.elevationBottom_1_600.color) } - func testElevationBoxShadowBottom_2_100ColorDarkerThan_2_200() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_2_100.color, ElevationRawTokens.elevationBoxShadowBottom_2_200.color) + func testElevationBottom_2_100ColorDarkerThan_2_200() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_2_100.color, ElevationRawTokens.elevationBottom_2_200.color) } - func testElevationBoxShadowBottom_2_200ColorDarkerThan_2_300() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_2_200.color, ElevationRawTokens.elevationBoxShadowBottom_2_300.color) + func testElevationBottom_2_200ColorDarkerThan_2_300() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_2_200.color, ElevationRawTokens.elevationBottom_2_300.color) } - func testElevationBoxShadowBottom_2_300ColorDarkerThan_2_400() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_2_300.color, ElevationRawTokens.elevationBoxShadowBottom_2_400.color) + func testElevationBottom_2_300ColorDarkerThan_2_400() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_2_300.color, ElevationRawTokens.elevationBottom_2_400.color) } - func testElevationBoxShadowBottom_2_400ColorDarkerThan_2_500() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_2_400.color, ElevationRawTokens.elevationBoxShadowBottom_2_500.color) + func testElevationBottom_2_400ColorDarkerThan_2_500() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_2_400.color, ElevationRawTokens.elevationBottom_2_500.color) } - func testElevationBoxShadowBottom_2_500ColorDarkerThan_2_600() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_2_500.color, ElevationRawTokens.elevationBoxShadowBottom_2_600.color) + func testElevationBottom_2_500ColorDarkerThan_2_600() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_2_500.color, ElevationRawTokens.elevationBottom_2_600.color) } - func testElevationBoxShadowBottom_3_100ColorDarkerThan_3_200() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_3_100.color, ElevationRawTokens.elevationBoxShadowBottom_3_200.color) + func testElevationBottom_3_100ColorDarkerThan_3_200() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_3_100.color, ElevationRawTokens.elevationBottom_3_200.color) } - func testElevationBoxShadowBottom_3_200ColorDarkerThan_3_300() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_3_200.color, ElevationRawTokens.elevationBoxShadowBottom_3_300.color) + func testElevationBottom_3_200ColorDarkerThan_3_300() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_3_200.color, ElevationRawTokens.elevationBottom_3_300.color) } - func testElevationBoxShadowBottom_3_300ColorDarkerThan_3_400() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_3_300.color, ElevationRawTokens.elevationBoxShadowBottom_3_400.color) + func testElevationBottom_3_300ColorDarkerThan_3_400() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_3_300.color, ElevationRawTokens.elevationBottom_3_400.color) } - func testElevationBoxShadowBottom_3_400ColorDarkerThan_3_500() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_3_400.color, ElevationRawTokens.elevationBoxShadowBottom_3_500.color) + func testElevationBottom_3_400ColorDarkerThan_3_500() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_3_400.color, ElevationRawTokens.elevationBottom_3_500.color) } - func testElevationBoxShadowBottom_3_500ColorDarkerThan_3_600() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_3_500.color, ElevationRawTokens.elevationBoxShadowBottom_3_600.color) + func testElevationBottom_3_500ColorDarkerThan_3_600() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_3_500.color, ElevationRawTokens.elevationBottom_3_600.color) } - func testElevationBoxShadowBottom_4_100ColorDarkerThan_4_200() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_4_100.color, ElevationRawTokens.elevationBoxShadowBottom_4_200.color) + func testElevationBottom_4_100ColorDarkerThan_4_200() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_4_100.color, ElevationRawTokens.elevationBottom_4_200.color) } - func testElevationBoxShadowBottom_4_200ColorDarkerThan_4_300() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_4_200.color, ElevationRawTokens.elevationBoxShadowBottom_4_300.color) + func testElevationBottom_4_200ColorDarkerThan_4_300() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_4_200.color, ElevationRawTokens.elevationBottom_4_300.color) } - func testElevationBoxShadowBottom_4_300ColorDarkerThan_4_400() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_4_300.color, ElevationRawTokens.elevationBoxShadowBottom_4_400.color) + func testElevationBottom_4_300ColorDarkerThan_4_400() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_4_300.color, ElevationRawTokens.elevationBottom_4_400.color) } - func testElevationBoxShadowBottom_4_400ColorDarkerThan_4_500() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_4_400.color, ElevationRawTokens.elevationBoxShadowBottom_4_500.color) + func testElevationBottom_4_400ColorDarkerThan_4_500() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_4_400.color, ElevationRawTokens.elevationBottom_4_500.color) } - func testElevationBoxShadowBottom_4_500ColorDarkerThan_4_600() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_4_500.color, ElevationRawTokens.elevationBoxShadowBottom_4_600.color) + func testElevationBottom_4_500ColorDarkerThan_4_600() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_4_500.color, ElevationRawTokens.elevationBottom_4_600.color) } - func testElevationBoxShadowBottom_5_100ColorDarkerThan_5_200() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_100.color, ElevationRawTokens.elevationBoxShadowBottom_5_200.color) + func testElevationBottom_5_100ColorDarkerThan_5_200() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_100.color, ElevationRawTokens.elevationBottom_5_200.color) } - func testElevationBoxShadowBottom_5_200ColorDarkerThan_5_300() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_200.color, ElevationRawTokens.elevationBoxShadowBottom_5_300.color) + func testElevationBottom_5_200ColorDarkerThan_5_300() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_200.color, ElevationRawTokens.elevationBottom_5_300.color) } - func testElevationBoxShadowBottom_5_300ColorDarkerThan_5_400() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_300.color, ElevationRawTokens.elevationBoxShadowBottom_5_400.color) + func testElevationBottom_5_300ColorDarkerThan_5_400() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_300.color, ElevationRawTokens.elevationBottom_5_400.color) } - func testElevationBoxShadowBottom_5_400ColorDarkerThan_5_500() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_400.color, ElevationRawTokens.elevationBoxShadowBottom_5_500.color) + func testElevationBottom_5_400ColorDarkerThan_5_500() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_400.color, ElevationRawTokens.elevationBottom_5_500.color) } - func testElevationBoxShadowBottom_5_500ColorDarkerThan_5_600() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_500.color, ElevationRawTokens.elevationBoxShadowBottom_5_600.color) + func testElevationBottom_5_500ColorDarkerThan_5_600() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_500.color, ElevationRawTokens.elevationBottom_5_600.color) } - func testElevationBoxShadowBottom_5_100ColorDarkerThan_6_200() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_100.color, ElevationRawTokens.elevationBoxShadowBottom_6_200.color) + func testElevationBottom_5_100ColorDarkerThan_6_200() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_100.color, ElevationRawTokens.elevationBottom_6_200.color) } - func testElevationBoxShadowBottom_5_200ColorDarkerThan_6_300() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_200.color, ElevationRawTokens.elevationBoxShadowBottom_6_300.color) + func testElevationBottom_5_200ColorDarkerThan_6_300() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_200.color, ElevationRawTokens.elevationBottom_6_300.color) } - func testElevationBoxShadowBottom_5_300ColorDarkerThan_6_400() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_300.color, ElevationRawTokens.elevationBoxShadowBottom_6_400.color) + func testElevationBottom_5_300ColorDarkerThan_6_400() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_300.color, ElevationRawTokens.elevationBottom_6_400.color) } - func testElevationBoxShadowBottom_5_400ColorDarkerThan_6_500() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_400.color, ElevationRawTokens.elevationBoxShadowBottom_6_500.color) + func testElevationBottom_5_400ColorDarkerThan_6_500() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_400.color, ElevationRawTokens.elevationBottom_6_500.color) } - func testElevationBoxShadowBottom_5_500ColorDarkerThan_6_600() throws { - XCTAssertColorDarkerThan(ElevationRawTokens.elevationBoxShadowBottom_5_500.color, ElevationRawTokens.elevationBoxShadowBottom_6_600.color) + func testElevationBottom_5_500ColorDarkerThan_6_600() throws { + XCTAssertColorDarkerThan(ElevationRawTokens.elevationBottom_5_500.color, ElevationRawTokens.elevationBottom_6_600.color) } - func testBoxShadowBottom_1_100_LowerThan_2_100() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_1_100, ElevationRawTokens.elevationBoxShadowBottom_2_100) + func testCompositeBottom_1_100_LowerThan_2_100() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_1_100, ElevationRawTokens.elevationBottom_2_100) } - func testBoxShadowBottom_2_100_LowerThan_3_100() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_2_100, ElevationRawTokens.elevationBoxShadowBottom_3_100) + func testCompositeBottom_2_100_LowerThan_3_100() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_2_100, ElevationRawTokens.elevationBottom_3_100) } - func testBoxShadowBottom_3_100_LowerThan_4_100() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_3_100, ElevationRawTokens.elevationBoxShadowBottom_4_100) + func testCompositeBottom_3_100_LowerThan_4_100() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_3_100, ElevationRawTokens.elevationBottom_4_100) } - func testBoxShadowBottom_4_100_LowerThan_5_100() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_4_100, ElevationRawTokens.elevationBoxShadowBottom_5_100) + func testCompositeBottom_4_100_LowerThan_5_100() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_4_100, ElevationRawTokens.elevationBottom_5_100) } - func testBoxShadowBottom_5_100_LowerThan_6_100() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_5_100, ElevationRawTokens.elevationBoxShadowBottom_6_100) + func testCompositeBottom_5_100_LowerThan_6_100() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_5_100, ElevationRawTokens.elevationBottom_6_100) } - func testBoxShadowBottom_1_200_LowerThan_2_200() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_1_200, ElevationRawTokens.elevationBoxShadowBottom_2_200) + func testCompositeBottom_1_200_LowerThan_2_200() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_1_200, ElevationRawTokens.elevationBottom_2_200) } - func testBoxShadowBottom_2_200_LowerThan_3_200() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_2_200, ElevationRawTokens.elevationBoxShadowBottom_3_200) + func testCompositeBottom_2_200_LowerThan_3_200() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_2_200, ElevationRawTokens.elevationBottom_3_200) } - func testBoxShadowBottom_3_200_LowerThan_4_200() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_3_200, ElevationRawTokens.elevationBoxShadowBottom_4_200) + func testCompositeBottom_3_200_LowerThan_4_200() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_3_200, ElevationRawTokens.elevationBottom_4_200) } - func testBoxShadowBottom_4_200_LowerThan_5_200() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_4_200, ElevationRawTokens.elevationBoxShadowBottom_5_200) + func testCompositeBottom_4_200_LowerThan_5_200() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_4_200, ElevationRawTokens.elevationBottom_5_200) } - func testBoxShadowBottom_5_200_LowerThan_6_200() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_5_200, ElevationRawTokens.elevationBoxShadowBottom_6_200) + func testCompositeBottom_5_200_LowerThan_6_200() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_5_200, ElevationRawTokens.elevationBottom_6_200) } - func testBoxShadowBottom_1_300_LowerThan_2_300() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_1_300, ElevationRawTokens.elevationBoxShadowBottom_2_300) + func testCompositeBottom_1_300_LowerThan_2_300() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_1_300, ElevationRawTokens.elevationBottom_2_300) } - func testBoxShadowBottom_2_300_LowerThan_3_300() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_2_300, ElevationRawTokens.elevationBoxShadowBottom_3_300) + func testCompositeBottom_2_300_LowerThan_3_300() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_2_300, ElevationRawTokens.elevationBottom_3_300) } - func testBoxShadowBottom_3_300_LowerThan_4_300() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_3_300, ElevationRawTokens.elevationBoxShadowBottom_4_300) + func testCompositeBottom_3_300_LowerThan_4_300() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_3_300, ElevationRawTokens.elevationBottom_4_300) } - func testBoxShadowBottom_4_300_LowerThan_5_300() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_4_300, ElevationRawTokens.elevationBoxShadowBottom_5_300) + func testCompositeBottom_4_300_LowerThan_5_300() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_4_300, ElevationRawTokens.elevationBottom_5_300) } - func testBoxShadowBottom_5_300_LowerThan_6_300() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_5_300, ElevationRawTokens.elevationBoxShadowBottom_6_300) + func testCompositeBottom_5_300_LowerThan_6_300() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_5_300, ElevationRawTokens.elevationBottom_6_300) } - func testBoxShadowBottom_1_400_LowerThan_2_400() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_1_400, ElevationRawTokens.elevationBoxShadowBottom_2_400) + func testCompositeBottom_1_400_LowerThan_2_400() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_1_400, ElevationRawTokens.elevationBottom_2_400) } - func testBoxShadowBottom_2_400_LowerThan_3_400() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_2_400, ElevationRawTokens.elevationBoxShadowBottom_3_400) + func testCompositeBottom_2_400_LowerThan_3_400() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_2_400, ElevationRawTokens.elevationBottom_3_400) } - func testBoxShadowBottom_3_400_LowerThan_4_400() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_3_400, ElevationRawTokens.elevationBoxShadowBottom_4_400) + func testCompositeBottom_3_400_LowerThan_4_400() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_3_400, ElevationRawTokens.elevationBottom_4_400) } - func testBoxShadowBottom_4_400_LowerThan_5_400() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_4_400, ElevationRawTokens.elevationBoxShadowBottom_5_400) + func testCompositeBottom_4_400_LowerThan_5_400() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_4_400, ElevationRawTokens.elevationBottom_5_400) } - func testBoxShadowBottom_5_400_LowerThan_6_400() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_5_400, ElevationRawTokens.elevationBoxShadowBottom_6_400) + func testCompositeBottom_5_400_LowerThan_6_400() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_5_400, ElevationRawTokens.elevationBottom_6_400) } - func testBoxShadowBottom_1_500_LowerThan_2_500() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_1_500, ElevationRawTokens.elevationBoxShadowBottom_2_500) + func testCompositeBottom_1_500_LowerThan_2_500() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_1_500, ElevationRawTokens.elevationBottom_2_500) } - func testBoxShadowBottom_2_500_LowerThan_3_500() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_2_500, ElevationRawTokens.elevationBoxShadowBottom_3_500) + func testCompositeBottom_2_500_LowerThan_3_500() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_2_500, ElevationRawTokens.elevationBottom_3_500) } - func testBoxShadowBottom_3_500_LowerThan_4_500() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_3_500, ElevationRawTokens.elevationBoxShadowBottom_4_500) + func testCompositeBottom_3_500_LowerThan_4_500() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_3_500, ElevationRawTokens.elevationBottom_4_500) } - func testBoxShadowBottom_4_500_LowerThan_5_500() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_4_500, ElevationRawTokens.elevationBoxShadowBottom_5_500) + func testCompositeBottom_4_500_LowerThan_5_500() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_4_500, ElevationRawTokens.elevationBottom_5_500) } - func testBoxShadowBottom_5_500_LowerThan_6_500() throws { - assertBoxShadowLowerThan(ElevationRawTokens.elevationBoxShadowBottom_5_500, ElevationRawTokens.elevationBoxShadowBottom_6_500) + func testCompositeBottom_5_500_LowerThan_6_500() throws { + assertCompositeLowerThan(ElevationRawTokens.elevationBottom_5_500, ElevationRawTokens.elevationBottom_6_500) } // MARK: - Helpers - func assertBoxShadowLowerThan(_ left: ElevationBoxShadowRawToken, _ right: ElevationBoxShadowRawToken) { + func assertCompositeLowerThan(_ left: ElevationCompositeRawToken, _ right: ElevationCompositeRawToken) { XCTAssertLessThanOrEqual(left.y, right.y) - XCTAssertLessThanOrEqual(left.blur, right.blur) - XCTAssertGreaterThanOrEqual(left.spread, right.spread) + XCTAssertLessThanOrEqual(left.radius, right.radius) } } - -// swiftlint:enable type_body_length diff --git a/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift index aff2aff2e..6361d3821 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/GridRawTokensTests.swift @@ -21,86 +21,149 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class GridRawTokensTests: XCTestCase { + // Curent value ofGridRawTokens.dimensionBase + static let gridRawTokensDimensionBase = 4 + // MARK: - Primitive token - Grid - Design Width func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth200() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth100, GridRawTokens.gridDesignWidth200) + XCTAssertLessThan(GridRawTokens.gridWidth100, GridRawTokens.gridWidth200) } func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth300() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth100, GridRawTokens.gridDesignWidth300) + XCTAssertLessThan(GridRawTokens.gridWidth100, GridRawTokens.gridWidth300) } func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth400() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth100, GridRawTokens.gridDesignWidth400) + XCTAssertLessThan(GridRawTokens.gridWidth100, GridRawTokens.gridWidth400) } func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth500() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth100, GridRawTokens.gridDesignWidth500) + XCTAssertLessThan(GridRawTokens.gridWidth100, GridRawTokens.gridWidth500) } func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth600() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth100, GridRawTokens.gridDesignWidth600) + XCTAssertLessThan(GridRawTokens.gridWidth100, GridRawTokens.gridWidth600) } func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth700() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth100, GridRawTokens.gridDesignWidth700) + XCTAssertLessThan(GridRawTokens.gridWidth100, GridRawTokens.gridWidth700) } func testGridRawTokenGridDesignWidth100LessThanGridDesignWidth800() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth100, GridRawTokens.gridDesignWidth800) + XCTAssertLessThan(GridRawTokens.gridWidth100, GridRawTokens.gridWidth800) } func testGridRawTokenGridDesignWidth200LessThanGridDesignWidth300() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth200, GridRawTokens.gridDesignWidth300) + XCTAssertLessThan(GridRawTokens.gridWidth200, GridRawTokens.gridWidth300) } func testGridRawTokenGridDesignWidth200LessThanGridDesignWidth400() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth200, GridRawTokens.gridDesignWidth400) + XCTAssertLessThan(GridRawTokens.gridWidth200, GridRawTokens.gridWidth400) } func testGridRawTokenGridDesignWidth200LessThanGridDesignWidth500() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth200, GridRawTokens.gridDesignWidth500) + XCTAssertLessThan(GridRawTokens.gridWidth200, GridRawTokens.gridWidth500) } func testGridRawTokenGridDesignWidth200LessThanGridDesignWidth600() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth200, GridRawTokens.gridDesignWidth600) + XCTAssertLessThan(GridRawTokens.gridWidth200, GridRawTokens.gridWidth600) } func testGridRawTokenGridDesignWidth200LessThanGridDesignWidth700() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth200, GridRawTokens.gridDesignWidth700) + XCTAssertLessThan(GridRawTokens.gridWidth200, GridRawTokens.gridWidth700) } func testGridRawTokenGridDesignWidth200LessThanGridDesignWidth800() throws { - XCTAssertLessThan(GridRawTokens.gridDesignWidth200, GridRawTokens.gridDesignWidth800) + XCTAssertLessThan(GridRawTokens.gridWidth200, GridRawTokens.gridWidth800) } // MARK: - Primitive token - Grid - Min width - func testGridRawTokenGridMinWidthIOSExtraCompactLessThanGridMinWidthIOSCompact() throws { - XCTAssertLessThan(GridRawTokens.gridMinWidthIOSExtraCompact, GridRawTokens.gridMinWidthIOSCompact) + func testGridRawTokenGridMinWidth100LessThanGridMinWidth200() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidth100, GridRawTokens.gridMinWidth200) + } + + func testGridRawTokenGridMinWidth200LessThanGridMinWidth300() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidth200, GridRawTokens.gridMinWidth300) + } + + func testGridRawTokenGridMinWidth300LessThanGridMinWidth400() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidth300, GridRawTokens.gridMinWidth400) + } + + func testGridRawTokenGridMinWidth400LessThanGridMinWidth500() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidth400, GridRawTokens.gridMinWidth500) + } + + func testGridRawTokenGridMinWidth500LessThanGridMinWidth600() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidth500, GridRawTokens.gridMinWidth600) + } + + func testGridRawTokenGridMinWidth600LessThanGridMinWidth700() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidth600, GridRawTokens.gridMinWidth700) + } + + func testGridRawTokenGridMinWidth700LessThanGridMinWidth800() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidth700, GridRawTokens.gridMinWidth800) + } + + func testGridRawTokenGridMinWidthExtraCompactLessThanGridMinWidthCompact() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidthExtraCompact, GridRawTokens.gridMinWidthCompact) } - func testGridRawTokenGridMinWidthIOSExtraCompactLessThanGridMinWidthIOSRegular() throws { - XCTAssertLessThan(GridRawTokens.gridMinWidthIOSExtraCompact, GridRawTokens.gridMinWidthIOSRegular) + func testGridRawTokenGridMinWidthExtraCompactLessThanGridMinWidthRegular() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidthExtraCompact, GridRawTokens.gridMinWidthRegular) } - func testGridRawTokenGridMinWidthIOSCompactLessThanGridMinWidthIOSRegular() throws { - XCTAssertLessThan(GridRawTokens.gridMinWidthIOSCompact, GridRawTokens.gridMinWidthIOSRegular) + func testGridRawTokenGridMinWidthCompactLessThanGridMinWidthRegular() throws { + XCTAssertLessThan(GridRawTokens.gridMinWidthCompact, GridRawTokens.gridMinWidthRegular) } // MARK: - Primitive token - Grid - Max width - func testGridRawTokenGridMaxWidthIOSExtraCompactLessThanGridMaxWidthIOSCompact() throws { - XCTAssertLessThan(GridRawTokens.gridMaxWidthIOSExtraCompact, GridRawTokens.gridMaxWidthIOSCompact) + func testGridRawTokenGridMaxWidth100LessThanGridMaxWidth200() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth100, GridRawTokens.gridMaxWidth200) + } + + func testGridRawTokenGridMaxWidth200LessThanGridMaxWidth300() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth200, GridRawTokens.gridMaxWidth300) + } + + func testGridRawTokenGridMaxWidth300LessThanGridMaxWidth400() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth300, GridRawTokens.gridMaxWidth400) + } + + func testGridRawTokenGridMaxWidth400LessThanGridMaxWidth500() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth400, GridRawTokens.gridMaxWidth500) + } + + func testGridRawTokenGridMaxWidth500LessThanGridMaxWidth600() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth500, GridRawTokens.gridMaxWidth600) + } + + func testGridRawTokenGridMaxWidth600LessThanGridMaxWidth650() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth600, GridRawTokens.gridMaxWidth650) + } + + func testGridRawTokenGridMaxWidth650LessThanGridMaxWidth700() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth650, GridRawTokens.gridMaxWidth700) + } + + func testGridRawTokenGridMaxWidth700LessThanGridMaxWidth800() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidth700, GridRawTokens.gridMaxWidth800) + } + + func testGridRawTokenGridMaxWidthExtraCompactLessThanGridMaxWidthCompact() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidthExtraCompact, GridRawTokens.gridMaxWidthCompact) } - func testGridRawTokenGridMaxWidthIOSExtraCompactLessThanGridMaxWidthIOSRegular() throws { - XCTAssertLessThan(GridRawTokens.gridMaxWidthIOSExtraCompact, GridRawTokens.gridMaxWidthIOSRegular) + func testGridRawTokenGridMaxWidthExtraCompactLessThanGridMaxWidthRegular() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidthExtraCompact, GridRawTokens.gridMaxWidthRegular) } - func testGridRawTokenGridMaxWidthIOSCompactLessThanGridMaxWidthIOSRegular() throws { - XCTAssertLessThan(GridRawTokens.gridMaxWidthIOSCompact, GridRawTokens.gridMaxWidthIOSRegular) + func testGridRawTokenGridMaxWidthCompactLessThanGridMaxWidthRegular() throws { + XCTAssertLessThan(GridRawTokens.gridMaxWidthCompact, GridRawTokens.gridMaxWidthRegular) } // MARK: - Primitive token - Grid - Margin @@ -109,62 +172,122 @@ final class GridRawTokensTests: XCTestCase { XCTAssertLessThan(GridRawTokens.gridMargin100, GridRawTokens.gridMargin300) } + func testGridRawTokenMargin100MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin100, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin300LessThanGridMargin400() throws { XCTAssertLessThan(GridRawTokens.gridMargin300, GridRawTokens.gridMargin400) } + func testGridRawTokenMargin300MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin300, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin400LessThanGridMargin500() throws { XCTAssertLessThan(GridRawTokens.gridMargin400, GridRawTokens.gridMargin500) } + func testGridRawTokenMargin400MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin400, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin500LessThanGridMargin600() throws { XCTAssertLessThan(GridRawTokens.gridMargin500, GridRawTokens.gridMargin600) } + func testGridRawTokenMargin500MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin500, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin600LessThanGridMargin700() throws { XCTAssertLessThan(GridRawTokens.gridMargin600, GridRawTokens.gridMargin700) } + func testGridRawTokenMargin600MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin600, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin700LessThanGridMargin900() throws { XCTAssertLessThan(GridRawTokens.gridMargin700, GridRawTokens.gridMargin900) } + func testGridRawTokenMargin700MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin700, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin900LessThanGridMargin1000() throws { XCTAssertLessThan(GridRawTokens.gridMargin900, GridRawTokens.gridMargin1000) } + func testGridRawTokenMargin900MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin900, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin1000LessThanGridMargin1100() throws { XCTAssertLessThan(GridRawTokens.gridMargin1000, GridRawTokens.gridMargin1100) } + func testGridRawTokenMargin1000MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin1000, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin1100LessThanGridMargin1700() throws { XCTAssertLessThan(GridRawTokens.gridMargin1100, GridRawTokens.gridMargin1700) } + func testGridRawTokenMargin1700MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin1700, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridMargin1700LessThanGridMargin2500() throws { XCTAssertLessThan(GridRawTokens.gridMargin1700, GridRawTokens.gridMargin2500) } + func testGridRawTokenMargin2500MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridMargin2500, factor: Self.gridRawTokensDimensionBase) + } + // MARK: - Primitive token - Grid - Column gap func testGridRawTokenGridColumnGap10LessThanGridColumnGap100() throws { XCTAssertLessThan(GridRawTokens.gridColumnGap10, GridRawTokens.gridColumnGap100) } + func testGridRawTokenColumnGap10MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridColumnGap10, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridColumnGap100LessThanGridColumnGap200() throws { XCTAssertLessThan(GridRawTokens.gridColumnGap100, GridRawTokens.gridColumnGap200) } + func testGridRawTokenColumnGap100MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridColumnGap100, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridColumnGap200LessThanGridColumnGap300() throws { XCTAssertLessThan(GridRawTokens.gridColumnGap200, GridRawTokens.gridColumnGap300) } + func testGridRawTokenColumnGap200MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridColumnGap200, factor: Self.gridRawTokensDimensionBase) + } + func testGridRawTokenGridColumnGap300LessThanGridColumnGap500() throws { - XCTAssertLessThan(GridRawTokens.gridColumnGap300, GridRawTokens.gridColumnGap500) + XCTAssertLessThan(GridRawTokens.gridColumnGap300, GridRawTokens.gridColumnGap600) + } + + func testGridRawTokenColumnGap300MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridColumnGap300, factor: Self.gridRawTokensDimensionBase) + } + + func testGridRawTokenGridColumnGap600LessThanGridColumnGap700() throws { + XCTAssertLessThan(GridRawTokens.gridColumnGap600, GridRawTokens.gridColumnGap700) } - func testGridRawTokenGridColumnGap500LessThanGridColumnGap700() throws { - XCTAssertLessThan(GridRawTokens.gridColumnGap500, GridRawTokens.gridColumnGap700) + func testGridRawTokenColumnGap700MultipleOfBase() throws { + XCTAssertMultipleOf(GridRawTokens.gridColumnGap700, factor: Self.gridRawTokensDimensionBase) } // MARK: - Primitive token - Grid - Column count diff --git a/OUDS/Core/Tokens/RawTokens/Tests/OpacityRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/OpacityRawTokensTests.swift index e786c0e49..d0157cb98 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/OpacityRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/OpacityRawTokensTests.swift @@ -25,31 +25,75 @@ final class OpacityRawTokensTests: XCTestCase { XCTAssertLessThan(OpacityRawTokens.opacity0, OpacityRawTokens.opacity100) } + func testOpacityRawToken0Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity0, max: 1) + } + func testOpacityRawToken100LessThan200() throws { XCTAssertLessThan(OpacityRawTokens.opacity100, OpacityRawTokens.opacity200) } + func testOpacityRawToken100Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity100, max: 1) + } + func testOpacityRawToken200LessThan300() throws { XCTAssertLessThan(OpacityRawTokens.opacity200, OpacityRawTokens.opacity300) } + func testOpacityRawToken200Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity200, max: 1) + } + func testOpacityRawToken300LessThan400() throws { XCTAssertLessThan(OpacityRawTokens.opacity300, OpacityRawTokens.opacity400) } + func testOpacityRawToken300Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity300, max: 1) + } + func testOpacityRawToken400LessThan500() throws { XCTAssertLessThan(OpacityRawTokens.opacity400, OpacityRawTokens.opacity500) } + func testOpacityRawToken400Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity400, max: 1) + } + func testOpacityRawToken500LessThan600() throws { XCTAssertLessThan(OpacityRawTokens.opacity500, OpacityRawTokens.opacity600) } + func testOpacityRawToken500Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity500, max: 1) + } + func testOpacityRawToken600LessThan700() throws { XCTAssertLessThan(OpacityRawTokens.opacity600, OpacityRawTokens.opacity700) } + func testOpacityRawToken600Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity600, max: 1) + } + func testOpacityRawToken700LessThan800() throws { XCTAssertLessThan(OpacityRawTokens.opacity700, OpacityRawTokens.opacity800) } + + func testOpacityRawToken700Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity700, max: 1) + } + + func testOpacityRawToken800LessThan900() throws { + XCTAssertLessThan(OpacityRawTokens.opacity800, OpacityRawTokens.opacity900) + } + + func testOpacityRawToken800Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity800, max: 1) + } + + func testOpacityRawToken900Between0and1() throws { + XCTAssertBetween(min: 0, OpacityRawTokens.opacity900, max: 1) + } } diff --git a/OUDS/Core/Tokens/RawTokens/Tests/TypographyRawTokensTests.swift b/OUDS/Core/Tokens/RawTokens/Tests/TypographyRawTokensTests.swift index eee3e842d..5c3fb4680 100644 --- a/OUDS/Core/Tokens/RawTokens/Tests/TypographyRawTokensTests.swift +++ b/OUDS/Core/Tokens/RawTokens/Tests/TypographyRawTokensTests.swift @@ -21,6 +21,30 @@ import OUDSTokensRaw /// Thus this tests class just checks if such relationships are still here whatever the values at the end. final class TypographyRawTokensTests: XCTestCase { + // MARK: - Primitive token - Typography - Font family + + // Just to ensure the font families in tokens are the ones in system with the same name + + func testTypographyRawTokenFontFamilyBrandDefault() throws { + XCTAssertEqual(TypographyRawTokens.fontFamilyBrandDefault, "Helvetica Neue") + } + + func testTypographyRawTokenFontFamilySystemArial() throws { + XCTAssertEqual(TypographyRawTokens.fontFamilySystemArial, "Arial") + } + + func testTypographyRawTokenFontFamilySystemHelvetica() throws { + XCTAssertEqual(TypographyRawTokens.fontFamilySystemHelvetica, "Helvetica") + } + + func testTypographyRawTokenFontFamilyMonospaceMenlo() throws { + XCTAssertEqual(TypographyRawTokens.fontFamilyMonospaceMenlo, "Menlo") + } + + func testTypographyRawTokenFontFamilyCourrierNew() throws { + XCTAssertEqual(TypographyRawTokens.fontFamilyMonospaceCourierNew, "Courier New") + } + // MARK: - Primitive token - Typography - Font size func testTypographyRawTokensFontSize100LessThanFontSize150() throws { @@ -149,24 +173,13 @@ final class TypographyRawTokensTests: XCTestCase { XCTAssertLessThan(TypographyRawTokens.fontLineHeight1850, TypographyRawTokens.fontLineHeight2050) } - // MARK: - Primitive token - Typography - Paragraph spacing - - func testTypographyRawTokensFontParagraphSpacing100LessThanFontParagraphSpacing200() throws { - XCTAssertLessThan(TypographyRawTokens.fontParagraphSpacing100, TypographyRawTokens.fontParagraphSpacing200) - } - - func testTypographyRawTokensFontParagraphSpacing200LessThanFontParagraphSpacing300() throws { - XCTAssertLessThan(TypographyRawTokens.fontParagraphSpacing200, TypographyRawTokens.fontParagraphSpacing300) - } - - func testTypographyRawTokensFontParagraphSpacing300LessThanFontParagraphSpacing400() throws { - XCTAssertLessThan(TypographyRawTokens.fontParagraphSpacing300, TypographyRawTokens.fontParagraphSpacing400) - } - // MARK: - Primitive token - Typography - Font family func testTypographyRawTokensFontFamiliesAreAllDifferent() throws { - XCTAssertNotEqual(TypographyRawTokens.fontFamilySystem, TypographyRawTokens.fontFamilyMonospace) + XCTAssertNotEqual(TypographyRawTokens.fontFamilyBrandDefault, TypographyRawTokens.fontFamilySystemArial) + XCTAssertNotEqual(TypographyRawTokens.fontFamilySystemArial, TypographyRawTokens.fontFamilySystemHelvetica) + XCTAssertNotEqual(TypographyRawTokens.fontFamilySystemHelvetica, TypographyRawTokens.fontFamilyMonospaceMenlo) + XCTAssertNotEqual(TypographyRawTokens.fontFamilyMonospaceMenlo, TypographyRawTokens.fontFamilyMonospaceCourierNew) } // MARK: - Primitive token - Typography - Font weight @@ -210,79 +223,117 @@ final class TypographyRawTokensTests: XCTestCase { // MARK: - Primitive token - Typography - Composite - func testTypographyRawTokensTypeRegular150SizeLessThanTypeRegular175Size() throws { + func testTypographyRawTokensTypeRegular150LessThanTypeRegular175() throws { XCTAssertLessThan(TypographyRawTokens.typeRegular150.size, TypographyRawTokens.typeRegular175.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeRegular150.lineHeight, TypographyRawTokens.typeRegular175.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeRegular150.weight, TypographyRawTokens.typeRegular175.weight) } - func testTypographyRawTokensTypeRegular175SizeLessThanTypeRegular200Size() throws { + func testTypographyRawTokensTypeRegular175LessThanTypeRegular200() throws { XCTAssertLessThan(TypographyRawTokens.typeRegular175.size, TypographyRawTokens.typeRegular200.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeRegular175.lineHeight, TypographyRawTokens.typeRegular200.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeRegular175.weight, TypographyRawTokens.typeRegular200.weight) } - func testTypographyRawTokensTypeRegular200SizeLessThanTypeRegular250Size() throws { + func testTypographyRawTokensTypeRegular200LessThanTypeRegular250() throws { XCTAssertLessThan(TypographyRawTokens.typeRegular200.size, TypographyRawTokens.typeRegular250.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeRegular200.lineHeight, TypographyRawTokens.typeRegular250.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeRegular200.weight, TypographyRawTokens.typeRegular250.weight) } - func testTypographyRawTokensTypeBold150SizeLessThanTypeBold175Size() throws { + func testTypographyRawTokensTypeBold150LessThanTypeBold175() throws { XCTAssertLessThan(TypographyRawTokens.typeBold150.size, TypographyRawTokens.typeBold175.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold150.lineHeight, TypographyRawTokens.typeBold175.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold150.weight, TypographyRawTokens.typeBold175.weight) } - func testTypographyRawTokensTypeBold175SizeLessThanTypeBold200Size() throws { + func testTypographyRawTokensTypeBold175LessThanTypeBold200() throws { XCTAssertLessThan(TypographyRawTokens.typeBold175.size, TypographyRawTokens.typeBold200.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold175.lineHeight, TypographyRawTokens.typeBold200.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold175.weight, TypographyRawTokens.typeBold200.weight) } - func testTypographyRawTokensTypeBold200SizeLessThanTypeBold250Size() throws { + func testTypographyRawTokensTypeBold200LessThanTypeBold250() throws { XCTAssertLessThan(TypographyRawTokens.typeBold200.size, TypographyRawTokens.typeBold250.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold200.lineHeight, TypographyRawTokens.typeBold250.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold200.weight, TypographyRawTokens.typeBold250.weight) } - func testTypographyRawTokensTypeBold250SizeLessThanTypeBold300Size() throws { + func testTypographyRawTokensTypeBold250LessThanTypeBold300() throws { XCTAssertLessThan(TypographyRawTokens.typeBold250.size, TypographyRawTokens.typeBold300.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold250.lineHeight, TypographyRawTokens.typeBold300.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold250.weight, TypographyRawTokens.typeBold300.weight) } - func testTypographyRawTokensTypeBold300SizeLessThanTypeBold350Size() throws { + func testTypographyRawTokensTypeBold300LessThanTypeBold350() throws { XCTAssertLessThan(TypographyRawTokens.typeBold300.size, TypographyRawTokens.typeBold350.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold300.lineHeight, TypographyRawTokens.typeBold350.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold300.weight, TypographyRawTokens.typeBold350.weight) } - func testTypographyRawTokensTypeBold350SizeLessThanTypeBold450Size() throws { + func testTypographyRawTokensTypeBold350LessThanTypeBold450() throws { XCTAssertLessThan(TypographyRawTokens.typeBold350.size, TypographyRawTokens.typeBold450.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold350.lineHeight, TypographyRawTokens.typeBold450.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold350.weight, TypographyRawTokens.typeBold450.weight) } - func testTypographyRawTokensTypeBold450SizeLessThanTypeBold550Size() throws { + func testTypographyRawTokensTypeBold450LessThanTypeBold550() throws { XCTAssertLessThan(TypographyRawTokens.typeBold450.size, TypographyRawTokens.typeBold550.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold450.lineHeight, TypographyRawTokens.typeBold550.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold450.weight, TypographyRawTokens.typeBold550.weight) } - func testTypographyRawTokensTypeBold550SizeLessThanTypeBold650Size() throws { + func testTypographyRawTokensTypeBold550LessThanTypeBold650() throws { XCTAssertLessThan(TypographyRawTokens.typeBold550.size, TypographyRawTokens.typeBold650.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold550.lineHeight, TypographyRawTokens.typeBold650.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold550.weight, TypographyRawTokens.typeBold650.weight) } - func testTypographyRawTokensTypeBold650SizeLessThanTypeBold750Size() throws { + func testTypographyRawTokensTypeBold650LessThanTypeBold750() throws { XCTAssertLessThan(TypographyRawTokens.typeBold650.size, TypographyRawTokens.typeBold750.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold650.lineHeight, TypographyRawTokens.typeBold750.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold650.weight, TypographyRawTokens.typeBold750.weight) } - func testTypographyRawTokensTypeBold750SizeLessThanTypeBold850Size() throws { + func testTypographyRawTokensTypeBold750LessThanTypeBold850() throws { XCTAssertLessThan(TypographyRawTokens.typeBold750.size, TypographyRawTokens.typeBold850.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold750.lineHeight, TypographyRawTokens.typeBold850.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold750.weight, TypographyRawTokens.typeBold850.weight) } - func testTypographyRawTokensTypeBold850SizeLessThanTypeBold950Size() throws { + func testTypographyRawTokensTypeBold850LessThanTypeBold950() throws { XCTAssertLessThan(TypographyRawTokens.typeBold850.size, TypographyRawTokens.typeBold950.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold850.lineHeight, TypographyRawTokens.typeBold950.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold850.weight, TypographyRawTokens.typeBold950.weight) } - func testTypographyRawTokensTypeBold950SizeLessThanTypeBold1050Size() throws { + func testTypographyRawTokensTypeBold950LessThanTypeBold1050() throws { XCTAssertLessThan(TypographyRawTokens.typeBold950.size, TypographyRawTokens.typeBold1050.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold950.lineHeight, TypographyRawTokens.typeBold1050.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold950.weight, TypographyRawTokens.typeBold1050.weight) } - func testTypographyRawTokensTypeBold1050SizeLessThanTypeBold1150Size() throws { + func testTypographyRawTokensTypeBold1050LessThanTypeBold1150() throws { XCTAssertLessThan(TypographyRawTokens.typeBold1050.size, TypographyRawTokens.typeBold1150.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1050.lineHeight, TypographyRawTokens.typeBold1150.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1050.weight, TypographyRawTokens.typeBold1150.weight) } - func testTypographyRawTokensTypeBold1150SizeLessThanTypeBold1250Size() throws { + func testTypographyRawTokensTypeBold1150LessThanTypeBold1250() throws { XCTAssertLessThan(TypographyRawTokens.typeBold1150.size, TypographyRawTokens.typeBold1250.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1150.lineHeight, TypographyRawTokens.typeBold1250.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1150.weight, TypographyRawTokens.typeBold1250.weight) } - func testTypographyRawTokensTypeBold1250SizeLessThanTypeBold1450Size() throws { + func testTypographyRawTokensTypeBold1250LessThanTypeBold1450() throws { XCTAssertLessThan(TypographyRawTokens.typeBold1250.size, TypographyRawTokens.typeBold1450.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1250.lineHeight, TypographyRawTokens.typeBold1450.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1250.weight, TypographyRawTokens.typeBold1450.weight) } - func testTypographyRawTokensTypeBold1450SizeLessThanTypeBold1850Size() throws { + func testTypographyRawTokensTypeBold1450LessThanTypeBold1850() throws { XCTAssertLessThan(TypographyRawTokens.typeBold1450.size, TypographyRawTokens.typeBold1850.size) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1450.lineHeight, TypographyRawTokens.typeBold1850.lineHeight) + XCTAssertLessThanOrEqual(TypographyRawTokens.typeBold1450.weight, TypographyRawTokens.typeBold1850.weight) } } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/SizingSemanticTokens+Composites.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/SizingSemanticTokens+Composites.swift new file mode 100644 index 000000000..f6d5efb46 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/SizingSemanticTokens+Composites.swift @@ -0,0 +1,41 @@ +// +// 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 + +/// Composite semantic tokens which will wrap a combination of `SizingWidthHeightSemanticToken` depending to viewports / size classes. +public final class SizingCompositeSemanticToken: NSObject { + + /// For **extra-compact** and **compact** viewports + public let compact: SizingWidthHeightSemanticToken + + /// For **regular** and **medium** viewports + public let regular: SizingWidthHeightSemanticToken + + /// Initializes a new sizing composite semantic token. + /// - Parameters: + /// - compact: The `SizingWidthHeightSemanticToken` to apply if device in *compact* mode + /// - regular: The `SizingWidthHeightSemanticToken` to apply if device in *regular* mode + public init(compact: SizingWidthHeightSemanticToken, regular: SizingWidthHeightSemanticToken) { + self.compact = compact + self.regular = regular + } + + /// Returns `true` if `self` and `object` has the same `compact` and `regular` values and with `object` + /// as a `SizingCompositeSemanticToken`. Otherwise returns `false`. + /// `isEqual` override is preferred for `NSObject`. + public override func isEqual(_ object: Any?) -> Bool { + guard let other = object as? SizingCompositeSemanticToken else { return false } + return self.compact == other.compact && self.regular == other.regular + } +} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/SpacingSemanticTokens+Composites.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/SpacingSemanticTokens+Composites.swift new file mode 100644 index 000000000..ac0a91606 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/SpacingSemanticTokens+Composites.swift @@ -0,0 +1,42 @@ +// +// 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. +// ww +// Authors: See CONTRIBUTORS.txt +// Software description: A SwiftUI components library with code examples for Orange Unified Design System +// + +import Foundation +import OUDSTokensRaw + +/// Composite semantic tokens which will wrap a combination of `DimensionRawToken` depending to viewports. +public final class SpacingCompositeSemanticToken: NSObject { + + /// For **extra-compact** and **compact** viewports + public let compact: DimensionRawToken + + /// For **regular** and **medium** viewports + public let regular: DimensionRawToken + + /// Initializes a new spacing composite semantic token. + /// - Parameters: + /// - compact: The `DimensionRawToken` to apply if device in *compact* mode + /// - regular: The `DimensionRawToken` to apply if device in *regular* mode + public init(compact: DimensionRawToken, regular: DimensionRawToken) { + self.compact = compact + self.regular = regular + } + + /// Returns `true` if `self` and `object` has the same `compact` and `regular` values and with `object` + /// as a `SpacingCompositeSemanticToken`. Otherwise returns `false`. + /// `isEqual` override is preferred for `NSObject`. + public override func isEqual(_ object: Any?) -> Bool { + guard let other = object as? SpacingCompositeSemanticToken else { return false } + return self.compact == other.compact && self.regular == other.regular + } +} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/TypographySemanticTokens+Composites.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/TypographySemanticTokens+Composites.swift new file mode 100644 index 000000000..d0373a422 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Composites/TypographySemanticTokens+Composites.swift @@ -0,0 +1,42 @@ +// +// 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 + +/// Composite semantic tokens which will wrap a combination of `TypographyCompositeRawToken` depending to viewports. +public final class TypographyCompositeSemanticToken: NSObject { + + /// For **extra-compact** and **compact** viewports + public let compact: TypographyCompositeRawToken + + /// For **regular** and **medium** viewports + public let regular: TypographyCompositeRawToken + + /// Initializes a new typography composite semantic token. + /// - Parameters: + /// - compact: The `TypographyCompositeRawToken` to apply if device in *compact* mode + /// - regular: The `TypographyCompositeRawToken` to apply if device in *regular* mode + public init(compact: TypographyCompositeRawToken, regular: TypographyCompositeRawToken) { + self.compact = compact + self.regular = regular + } + + /// Returns `true` if `self` and `object` has the same `compact` and `regular` values and with `object` + /// as a `TypographyCompositeSemanticToken`. Otherwise returns `false`. + /// `isEqual` override is preferred for `NSObject`. + public override func isEqual(_ object: Any?) -> Bool { + guard let object = object as? TypographyCompositeSemanticToken else { return false } + return self.compact == object.compact && self.regular == object.regular + } +} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/ElevationSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/ElevationSemanticTokens.swift deleted file mode 100644 index 739861e26..000000000 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/ElevationSemanticTokens.swift +++ /dev/null @@ -1,171 +0,0 @@ -// -// 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 - -// MARK: - Type aliases to keep grammar clear - -public typealias ElevationZIndexSemanticToken = ElevationRawToken -public typealias ElevationXSemanticToken = ElevationRawToken -public typealias ElevationYSemanticToken = ElevationRawToken -public typealias ElevationBlurSemanticToken = ElevationRawToken -public typealias ElevationSpreadSemanticToken = ElevationRawToken -public typealias ElevationColorSemanticToken = ColorRawToken -public typealias ElevationBoxShadowSemanticToken = ElevationBoxShadowRawToken - -// MARK: - Semantic tokens - -/// This is a group of semantic tokens for **elevations**. -/// It defines all elevation semantic tokens a theme must have. (`ElevationZIndexSemanticToken`,`ElevationXSemanticToken`,`ElevationYSemanticToken`, -/// `ElevationBlurSemanticToken`,`ElevationSpreadSemanticToken` and `ElevationColorSemanticToken`) -public protocol ElevationSemanticTokens { - - // MARK: Semantic token - Elevation - Z index - - var elevationZIndexDeep: ElevationZIndexSemanticToken { get } - var elevationZIndexDefault: ElevationZIndexSemanticToken { get } - var elevationZIndexDropdown: ElevationZIndexSemanticToken { get } - var elevationZIndexSticky: ElevationZIndexSemanticToken { get } - var elevationZIndexFixed: ElevationZIndexSemanticToken { get } - var elevationZIndexBackToTop: ElevationZIndexSemanticToken { get } - var elevationZIndexSpinner: ElevationZIndexSemanticToken { get } - var elevationZIndexOffCanvasBackdrop: ElevationZIndexSemanticToken { get } - var elevationZIndexOffCanvas: ElevationZIndexSemanticToken { get } - var elevationZIndexModalBackdrop: ElevationZIndexSemanticToken { get } - var elevationZIndexModal: ElevationZIndexSemanticToken { get } - var elevationZIndexPopover: ElevationZIndexSemanticToken { get } - var elevationZIndexTooltip: ElevationZIndexSemanticToken { get } - var elevationZIndexToast: ElevationZIndexSemanticToken { get } - - // MARK: Semantic token - Elevation - X - - var elevationXNone: ElevationZIndexSemanticToken { get } - var elevationXRaised: ElevationZIndexSemanticToken { get } - var elevationXDrag: ElevationZIndexSemanticToken { get } - var elevationXOverlayDefault: ElevationZIndexSemanticToken { get } - var elevationXOverlayEmphasis: ElevationZIndexSemanticToken { get } - var elevationXStickyDefault: ElevationZIndexSemanticToken { get } - var elevationXStickyEmphasis: ElevationZIndexSemanticToken { get } - var elevationXStickyNavigationScrolled: ElevationZIndexSemanticToken { get } - var elevationXFocus: ElevationZIndexSemanticToken { get } - - // MARK: Semantic token - Elevation - Y - - var elevationYNone: ElevationZIndexSemanticToken { get } - var elevationYRaised: ElevationZIndexSemanticToken { get } - var elevationYDrag: ElevationZIndexSemanticToken { get } - var elevationYOverlayDefault: ElevationZIndexSemanticToken { get } - var elevationYOverlayEmphasis: ElevationZIndexSemanticToken { get } - var elevationYStickyDefault: ElevationZIndexSemanticToken { get } - var elevationYStickyEmphasis: ElevationZIndexSemanticToken { get } - var elevationYStickyNavigationScrolled: ElevationZIndexSemanticToken { get } - var elevationYFocus: ElevationZIndexSemanticToken { get } - - // MARK: Semantic token - Elevation - Blur - - var elevationBlurNone: ElevationBlurSemanticToken { get } - var elevationBlurRaised: ElevationBlurSemanticToken { get } - var elevationBlurDrag: ElevationBlurSemanticToken { get } - var elevationBlurOverlayDefault: ElevationBlurSemanticToken { get } - var elevationBlurOverlayEmphasis: ElevationBlurSemanticToken { get } - var elevationBlurStickyDefault: ElevationBlurSemanticToken { get } - var elevationBlurStickyEmphasis: ElevationBlurSemanticToken { get } - var elevationBlurStickyNavigationScrolled: ElevationBlurSemanticToken { get } - var elevationBlurFocus: ElevationBlurSemanticToken { get } - - // MARK: Semantic token - Elevation - Spread - - var elevationSpreadNone: ElevationSpreadSemanticToken { get } - var elevationSpreadRaised: ElevationSpreadSemanticToken { get } - var elevationSpreadDrag: ElevationSpreadSemanticToken { get } - var elevationSpreadOverlayDefault: ElevationSpreadSemanticToken { get } - var elevationSpreadOverlayEmphasis: ElevationSpreadSemanticToken { get } - var elevationSpreadStickyDefault: ElevationSpreadSemanticToken { get } - var elevationSpreadStickyEmphasis: ElevationSpreadSemanticToken { get } - var elevationSpreadStickyNavigationScrolled: ElevationSpreadSemanticToken { get } - var elevationSpreadFocus: ElevationSpreadSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - None - - var elevationColorNoneLight: ElevationColorSemanticToken { get } - var elevationColorNoneDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Raised - - var elevationColorRaisedLight: ElevationColorSemanticToken { get } - var elevationColorRaisedDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Drag - - var elevationColorDragLight: ElevationColorSemanticToken { get } - var elevationColorDragDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Overlay - Default - - var elevationColorOverlayDefaultLight: ElevationColorSemanticToken { get } - var elevationColorOverlayDefaultDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Overlay - Emphasis - - var elevationColorOverlayEmphasisLight: ElevationColorSemanticToken { get } - var elevationColorOverlayEmphasisDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Sticky - Default - - var elevationColorStickyDefaultLight: ElevationColorSemanticToken { get } - var elevationColorStickyDefaultDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Sticky - Emphasis - - var elevationColorStickyEmphasisLight: ElevationColorSemanticToken { get } - var elevationColorStickyEmphasisDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Sticky - Navigation scrolled - - var elevationColorStickyNavigationScrolledLight: ElevationColorSemanticToken { get } - var elevationColorStickyNavigationScrolledDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Color - Focus - - var elevationColorFocusLight: ElevationColorSemanticToken { get } - var elevationColorFocusDark: ElevationColorSemanticToken { get } - - // MARK: Semantic token - Elevation - Bow shadow - - // TODO: Missing elevationBoxShadowNoneLight semantic token - - var elevationBoxShadowRaisedLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowRaisedDark: ElevationBoxShadowSemanticToken { get } - - var elevationBoxShadowDragLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowDragDark: ElevationBoxShadowSemanticToken { get } - - var elevationBoxShadowOverlayDefaultLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowOverlayDefaultDark: ElevationBoxShadowSemanticToken { get } - - var elevationBoxShadowOverlayEmphasisLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowOverlayEmphasisDark: ElevationBoxShadowSemanticToken { get } - - var elevationBoxShadowStickyDefaultLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowStickyDefaultDark: ElevationBoxShadowSemanticToken { get } - - var elevationBoxShadowStickyEmphasisLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowStickyEmphasisDark: ElevationBoxShadowSemanticToken { get } - - var elevationBoxShadowStickyNavigationScrolledLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowStickyNavigationScrolledDark: ElevationBoxShadowSemanticToken { get } - - var elevationBoxShadowFocusLight: ElevationBoxShadowSemanticToken { get } - var elevationBoxShadowFocusDark: ElevationBoxShadowSemanticToken { get } -} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/GridSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/GridSemanticTokens.swift deleted file mode 100644 index 0a679d8b6..000000000 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/GridSemanticTokens.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// 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 - -// MARK: - Type aliases to keep grammar clear - -public typealias GridIOSExtraCompactSemanticToken = GridRawToken -public typealias GridIOSCompactSemanticToken = GridRawToken -public typealias GridIOSRegularSemanticToken = GridRawToken - -// MARK: - Semantic tokens - -/// This is a group of semantic tokens for **grids**. -/// It defines all `GridSemanticToken` a theme must have. -public protocol GridSemanticTokens { - - // MARK: Semantic token - Grid - iOS Extra compact - - var gridIOSExtraCompactDesignWidth: GridIOSExtraCompactSemanticToken { get } - var gridIOSExtraCompactMinWidth: GridIOSExtraCompactSemanticToken { get } - var gridIOSExtraCompactMaxWidth: GridIOSExtraCompactSemanticToken { get } - var gridIOSExtraCompactMargin: GridIOSExtraCompactSemanticToken { get } - var gridIOSExtraCompactColumnGap: GridIOSExtraCompactSemanticToken { get } - var gridIOSExtraCompactColumnCount: GridIOSExtraCompactSemanticToken { get } - - // MARK: Semantic token - Grid - iOS Compact - - var gridIOSCompactDesignWidth: GridIOSCompactSemanticToken { get } - var gridIOSCompactMinWidth: GridIOSCompactSemanticToken { get } - var gridIOSCompactMaxWidth: GridIOSCompactSemanticToken { get } - var gridIOSCompactMargin: GridIOSCompactSemanticToken { get } - var gridIOSCompactColumnGap: GridIOSCompactSemanticToken { get } - var gridIOSCompactColumnCount: GridIOSCompactSemanticToken { get } - - // MARK: Semantic token - Grid - iOS Regular - - var gridIOSRegularDesignWidth: GridIOSRegularSemanticToken { get } - var gridIOSRegularMinWidth: GridIOSRegularSemanticToken { get } - var gridIOSRegularMaxWidth: GridIOSRegularSemanticToken { get } - var gridIOSRegularMargin: GridIOSRegularSemanticToken { get } - var gridIOSRegularColumnGap: GridIOSRegularSemanticToken { get } - var gridIOSRegularColumnCount: GridIOSRegularSemanticToken { get } -} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/BorderSemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/BorderSemanticTokens+Aliases.swift new file mode 100644 index 000000000..35eeef37f --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/BorderSemanticTokens+Aliases.swift @@ -0,0 +1,23 @@ +// +// 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 OUDSTokensRaw + +/// Type alias precising `BorderWidthRawToken` is used as a value of this **border width semantic token**, to keep grammar clean and clear with design system grammar. +public typealias BorderWidthSemanticToken = BorderWidthRawToken + +/// Type alias precising `BorderRadiusRawToken` is used as a value of this **border raw semantic token**, to keep grammar clean and clear with design system grammar. +public typealias BorderRadiusSemanticToken = BorderRadiusRawToken + +/// Type alias precising `BorderStyleRawToken` is used as a value of this **border style semantic token**, to keep grammar clean and clear with design system grammar. +public typealias BorderStyleSemanticToken = BorderStyleRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/ColorSemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/ColorSemanticTokens+Aliases.swift new file mode 100644 index 000000000..433d13761 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/ColorSemanticTokens+Aliases.swift @@ -0,0 +1,20 @@ +// +// 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 OUDSTokensRaw + +/// Basically a semantic color token, which can be either a functional or a decorative token, is a `String`, to keep grammar clean and clear with design system grammar. +public typealias ColorSemanticToken = ColorRawToken + +/// The global design system tool defines aliases of semantic colors token as semantic color tokens, to keep grammar clean and clear with design system grammar. +public typealias ColorAliasSemanticToken = ColorSemanticToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/DimensionSemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/DimensionSemanticTokens+Aliases.swift new file mode 100644 index 000000000..6809e15e1 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/DimensionSemanticTokens+Aliases.swift @@ -0,0 +1,17 @@ +// +// 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 OUDSTokensRaw + +/// Basically a semantic token for dimensions is a raw token for dimensions, to keep grammar clean and clear with design system grammar. +public typealias DimensionSemanticToken = DimensionRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/ElevationSemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/ElevationSemanticTokens+Aliases.swift new file mode 100644 index 000000000..dfe4f183e --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/ElevationSemanticTokens+Aliases.swift @@ -0,0 +1,32 @@ +// +// 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 OUDSTokensRaw + +/// Basically an elevation semantic token for Z Index is a raw token for elevation, with the same final type, to keep grammar clean and clear with design system grammar. +public typealias ElevationZIndexSemanticToken = ElevationRawToken + +/// Basically an elevation semantic token for X offset is a raw token for elevation, with the same final type, to keep grammar clean and clear with design system grammar. +public typealias ElevationXSemanticToken = ElevationRawToken + +/// Basically an elevation semantic token for Y Index is a raw token for elevation, with the same final type, to keep grammar clean and clear with design system grammar. +public typealias ElevationYSemanticToken = ElevationRawToken + +/// Basically an elevation semantic token for blur effect is a raw token for elevation, with the same final type, to keep grammar clean and clear with design system grammar. +public typealias ElevationBlurSemanticToken = ElevationRawToken + +/// Basically an elevation semantic token for shadow colors is a raw token for colors, to keep grammar clean and clear with design system grammar. +public typealias ElevationColorSemanticToken = ColorRawToken + +/// Basically an elevation semantic token for box shadow is a raw token for box shadow, with the same final type, to keep grammar clean and clear with design system grammar. +public typealias ElevationCompositeSemanticToken = ElevationCompositeRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/GridSemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/GridSemanticTokens+Aliases.swift new file mode 100644 index 000000000..045ecb7ec --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/GridSemanticTokens+Aliases.swift @@ -0,0 +1,23 @@ +// +// 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 OUDSTokensRaw + +/// Basically a grid semantic token for iOS Extra Compact values is a grid raw token, to keep grammar clean and clear with design system grammar. +public typealias GridExtraCompactSemanticToken = GridRawToken + +/// Basically a grid semantic token for iOS Compact values is a grid raw token, to keep grammar clean and clear with design system grammar. +public typealias GridCompactSemanticToken = GridRawToken + +/// Basically a grid semantic token for iOS Regulard values is a grid raw token, to keep grammar clean and clear with design system grammar. +public typealias GridRegularSemanticToken = GridRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/OpacitySemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/OpacitySemanticTokens+Aliases.swift new file mode 100644 index 000000000..1e72f46e8 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/OpacitySemanticTokens+Aliases.swift @@ -0,0 +1,17 @@ +// +// 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 OUDSTokensRaw + +/// Basically an opacity semantic token is an opacity raw token, to keep grammar clean and clear with design system grammar. +public typealias OpacitySemanticToken = OpacityRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/SizingSemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/SizingSemanticTokens+Aliases.swift new file mode 100644 index 000000000..579359d81 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/SizingSemanticTokens+Aliases.swift @@ -0,0 +1,20 @@ +// +// 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 OUDSTokensRaw + +/// Basically a size semantic token for width and height is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SizingWidthHeightSemanticToken = DimensionRawToken + +/// Basically a size semantic token for max width is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SizingMaxWidthSemanticToken = DimensionRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/SpacingSemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/SpacingSemanticTokens+Aliases.swift new file mode 100644 index 000000000..2ca3c5cbd --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/SpacingSemanticTokens+Aliases.swift @@ -0,0 +1,32 @@ +// +// 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 OUDSTokensRaw + +/// Basically a space semantic token for layout is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SpacingLayoutSemanticToken = DimensionRawToken + +/// Basically a space semantic token for padding inline is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SpacingPaddingInlineSemanticToken = DimensionRawToken + +/// Basically a space semantic token for padding block is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SpacingPaddingBlockSemanticToken = DimensionRawToken + +/// Basically a space semantic token for padding inset is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SpacingPaddingInsetSemanticToken = DimensionRawToken + +/// Basically a space semantic token for gap inline is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SpacingGapInlineSemanticToken = DimensionRawToken + +/// Basically a space semantic token for gap stack is a dimension raw token, it has the same final type, to keep grammar clean and clear with design system grammar. +public typealias SpacingGapStackSemanticToken = DimensionRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/TypographySemanticTokens+Aliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/TypographySemanticTokens+Aliases.swift new file mode 100644 index 000000000..88e7441a4 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/TypeAliases/TypographySemanticTokens+Aliases.swift @@ -0,0 +1,26 @@ +// +// 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 OUDSTokensRaw + +/// The global design system tools uses verbs of semantic token for font family, which is basically a raw token for font family +public typealias TypographyFontFamilySemanticToken = TypographyFontFamilyRawToken + +/// The global design system tools uses verbs of semantic token for font weight, which is basically a raw token for font weight +public typealias TypographyFontWeightSemanticToken = TypographyFontWeightRawToken + +/// The global design system tools uses verbs of semantic token for font size, which is basically a raw token for font size +public typealias TypographyFontSizeSemanticToken = TypographyFontSizeRawToken + +/// The global design system tools uses verbs of semantic token for font line height, which is basically a raw token for font line height +public typealias TypographyFontLineHeightSemanticToken = TypographyFontLineHeightRawToken diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/BorderSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/BorderSemanticTokens.swift similarity index 63% rename from OUDS/Core/Tokens/SemanticTokens/Sources/BorderSemanticTokens.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Values/BorderSemanticTokens.swift index d1473a8b2..b6c849b22 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/BorderSemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/BorderSemanticTokens.swift @@ -11,22 +11,10 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import OUDSTokensRaw - -// MARK: - Type aliases to keep grammar clear - -/// Typeliases precising `BorderWidthRawToken` is used as a value of this **border width semantic token**. -public typealias BorderWidthSemanticToken = BorderWidthRawToken -/// Typeliases precising `BorderRadiusSemanticToken` is used as a value of t**his border raw semantic token**. -public typealias BorderRadiusSemanticToken = BorderRadiusRawToken -/// Typeliases precising `BorderStyleSemanticToken` is used as a value of this **border style semantic token**. -public typealias BorderStyleSemanticToken = BorderStyleRawToken - -// MARK: - Semantic tokens - /// This is a group of semantic tokens for **borders**. /// It defines all `BorderWidthSemanticToken`, `BorderRadiusSemanticToken` and `BorderStyleSemanticToken` a theme must have. +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. public protocol BorderSemanticTokens { // MARK: - Semantic token - Border - Width @@ -34,10 +22,10 @@ public protocol BorderSemanticTokens { var borderWidthNone: BorderWidthSemanticToken { get } var borderWidthDefault: BorderWidthSemanticToken { get } var borderWidthThin: BorderWidthSemanticToken { get } + var borderWidthMedium: BorderWidthSemanticToken { get } var borderWidthThick: BorderWidthSemanticToken { get } var borderWidthThicker: BorderWidthSemanticToken { get } - var borderWidthThickest: BorderWidthSemanticToken { get } - var borderWidthInterfactivePrimaryFocus: BorderWidthSemanticToken { get } + var borderWidthOutsideFocus: BorderWidthSemanticToken { get } // MARK: - Semantic token - Border - Radius @@ -46,8 +34,6 @@ public protocol BorderSemanticTokens { var borderRadiusShort: BorderRadiusSemanticToken { get } var borderRadiusMedium: BorderRadiusSemanticToken { get } var borderRadiusTall: BorderRadiusSemanticToken { get } - var borderRadiusPill: BorderRadiusSemanticToken { get } - // TODO: How to deal with "border-radius-circle"? // MARK: - Semantic token - Border - Style diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/ColorSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/ColorSemanticTokens.swift similarity index 78% rename from OUDS/Core/Tokens/SemanticTokens/Sources/ColorSemanticTokens.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Values/ColorSemanticTokens.swift index 5b0ca0acb..c2a7a74d4 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/ColorSemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/ColorSemanticTokens.swift @@ -11,19 +11,10 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import SwiftUI -import OUDSTokensRaw - -// MARK: - Type aliases to keep grammar clear - -public typealias ColorSemanticToken = String // ColorFunctionalRawToken and ColorFunctionalRawToken -public typealias ColorAliasSemanticToken = String - -// MARK: - Semantic tokens - /// This is a group of semantic tokens for **colors**. -/// It defines all `ColorSemanticToken` a theme must have. +/// It defines all `ColorSemanticToken` and `ColorAliasSemanticToken` a theme must have. +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. public protocol ColorSemanticTokens { // MARK: Semantic token - Colors - Alias - Primary @@ -67,16 +58,16 @@ public protocol ColorSemanticTokens { var sysColorBrandNeutralMutedHigher: ColorAliasSemanticToken? { get } var sysColorBrandNeutralMutedHighest: ColorAliasSemanticToken? { get } - // MARK: Semantic token - Colors - Alias - Neutral - Emphasis + // MARK: Semantic token - Colors - Alias - Neutral - Emphasized - var sysColorBrandNeutralEmphasisLowest: ColorAliasSemanticToken? { get } - var sysColorBrandNeutralEmphasisLower: ColorAliasSemanticToken? { get } - var sysColorBrandNeutralEmphasisLow: ColorAliasSemanticToken? { get } - var sysColorBrandNeutralEmphasisMedium: ColorAliasSemanticToken? { get } - var sysColorBrandNeutralEmphasisHigh: ColorAliasSemanticToken? { get } - var sysColorBrandNeutralEmphasisHigher: ColorAliasSemanticToken? { get } - var sysColorBrandNeutralEmphasisHighest: ColorAliasSemanticToken? { get } - var sysColorBrandNeutralEmphasisBlack: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedLowest: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedLower: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedLow: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedMedium: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedHigh: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedHigher: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedHighest: ColorAliasSemanticToken? { get } + var sysColorBrandNeutralEmphasizedBlack: ColorAliasSemanticToken? { get } // MARK: Semantic token - Colors - Alias - Positive @@ -143,15 +134,15 @@ public protocol ColorSemanticTokens { var colorBackgroundDefaultTertiaryLight: ColorSemanticToken? { get } var colorBackgroundDefaultTertiaryDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Background - Emphasis - Primary + // MARK: Semantic token - Colors - Background - Emphasized - Primary - var colorBackgroundEmphasisPrimaryLight: ColorSemanticToken? { get } - var colorBackgroundEmphasisPrimaryDark: ColorSemanticToken? { get } + var colorBackgroundEmphasizedPrimaryLight: ColorSemanticToken? { get } + var colorBackgroundEmphasizedPrimaryDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Background - Emphasis - Secondary + // MARK: Semantic token - Colors - Background - Emphasized - Secondary - var colorBackgroundEmphasisSecondaryLight: ColorSemanticToken? { get } - var colorBackgroundEmphasisSecondaryDark: ColorSemanticToken? { get } + var colorBackgroundEmphasizedSecondaryLight: ColorSemanticToken? { get } + var colorBackgroundEmphasizedSecondaryDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Background - Brand - Primary @@ -171,80 +162,80 @@ public protocol ColorSemanticTokens { var colorBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { get } var colorBackgroundStatusAttractiveMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Background - Status - Attractive - Emphasis + // MARK: Semantic token - Colors - Background - Status - Attractive - Emphasized - var colorBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken? { get } - var colorBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken? { get } + var colorBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken? { get } + var colorBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Background - Status - Warning - Muted var colorBackgroundStatusWarningMutedLight: ColorSemanticToken? { get } var colorBackgroundStatusWarningMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Background - Status - Warning - Emphasis + // MARK: Semantic token - Colors - Background - Status - Warning - Emphasized - var colorBackgroundStatusWarningEmphasisLight: ColorSemanticToken? { get } - var colorBackgroundStatusWarningEmphasisDark: ColorSemanticToken? { get } + var colorBackgroundStatusWarningEmphasizedLight: ColorSemanticToken? { get } + var colorBackgroundStatusWarningEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Background - Status - Negative - Muted var colorBackgroundStatusNegativeMutedLight: ColorSemanticToken? { get } var colorBackgroundStatusNegativeMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Background - Status - Negative - Emphasis + // MARK: Semantic token - Colors - Background - Status - Negative - Emphasized - var colorBackgroundStatusNegativeEmphasisLight: ColorSemanticToken? { get } - var colorBackgroundStatusNegativeEmphasisDark: ColorSemanticToken? { get } + var colorBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken? { get } + var colorBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Background - Status - Positive - Muted var colorBackgroundStatusPositiveMutedLight: ColorSemanticToken? { get } var colorBackgroundStatusPositiveMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Background - Status - Positive - Emphasis + // MARK: Semantic token - Colors - Background - Status - Positive - Emphasized - var colorBackgroundStatusPositiveEmphasisLight: ColorSemanticToken? { get } - var colorBackgroundStatusPositiveEmphasisDark: ColorSemanticToken? { get } + var colorBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken? { get } + var colorBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Background - Status - Information - Muted var colorBackgroundStatusInformationMutedLight: ColorSemanticToken? { get } var colorBackgroundStatusInformationMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Background - Status - Information - Emphasis + // MARK: Semantic token - Colors - Background - Status - Information - Emphasized - var colorBackgroundStatusInformationEmphasisLight: ColorSemanticToken? { get } - var colorBackgroundStatusInformationEmphasisDark: ColorSemanticToken? { get } + var colorBackgroundStatusInformationEmphasizedLight: ColorSemanticToken? { get } + var colorBackgroundStatusInformationEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Content - Default var colorContentDefaultLight: ColorSemanticToken? { get } var colorContentDefaultDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Content - Default - On background emphasis + // MARK: Semantic token - Colors - Content - Default - On background emphasized - var colorContentDefaultOnBackgroundEmphasisLight: ColorSemanticToken? { get } - var colorContentDefaultOnBackgroundEmphasisDark: ColorSemanticToken? { get } + var colorContentDefaultOnBackgroundEmphasizedLight: ColorSemanticToken? { get } + var colorContentDefaultOnBackgroundEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Content - Muted var colorContentMutedLight: ColorSemanticToken? { get } var colorContentMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Content - Muted - On background emphasis + // MARK: Semantic token - Colors - Content - Muted - On background emphasized - var colorContentMutedOnBackgroundEmphasisLight: ColorSemanticToken? { get } - var colorContentMutedOnBackgroundEmphasisDark: ColorSemanticToken? { get } + var colorContentMutedOnBackgroundEmphasizedLight: ColorSemanticToken? { get } + var colorContentMutedOnBackgroundEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Content - Brand - Primary var colorContentBrandPrimaryLight: ColorSemanticToken? { get } var colorContentBrandPrimaryDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Content - Brand - Primary - On background emphasis + // MARK: Semantic token - Colors - Content - Brand - Primary - On background emphasized - var colorContentBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken? { get } - var colorContentBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken? { get } + var colorContentBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken? { get } + var colorContentBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Content - Brand - Secondary @@ -281,30 +272,30 @@ public protocol ColorSemanticTokens { var colorBorderDefaultLight: ColorSemanticToken? { get } var colorBorderDefaultDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Border - Default - On background emphasis + // MARK: Semantic token - Colors - Border - Default - On background emphasized - var colorBorderDefaultOnBackgroundEmphasisLight: ColorSemanticToken? { get } - var colorBorderDefaultOnBackgroundEmphasisDark: ColorSemanticToken? { get } + var colorBorderDefaultOnBackgroundEmphasizedLight: ColorSemanticToken? { get } + var colorBorderDefaultOnBackgroundEmphasizedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Border - Emphasis + // MARK: Semantic token - Colors - Border - Emphasized - var colorBorderEmphasisLight: ColorSemanticToken? { get } - var colorBorderEmphasisDark: ColorSemanticToken? { get } + var colorBorderEmphasizedLight: ColorSemanticToken? { get } + var colorBorderEmphasizedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Border - Emphasis - On background emphasis + // MARK: Semantic token - Colors - Border - Emphasized - On background emphasized - var colorBorderEmphasisOnBackgroundEmphasisLight: ColorSemanticToken? { get } - var colorBorderEmphasisOnBackgroundEmphasisDark: ColorSemanticToken? { get } + var colorBorderEmphasizedOnBackgroundEmphasizedLight: ColorSemanticToken? { get } + var colorBorderEmphasizedOnBackgroundEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Border - Brand - Primary var colorBorderBrandPrimaryLight: ColorSemanticToken? { get } var colorBorderBrandPrimaryDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - Border - Brand - Primary - On background emphasis + // MARK: Semantic token - Colors - Border - Brand - Primary - On background emphasized - var colorBorderBrandPrimaryOnBackgroundEmphasisLight: ColorSemanticToken? { get } - var colorBorderBrandPrimaryOnBackgroundEmphasisDark: ColorSemanticToken? { get } + var colorBorderBrandPrimaryOnBackgroundEmphasizedLight: ColorSemanticToken? { get } + var colorBorderBrandPrimaryOnBackgroundEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - Border - Brand - Secondary @@ -361,49 +352,49 @@ public protocol ColorSemanticTokens { var colorOnBackgroundStatusAttractiveMutedLight: ColorSemanticToken? { get } var colorOnBackgroundStatusAttractiveMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - On background - Status - Attrative - Emphasis + // MARK: Semantic token - Colors - On background - Status - Attrative - Emphasized - var colorOnBackgroundStatusAttractiveEmphasisLight: ColorSemanticToken? { get } - var colorOnBackgroundStatusAttractiveEmphasisDark: ColorSemanticToken? { get } + var colorOnBackgroundStatusAttractiveEmphasizedLight: ColorSemanticToken? { get } + var colorOnBackgroundStatusAttractiveEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - On background - Status - Warning - Muted var colorOnBackgroundStatusWarningMutedLight: ColorSemanticToken? { get } var colorOnBackgroundStatusWarningMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - On background - Status - Warning - Emphasis + // MARK: Semantic token - Colors - On background - Status - Warning - Emphasized - var colorOnBackgroundStatusWarningEmphasisLight: ColorSemanticToken? { get } - var colorOnBackgroundStatusWarningEmphasisDark: ColorSemanticToken? { get } + var colorOnBackgroundStatusWarningEmphasizedLight: ColorSemanticToken? { get } + var colorOnBackgroundStatusWarningEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - On background - Status - Negative - Muted var colorOnBackgroundStatusNegativeMutedLight: ColorSemanticToken? { get } var colorOnBackgroundStatusNegativeMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - On background - Status - Negative - Emphasis + // MARK: Semantic token - Colors - On background - Status - Negative - Emphasized - var colorOnBackgroundStatusNegativeEmphasisLight: ColorSemanticToken? { get } - var colorOnBackgroundStatusNegativeEmphasisDark: ColorSemanticToken? { get } + var colorOnBackgroundStatusNegativeEmphasizedLight: ColorSemanticToken? { get } + var colorOnBackgroundStatusNegativeEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - On background - Status - Positive - Muted var colorOnBackgroundStatusPositiveMutedLight: ColorSemanticToken? { get } var colorOnBackgroundStatusPositiveMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - On background - Status - Positive - Emphasis + // MARK: Semantic token - Colors - On background - Status - Positive - Emphasized - var colorOnBackgroundStatusPositiveEmphasisLight: ColorSemanticToken? { get } - var colorOnBackgroundStatusPositiveEmphasisDark: ColorSemanticToken? { get } + var colorOnBackgroundStatusPositiveEmphasizedLight: ColorSemanticToken? { get } + var colorOnBackgroundStatusPositiveEmphasizedDark: ColorSemanticToken? { get } // MARK: Semantic token - Colors - On background - Status - Information - Muted var colorOnBackgroundStatusInformationMutedLight: ColorSemanticToken? { get } var colorOnBackgroundStatusInformationMutedDark: ColorSemanticToken? { get } - // MARK: Semantic token - Colors - On background - Status - Information - Emphasis + // MARK: Semantic token - Colors - On background - Status - Information - Emphasized - var colorOnBackgroundStatusInformationEmphasisLight: ColorSemanticToken? { get } - var colorOnBackgroundStatusInformationEmphasisDark: ColorSemanticToken? { get } + var colorOnBackgroundStatusInformationEmphasizedLight: ColorSemanticToken? { get } + var colorOnBackgroundStatusInformationEmphasizedDark: ColorSemanticToken? { get } } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/DimensionSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/DimensionSemanticTokens.swift similarity index 80% rename from OUDS/Core/Tokens/SemanticTokens/Sources/DimensionSemanticTokens.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Values/DimensionSemanticTokens.swift index e7e382f10..88a3c045c 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/DimensionSemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/DimensionSemanticTokens.swift @@ -11,17 +11,10 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import OUDSTokensRaw - -// MARK: - Type aliases to keep grammar clear - -public typealias DimensionSemanticToken = DimensionRawToken - -// MARK: - Semantic tokens - /// This is a group of semantic tokens for **dimensions**. /// It defines all `DimensionSemanticToken` a theme must have. +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. public protocol DimensionSemanticTokens { // MARK: Semantic token - Dimension diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Values/ElevationSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/ElevationSemanticTokens.swift new file mode 100644 index 000000000..91cbe5335 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/ElevationSemanticTokens.swift @@ -0,0 +1,129 @@ +// +// 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 +// + +/// This is a group of semantic tokens for **elevations**. +/// It defines all elevation semantic tokens a theme must have. (`ElevationXSemanticToken`,`ElevationYSemanticToken`, +/// `ElevationBlurSemanticToken` and `ElevationColorSemanticToken`) +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. +public protocol ElevationSemanticTokens { + + // MARK: Semantic token - Elevation - X + + var elevationXNone: ElevationXSemanticToken { get } + var elevationXRaised: ElevationXSemanticToken { get } + var elevationXDrag: ElevationXSemanticToken { get } + var elevationXOverlayDefault: ElevationXSemanticToken { get } + var elevationXOverlayEmphasized: ElevationXSemanticToken { get } + var elevationXStickyDefault: ElevationXSemanticToken { get } + var elevationXStickyEmphasized: ElevationXSemanticToken { get } + var elevationXStickyNavigationScrolled: ElevationXSemanticToken { get } + var elevationXFocus: ElevationXSemanticToken { get } + + // MARK: Semantic token - Elevation - Y + + var elevationYNone: ElevationYSemanticToken { get } + var elevationYRaised: ElevationYSemanticToken { get } + var elevationYDrag: ElevationYSemanticToken { get } + var elevationYOverlayDefault: ElevationYSemanticToken { get } + var elevationYOverlayEmphasized: ElevationYSemanticToken { get } + var elevationYStickyDefault: ElevationYSemanticToken { get } + var elevationYStickyEmphasized: ElevationYSemanticToken { get } + var elevationYStickyNavigationScrolled: ElevationYSemanticToken { get } + var elevationYFocus: ElevationYSemanticToken { get } + + // MARK: Semantic token - Elevation - Blur + + var elevationBlurNone: ElevationBlurSemanticToken { get } + var elevationBlurRaised: ElevationBlurSemanticToken { get } + var elevationBlurDrag: ElevationBlurSemanticToken { get } + var elevationBlurOverlayDefault: ElevationBlurSemanticToken { get } + var elevationBlurOverlayEmphasized: ElevationBlurSemanticToken { get } + var elevationBlurStickyDefault: ElevationBlurSemanticToken { get } + var elevationBlurStickyEmphasized: ElevationBlurSemanticToken { get } + var elevationBlurStickyNavigationScrolled: ElevationBlurSemanticToken { get } + var elevationBlurFocus: ElevationBlurSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - None + + var elevationColorNoneLight: ElevationColorSemanticToken { get } + var elevationColorNoneDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Raised + + var elevationColorRaisedLight: ElevationColorSemanticToken { get } + var elevationColorRaisedDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Drag + + var elevationColorDragLight: ElevationColorSemanticToken { get } + var elevationColorDragDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Overlay - Default + + var elevationColorOverlayDefaultLight: ElevationColorSemanticToken { get } + var elevationColorOverlayDefaultDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Overlay - Emphasized + + var elevationColorOverlayEmphasizedLight: ElevationColorSemanticToken { get } + var elevationColorOverlayEmphasizedDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Sticky - Default + + var elevationColorStickyDefaultLight: ElevationColorSemanticToken { get } + var elevationColorStickyDefaultDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Sticky - Emphasized + + var elevationColorStickyEmphasizedLight: ElevationColorSemanticToken { get } + var elevationColorStickyEmphasizedDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Sticky - Navigation scrolled + + var elevationColorStickyNavigationScrolledLight: ElevationColorSemanticToken { get } + var elevationColorStickyNavigationScrolledDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Color - Focus + + var elevationColorFocusLight: ElevationColorSemanticToken { get } + var elevationColorFocusDark: ElevationColorSemanticToken { get } + + // MARK: Semantic token - Elevation - Bow shadow + + // TODO: Missing elevationBoxShadowNoneLight semantic token + + var elevationRaisedLight: ElevationCompositeSemanticToken { get } + var elevationRaisedDark: ElevationCompositeSemanticToken { get } + + var elevationDragLight: ElevationCompositeSemanticToken { get } + var elevationDragDark: ElevationCompositeSemanticToken { get } + + var elevationOverlayDefaultLight: ElevationCompositeSemanticToken { get } + var elevationOverlayDefaultDark: ElevationCompositeSemanticToken { get } + + var elevationOverlayEmphasizedLight: ElevationCompositeSemanticToken { get } + var elevationOverlayEmphasizedDark: ElevationCompositeSemanticToken { get } + + var elevationStickyDefaultLight: ElevationCompositeSemanticToken { get } + var elevationStickyDefaultDark: ElevationCompositeSemanticToken { get } + + var elevationStickyEmphasizedLight: ElevationCompositeSemanticToken { get } + var elevationStickyEmphasizedDark: ElevationCompositeSemanticToken { get } + + var elevationStickyNavigationScrolledLight: ElevationCompositeSemanticToken { get } + var elevationStickyNavigationScrolledDark: ElevationCompositeSemanticToken { get } + + var elevationFocusLight: ElevationCompositeSemanticToken { get } + var elevationFocusDark: ElevationCompositeSemanticToken { get } +} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Values/GridSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/GridSemanticTokens.swift new file mode 100644 index 000000000..e6c7e1e43 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/GridSemanticTokens.swift @@ -0,0 +1,46 @@ +// +// 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 +// + +/// This is a group of semantic tokens for **grids**. +/// It defines all `GridSemanticToken` a theme must have. +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. +public protocol GridSemanticTokens { + + // MARK: Semantic token - Grid - iOS Extra compact + + var gridExtraCompactWidth: GridExtraCompactSemanticToken { get } + var gridExtraCompactMinWidth: GridExtraCompactSemanticToken { get } + var gridExtraCompactMaxWidth: GridExtraCompactSemanticToken { get } + var gridExtraCompactMargin: GridExtraCompactSemanticToken { get } + var gridExtraCompactColumnGap: GridExtraCompactSemanticToken { get } + var gridExtraCompactColumnCount: GridExtraCompactSemanticToken { get } + + // MARK: Semantic token - Grid - iOS Compact + + var gridCompactWidth: GridCompactSemanticToken { get } + var gridCompactMinWidth: GridCompactSemanticToken { get } + var gridCompactMaxWidth: GridCompactSemanticToken { get } + var gridCompactMargin: GridCompactSemanticToken { get } + var gridCompactColumnGap: GridCompactSemanticToken { get } + var gridCompactColumnCount: GridCompactSemanticToken { get } + + // MARK: Semantic token - Grid - iOS Regular + + var gridRegularWidth: GridRegularSemanticToken { get } + var gridRegularMinWidth: GridRegularSemanticToken { get } + var gridRegularMaxWidth: GridRegularSemanticToken { get } + var gridRegularMargin: GridRegularSemanticToken { get } + var gridRegularColumnGap: GridRegularSemanticToken { get } + var gridRegularColumnCount: GridRegularSemanticToken { get } +} diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/OpacitySemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/OpacitySemanticTokens.swift similarity index 79% rename from OUDS/Core/Tokens/SemanticTokens/Sources/OpacitySemanticTokens.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Values/OpacitySemanticTokens.swift index 317b1d09f..17e600fc0 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/OpacitySemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/OpacitySemanticTokens.swift @@ -11,17 +11,10 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import OUDSTokensRaw - -// MARK: - Type aliases to keep grammar clear - -public typealias OpacitySemanticToken = OpacityRawToken - -// MARK: - Semantic tokens - /// This is a group of semantic tokens for **opacity.** /// It defines all `OpacitySemanticToken` a theme must have. +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. public protocol OpacitySemanticTokens { // MARK: Semantic token - Opacity @@ -30,6 +23,6 @@ public protocol OpacitySemanticTokens { var opacityWeaker: OpacitySemanticToken { get } var opacityWeak: OpacitySemanticToken { get } var opacityMedium: OpacitySemanticToken { get } - var opacityEmphasis: OpacitySemanticToken { get } + var opacityStrong: OpacitySemanticToken { get } var opacityOpaque: OpacitySemanticToken { get } } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/SizingSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SizingSemanticTokens.swift similarity index 53% rename from OUDS/Core/Tokens/SemanticTokens/Sources/SizingSemanticTokens.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Values/SizingSemanticTokens.swift index 7ca2278dd..5bb1af1ec 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/SizingSemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SizingSemanticTokens.swift @@ -11,18 +11,10 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import OUDSTokensRaw - -// MARK: - Type aliases to keep grammar clear - -public typealias SizingWidthHeightSemanticToken = DimensionRawToken -public typealias SizingMaxWidthSemanticToken = DimensionRawToken - -// MARK: - Semantic tokens - /// This is a group of semantic tokens for **sizing**. /// It defines all `SizingSemanticToken` a theme must have. +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. public protocol SizingSemanticTokens { // MARK: - Semantic token - Sizing - Width height - Icon decorative @@ -54,41 +46,41 @@ public protocol SizingSemanticTokens { // MARK: - Semantic token - Sizing - Width height - Icon typography - Heading - var sizeWidthHeightIconIsHeadingSmallShort: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingSmallMedium: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingSmallTall: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingMediumShort: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingMediumMedium: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingMediumTall: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingLargeShort: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingLargeMedium: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingLargeTall: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingXLargeShort: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingXLargeMedium: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsHeadingXLargeTall: SizingWidthHeightSemanticToken { get } + var sizeWidthHeightIconIsHeadingSmallShort: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingSmallMedium: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingSmallTall: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingMediumShort: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingMediumMedium: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingMediumTall: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingLargeShort: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingLargeMedium: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingLargeTall: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingXLargeShort: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingXLargeMedium: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsHeadingXLargeTall: SizingCompositeSemanticToken { get } // MARK: - Semantic token - Sizing - Width height - Icon typography - Body - var sizeWidthHeightIconIsBodySmallShort: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodySmallMedium: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodySmallTall: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodyMediumShort: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodyMediumMedium: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodyMediumTall: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodyLargeShort: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodyLargeMedium: SizingWidthHeightSemanticToken { get } - var sizeWidthHeightIconIsBodyLargeTall: SizingWidthHeightSemanticToken { get } + var sizeWidthHeightIconIsBodySmallShort: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodySmallMedium: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodySmallTall: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodyMediumShort: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodyMediumMedium: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodyMediumTall: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodyLargeShort: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodyLargeMedium: SizingCompositeSemanticToken { get } + var sizeWidthHeightIconIsBodyLargeTall: SizingCompositeSemanticToken { get } // MARK: - Semantic token - Sizing - Max width - var sizeMaxWidthTypographyDisplaySmall: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyDisplayMedium: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyDisplayLarge: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyHeadingSmall: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyHeadingMedium: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyHeadingLarge: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyHeadingXLarge: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyBodySmall: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyBodyMedium: SizingMaxWidthSemanticToken { get } - var sizeMaxWidthTypographyBodyLarge: SizingMaxWidthSemanticToken { get } + var sizeMaxWidthTypographyDisplaySmall: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyDisplayMedium: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyDisplayLarge: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyHeadingSmall: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyHeadingMedium: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyHeadingLarge: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyHeadingXLarge: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyBodySmall: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyBodyMedium: SizingCompositeSemanticToken { get } + var sizeMaxWidthTypographyBodyLarge: SizingCompositeSemanticToken { get } } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/SpacingSemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SpacingSemanticTokens.swift similarity index 86% rename from OUDS/Core/Tokens/SemanticTokens/Sources/SpacingSemanticTokens.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Values/SpacingSemanticTokens.swift index ad4144d14..dfdf2bcec 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/SpacingSemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/SpacingSemanticTokens.swift @@ -11,22 +11,10 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation -import OUDSTokensRaw - -// MARK: - Type aliases to keep grammar clear - -public typealias SpacingLayoutSemanticToken = DimensionRawToken -public typealias SpacingPaddingInlineSemanticToken = DimensionRawToken -public typealias SpacingPaddingBlockSemanticToken = DimensionRawToken -public typealias SpacingPaddingInsetSemanticToken = DimensionRawToken -public typealias SpacingGapInlineSemanticToken = DimensionRawToken -public typealias SpacingGapStackSemanticToken = DimensionRawToken - -// MARK: - Semantic tokens - /// This is a group of semantic tokens for **spacing**. /// It defines all `SpacingSemanticToken` a theme must have. +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. public protocol SpacingSemanticTokens { // MARK: Semantic token - Spacing - Layout fix @@ -44,16 +32,16 @@ public protocol SpacingSemanticTokens { // MARK: Semantic token - Spacing - Layout fluid - var spaceLayoutFluidNone: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidSmash: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidShortest: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidShorter: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidShort: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidMedium: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidTall: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidTaller: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidTallest: SpacingLayoutSemanticToken { get } - var spaceLayoutFluidSpacious: SpacingLayoutSemanticToken { get } + var spaceLayoutAdaptableNone: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableSmash: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableShortest: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableShorter: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableShort: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableMedium: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableTall: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableTaller: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableTallest: SpacingCompositeSemanticToken { get } + var spaceLayoutAdaptableSpacious: SpacingCompositeSemanticToken { get } // MARK: Semantic token - Spacing - Padding - Padding inline diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/TypographySemanticTokens.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/TypographySemanticTokens.swift similarity index 59% rename from OUDS/Core/Tokens/SemanticTokens/Sources/TypographySemanticTokens.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Values/TypographySemanticTokens.swift index 443d2cd34..a4a315a6c 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/TypographySemanticTokens.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Values/TypographySemanticTokens.swift @@ -11,24 +11,19 @@ // Software description: A SwiftUI components library with code examples for Orange Unified Design System // -import Foundation import OUDSTokensRaw -// MARK: - Type aliases to keep grammar clear - -public typealias TypographyFontFamilySemanticToken = TypographyFontFamilyRawToken -public typealias TypographyFontWeightSemanticToken = TypographyFontWeightRawToken -public typealias TypographyFontSizeSemanticToken = TypographyFontSizeRawToken -public typealias TypographyFontLineHeightSemanticToken = TypographyFontLineHeightRawToken - -// MARK: - Semantic tokens - /// This is a group of semantic tokens for **typography**. -/// It defines all `TypographySemanticToken` a theme must have. +/// It defines all typography semantic tokens a theme must have +/// (`TypographyFontFamilySemanticToken`, `TypographyFontWeightSemanticToken`, `TypographyFontSizeSemanticToken`, `TypographyFontLineHeightSemanticToken`). +/// +/// In the future this file should be generated by a parser converting Figma JSON to Swift code. public protocol TypographySemanticTokens { // MARK: - Semantic token - Typography - Font - Family + // TODO: Should we suffix our tokens names by "iOS"? + var fontFamily: TypographyFontFamilyRawToken { get } var fontFamilyDisplay: TypographyFontFamilySemanticToken { get } var fontFamilyHeading: TypographyFontFamilySemanticToken { get } @@ -38,6 +33,8 @@ public protocol TypographySemanticTokens { // MARK: - Semantic token - Typography - Font - Weight + var fontWeightDefault: TypographyFontWeightSemanticToken { get } + var fontWeightStrong: TypographyFontWeightSemanticToken { get } var fontWeightDisplay: TypographyFontWeightSemanticToken { get } var fontWeightHeading: TypographyFontWeightSemanticToken { get } var fontWeightBodyDefault: TypographyFontWeightSemanticToken { get } @@ -46,7 +43,7 @@ public protocol TypographySemanticTokens { var fontWeightLabelStrong: TypographyFontWeightSemanticToken { get } var fontWeightCode: TypographyFontWeightSemanticToken { get } - // MARK: - Semantic token - Typography - Font - Size - Mobile + // MARK: - Semantic token - Typography - Font - Size - Mobile (extra-compact/compact) var fontSizeMobileDisplayLarge: TypographyFontSizeSemanticToken { get } var fontSizeMobileDisplayMedium: TypographyFontSizeSemanticToken { get } @@ -58,10 +55,8 @@ public protocol TypographySemanticTokens { var fontSizeMobileBodyLarge: TypographyFontSizeSemanticToken { get } var fontSizeMobileBodyMedium: TypographyFontSizeSemanticToken { get } var fontSizeMobileBodySmall: TypographyFontSizeSemanticToken { get } - var fontSizeMobileCodeMedium: TypographyFontSizeSemanticToken { get } - var fontSizeMobileCodeSmall: TypographyFontSizeSemanticToken { get } - // MARK: - Semantic token - Typography - Font - Size - Tablet + // MARK: - Semantic token - Typography - Font - Size - Tablet (regular/medium var fontSizeTabletDisplayLarge: TypographyFontSizeSemanticToken { get } var fontSizeTabletDisplayMedium: TypographyFontSizeSemanticToken { get } @@ -73,8 +68,6 @@ public protocol TypographySemanticTokens { var fontSizeTabletBodyLarge: TypographyFontSizeSemanticToken { get } var fontSizeTabletBodyMedium: TypographyFontSizeSemanticToken { get } var fontSizeTabletBodySmall: TypographyFontSizeSemanticToken { get } - var fontSizeTabletCodeMedium: TypographyFontSizeSemanticToken { get } - var fontSizeTabletCodeSmall: TypographyFontSizeSemanticToken { get } // MARK: - Semantic token - Typography - Font - Size - Others @@ -85,7 +78,7 @@ public protocol TypographySemanticTokens { var fontSizeCodeMedium: TypographyFontSizeSemanticToken { get } var fontSizeCodeSmall: TypographyFontSizeSemanticToken { get } - // MARK: - Semantic token - Typography - Font - Line height - Mobile + // MARK: - Semantic token - Typography - Font - Line height - Mobile (extra-compact/compact) var fontLineHeightMobileDisplayLarge: TypographyFontLineHeightSemanticToken { get } var fontLineHeightMobileDisplayMedium: TypographyFontLineHeightSemanticToken { get } @@ -97,10 +90,8 @@ public protocol TypographySemanticTokens { var fontLineHeightMobileBodyLarge: TypographyFontLineHeightSemanticToken { get } var fontLineHeightMobileBodyMedium: TypographyFontLineHeightSemanticToken { get } var fontLineHeightMobileBodySmall: TypographyFontLineHeightSemanticToken { get } - var fontLineHeightMobileCodeMedium: TypographyFontLineHeightSemanticToken { get } - var fontLineHeightMobileCodeSmall: TypographyFontLineHeightSemanticToken { get } - // MARK: - Semantic token - Typography - Font - Line height - Tablet + // MARK: - Semantic token - Typography - Font - Line height - Tablet (regular/medium) var fontLineHeightTabletDisplayLarge: TypographyFontLineHeightSemanticToken { get } var fontLineHeightTabletDisplayMedium: TypographyFontLineHeightSemanticToken { get } @@ -112,8 +103,6 @@ public protocol TypographySemanticTokens { var fontLineHeightTabletBodyLarge: TypographyFontLineHeightSemanticToken { get } var fontLineHeightTabletBodyMedium: TypographyFontLineHeightSemanticToken { get } var fontLineHeightTabletBodySmall: TypographyFontLineHeightSemanticToken { get } - var fontLineHeightTabletCodeMedium: TypographyFontLineHeightSemanticToken { get } - var fontLineHeightTabletCodeSmall: TypographyFontLineHeightSemanticToken { get } // MARK: - Semantic token - Typography - Font - Line height - Others @@ -127,45 +116,41 @@ public protocol TypographySemanticTokens { // MARK: - Semantic token - Typography - Font - Letter spacing // TODO: Missing details about the types of the associated raw tokens - // MARK: - Semantic token - Typography - Font - Paragraph spacing - Mobile - - var fontParagraphSpacingMobileDisplayLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileDisplayMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileDisplaySmall: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileHeadingXLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileHeadingLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileHeadingMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileHeadingSmall: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileBodyLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileBodyMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileBodySmall: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileCodeMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingMobileCodeSmall: TypographyFontParagraphSpacingRawToken { get } - - // MARK: - Semantic token - Typography - Font - Paragraph spacing - Tablet - - var fontParagraphSpacingTabletDisplayLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletDisplayMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletDisplaySmall: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletHeadingXLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletHeadingLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletHeadingMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletHeadingSmall: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletBodyLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletBodyMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletBodySmall: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletCodeMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingTabletCodeSmall: TypographyFontParagraphSpacingRawToken { get } - - // MARK: - Semantic token - Typography - Font - Paragraph spacing - Others - - var fontParagraphSpacingLabelXLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingLabelLarge: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingLabelMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingLabelSmall: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingCodeMedium: TypographyFontParagraphSpacingRawToken { get } - var fontParagraphSpacingCodeSmall: TypographyFontParagraphSpacingRawToken { get } - - // MARK: - Semantic tplens - Typography - Composites - // TODO: Missing specifications, composite semantic tokens to dd for display, heading, body, label, code + // MARK: - Semantic tokens - Typography - Composites - Display + + var typeDisplayLarge: TypographyCompositeSemanticToken { get } + var typeDisplayMedium: TypographyCompositeSemanticToken { get } + var typeDisplaySmall: TypographyCompositeSemanticToken { get } + + // MARK: - Semantic tokens - Typography - Composites - Heading + + var typeHeadingXLarge: TypographyCompositeSemanticToken { get } + var typeHeadingLarge: TypographyCompositeSemanticToken { get } + var typeHeadingMedium: TypographyCompositeSemanticToken { get } + var typeHeadingSmall: TypographyCompositeSemanticToken { get } + + // MARK: - Semantic tokens - Typography - Composites - Body + + var typeBodyDefaultLarge: TypographyCompositeSemanticToken { get } + var typeBodyDefaultMedium: TypographyCompositeSemanticToken { get } + var typeBodyDefaultSmall: TypographyCompositeSemanticToken { get } + var typeBodyStrongLarge: TypographyCompositeSemanticToken { get } + var typeBodyStrongMedium: TypographyCompositeSemanticToken { get } + var typeBodyStrongSmall: TypographyCompositeSemanticToken { get } + + // MARK: - Semantic tokens - Typography - Composites - Label + + var typeLabelDefaultXLarge: TypographyCompositeSemanticToken { get } + var typeLabelDefaultLarge: TypographyCompositeSemanticToken { get } + var typeLabelDefaultMedium: TypographyCompositeSemanticToken { get } + var typeLabelDefaultSmall: TypographyCompositeSemanticToken { get } + var typeLabelStrongXLarge: TypographyCompositeSemanticToken { get } + var typeLabelStrongLarge: TypographyCompositeSemanticToken { get } + var typeLabelStrongMedium: TypographyCompositeSemanticToken { get } + var typeLabelStrongSmall: TypographyCompositeSemanticToken { get } + + // MARK: - Semantic tokens - Typography - Composites - Code + + var typeCodeMedium: TypographyCompositeSemanticToken { get } + var typeCodeSmall: TypographyCompositeSemanticToken { get } } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md b/OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md new file mode 100644 index 000000000..6a15b9609 --- /dev/null +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/_OUDSTokensSemantic.docc/OUDSTokensSemantic.md @@ -0,0 +1,43 @@ +# ``OUDSTokensSemantic`` + +These _tokens_ can be used mainly for _component tokens_ ([OUDSTokensComponent](https://ios.unified-design-system.orange.com/documentation/oudstokenscomponent/)) to apply some style and configuration values. +They can be seen as an high level of usage with functional meanings. + +## Overview + +Thus if we need for example to change a warning color, supposing this color is defined as a _semantic token_, we onlyhave to change its assigned value and all components using the _semantic token_ won't be impacted in their definition. + +In addition, there are hundreds of _semantics tokens_ and we needed to add them to the abstract root theme using extensions for clarity reasons to prevent to have a _Swift class_ with thousands of lines. Each _raw token_ "family" is then declared in its dedicated _Swift protocol_ any root theme must implement. Because we choose to split responsabilities and objects into their own modules, we faced troubles to make possible for children themes to override properties declared in _protocols_ and defined in _extensions_. + +That is the reason why tokens are exposed as `@objc open` to be available and oveeridable anywhere. + +To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are avaialble for those who want too make their own theme. + +Example with ``ColorSemanticTokens``: + +```swift +// Delcare the semantic tokens +protocol ColorSemanticTokens { + var sysColorBrandNeutralMutedWhite: ColorAliasSemanticToken? { get } +} + +// Define the semantic tokens exposed through the theme +extension OUDSTheme: ColorSemanticTokens { + + @objc open var sysColorBrandNeutralMutedWhite: ColorAliasSemanticToken? { ColorRawTokens.colorFunctionalWhite } +} +``` + +## Topics + +### Group + +- ``BorderSemanticTokens`` +- ``ColorSemanticTokens`` +- ``DimensionSemanticTokens`` +- ``ElevationSemanticTokens`` +- ``GridSemanticTokens`` +- ``OpacitySemanticTokens`` +- ``SizingSemanticTokens`` +- ``SpacingSemanticTokens`` +- ``TypographySemanticTokens`` diff --git a/OUDS/Foundations/Sources/Extensions/Color+extensions.swift b/OUDS/Foundations/Sources/Extensions/Color+extensions.swift index 3c17e6def..a445fabf8 100644 --- a/OUDS/Foundations/Sources/Extensions/Color+extensions.swift +++ b/OUDS/Foundations/Sources/Extensions/Color+extensions.swift @@ -16,6 +16,7 @@ import SwiftUI extension Color { + /// `Color` extension to get a `Color` from its hexadecimal string representation. public init?(hexadecimalCode: String) { let hexadecimalCodeSanitized = hexadecimalCode.trimmingCharacters(in: .whitespacesAndNewlines).replacingOccurrences(of: "#", with: "") diff --git a/OUDS/Foundations/Sources/Extensions/String+SwiftUI.swift b/OUDS/Foundations/Sources/Extensions/String+SwiftUI.swift index 45263fba7..72a56e8cb 100644 --- a/OUDS/Foundations/Sources/Extensions/String+SwiftUI.swift +++ b/OUDS/Foundations/Sources/Extensions/String+SwiftUI.swift @@ -16,10 +16,12 @@ import SwiftUI extension String { + /// `String` extension to get a `Color` from `self` supposed to be an hexadecimal string representation. public var color: Color! { Color(hexadecimalCode: self) } + /// `String` extension to get `Font.Weight` of *SwiftUI* from its string representation. public var fontWeight: Font.Weight { if self == "thin" { return Font.Weight.thin } if self == "ultraLight" { return Font.Weight.ultraLight } @@ -31,4 +33,26 @@ extension String { if self == "heavy" { return Font.Weight.heavy } return Font.Weight.regular } + + /// Forges the font name which is expected for the given weight. + /// Beware, the function does not check if the font exists. + /// - Parameters: + /// - name: The font family name (e.g. "Menlo") + /// - weight: The weight to apply (e.g. "bold", "italic") + /// - Returns String: The full name of the font to use (e.g. "Menlo-Bold" or "Menlo-Italic") + public func compose(withFont weight: String) -> String { + guard !self.isEmpty else { + OUDSLogger.error("No font family to compose with weight") + return self + } + var characters = Array(weight) + guard characters.count > 0, let formattedFirst = characters[0].uppercased().first else { + OUDSLogger.error("The given weight cannot be parsed to compose a font family") + return self + } + characters[0] = formattedFirst + let formattedWeight = String(characters) + return self + "-" + formattedWeight + // TODO: String manipulation can be costly, add values in Cache + } } diff --git a/OUDS/Foundations/Sources/OUDSLogger.swift b/OUDS/Foundations/Sources/OUDSLogger.swift index 12171d48a..74bdbe112 100644 --- a/OUDS/Foundations/Sources/OUDSLogger.swift +++ b/OUDS/Foundations/Sources/OUDSLogger.swift @@ -14,7 +14,8 @@ import Foundation import os -struct OUDSLogger { +/// The `os.Logger` wrapper used in the *OUDS iOS* library so as to logs things in standard output or elswhere. +public struct OUDSLogger { private init() {} @@ -22,27 +23,27 @@ struct OUDSLogger { private static let bullet: String = "🍊" private static let prefix: String = "\(bullet) [OUDS]" - static func debug(_ message: String) { + public static func debug(_ message: String) { #if DEBUG logger.debug("\(prefix):debug: πŸͺ² \(message)") #endif } - static func log(_ message: String) { + public static func log(_ message: String) { #if DEBUG logger.log("\(prefix): πŸ—’οΈ \(message)") #endif } - static func info(_ message: String) { + public static func info(_ message: String) { logger.info("\(prefix):info: ℹ️ \(message)") } - static func warning(_ message: String) { + public static func warning(_ message: String) { logger.warning("\(prefix):warning: ⚠️ \(message)") } - static func error(_ message: String) { + public static func error(_ message: String) { logger.error("\(prefix):error: πŸ’₯ \(message)") } } diff --git a/OUDS/Foundations/Sources/_OUDSFoundations.docc/OUDSFoundations.md b/OUDS/Foundations/Sources/_OUDSFoundations.docc/OUDSFoundations.md new file mode 100644 index 000000000..c1759467c --- /dev/null +++ b/OUDS/Foundations/Sources/_OUDSFoundations.docc/OUDSFoundations.md @@ -0,0 +1,10 @@ +# ``OUDSFoundations`` + +Contains a set of helpers shared for higher level targets. + +## Overview + +- Helpers to create a *SwiftUI* `Color` from string in hexadecimal format ; +- Helper to get *SwiftUI* `Font.Weight` from a string value ; +- Logger for logging logs in console. + diff --git a/OUDS/Foundations/Tests/Extensions/TestString+SwiftUI.swift b/OUDS/Foundations/Tests/Extensions/TestString+SwiftUI.swift index 82b8f8e2f..5f5357034 100644 --- a/OUDS/Foundations/Tests/Extensions/TestString+SwiftUI.swift +++ b/OUDS/Foundations/Tests/Extensions/TestString+SwiftUI.swift @@ -20,7 +20,7 @@ import OUDSFoundations final class TestString_SwiftUI: XCTestCase { /// Tests values of font weight - func testFontWeightValues() throws { + func testFontWeightValues() { // Expected values XCTAssertTrue("thin".fontWeight == Font.Weight.thin) @@ -37,4 +37,44 @@ final class TestString_SwiftUI: XCTestCase { XCTAssertTrue("42".fontWeight == Font.Weight.regular) XCTAssertTrue("Yowzah!".fontWeight == Font.Weight.regular) } + + /// Tests the font family values created using a font amily name and a weight + func testComposeWithFonts() { + + var result: String + + // Expected values + + result = "Menlo".compose(withFont: "thin") + XCTAssertTrue(result == "Menlo-Thin", "Current value is '\(result)") + + result = "Menlo".compose(withFont: "ultraLight") + XCTAssertTrue(result == "Menlo-UltraLight", "Current value is '\(result)") + + result = "Menlo".compose(withFont: "light") + XCTAssertTrue(result == "Menlo-Light", "Current value is '\(result)") + + result = "Menlo".compose(withFont: "regular") + XCTAssertTrue(result == "Menlo-Regular", "Current value is '\(result)") + + result = "Menlo".compose(withFont: "medium") + XCTAssertTrue(result == "Menlo-Medium", "Current value is '\(result)") + + result = "Menlo".compose(withFont: "semibold") + XCTAssertTrue(result == "Menlo-Semibold", "Current value is '\(result)") + + result = "Menlo".compose(withFont: "bold") + XCTAssertTrue(result == "Menlo-Bold", "Current value is '\(result)") + + result = "Menlo".compose(withFont: "heavy") + XCTAssertTrue(result == "Menlo-Heavy", "Current value is '\(result)") + + // Edge cases + + result = "Menlo".compose(withFont: "") + XCTAssertTrue(result == "Menlo", "Current value is '\(result)") + + result = "".compose(withFont: "Yippee ki-yay") + XCTAssertTrue(result == "", "Current value is '\(result)") + } } diff --git a/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift b/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift index b30123ce8..bc1412038 100644 --- a/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift +++ b/OUDS/Foundations/TestsUtils/XCTestCase+extensions.swift @@ -16,6 +16,18 @@ import XCTest extension XCTestCase { + /// Checks if `value` is between `min` and `max` + public func XCTAssertBetween(min: Double, _ value: Double, max: Double, file: StaticString = #file, line: UInt = #line) { + XCTAssertTrue(min <= value && value <= max) + } + + /// 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 + // 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)") + } + /// Compares two colors in hexadecimal values and asserts if `left` is "lighter" than `right`, i.e. has a bigger integer value public func XCTAssertColorLighterThan(_ left: String, _ right: String, file: StaticString = #file, line: UInt = #line) { let leftBrightness = hexadecimalStringToInt(left) diff --git a/OUDS/Modules/Sources/_OUDSModules.docc/OUDSModules.md b/OUDS/Modules/Sources/_OUDSModules.docc/OUDSModules.md new file mode 100644 index 000000000..2dce9a470 --- /dev/null +++ b/OUDS/Modules/Sources/_OUDSModules.docc/OUDSModules.md @@ -0,0 +1,8 @@ +# ``OUDSModules`` + +The catalog of all modules provided by OUDS. + +## Overview + +Comming soon + diff --git a/OUDS/OUDS Library TestPlan.xctestplan b/OUDS/OUDS Library TestPlan.xctestplan index 972d6340c..500b0624b 100644 --- a/OUDS/OUDS Library TestPlan.xctestplan +++ b/OUDS/OUDS Library TestPlan.xctestplan @@ -15,43 +15,43 @@ { "target" : { "containerPath" : "container:..", - "identifier" : "Foundations-Tests", - "name" : "Foundations-Tests" + "identifier" : "OUDS-Tests", + "name" : "OUDS-Tests" } }, { "target" : { "containerPath" : "container:..", - "identifier" : "Raw-Tokens-Tests", - "name" : "Raw-Tokens-Tests" + "identifier" : "OUDSFoundations-Tests", + "name" : "OUDSFoundations-Tests" } }, { "target" : { "containerPath" : "container:..", - "identifier" : "Theme-Tests-Commons", - "name" : "Theme-Tests-Commons" + "identifier" : "OUDSThemesInverse-Tests", + "name" : "OUDSThemesInverse-Tests" } }, { "target" : { "containerPath" : "container:..", - "identifier" : "Theme-Tests-Inverse", - "name" : "Theme-Tests-Inverse" + "identifier" : "OUDSThemesOrange-Tests", + "name" : "OUDSThemesOrange-Tests" } }, { "target" : { "containerPath" : "container:..", - "identifier" : "Theme-Tests-Orange", - "name" : "Theme-Tests-Orange" + "identifier" : "OUDSThemesSosh-Tests", + "name" : "OUDSThemesSosh-Tests" } }, { "target" : { "containerPath" : "container:..", - "identifier" : "Theme-Tests-Sosh", - "name" : "Theme-Tests-Sosh" + "identifier" : "OUDSTokensRaw-Tests", + "name" : "OUDSTokensRaw-Tests" } } ], diff --git a/OUDS/README.md b/OUDS/README.md index 342689490..f066b4ebf 100644 --- a/OUDS/README.md +++ b/OUDS/README.md @@ -7,13 +7,13 @@ It contains modules, components, themes, and tokens (of components,s emantic and ## Exposed SPM modules -This _Swift package_ exposes up to #0 _products_ as _libraries_: +This _Swift package_ exposes up to 10 _products_ as _libraries_: 1. `OUDSModules` containing OUDS modules with features ; 2. `OUDSComponents` containing all components embeded also inside _modules_ ; 3. `OUDSThemesSoshTheme` providing the default _Sosh_ theme defining style for _components_; -4. `OUDSThemesInverseTheme` providing a _theme_ with inversed colors for _components_; +4. `OUDSThemesInverseTheme` providing a _theme_ with inverted colors for _components_; 5. `OUDSThemesOrangeTheme` providing the default _Orange_ theme defining style for _components_; -6. `OUDSThemesCommons` providing basic objects and low layer of responsabilities to help to implement _themes_ ; +6. `OUDS` providing basic objects and low layer of responsabilities to help to implement _themes_ ; 7. `OUDSTokensComponent` providing _component tokens_ for _components_ to add in applications and _modules_ ; 8. `OUDSTokensSemantic` providing _semantic tokens_ ; 9. `OUDSTokensRaw` providing _raw tokens_ ; @@ -34,8 +34,9 @@ A _theme_ contains any relevant _semantic tokens_ and _component tokens_ which c A _theme_ has also _raw tokens_ associated to primitive types so as to give to _components_, written with _SwiftUI_, the needed values in the suitable type. A _theme_ can add for itself any new _tokens_. This library exposes today up to two themes: -1. `OrangeTheme` which can be seen as the default _theme_ -2. `SoshTheme` for Sosh. +1. `OrangeTheme` which can be seen as the default _theme_ ; +2. `SoshTheme` for Sosh ; +2. `InverseTheme` for other use cases. They both are based on an `OUDSTheme` defining default values. @@ -66,10 +67,10 @@ These _tokens_ can be used to apply some style and configuration values to _comp Thus if a component need to change for example its _background color_, and if a _component token_ is used for it, then only the value of this _token_ should be changed without any modification on the _component_ definition. _Components_ use _component tokens_ exposed through the _theme_ to get their style values. -Example with `FormsTextInputComponentToken`: +Example with `FormsTextInputComponentTokens`: ```swift -public protocol FormsTextInputComponentToken { +public protocol FormsTextInputComponentTokens { var ftiTitleFontWeight: TypographyFontWeightSemanticToken { get } var ftiTitleFontSize: TypographyFontSizeSemanticToken { get } var ftiTitleColor: ColorSemanticToken { get } @@ -79,7 +80,7 @@ public protocol FormsTextInputComponentToken { var ftiBorderWidth: BorderWidthSemanticToken { get } } -extension OUDSTheme: FormsTextInputComponentToken { +extension OUDSTheme: FormsTextInputComponentTokens { private static let defaultBlack: ColorSemanticToken = ColorRawTokens.colorFunctionalBlack private static let defaultWhite: ColorSemanticToken = ColorRawTokens.colorFunctionalWhite @@ -87,11 +88,40 @@ extension OUDSTheme: FormsTextInputComponentToken { @objc open var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelLarge } @objc open var ftiTitleColor: ColorSemanticToken { colorContentBrandPrimaryLight ?? Self.defaultBlack } - @objc open var ftiBorderColor: ColorSemanticToken { colorBorderEmphasisLight ?? Self.defaultBlack } + @objc open var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedLight ?? Self.defaultBlack } @objc open var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDefault } @objc open var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThin } } +// The View + +struct OUDSFormsTextInput: View { + + // ... + @Environment(\.theme) var theme + + public var body: some View { + VStack(spacing: theme.spacePaddingBlockComponentTall) { + Label( + title: { + Text("Example of OUDSFormsTextInput") + .fontWeight(theme.ftiTitleFontWeight.fontWeight) + .font(.system(size: theme.ftiTitleFontSize)) + .foregroundColor(theme.ftiTitleColor.color) + }, + icon: { /*@START_MENU_TOKEN@*/Image(systemName: "42.circle")/*@END_MENU_TOKEN@*/ } + ) + Text("Write bellow some awesome text!") + .fontWeight(theme.ftiSubtitleFontWeight.fontWeight) + .font(.system(size: theme.ftiSubtitleFontSize)) + .foregroundColor(theme.ftiSubtitleColor.color) + TextField(placeholder, text: $value) + } + .padding(theme.spacePaddingBlockComponentTall) + .background(colorScheme == .light ? theme.ftiBackgroundColorLight.color : theme.ftiBackgroundColorDark.color) + .border(theme.ftiBorderColor.color, width: theme.ftiBorderWidth) + } +} ``` #### Semantic tokens @@ -101,7 +131,7 @@ They can be seen as an high level of usage with functional meanings. Thus if we need for example to change a warning color, supposing this color is defined as a _semantic token_, we onlyhave to change its assigned value and all components using the _semantic token_ won't be impacted in their definition. In addition, there are hundreds of _semantics tokens_ and we needed to add them to the abstract root theme using extensions for clarity reasons to prevent to have a _Swift class_ with thousands of lines. Each _raw token_ "family" is then declared in its dedicated _Swift protocol_ any root theme must implement. Because we choose to split responsabilities and objects into their own modules, we faced troubles to make possible for children themes to override properties declared in _protocols_ and defined in _extensions_. That is the reason why tokens are exposed as `@objc open` to be available and oveeridable anywhere. -To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are avaialble for those who want too make their own theme. +To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are available for those who want too make their own theme. Example with `ColorSemanticTokens`: @@ -122,17 +152,21 @@ _Raw tokens_ are smallest _tokens_ possible. They are associated to raw values a In fact, we choose to use as most as possible primitive types for raw values, like `Int`, `Double`, `CGFloat` or `String` so as to handle the smallest types with few impacts on the memory for ecodesign principles. Indeed with hundreds of raw tokens, it will be more efficient to store primitive small types than structs or classes. So we expose also in higher level some properties so as to convert when needed some of these types to `SwiftUI` types (like `Font.Weight` and `Color`). -To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are avaialble for those who want too make their own theme. +To keep the same semantics as the ones used in our specifications, _typealias_ are used to as to make the links to _primitive types_ and our logic of _tokens_. These type aliases are available for those who want too make their own theme. Using more simple and primitive types will help also to test the library. With also type aliases we force users to use our types and not higher level types like _SwiftUI_ types. +We also choose to add in _extension_ all the tokens values in a separated file so as to help the *Figma*-JSON-to-Swift parser to build files to copy and past easily in the project and keeping all the other objects. + Example for `ColorRawTokens`: ```swift // Define types for color raw tokens public typealias ColorRawToken = String -public enum ColorRawTokens { // Gathers all color raw tokens +public enum ColorRawTokens { } + +extension ColorRawTokens { // Gathers all color raw tokens public static let colorFunctionalWhite: ColorRawToken = "#FFFFFF" public static let colorFunctionalScarlet400: ColorRawToken = "#FF4D4E" @@ -204,7 +238,7 @@ import OUDSThemesOrange // To override OrangeTheme (which is default theme) // Can be for example a country theme class OrangeCustomTheme: OrangeTheme { } -extension OrangeCustomTheme { // For FormsTextInputComponentToken, used in component FormsTextInputComponent +extension OrangeCustomTheme { // For FormsTextInputComponentTokens, used in component FormsTextInputComponent public override var ftiTitleFontWeight: TypographyFontWeightSemanticToken { fontWeightLabelStrong } public override var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelXLarge } @@ -217,11 +251,11 @@ extension OrangeCustomTheme { // For FormsTextInputComponentToken, used in compo public override var ftiBackgroundColorLight: ColorSemanticToken { colorBackgroundDefaultPrimaryLight } public override var ftiBackgroundColorDark: ColorSemanticToken { colorBackgroundDefaultPrimaryDark } - public override var ftiBorderColor: ColorSemanticToken { colorBorderEmphasisDark ?? MyThemeColorRawTokens.someAwesomeThemeExclusiveColor } + public override var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedDark ?? MyThemeColorRawTokens.someAwesomeThemeExclusiveColor } public override var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDrag } - public override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThickest } + public override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThick } } extension OrangeCustomTheme { // For ColorSemanticTokens using anywhere @@ -248,7 +282,7 @@ The for your root view: ```swift import SwiftUI -import OUDSThemesCommons // To get OUDSThemeableView +import OUDS // To get OUDSThemeableView struct MyAppRootView: View { diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 000000000..faaccc756 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,24 @@ +{ + "originHash" : "e71a5b08dd41106aab31bef69b8183c27372e20aad985d3798a43491894b7e7c", + "pins" : [ + { + "identity" : "swift-docc-plugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-plugin", + "state" : { + "revision" : "2eb22993b3dfd0c0d32729b357c8dabb6cd44680", + "version" : "1.4.2" + } + }, + { + "identity" : "swift-docc-symbolkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-docc-symbolkit", + "state" : { + "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", + "version" : "1.0.0" + } + } + ], + "version" : 3 +} diff --git a/Package.swift b/Package.swift index 5a2058138..5da74b90a 100644 --- a/Package.swift +++ b/Package.swift @@ -22,16 +22,23 @@ let package = Package( name: "OUDS", defaultLocalization: "en", - platforms: [.iOS(.v15)], + platforms: [.iOS(.v15), + .macOS(.v11)], // macOS v11 required for swift-docc-plugin, not official support of OUDS for macOS! // Products define the executables and libraries a package produces, making them visible to other packages. products: [ + .library( + name: "OUDS", + targets: ["OUDS"]), .library( name: "OUDSModules", targets: ["OUDSModules"]), .library( name: "OUDSComponents", targets: ["OUDSComponents"]), + .library( + name: "OUDSTokensComponent", + targets: ["OUDSTokensComponent"]), .library( name: "OUDSThemesSosh", targets: ["OUDSThemesSosh"]), @@ -41,12 +48,6 @@ let package = Package( .library( name: "OUDSThemesOrange", targets: ["OUDSThemesOrange"]), - .library( - name: "OUDSThemesCommons", - targets: ["OUDSThemesCommons"]), - .library( - name: "OUDSTokensComponent", - targets: ["OUDSTokensComponent"]), .library( name: "OUDSTokensSemantic", targets: ["OUDSTokensRaw"]), @@ -58,23 +59,36 @@ let package = Package( targets: ["OUDSFoundations"]), ], + dependencies: [ + // To build DocC documentation + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + ], + // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. targets: [ + .target( + name: "OUDS", + dependencies: ["OUDSTokensRaw", "OUDSTokensSemantic", "OUDSTokensComponent"], + path: "OUDS/Core/OUDS/Sources"), + .testTarget( + name: "OUDS-Tests", + dependencies: ["OUDS"], + path: "OUDS/Core/OUDS/Tests"), .target( name: "OUDSModules", dependencies: ["OUDSComponents"], path: "OUDS/Modules/Sources"), .target( name: "OUDSComponents", - dependencies: ["OUDSTokensComponent", "OUDSThemesOrange"], + dependencies: ["OUDSTokensComponent", "OUDS"], path: "OUDS/Core/Components/Sources"), .target( name: "OUDSThemesSosh", - dependencies: ["OUDSThemesCommons"], + dependencies: ["OUDS"], path: "OUDS/Core/Themes/Sosh/Sources"), .testTarget( - name: "Theme-Tests-Sosh", + name: "OUDSThemesSosh-Tests", dependencies: ["TestsUtils", "OUDSThemesSosh"], path: "OUDS/Core/Themes/Sosh/Tests"), .target( @@ -82,25 +96,17 @@ let package = Package( dependencies: ["OUDSThemesOrange"], path: "OUDS/Core/Themes/Inverse/Sources"), .testTarget( - name: "Theme-Tests-Inverse", + name: "OUDSThemesInverse-Tests", dependencies: ["OUDSThemesInverse"], path: "OUDS/Core/Themes/Inverse/Tests"), .target( name: "OUDSThemesOrange", - dependencies: ["OUDSThemesCommons"], + dependencies: ["OUDS"], path: "OUDS/Core/Themes/Orange/Sources"), .testTarget( - name: "Theme-Tests-Orange", + name: "OUDSThemesOrange-Tests", dependencies: ["TestsUtils", "OUDSThemesOrange"], path: "OUDS/Core/Themes/Orange/Tests"), - .target( - name: "OUDSThemesCommons", - dependencies: ["OUDSTokensRaw", "OUDSTokensSemantic", "OUDSTokensComponent"], - path: "OUDS/Core/Themes/Commons/Sources"), - .testTarget( - name: "Theme-Tests-Commons", - dependencies: ["OUDSThemesCommons"], - path: "OUDS/Core/Themes/Commons/Tests"), .target( name: "OUDSTokensComponent", dependencies: ["OUDSTokensSemantic"], @@ -114,19 +120,20 @@ let package = Package( dependencies: ["OUDSFoundations"], path: "OUDS/Core/Tokens/RawTokens/Sources"), .testTarget( - name: "Raw-Tokens-Tests", + name: "OUDSTokensRaw-Tests", dependencies: ["TestsUtils", "OUDSTokensRaw"], path: "OUDS/Core/Tokens/RawTokens/Tests"), .target( name: "OUDSFoundations", path: "OUDS/Foundations/Sources"), .testTarget( - name: "Foundations-Tests", + name: "OUDSFoundations-Tests", dependencies: ["OUDSFoundations"], path: "OUDS/Foundations/Tests"), .target( name: "TestsUtils", path: "OUDS/Foundations/TestsUtils"), ], + swiftLanguageVersions: [.v5] ) diff --git a/README.md b/README.md index f6f01e778..31a47ba9d 100644 --- a/README.md +++ b/README.md @@ -6,85 +6,37 @@ Report bug Β· Request feature + Β· + Online documentation

## Table of contents - [Status](#status) - [Content](#content) -- [Integrate OUDS](#integrate-ouds) - * [Use Swift Package Manager](#use-swift-package-manager) - * [Import the library you need](#import-the-library-you-need) - * [Use themeable view](#use-themeable-view) - * [Define a custom theme if needed](#define-a-custom-theme-if-needed) - [Bugs and feature requests](#bugs-and-feature-requests) - [Contributing](#contributing) - [Copyright and license](#copyright-and-license) ## Status -[![MIT license](https://img.shields.io/github/license/Orange-OpenSource/ouds-ios)](https://github.com/Orange-OpenSource/ouds-ios/blob/main/LICENSE) -[![iOS 15.0](https://img.shields.io/badge/iOS-15.0-informational.svg)](https://developer.apple.com/support/app-store "iOS 15 supports") -[![Still maintained](https://img.shields.io/maintenance/yes/2024)](https://github.com/Orange-OpenSource/ouds-ios/issues?q=is%3Aissue+is%3Aclosed) -[![Code size](https://img.shields.io/github/languages/code-size/Orange-OpenSource/ouds-ios)](https://github.com/Orange-OpenSource/ouds-ios) - -## Content - -This repository contains the OUDS iOS library that provides Orange iOS components, but also a demo application showcasing these different components. - -## Integrate OUDS - -### Use Swift Package Manager +[![MIT license](https://img.shields.io/github/license/Orange-OpenSource/ouds-ios?style=for-the-badge)](https://github.com/Orange-OpenSource/ouds-ios/blob/main/LICENSE) -If you want to add the iOS library of `Orange Unified Design System`, you need to add our _Swift Package_ into your project. -To do that, add a new _package dependency_ to your _Xcode_ project by refering to it with `https://github.com/Orange-OpenSource/ouds-ios`. -You are free to choose wether or not you want a branch or a specific tag, pick the solution you want. +[![Versions](https://img.shields.io/github/v/release/Orange-OpenSource/ouds-ios?label=Last%20version&style=for-the-badge)](https://github.com/Orange-OpenSource/ouds-ios/releases) +[![Still maintained](https://img.shields.io/maintenance/yes/2024?style=for-the-badge)](https://github.com/Orange-OpenSource/ouds-ios/issues?q=is%3Aissue+is%3Aclosed) -### Import the library you need +[![Code size](https://img.shields.io/github/languages/code-size/Orange-OpenSource/ouds-ios?style=for-the-badge)](https://github.com/Orange-OpenSource/ouds-ios) +[![Opened issues](https://img.shields.io/github/issues-raw/Orange-OpenSource/ouds-ios?style=for-the-badge)](https://github.com/Orange-OpenSource/ouds-ios/issues) -You should use one of the following imports for your needs: +[![iOS 15.0](https://img.shields.io/badge/iOS-15.0-informational.svg?style=for-the-badge)](https://developer.apple.com/support/app-store "iOS 15 supports") -```swift -import OUDSModules // To use modules -import OUDSComponents // To use components -import OUDSThemesOrange // To use the default theme -import OUDSThemesCommons // If you want to define your theme or use OUDSThemeableView -import OUDSTokensComponent // If you need to override components tokens -import OUDSTokenSemantic // If you need to override semantic tokens -import OUDSTokensRaw // If you need to override raw tokens -``` - -### Use themeable view - -```swift -// Make imports -import OUDSThemesCommons -import OUDSThemesOrange - -// Add themeable view to your root view -OUDSThemeableView(theme: OrangeTheme()) { - YourRootView() -} -``` - -### Define a custom theme if needed +## Content -```swift -class YourCustomTheme: OrangeTheme { } +This repository contains the OUDS iOS library that provides Orange iOS components for its unified design system, but also a demo application showcasing these different components. -extension YourCustomTheme { +You can find the [detailed technical documentation online](https://ios.unified-design-system.orange.com/), and also the [whole design system](https://unified-design-system.orange.com/). - // Override components tokens if needed - override var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDrag } - override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThickest } - - // Override colors semantic tokens if needed - override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun500 } - override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun800 } - - // Etc. -} -``` +Documentation is powered by [GitHub Pages](https://github.com/Orange-OpenSource/ouds-ios/tree/gh-pages). ## Bugs and feature requests @@ -92,8 +44,9 @@ Have a bug or a feature request? Please first search for existing and closed iss ## Contributing -Please read through our [contributing guidelines](https://github.com/Orange-OpenSource/ouds-ios/blob/main/.github/CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development. +Please read through our [contributing guidelines](https://github.com/Orange-OpenSource/ouds-ios/blob/main/.github/CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development. More technical details are available also in the [DEVELOP](https://github.com/Orange-OpenSource/ouds-ios/blob/main/.github/DEVELOP.md) file. ## Copyright and license Code released under the [MIT License](https://github.com/Orange-OpenSource/ouds-ios/blob/main/LICENSE). +For images and other assets, please [refer to the NOTICE.txt](https://github.com/Orange-OpenSource/ouds-ios/blob/ain/NOTICE.txt). diff --git a/Showcase/Showcase.xcodeproj/project.pbxproj b/Showcase/Showcase.xcodeproj/project.pbxproj index e44cc9263..8e5fbf04d 100644 --- a/Showcase/Showcase.xcodeproj/project.pbxproj +++ b/Showcase/Showcase.xcodeproj/project.pbxproj @@ -21,13 +21,21 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 070C35622C75EB1C0029C6A8 /* OUDS in Frameworks */ = {isa = PBXBuildFile; productRef = 070C35612C75EB1C0029C6A8 /* OUDS */; }; + 070C35642C773A0D0029C6A8 /* OUDSThemesInverse in Frameworks */ = {isa = PBXBuildFile; productRef = 070C35632C773A0D0029C6A8 /* OUDSThemesInverse */; }; + 070C35662C7762B90029C6A8 /* OUDSModules in Frameworks */ = {isa = PBXBuildFile; productRef = 070C35652C7762B90029C6A8 /* OUDSModules */; }; + 070C35682C7762B90029C6A8 /* OUDSThemesSosh in Frameworks */ = {isa = PBXBuildFile; productRef = 070C35672C7762B90029C6A8 /* OUDSThemesSosh */; }; + 0740A9982C9874160069D24A /* OUDSFormsTextInputUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 074008182C942753006B8729 /* OUDSFormsTextInputUITests.swift */; }; + 0740A99A2C9874670069D24A /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 0740A9992C9874670069D24A /* SnapshotTesting */; }; + 0740A99B2C9874E70069D24A /* Snapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 074008222C942810006B8729 /* Snapshot.swift */; }; 51087A7B2C46DF9F00160CCF /* Bundle+extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51087A7A2C46DF9F00160CCF /* Bundle+extension.swift */; }; 510A9CD02C5679A300430620 /* OUDSComponents in Frameworks */ = {isa = PBXBuildFile; productRef = 510A9CCF2C5679A300430620 /* OUDSComponents */; }; + 511B8EC12C99861600E7C2F1 /* ElevationsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 511B8EC02C99861600E7C2F1 /* ElevationsList.swift */; }; 512364792C3D7B2D00572FD5 /* Podfile.lock in Resources */ = {isa = PBXBuildFile; fileRef = 512364782C3D7B2D00572FD5 /* Podfile.lock */; }; 5123647B2C3D7B3500572FD5 /* Gemfile.lock in Resources */ = {isa = PBXBuildFile; fileRef = 5123647A2C3D7B3500572FD5 /* Gemfile.lock */; }; 513AD9402C5AAADE0003253B /* OUDSTokensComponent in Frameworks */ = {isa = PBXBuildFile; productRef = 513AD93F2C5AAADE0003253B /* OUDSTokensComponent */; }; + 513D58C22C9B28E100614929 /* ElevationsEffectsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513D58C12C9B28E100614929 /* ElevationsEffectsUITests.swift */; }; 5149BADB2C3D6F4F000FA4BF /* Podfile in Resources */ = {isa = PBXBuildFile; fileRef = 5149BADA2C3D6F4F000FA4BF /* Podfile */; }; - 518CAA822C650DB9005B61CA /* OUDSThemesCommons in Frameworks */ = {isa = PBXBuildFile; productRef = 518CAA812C650DB9005B61CA /* OUDSThemesCommons */; }; 51B4F7F42C5BEAB700312019 /* OrangeCustomTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51B4F7F32C5BEAB700312019 /* OrangeCustomTheme.swift */; }; 51BC9DE72C6513F200EB2A11 /* OUDSFoundations in Frameworks */ = {isa = PBXBuildFile; productRef = 51BC9DE62C6513F200EB2A11 /* OUDSFoundations */; }; 51BD76212C466FCF0033365D /* AboutPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51BD760B2C466FCF0033365D /* AboutPage.swift */; }; @@ -45,9 +53,27 @@ E537B9B66A6466473179DEE8 /* Pods_Showcase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E0D3017314DBC1733F8D0C79 /* Pods_Showcase.framework */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 0740A9932C9873500069D24A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 07FDCD892C296A500009AA13 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 07FDCD902C296A500009AA13; + remoteInfo = Showcase; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ 0707B6402C2C3C0400A911E7 /* .github */ = {isa = PBXFileReference; lastKnownFileType = folder; name = .github; path = ../.github; sourceTree = ""; }; 0707B6432C2C569500A911E7 /* Gemfile */ = {isa = PBXFileReference; lastKnownFileType = text; name = Gemfile; path = ../Gemfile; sourceTree = ""; }; + 074008182C942753006B8729 /* OUDSFormsTextInputUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OUDSFormsTextInputUITests.swift; sourceTree = ""; }; + 074008222C942810006B8729 /* Snapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Snapshot.swift; sourceTree = ""; }; + 0740A9872C9833670069D24A /* Appfile */ = {isa = PBXFileReference; lastKnownFileType = text; name = Appfile; path = fastlane/Appfile; sourceTree = ""; }; + 0740A9882C9833670069D24A /* Fastfile */ = {isa = PBXFileReference; lastKnownFileType = text; name = Fastfile; path = fastlane/Fastfile; sourceTree = ""; }; + 0740A9892C9833670069D24A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = fastlane/README.md; sourceTree = ""; }; + 0740A98F2C9873500069D24A /* ShowcaseTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShowcaseTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 0740A99C2C9888CF0069D24A /* ShowcaseUITestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = ShowcaseUITestPlan.xctestplan; path = ../ShowcaseUITestPlan.xctestplan; sourceTree = ""; }; + 07CEDD802C7DB921003E1885 /* generateDoc.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = generateDoc.sh; path = ../generateDoc.sh; sourceTree = ""; }; 07FDCD912C296A500009AA13 /* OUDS Showcase.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OUDS Showcase.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 07FDCDA52C296B4B0009AA13 /* .gitattributes */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = .gitattributes; path = ../.gitattributes; sourceTree = ""; }; 07FDCDA72C296B7A0009AA13 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; @@ -60,9 +86,11 @@ 07FDCDB72C296C370009AA13 /* .swiftformat */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = .swiftformat; path = ../.swiftformat; sourceTree = ""; }; 07FDCDB82C296C370009AA13 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = .gitignore; path = ../.gitignore; sourceTree = ""; }; 51087A7A2C46DF9F00160CCF /* Bundle+extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+extension.swift"; sourceTree = ""; }; + 511B8EC02C99861600E7C2F1 /* ElevationsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElevationsList.swift; sourceTree = ""; }; 512364782C3D7B2D00572FD5 /* Podfile.lock */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Podfile.lock; sourceTree = ""; }; 5123647A2C3D7B3500572FD5 /* Gemfile.lock */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Gemfile.lock; path = ../Gemfile.lock; sourceTree = ""; }; - 5149BADA2C3D6F4F000FA4BF /* Podfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Podfile; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 513D58C12C9B28E100614929 /* ElevationsEffectsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElevationsEffectsUITests.swift; sourceTree = ""; }; + 5149BADA2C3D6F4F000FA4BF /* Podfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Podfile; sourceTree = ""; }; 51A7A9DA2C46E17F00EF7A77 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 51B4F7F32C5BEAB700312019 /* OrangeCustomTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrangeCustomTheme.swift; sourceTree = ""; }; 51BD760B2C466FCF0033365D /* AboutPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutPage.swift; sourceTree = ""; }; @@ -84,27 +112,68 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 0740A98C2C9873500069D24A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0740A99A2C9874670069D24A /* SnapshotTesting in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 07FDCD8E2C296A500009AA13 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 51BC9DE72C6513F200EB2A11 /* OUDSFoundations in Frameworks */, + 070C35682C7762B90029C6A8 /* OUDSThemesSosh in Frameworks */, E537B9B66A6466473179DEE8 /* Pods_Showcase.framework in Frameworks */, + 070C35642C773A0D0029C6A8 /* OUDSThemesInverse in Frameworks */, 51EE2C682C5BF5DE00F634EC /* OUDSThemesOrange in Frameworks */, - 518CAA822C650DB9005B61CA /* OUDSThemesCommons in Frameworks */, + 070C35622C75EB1C0029C6A8 /* OUDS in Frameworks */, 513AD9402C5AAADE0003253B /* OUDSTokensComponent in Frameworks */, 510A9CD02C5679A300430620 /* OUDSComponents in Frameworks */, + 070C35662C7762B90029C6A8 /* OUDSModules in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 074008212C9427F8006B8729 /* Snapshots */ = { + isa = PBXGroup; + children = ( + 074008222C942810006B8729 /* Snapshot.swift */, + ); + path = Snapshots; + sourceTree = ""; + }; + 0740A98A2C98337C0069D24A /* fastlane */ = { + isa = PBXGroup; + children = ( + 0740A9872C9833670069D24A /* Appfile */, + 0740A9882C9833670069D24A /* Fastfile */, + 0740A9892C9833670069D24A /* README.md */, + ); + name = fastlane; + sourceTree = ""; + }; + 0740A9902C9873500069D24A /* ShowcaseTests */ = { + isa = PBXGroup; + children = ( + 074008212C9427F8006B8729 /* Snapshots */, + 074008182C942753006B8729 /* OUDSFormsTextInputUITests.swift */, + 513D58C12C9B28E100614929 /* ElevationsEffectsUITests.swift */, + 0740A99C2C9888CF0069D24A /* ShowcaseUITestPlan.xctestplan */, + ); + path = ShowcaseTests; + sourceTree = ""; + }; 07FDCD882C296A500009AA13 = { isa = PBXGroup; children = ( 07FDCDA32C296B170009AA13 /* πŸ›  */, 51BD76202C466FCF0033365D /* Showcase */, + 0740A9902C9873500069D24A /* ShowcaseTests */, 07FDCD922C296A500009AA13 /* Products */, AFD4931269C94655071502F6 /* Pods */, 6E90D400B72B50FE406E8DFC /* Frameworks */, @@ -115,6 +184,7 @@ isa = PBXGroup; children = ( 07FDCD912C296A500009AA13 /* OUDS Showcase.app */, + 0740A98F2C9873500069D24A /* ShowcaseTests.xctest */, ); name = Products; sourceTree = ""; @@ -136,6 +206,8 @@ 07FDCDA42C296B220009AA13 /* Configuration */ = { isa = PBXGroup; children = ( + 0740A98A2C98337C0069D24A /* fastlane */, + 07CEDD802C7DB921003E1885 /* generateDoc.sh */, 0707B6432C2C569500A911E7 /* Gemfile */, 5123647A2C3D7B3500572FD5 /* Gemfile.lock */, 5149BADA2C3D6F4F000FA4BF /* Podfile */, @@ -149,6 +221,14 @@ name = Configuration; sourceTree = ""; }; + 511B8EBF2C9985C700E7C2F1 /* Elevations */ = { + isa = PBXGroup; + children = ( + 511B8EC02C99861600E7C2F1 /* ElevationsList.swift */, + ); + path = Elevations; + sourceTree = ""; + }; 51BD760C2C466FCF0033365D /* About */ = { isa = PBXGroup; children = ( @@ -160,6 +240,7 @@ 51BD760E2C466FCF0033365D /* Components */ = { isa = PBXGroup; children = ( + 511B8EBF2C9985C700E7C2F1 /* Elevations */, 51BD760D2C466FCF0033365D /* ComponentsPage.swift */, ); path = Components; @@ -248,6 +329,27 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 0740A98E2C9873500069D24A /* ShowcaseTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0740A9952C9873500069D24A /* Build configuration list for PBXNativeTarget "ShowcaseTests" */; + buildPhases = ( + 0740A98B2C9873500069D24A /* Sources */, + 0740A98C2C9873500069D24A /* Frameworks */, + 0740A98D2C9873500069D24A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 0740A9942C9873500069D24A /* PBXTargetDependency */, + ); + name = ShowcaseTests; + packageProductDependencies = ( + 0740A9992C9874670069D24A /* SnapshotTesting */, + ); + productName = "OUDS ShowcaseTests"; + productReference = 0740A98F2C9873500069D24A /* ShowcaseTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 07FDCD902C296A500009AA13 /* Showcase */ = { isa = PBXNativeTarget; buildConfigurationList = 07FDCD9F2C296A540009AA13 /* Build configuration list for PBXNativeTarget "Showcase" */; @@ -267,8 +369,11 @@ 510A9CCF2C5679A300430620 /* OUDSComponents */, 513AD93F2C5AAADE0003253B /* OUDSTokensComponent */, 51EE2C672C5BF5DE00F634EC /* OUDSThemesOrange */, - 518CAA812C650DB9005B61CA /* OUDSThemesCommons */, 51BC9DE62C6513F200EB2A11 /* OUDSFoundations */, + 070C35612C75EB1C0029C6A8 /* OUDS */, + 070C35632C773A0D0029C6A8 /* OUDSThemesInverse */, + 070C35652C7762B90029C6A8 /* OUDSModules */, + 070C35672C7762B90029C6A8 /* OUDSThemesSosh */, ); productName = DemoApp; productReference = 07FDCD912C296A500009AA13 /* OUDS Showcase.app */; @@ -284,6 +389,10 @@ LastSwiftUpdateCheck = 1540; LastUpgradeCheck = 1540; TargetAttributes = { + 0740A98E2C9873500069D24A = { + CreatedOnToolsVersion = 15.4; + TestTargetID = 07FDCD902C296A500009AA13; + }; 07FDCD902C296A500009AA13 = { CreatedOnToolsVersion = 15.4; }; @@ -301,17 +410,28 @@ Base, ); mainGroup = 07FDCD882C296A500009AA13; + packageReferences = ( + 0740080F2C94256C006B8729 /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */, + ); productRefGroup = 07FDCD922C296A500009AA13 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 07FDCD902C296A500009AA13 /* Showcase */, 5123647C2C3D7D6F00572FD5 /* Periphery */, + 0740A98E2C9873500069D24A /* ShowcaseTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 0740A98D2C9873500069D24A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 07FDCD8F2C296A500009AA13 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -392,6 +512,16 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 0740A98B2C9873500069D24A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0740A9982C9874160069D24A /* OUDSFormsTextInputUITests.swift in Sources */, + 0740A99B2C9874E70069D24A /* Snapshot.swift in Sources */, + 513D58C22C9B28E100614929 /* ElevationsEffectsUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 07FDCD8D2C296A500009AA13 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -400,6 +530,7 @@ 51B4F7F42C5BEAB700312019 /* OrangeCustomTheme.swift in Sources */, 51BD76292C466FCF0033365D /* WebView.swift in Sources */, 51BD76232C466FCF0033365D /* GuidelinesPage.swift in Sources */, + 511B8EC12C99861600E7C2F1 /* ElevationsList.swift in Sources */, 51087A7B2C46DF9F00160CCF /* Bundle+extension.swift in Sources */, 51BD76222C466FCF0033365D /* ComponentsPage.swift in Sources */, 51BD76212C466FCF0033365D /* AboutPage.swift in Sources */, @@ -409,6 +540,14 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 0740A9942C9873500069D24A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 07FDCD902C296A500009AA13 /* Showcase */; + targetProxy = 0740A9932C9873500069D24A /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 51BD76152C466FCF0033365D /* about_legal_information.html */ = { isa = PBXVariantGroup; @@ -437,6 +576,54 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 0740A9962C9873500069D24A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = MG2LSJNJB6; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.orange.uds.demoapp.SnapshotTests.OUDS-ShowcaseTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OUDS Showcase.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/OUDS Showcase"; + }; + name = Debug; + }; + 0740A9972C9873500069D24A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = MG2LSJNJB6; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.orange.uds.demoapp.SnapshotTests.OUDS-ShowcaseTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OUDS Showcase.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/OUDS Showcase"; + }; + name = Release; + }; 07FDCD9D2C296A540009AA13 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -564,7 +751,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 8; + CURRENT_PROJECT_VERSION = 9; DEVELOPMENT_ASSET_PATHS = "\"Showcase/Preview Content\""; DEVELOPMENT_TEAM = MG2LSJNJB6; ENABLE_PREVIEWS = YES; @@ -580,7 +767,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.1.0; + MARKETING_VERSION = 0.2.0; PRODUCT_BUNDLE_IDENTIFIER = "com.orange.ouds.demoapp-debug"; PRODUCT_NAME = "OUDS Showcase"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -602,7 +789,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 8; + CURRENT_PROJECT_VERSION = 9; DEVELOPMENT_ASSET_PATHS = "\"Showcase/Preview Content\""; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = MG2LSJNJB6; @@ -619,7 +806,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.1.0; + MARKETING_VERSION = 0.2.0; PRODUCT_BUNDLE_IDENTIFIER = com.orange.ouds.demoapp; PRODUCT_NAME = "OUDS Showcase"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -653,6 +840,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 0740A9952C9873500069D24A /* Build configuration list for PBXNativeTarget "ShowcaseTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0740A9962C9873500069D24A /* Debug */, + 0740A9972C9873500069D24A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 07FDCD8C2C296A500009AA13 /* Build configuration list for PBXProject "Showcase" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -682,7 +878,39 @@ }; /* End XCConfigurationList section */ +/* Begin XCRemoteSwiftPackageReference section */ + 0740080F2C94256C006B8729 /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/pointfreeco/swift-snapshot-testing.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.17.5; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + /* Begin XCSwiftPackageProductDependency section */ + 070C35612C75EB1C0029C6A8 /* OUDS */ = { + isa = XCSwiftPackageProductDependency; + productName = OUDS; + }; + 070C35632C773A0D0029C6A8 /* OUDSThemesInverse */ = { + isa = XCSwiftPackageProductDependency; + productName = OUDSThemesInverse; + }; + 070C35652C7762B90029C6A8 /* OUDSModules */ = { + isa = XCSwiftPackageProductDependency; + productName = OUDSModules; + }; + 070C35672C7762B90029C6A8 /* OUDSThemesSosh */ = { + isa = XCSwiftPackageProductDependency; + productName = OUDSThemesSosh; + }; + 0740A9992C9874670069D24A /* SnapshotTesting */ = { + isa = XCSwiftPackageProductDependency; + package = 0740080F2C94256C006B8729 /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */; + productName = SnapshotTesting; + }; 510A9CCF2C5679A300430620 /* OUDSComponents */ = { isa = XCSwiftPackageProductDependency; productName = OUDSComponents; @@ -691,10 +919,6 @@ isa = XCSwiftPackageProductDependency; productName = OUDSTokensComponent; }; - 518CAA812C650DB9005B61CA /* OUDSThemesCommons */ = { - isa = XCSwiftPackageProductDependency; - productName = OUDSThemesCommons; - }; 51BC9DE62C6513F200EB2A11 /* OUDSFoundations */ = { isa = XCSwiftPackageProductDependency; productName = OUDSFoundations; diff --git a/Showcase/Showcase.xcodeproj/xcshareddata/xcschemes/ShowcaseTests.xcscheme b/Showcase/Showcase.xcodeproj/xcshareddata/xcschemes/ShowcaseTests.xcscheme new file mode 100644 index 000000000..337b552c8 --- /dev/null +++ b/Showcase/Showcase.xcodeproj/xcshareddata/xcschemes/ShowcaseTests.xcscheme @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Showcase/Showcase.xcworkspace/contents.xcworkspacedata b/Showcase/Showcase.xcworkspace/contents.xcworkspacedata index ff3964faa..a158f5a48 100644 --- a/Showcase/Showcase.xcworkspace/contents.xcworkspacedata +++ b/Showcase/Showcase.xcworkspace/contents.xcworkspacedata @@ -1,15 +1,18 @@ - - + + + + diff --git a/Showcase/Showcase.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Showcase/Showcase.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..c9543bd84 --- /dev/null +++ b/Showcase/Showcase.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,42 @@ +{ + "originHash" : "c8222820bbb3bf0533ea3b098f2334f8188d74c09aee2fb50ff24b3cfb9227bd", + "pins" : [ + { + "identity" : "swift-docc-plugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-plugin", + "state" : { + "revision" : "2eb22993b3dfd0c0d32729b357c8dabb6cd44680", + "version" : "1.4.2" + } + }, + { + "identity" : "swift-docc-symbolkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-docc-symbolkit", + "state" : { + "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", + "version" : "1.0.0" + } + }, + { + "identity" : "swift-snapshot-testing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-snapshot-testing.git", + "state" : { + "revision" : "7b0bbbae90c41f848f90ac7b4df6c4f50068256d", + "version" : "1.17.5" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-syntax", + "state" : { + "revision" : "515f79b522918f83483068d99c68daeb5116342d", + "version" : "600.0.0-prerelease-2024-09-04" + } + } + ], + "version" : 3 +} diff --git a/Showcase/Showcase/OrangeCustomTheme.swift b/Showcase/Showcase/OrangeCustomTheme.swift index 91ba70701..1e267896b 100644 --- a/Showcase/Showcase/OrangeCustomTheme.swift +++ b/Showcase/Showcase/OrangeCustomTheme.swift @@ -21,9 +21,9 @@ import OUDSThemesOrange // Can be for example a country theme class OrangeCustomTheme: OrangeTheme { } -/// Overrides for `FormsTextInputComponentToken` the configuration which for this theme. +/// Overrides for `FormsTextInputComponentTokens` the configuration which for this theme. /// **Warning: These are random and dumb values** -extension OrangeCustomTheme { // For FormsTextInputComponentToken +extension OrangeCustomTheme { // For FormsTextInputComponentTokens public override var ftiTitleFontWeight: TypographyFontWeightSemanticToken { fontWeightLabelStrong } public override var ftiTitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelXLarge } @@ -36,11 +36,11 @@ extension OrangeCustomTheme { // For FormsTextInputComponentToken public override var ftiBackgroundColorLight: ColorSemanticToken { colorBackgroundDefaultPrimaryLight } public override var ftiBackgroundColorDark: ColorSemanticToken { colorBackgroundDefaultPrimaryDark } - public override var ftiBorderColor: ColorSemanticToken { colorBorderEmphasisDark ?? OrangeBrandColorRawTokens.colorDecorativeShockingPink500 } + public override var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedDark ?? OrangeBrandColorRawTokens.colorDecorativeShockingPink500 } public override var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDrag } - public override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThickest } + public override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthDefault } } extension OrangeCustomTheme { // For ColorSemanticTokens @@ -48,3 +48,24 @@ extension OrangeCustomTheme { // For ColorSemanticTokens override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun500 } override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun800 } } + +extension OrangeCustomTheme { // For ButtonsComponentTokens + + override var buttonInternalSpacing: SpacingPaddingInlineSemanticToken { spacePaddingInlineComponentShorter } + + override var buttonBorderStyle: BorderStyleSemanticToken { borderStyleDrag } + override var buttonBorderColorLight: ColorSemanticToken { colorBorderDefaultLight! } + override var buttonBorderColorDark: ColorSemanticToken { colorBorderDefaultDark! } + override var buttonBorderWidth: BorderWidthSemanticToken { borderWidthDefault } + override var buttonBorderRadius: BorderRadiusSemanticToken { borderRadiusShort } + + override var buttonForegroundColorLight: ColorSemanticToken { sysColorBrandNeutralMutedLower! } + override var buttonForegroundColorDark: ColorSemanticToken { sysColorBrandNeutralMutedWhite! } + override var buttonBackgroundColorLight: ColorSemanticToken { sysColorBrandPositiveLowest! } + override var buttonBackgroundColorDark: ColorSemanticToken { sysColorBrandPositiveHighest! } + + override var buttonWidth: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension2000 } + override var buttonHeight: SizingWidthHeightSemanticToken { DimensionRawTokens.dimension800 } + + override var buttonTypography: TypographyCompositeSemanticToken { typeDisplaySmall } +} diff --git a/Showcase/Showcase/Pages/Components/ComponentsPage.swift b/Showcase/Showcase/Pages/Components/ComponentsPage.swift index 727702627..7b5154160 100644 --- a/Showcase/Showcase/Pages/Components/ComponentsPage.swift +++ b/Showcase/Showcase/Pages/Components/ComponentsPage.swift @@ -12,18 +12,16 @@ // import SwiftUI +import OUDSTokensSemantic +import OUDSTokensRaw + +// MARK: - View for display struct ComponentsPage: View { var body: some View { NavigationView { - VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundStyle(.tint) - Text("Hello, world!") - } - .navigationTitle("app_bottomBar_components") + ElevationsList().navigationTitle("app_bottomBar_components") } } } diff --git a/Showcase/Showcase/Pages/Components/Elevations/ElevationsList.swift b/Showcase/Showcase/Pages/Components/Elevations/ElevationsList.swift new file mode 100644 index 000000000..85bb715d7 --- /dev/null +++ b/Showcase/Showcase/Pages/Components/Elevations/ElevationsList.swift @@ -0,0 +1,95 @@ +// +// 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 OUDSTokensSemantic +import OUDSTokensRaw +import SwiftUI + +// MARK: - Raw tokens + +let raised = ElevationCompositeRawToken(x: 0, y: 1, blur: 2, color: ColorRawTokens.colorTransparentBlack500) +let overlayDefault = ElevationCompositeRawToken(x: 0, y: 2, blur: 3, color: ColorRawTokens.colorTransparentBlack400) +let allSticky = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack300) +let drag = ElevationCompositeRawToken(x: 0, y: 4, blur: 4, color: ColorRawTokens.colorTransparentBlack500) +let overlayEmphasized = ElevationCompositeRawToken(x: 0, y: 12, blur: 12, color: ColorRawTokens.colorTransparentBlack300) + +// MARK: - Rectangle for elevation tests + +/// Simple rectangle +struct ElevationRectangle: View { + + @Environment(\.colorScheme) private var colorScheme + + var foregroundColor: Color { + switch colorScheme { + case .light: + .white + case .dark: + "#333333".color + @unknown default: + fatalError() + } + } + + let elevation: ElevationCompositeSemanticToken + var body: some View { + Rectangle() + .frame(width: 300, height: 80) + .foregroundColor(foregroundColor) + .shadow(elevation: elevation) + } +} + +// MARK: - List of rectangles for rendering tests + +/// Just a debug `View` to list the elevations effects and render them. +/// Set as public for UI tests purposes. +public struct ElevationsList: View { + + public init() {} + + @Environment(\.colorScheme) private var colorScheme + + var backgroundColor: Color { + switch colorScheme { + case .light: + "#f4f4f4".color + case .dark: + "#272727".color + @unknown default: + fatalError() + } + } + + public var body: some View { + ScrollView { + VStack(alignment: .leading, spacing: 40) { + ElevationRectangle(elevation: raised) + ElevationRectangle(elevation: overlayDefault) + ElevationRectangle(elevation: allSticky) + ElevationRectangle(elevation: drag) + ElevationRectangle(elevation: overlayEmphasized) + } + .frame(maxWidth: .infinity) + } + .background(backgroundColor) + } +} + +#Preview { + ElevationsList().preferredColorScheme(.dark) +} +#Preview { + ElevationsList().preferredColorScheme(.light) +} diff --git a/Showcase/Showcase/Pages/Guidelines/GuidelinesPage.swift b/Showcase/Showcase/Pages/Guidelines/GuidelinesPage.swift index 43a6476c7..404bdf92e 100644 --- a/Showcase/Showcase/Pages/Guidelines/GuidelinesPage.swift +++ b/Showcase/Showcase/Pages/Guidelines/GuidelinesPage.swift @@ -12,9 +12,9 @@ // import SwiftUI -import OUDSComponents // To get for example OUDSFormsTextInput -import OUDSThemesCommons // To get OUDSThemeableView -import OUDSThemesOrange // To get OrangeTheme +import OUDS +import OUDSComponents +import OUDSThemesOrange struct GuidelinesPage: View { @@ -29,19 +29,25 @@ struct GuidelinesPage: View { var body: some View { OUDSThemeableView(theme: selectedTheme) { NavigationView { - VStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/, spacing: 20) { + VStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/, spacing: 30) { - OUDSFormsTextInput(placeholder: "Placeholder defined in app", + OUDSFormsTextInput(label: "Awesome form", + hint: "Type something", + placeholder: "Display large", value: $writtenText) + OUDSButton(text: "Some button") {} + Button("Try OUDS Orange Theme") { selectedTheme = OrangeTheme() print("Showcase app - Selected OUDS Orange theme") } + Button("Try custom \"local\" theme") { selectedTheme = OrangeCustomTheme() print("Showcase app - Selected app custom theme") } + } .padding(.horizontal, 20) .navigationTitle("app_bottomBar_guidelines") diff --git a/Showcase/ShowcaseTests/ElevationsEffectsUITests.swift b/Showcase/ShowcaseTests/ElevationsEffectsUITests.swift new file mode 100644 index 000000000..98b4c73fb --- /dev/null +++ b/Showcase/ShowcaseTests/ElevationsEffectsUITests.swift @@ -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 OUDS_Showcase +import OUDSComponents +import OUDSThemesOrange +import OUDSThemesSosh +import OUDSThemesInverse +import SwiftUI +import XCTest + +/// Class to make UI tests on elevations effects using the +/// [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing) library. +final class ElevationsEffectsUITests: XCTestCase { + + // MARK: - Tests + + func testElevationsEffects_OrangeTheme() { + Snapshot.assert(ElevationsList().environment(\.theme, OrangeTheme()), testName: "\(#function)OrangeTheme") + } + + func testElevationsEffects_SoshTheme() { + Snapshot.assert(ElevationsList().environment(\.theme, SoshTheme()), testName: "\(#function)SoshTheme") + } + + func testElevationsEffects_InverseTheme() { + Snapshot.assert(ElevationsList().environment(\.theme, InverseTheme()), testName: "\(#function)InverseTheme") + } +} diff --git a/Showcase/ShowcaseTests/OUDSFormsTextInputUITests.swift b/Showcase/ShowcaseTests/OUDSFormsTextInputUITests.swift new file mode 100644 index 000000000..4dade640f --- /dev/null +++ b/Showcase/ShowcaseTests/OUDSFormsTextInputUITests.swift @@ -0,0 +1,49 @@ +// +// 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_Showcase +import OUDSComponents +import OUDSThemesOrange +import OUDSThemesSosh +import OUDSThemesInverse +import SwiftUI +import XCTest + +/// Class to make UI tests on the fake component `OUDSFormsTextInput` using the +/// [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing) library. +final class OUDSFormsTextInputUITests: XCTestCase { + + // MARK: - Wrapper + + private struct TestFormsTextInput: View { + @State private var value: String = "" + + var body: some View { + OUDSFormsTextInput(label: "Some label", hint: "Some hint", placeholder: "Add text here", value: $value) + } + } + + // MARK: - Tests + + func testOUDSFormsTextInput_OrangeTheme() { + Snapshot.assert(TestFormsTextInput().environment(\.theme, OrangeTheme()), testName: "\(#function)OrangeTheme") + } + + func testOUDSFormsTextInput_SoshTheme() { + Snapshot.assert(TestFormsTextInput().environment(\.theme, SoshTheme()), testName: "\(#function)SoshTheme") + } + + func testOUDSFormsTextInput_InverseTheme() { + Snapshot.assert(TestFormsTextInput().environment(\.theme, InverseTheme()), testName: "\(#function)InverseTheme") + } +} diff --git a/Showcase/ShowcaseTests/Snapshots/Snapshot.swift b/Showcase/ShowcaseTests/Snapshots/Snapshot.swift new file mode 100644 index 000000000..6c1565795 --- /dev/null +++ b/Showcase/ShowcaseTests/Snapshots/Snapshot.swift @@ -0,0 +1,97 @@ +// +// 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 SnapshotTesting +import SwiftUI + +enum Snapshot { + + // MARK: - API + + /// Asserts that a given view matches a reference on disk. + /// The test is executed on light and dark modes on an iPhone 13 Pro Max. + /// + /// - Parameters: + /// - view: The view to compare against a reference. + /// - file: The file in which failure occurred. Defaults to the file path of the test case in + /// which this function was called. + /// - testName: The name of the test in which failure occurred. Defaults to the function name of + /// the test case in which this function was called. + /// - line: The line number on which failure occurred. Defaults to the line number on which this + /// function was called. + static func assert(_ view: Content, file: StaticString = #file, testName: String = #function, line: UInt = #line) where Content: View { + let viewController = UIHostingController(rootView: view) + assertSnapshot( + of: viewController, + as: .image(on: .iPhone13ProMax, traits: Self.darkStyleTraits), + file: file, + testName: testName, + line: line) + + assertSnapshot( + of: viewController, + as: .image(on: .iPhone13ProMax, traits: Self.lightStyleTraits), + file: file, + testName: testName, + line: line) + } + + static func assert(_ views: [Content], file: StaticString = #file, testName: String = #function, line: UInt = #line) where Content: View { + for view in views { + assert(view, file: file, testName: testName, line: line) + } + } + + // MARK: - Private Implementation + + private static let darkStyleTraits = UITraitCollection(userInterfaceStyle: .dark) + private static let lightStyleTraits = UITraitCollection(userInterfaceStyle: .light) + + /// Add support for iPhone 14 Pro Max + private static let iPhone14ProMax = iPhone14ProMax(.portrait) + + private static func iPhone14ProMax(_ orientation: ViewImageConfig.Orientation) -> ViewImageConfig { + let safeArea: UIEdgeInsets + let size: CGSize + switch orientation { + case .portrait: + safeArea = .init(top: 59, left: 0, bottom: 34, right: 0) + size = .init(width: 430, height: 932) + case .landscape: + safeArea = .init(top: 0, left: 59, bottom: 21, right: 59) + size = .init(width: 932, height: 430) + } + return .init(safeArea: safeArea, size: size, traits: iPhone14ProMaxTraits(orientation)) + } + + private static func iPhone14ProMaxTraits(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection { + let base: [UITraitCollection] = [ + .init(forceTouchCapability: .available), + .init(layoutDirection: .leftToRight), + .init(preferredContentSizeCategory: .medium), + .init(userInterfaceIdiom: .phone), + ] + switch orientation { + case .portrait: + return .init(traitsFrom: base + [ + .init(horizontalSizeClass: .compact), + .init(verticalSizeClass: .regular), + ]) + case .landscape: + return .init(traitsFrom: base + [ + .init(horizontalSizeClass: .regular), + .init(verticalSizeClass: .compact), + ]) + } + } +} diff --git a/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_InverseTheme-InverseTheme.1.png b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_InverseTheme-InverseTheme.1.png new file mode 100644 index 000000000..69f6afd8d Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_InverseTheme-InverseTheme.1.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_InverseTheme-InverseTheme.2.png b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_InverseTheme-InverseTheme.2.png new file mode 100644 index 000000000..770d03268 Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_InverseTheme-InverseTheme.2.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_OrangeTheme-OrangeTheme.1.png b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_OrangeTheme-OrangeTheme.1.png new file mode 100644 index 000000000..69f6afd8d Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_OrangeTheme-OrangeTheme.1.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_OrangeTheme-OrangeTheme.2.png b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_OrangeTheme-OrangeTheme.2.png new file mode 100644 index 000000000..770d03268 Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_OrangeTheme-OrangeTheme.2.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_SoshTheme-SoshTheme.1.png b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_SoshTheme-SoshTheme.1.png new file mode 100644 index 000000000..69f6afd8d Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_SoshTheme-SoshTheme.1.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_SoshTheme-SoshTheme.2.png b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_SoshTheme-SoshTheme.2.png new file mode 100644 index 000000000..770d03268 Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/ElevationsEffectsUITests/testElevationsEffects_SoshTheme-SoshTheme.2.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_InverseTheme-InverseTheme.1.png b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_InverseTheme-InverseTheme.1.png new file mode 100644 index 000000000..8c282f6fc Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_InverseTheme-InverseTheme.1.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_InverseTheme-InverseTheme.2.png b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_InverseTheme-InverseTheme.2.png new file mode 100644 index 000000000..2847c7442 Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_InverseTheme-InverseTheme.2.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_OrangeTheme-OrangeTheme.1.png b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_OrangeTheme-OrangeTheme.1.png new file mode 100644 index 000000000..5ad84d508 Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_OrangeTheme-OrangeTheme.1.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_OrangeTheme-OrangeTheme.2.png b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_OrangeTheme-OrangeTheme.2.png new file mode 100644 index 000000000..60f4608da Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_OrangeTheme-OrangeTheme.2.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_SoshTheme-SoshTheme.1.png b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_SoshTheme-SoshTheme.1.png new file mode 100644 index 000000000..ccc072705 Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_SoshTheme-SoshTheme.1.png differ diff --git a/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_SoshTheme-SoshTheme.2.png b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_SoshTheme-SoshTheme.2.png new file mode 100644 index 000000000..14600781c Binary files /dev/null and b/Showcase/ShowcaseTests/__Snapshots__/OUDSFormsTextInputUITests/testOUDSFormsTextInput_SoshTheme-SoshTheme.2.png differ diff --git a/Showcase/ShowcaseUITestPlan.xctestplan b/Showcase/ShowcaseUITestPlan.xctestplan new file mode 100644 index 000000000..eb7b9d571 --- /dev/null +++ b/Showcase/ShowcaseUITestPlan.xctestplan @@ -0,0 +1,19 @@ +{ + "configurations" : [ + + ], + "defaultOptions" : { + "language" : "en", + "testTimeoutsEnabled" : true + }, + "testTargets" : [ + { + "target" : { + "containerPath" : "container:Showcase.xcodeproj", + "identifier" : "0740A98E2C9873500069D24A", + "name" : "ShowcaseTests" + } + } + ], + "version" : 1 +} diff --git a/Showcase/fastlane/Fastfile b/Showcase/fastlane/Fastfile index b207c1bf5..1ea89c313 100644 --- a/Showcase/fastlane/Fastfile +++ b/Showcase/fastlane/Fastfile @@ -107,6 +107,31 @@ platform :ios do raise error end end + + # ------------ + # RUN UI TESTS + # ------------ + desc "RUN UI TESTS BY TRIGGERING THE TESTS PLANS OF THE PROJECT" + lane :test_ui do + puts "πŸ‘‰ Run UI tests" + + # Should have on runner one device under at least iOS 15 + # Check the available devices using `xcrun xctrace list devices` + # Add new environments using `xcodebuild -downloadPlatform iOS` + begin + device = "iPhone 15 Pro" + scan(scheme: "ShowcaseTests", + device: device, + skip_build: true + ) + + publish_mattermost_notification("πŸ§ͺ βœ… No issue with UI tests") + + rescue => error + publish_mattermost_notification("πŸ§ͺ 🚨 @channel Some issue occured with tests (:test_ui)") + raise error + end + end # ------------------------------------------------------------ # READ AND SET NEXT RELEASE NOTE IN CHANGELOG @@ -505,15 +530,18 @@ platform :ios do else comment_to_upload=<<-EOF -πŸ“£ **New TestFlight ALPHA upload** πŸš€ +πŸ“£ **New TestFlight ALPHA uploap available** πŸš€ + +Please, get the new build from *TestFlight* app. + - Display name: **#{build_display_name}** -- Version: #{build_version} +- Version: **#{build_version}** - Build number: **#{build_number}** -- Build tag: #{build_tag} -- Build type: #{build_type} -- Build details (GitHub):#{build_details} +- Build tag: **#{build_tag}** +- Build type: **#{build_type}** +- Build details (GitHub): **#{build_details}** -_This is an automated message sent with *Fastlane* from our CI/CD pipeline 🀘_ +_This is an automated message sent with love and *Fastlane* from our CI/CD pipeline 🀘_ EOF uri = URI("https://api.github.com/repos/Orange-OpenSource/ouds-ios/issues/#{issue_number}/comments") diff --git a/Showcase/fastlane/README.md b/Showcase/fastlane/README.md index 764d716bc..d12f684cf 100644 --- a/Showcase/fastlane/README.md +++ b/Showcase/fastlane/README.md @@ -31,6 +31,14 @@ UPDATE BUILD NUMBER WITH TIMESTAMP RUN TESTS BY TRIGGERING THE TESTS PLANS OF THE PROJECT +### ios test_ui + +```sh +[bundle exec] fastlane ios test_ui +``` + +RUN UI TESTS BY TRIGGERING THE TESTS PLANS OF THE PROJECT + ### ios prepare_release ```sh diff --git a/THIRD_PARTY.md b/THIRD_PARTY.md index b9a3f84e9..e1db805b4 100644 --- a/THIRD_PARTY.md +++ b/THIRD_PARTY.md @@ -5,66 +5,61 @@ This document contains the list of Third Party Softwares along with the license Third Party Software may impose additional restrictions and it is the user's responsibility to ensure that they have met the licensing requirements of the relevant license of the Third Party Software they are using. +For further details about versions, please refer to *Gemfile*, *Gemfile.lock*, *Package.swift*, *Package.resolved* and *Podfile* files. + ## In OUDS library ## In Showcase demo app +### swift-snapshot-testing + +Copyright 2019 Point-Free, Inc. + +*swift-snapshot-testing* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). +You may download the source code on the [following website](https://github.com/pointfreeco/swift-snapshot-testing). + ## In Project ### Ruby gems #### CocoaPods -Version 1.15.2 - -Copyright 2011 Eloy DurΓ‘n, Fabio Pelosin, Samuel Giddins, Marius Rackwitz, Kyle Fuller, Boris BΓΌgling, Orta Therox, Olivier Halligon, Danielle Tomlinson, Dimitris Koutsogiorgas, Paul Beusterien, Eric Amorde. +Copyright 2011 Eloy DurΓ‘n, Fabio Pelosin, Samuel Giddins, Marius Rackwitz, Kyle Fuller, Boris BΓΌgling, Orta Therox, Olivier Halligon, Danielle Tomlinson, Dimitris Koutsogiorgas, Paul Beusterien, Eric Amorde *CocoaPods* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). You may download the source code on the [following website](https://github.com/CocoaPods/CocoaPods). #### Fastlane -Version 2.221.1 - -Copyright 2015-2022 The Fastlane Authors. +Copyright 2015-2022 The Fastlane Authors *Fastlane* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). You may download the source code on the [following website](https://github.com/fastlane/fastlane). #### fastlane-plugin-changelog -Version 0.16.0 - -Copyright 2018 Pavel ProchΓ‘zka. +Copyright 2018 Pavel ProchΓ‘zka *fastlane-plugin-changelog* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). You may download the source code on the [following website](https://github.com/pajapro/fastlane-plugin-changelog). #### fastlane-plugin-mattermost -Version 1.3.2 - -Copyright 2020 cpfriend1721994. +Copyright 2020 cpfriend1721994 *fastlane-plugin-mattermost* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). You may download the source code on the [following website](https://github.com/cpfriend1721994/fastlane-plugin-mattermost). #### net-http -Version 0.4.1 - *net-http* is distributed under the terms and conditions of the [Ruby License](https://github.com/flori/json/blob/master/LICENSE). #### json -Version 2.7.2 - *json* is distributed under the terms and conditions of the [Ruby License](https://github.com/flori/json/blob/master/LICENSE). #### xcode-install -Version 2.8.1 - Copyright (c) 2015 Boris BΓΌgling *xcode-install* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). @@ -72,6 +67,13 @@ You may download the source code on the [following website](https://github.com/x ### Other tools +#### swift-docc-plugin + +Copyright (c) 2022 Apple Inc. and the Swift project authors + +*swift-docc-plugin* is distributed under the terms and conditions of the [Apache 2.0 License with Runtime Library Exception](https://github.com/swiftlang/swift-docc-plugin/blob/main/LICENSE.txt). +You may download the source code on the [following website](https://github.com/swiftlang/swift-docc-plugin). + #### Gitleaks Copyright (c) 2019 Zachary Rice @@ -88,18 +90,14 @@ You may download the source code on the [following website](https://github.com/p #### SwiftFormat -Version 0.54.3 - -Copyright 2016 Nick Lockwood. +Copyright 2016 Nick Lockwood *SwiftFormat* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). You may download the source code on the [following website](https://github.com/nicklockwood/SwiftFormat). #### SwiftLint -Version 0.56.1 - Copyright 2020 Realm Inc. *SwiftLint* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT). -You may download the source code on the [following website](https://github.com/realm/SwiftLint). \ No newline at end of file +You may download the source code on the [following website](https://github.com/realm/SwiftLint). diff --git a/docs_release/README.md b/docs_release/README.md index d15d67b6c..1c20cd791 100644 --- a/docs_release/README.md +++ b/docs_release/README.md @@ -6,6 +6,7 @@ This file lists all the steps to follow when releasing a new version of OUDS iOS - [Release](#release) * [Publish release to GitHub](#publish-release-to-github) - [Prepare Next Release](#prepare-next-release) +- [About documentation](#about-documentation) - [About CI/CD with GitLab CI](#about-cicd-with-gitlabci) * [GitLab CI pipeline](#gitlab-ci-pipeline) * [Prepare environment build Shell script](#prepare-environement-build-shell-script) @@ -56,7 +57,14 @@ This file lists all the steps to follow when releasing a new version of OUDS iOS - + +- Generate documentation from Swift sources, it will update online version and generate a ZIP file + ```shell + ./generateDoc.sh --libversion=X.Y.Z --usegit + # --usegit means updating GitHub Pages branch + # Add --nozip if you don't want a ZIP file + # X.Y.Z here is just the version number to display in main index.html pages, replace values of course + ``` - Create a new pull request named `Prepare release X.Y.Z` on GitHub to merge your branch into `develop`. - Review and merge this pull request on GitHub.

@@ -130,6 +138,8 @@ This file lists all the steps to follow when releasing a new version of OUDS iOS > --> +- Do not forget to update the documentation using `generateDoc.sh` script. It will let a ZIP file of the documentation in */tmp* folder ; get this file and add it as release artifact. You should also through Xcode build the documentation (_Product > Build Documentation_) and export each documentation catalog as documentation archive (_Right click on catalog > Export). + ## Prepare Next Release - Create a branch named `prepare-new-release` to prepare the new release for OUDS iOS version U.V.W. @@ -149,6 +159,33 @@ This file lists all the steps to follow when releasing a new version of OUDS iOS - Create a new pull request named `Update release U.V.W` on GitHub to merge your branch into `develop`. - Review and merge this pull request on GitHub.

+## About documentation + +The documentation tool in use is [Swift DocC](https://www.swift.org/documentation/docc/), and the [swift-docc](https://github.com/swiftlang/swift-docc) plugin is sued to build the HTML documentation. +To do that, the `generateDoc.sh` script has been defined, and helps to build the HTML documentation, compress it as archive file and also update the GitHub Pages dedicated branch. + +```shell +# To show the help: +./generateDoc.sh --help + +# To build the doc and push to GitHub: +# VERSION will be added in the main page +# --usegit make the script upload sources to GitHub +./generateDoc.sh --libversion=VERSION --usegit + +# If you don't want the ZIP to be computed: +./generateDoc.sh --libversion=VERSION --usegit --nozip +``` + +Keep in mind everything is stored in _/tmp_ folder with the execution timestamp, thus if you asked for a ZIP archive or want to get the generated files, look for files named "ouds-docs". + +The *swift-docc* plugin has troubles for Swift Package with several targets, we should wait for evolutions, an [issue has been created about evolutions of doc we would like to have](https://github.com/Orange-OpenSource/ouds-ios/issues/95). + +The plugin produces a lot of files, a lot. For example for our v0.1.0, more than 6,000 files have beenc reated for a ZIP archive of about 17 MB. +Thus, keeping all versions of the documentation is a non-sense, no one will read it and it will increase the size of the branch in our VCS tool. + +We prefer to build ZIP documentation and Xcode doc archive to add as artifacts of releases. + ## About CI/CD with GitLabCI You can setup in your side a _GitLab CI_ runner which can trigger some _Fastlane_ actions for example each night. diff --git a/generateDoc.sh b/generateDoc.sh new file mode 100755 index 000000000..b19e212c2 --- /dev/null +++ b/generateDoc.sh @@ -0,0 +1,334 @@ +#!/bin/bash +# +# 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 +# + +# Controls on script +set -euo pipefail + +# Configuration +# ------------- + +# The Swift Package targets to build documentation of +# Of course if your project is not compliant with Swift Package and DocC don't use this tool +TARGETS="OUDS \ + OUDSThemesSosh \ + OUDSThemesInverse \ + OUDSThemesOrange \ + OUDSTokensRaw \ + OUDSTokensSemantic \ + OUDSTokensComponent \ + OUDSComponents \ + OUDSModules \ + OUDSFoundations" + +# Services pages (like GitHub Pages) custom subdomain for the CNAME, don't forget to verify it in organization side for security reasons! +# For example, with GitHub pages; given the "ouds-ios" project for "Orange-OpenSource" organization, +# the custom domain "ios.unified-design-system.orange.com" will thus automatically redirect to "orange-opensource.github.io/ouds-ios" +SERVICE_PAGES_DOMAIN="ios.unified-design-system.orange.com" + +# Some HTML fragments to add in the HTML global page index.html +HTML_TITLE="OUDS iOS Swift Documentation" +HTML_H1="OUDS iOS Swift Documentation" +HTML_H2="iOS SwiftUI implementation of the Unified Design System of Orange" +HTML_PROJECT_URL="https://github.com/Orange-OpenSource/ouds-ios" +HTML_PROJECT_COPYRIGHT="Orange SA" + +# The name of the Git branch hosting the documentation (e.g. GitHub Pages branch defined in repository) +# We suppose all the documentation will be in this dedicated branch +SERVICE_PAGES_BRANCH="gh-pages" + +# Path where the documentation will be temporary +DOCS_DIRECTORY="./docs" + +# The generated name of the ZIP containing the generated sources of documentation (for archive) +timestamp=$(date +%s) +DOCUMENTATION_ZIP_NAME="ouds-docs-$timestamp.zip" +DOCUMENTATION_ZIP_LOCATION="/tmp/$DOCUMENTATION_ZIP_NAME" +DOCUMENTATION_HTML_LOCATION="/tmp/ouds-docs-$timestamp" + +# Errors management +# ----------------- + +EXIT_OK=0 +EXIT_ERROR_SIG=1 +EXIT_NOT_GIT_REPO=2 +EXIT_BAD_PARAMETER=3 + +on_error_signal() { + _ "❌ An error occurred with command '$BASH_COMMAND'. Exits. ($EXIT_ERROR_SIG)" + if [[ $use_git -eq 1 ]]; then + clean_repo + fi + exit $EXIT_ERROR_SIG +} + +trap 'on_error_signal' ERR +trap 'on_error_signal' SIGINT +trap 'on_error_signal' SIGTERM +trap 'on_error_signal' SIGABRT + +# Functions +# --------- + +_() { + local message="$1" + local is_error="${2:-false}" + local prefix="🍊 " + + if [[ "$is_error" == "true" ]]; then + echo "${prefix}❌ ERROR: $message" >&2 + else + echo "${prefix}$message" + fi +} + +clean_repo() { + _ "🧹 Cleaning Git repository" + git reset --hard + git clean -fd +} + +show_help() { + echo "This script will use swift-docc-plugin to build HTML documentation of the OUDS iOS Swift Package" + echo "It can also update the Git repository." + echo -e "Usage: $0 [--help] --libversion=VERSION [--usegit | --nozip | --nokeep]\n" + echo "Options:" + echo " --help Shows this help message." + echo " --libversion=VERSION Specifies the library version to include in HTML page (mandatory)." + echo " --usegit Specifies to version documentation in the current Git repository and upload (default it does not, only local)." + echo " --nozip Specifies the ZIP archive of the documentation must not be done (by default it is)." +} + +# Step 0 - Prerequisites checks +# ----------------------------- + +lib_version="" +use_git=0 +no_zip=0 +keep_generated=1 + +# Check for command-line arguments +for arg in "$@"; do + case "$arg" in + --help) + show_help + exit $EXIT_OK + ;; + --libversion=*) + lib_version="${arg#*=}" + _ "βœ”οΈ OK, library version to know is '$lib_version'" + ;; + --usegit) + use_git=1 + ;; + --nozip) + no_zip=1 + ;; + *) + _ "Unknown parameter: $arg. Exits. ($EXIT_BAD_PARAMETER)" true + exit $EXIT_BAD_PARAMETER + ;; + esac +done + +if [[ -z "$lib_version" ]]; then + _ "Parameter --libversion is mandatory. Exits. ($EXIT_BAD_PARAMETER)" true + exit $EXIT_BAD_PARAMETER +fi + +if [[ $use_git -eq 1 ]]; then + _ "βœ”οΈ OK, Git will be used" +else + _ "βœ”οΈ OK, Git will NOT be used" +fi + +if [[ $no_zip -eq 1 ]]; then + _ "βœ”οΈ OK, no ZIP archive will be done" +else + _ "βœ”οΈ OK, a ZIP archive will be created" +fi + +if [[ "$use_git" -eq 0 && "$no_zip" -eq 1 ]]; then + _ "πŸ₯΄ WARNING: What do you use this script for? You should at least save the doc in Git repository or in ZIP file" +fi + +# Step 1 - Git setup (if relevant) +# -------------------------------- + +start_time=$(date +%s) + +if [[ $use_git -eq 1 ]]; then + if [ -d ".git" ]; then + + # Xcode keeps files and dislikes updates of local branches... + _ "🚨 You should close Xcode or any software working on this workspace, before going further, just in case of..." + _ "Press any key to continue..." + read -n 1 -s # Don't care of the input, just want the user be ready in the end + + _ "βœ… This is a Git repository. Please ensure the credentials you need are ready (SSH, HTTPS, GPG, etc.)" + current_branch=$(git rev-parse --abbrev-ref HEAD) + _ "πŸ”¨ Current Git branch is '$current_branch'" + clean_repo # To get rid of unversioned files etc. + else + _ "This is not a Git repository. Exits. ($EXIT_NOT_GIT_REPO)" true + exit $EXIT_NOT_GIT_REPO + fi +fi + +_ "πŸ‘‰ Creating documentation folder..." +mkdir -p "$DOCS_DIRECTORY" +_ "πŸ‘ Documention folder created at '$DOCS_DIRECTORY'!" + +# Step 2 - For each target, build the DocC documentation +# ------------------------------------------------------ + +# WARNING +# The version of swift-docc-plugin (https://github.com/swiftlang/swift-docc-plugin) we use (here 1.4.2 according to the Package.resolved file) +# does not seem to manage very weell Swift Packages with several targets. +# Consider using this version of the tool or submit an issue / pull request for updates to https://github.com/Orange-OpenSource/ouds-ios +# Related issue: https://github.com/Orange-OpenSource/ouds-ios/issues/95 +# (β•―Β°β–‘Β°)β•―οΈ΅ ┻━┻ + +_ "πŸ‘‰ Generating docs..." + +for target in ${TARGETS} +do + _ "πŸ‘‰ Generating docs for $target..." + swift package --allow-writing-to-directory "$target-docs" generate-documentation --disable-indexing --transform-for-static-hosting --output-path "$target-docs" --target "$target" + + cp -r $target-docs/* $DOCS_DIRECTORY + modified_target=$(echo $target | tr '-' '_' | tr '[:upper:]' '[:lower:]') + cp -r $target-docs/index/index.json "$DOCS_DIRECTORY/index/$modified_target.json" + _ "πŸ‘ Docs generated for $target!" +done + +# Step 3 - Add CNAME file for GitHub Pages +# ---------------------------------------- + +if [[ $use_git -eq 1 ]]; then + _ "πŸ‘‰ Updating CNAME file" + echo "$SERVICE_PAGES_DOMAIN" > "$DOCS_DIRECTORY/CNAME" + _ "πŸ‘ Updated!" +fi + +# Step 4 - Update global HTML file +# -------------------------------- + +# This is only to build a global index.html file referencing all other targets index.html files + +_ "πŸ‘‰ Updating index.html..." + +echo "$HTML_TITLE

$HTML_H1

" > $DOCS_DIRECTORY/index.html +echo "

$HTML_H2

" >> $DOCS_DIRECTORY/index.html +echo "

Version v$lib_version

" >> $DOCS_DIRECTORY/index.html +echo "

All targets of the Swift Package are listed below

" >> $DOCS_DIRECTORY/index.html +echo "
    " >> $DOCS_DIRECTORY/index.html +for target in ${TARGETS} +do + cp -R "$target-docs/data/documentation/"* "$DOCS_DIRECTORY/data/documentation/" + cp -R "$target-docs/documentation/"* "$DOCS_DIRECTORY/documentation/" + rm -r "$target-docs" + modified_target=$(echo "$target" | tr '-' '_' | tr '[:upper:]' '[:lower:]') + echo "
  1. $target
  2. " >> $DOCS_DIRECTORY/index.html +done +echo "
" >> $DOCS_DIRECTORY/index.html +echo "" >> $DOCS_DIRECTORY/index.html + +_ "πŸ‘ index.html updated!" + +files_count=`find $DOCS_DIRECTORY -type f | wc -l | xargs` + +# Step 5a - Checkout to service pages dedicated branch (if relevant) +# ------------------------------------------------------------------ + +# When the files have been generated, stash them, change branch, unstash, add, commit, push then clean + +if [[ $use_git -eq 1 ]]; then + _ "πŸ‘‰ Versioning documentation in service pages branch (it can take a lot of time)..." + + _ "πŸ”¨ Saving things" + cp -r "$DOCS_DIRECTORY" "$DOCUMENTATION_HTML_LOCATION" + clean_repo + + _ "πŸ”¨ Checkout service pages branch, align with remote" + + # Check if the local branch exists + if git show-ref --verify --quiet refs/heads/"$SERVICE_PAGES_BRANCH"; then + _ "πŸ”¨ Checking out local branch '$SERVICE_PAGES_BRANCH'" + git checkout "$SERVICE_PAGES_BRANCH" + git reset --hard origin/$SERVICE_PAGES_BRANCH # Ensure to be aligned with remote version + else + _ "πŸ”¨ Local branch '$SERVICE_PAGES_BRANCH' does not exist. Checking out from remote." + git fetch origin + git checkout -b "$SERVICE_PAGES_BRANCH" origin/"$SERVICE_PAGES_BRANCH" + fi + + _ "πŸ”¨ Applying changes" + rm -rf "$DOCS_DIRECTORY" + cp -r "$DOCUMENTATION_HTML_LOCATION" "$DOCS_DIRECTORY" + + _ "πŸ”¨ Adding things (~ $files_count files)" + git add "$DOCS_DIRECTORY" + + _ "πŸ”¨ Committing things (be ready if passwords / passphrases are asked)" + commit_message=$(printf "doc: update DocC documentation for version v%s (%s)\n\nUpdate documentation for GitHub pages of version v%s of OUDS iOS library (build timestamp %s)\n\nWARNING: This is an automatic commit πŸ€–" "$lib_version" "$timestamp" "$lib_version" "$timestamp") + git commit -m "$commit_message" + + _ "πŸ”¨ Pushing things" + git push origin "$SERVICE_PAGES_BRANCH" + +else + _ "πŸ‘ Ok, just keep documentation here" +fi + +# Step 6 - Compress ZIP (if relevant) +# ----------------------------------- + +# ZIP action must be done before reseting the Git workspace (otherwise everything will be wiped out) +if [[ $no_zip -eq 0 ]]; then + _ "πŸ‘‰ Zipping documentation folder" + zip -r "$DOCUMENTATION_ZIP_LOCATION" "$DOCS_DIRECTORY"/* + size_in_byte=`du "$DOCUMENTATION_ZIP_LOCATION" | cut -f1` + _ "πŸ‘ Documentation ZIP available at $DOCUMENTATION_ZIP_LOCATION ($size_in_byte bytes)" +fi + +# Step 5b - Resume work on Git branch (if relevant) +# ------------------------------------------------- + +if [[ $use_git -eq 1 ]]; then + commit_hash=`git rev-parse HEAD` + _ "πŸ”¨ Going back to previous Git branch" + clean_repo + git checkout "$current_branch" + _ "πŸ‘ Pushed with commit '$commit_hash'" +fi + +# Step 7 - Metrics and conclusion +# ------------------------------- + +end_time=$(date +%s) +elapsed_time=$(( end_time - start_time )) +elapsed_time_minutes=$(( elapsed_time / 60 )) +elapsed_time_seconds=$(( elapsed_time % 60 )) + +_ "βŒ› Elapsed time: ${elapsed_time_minutes} minutes and ${elapsed_time_seconds} seconds" +_ "πŸš€ There were about $files_count files to process!" +_ "πŸ‘‹ Bye!" + +exit $EXIT_OK + +# In case of performances issues due to the large amount of files in the Git repository: +# run "git clean -fd ; git reset --hard ; rm -rf .build" +# Or use "git prune" +# Or reclone the repository \ No newline at end of file