Skip to content

Commit faa9b14

Browse files
authored
[Token Update] 🤖 Update of tokens (library version 0.7.0) (#494)
2 parents 7efd5b2 + 7b45820 commit faa9b14

16 files changed

+432
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010

11+
- [Library] `RadioButton` component tokens (tokens library v0.7.0)
1112
- [Library] Checkbox component ([#264](https://github.com/Orange-OpenSource/ouds-ios/issues/264))
1213
- [Library] `colorDecorativeNeutral*` color semantic tokens (tokens library v0.6.1)
1314

OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ open class OUDSTheme: @unchecked Sendable {
101101
/// All components tokens related to badge components like `OUDSBadge`
102102
public let badge: AllBadgeComponentTokensProvider
103103

104-
/// All component tokens related to control-item-layout-based components like `OUDSSwitch`, `OUDSRadioButton` and `OUDSCheckboxItem`
104+
/// All component tokens related to control-item-layout-based components like `OUDSSwitch`, `OUDSRadioButtonItem` and `OUDSCheckboxItem`
105105
public let controlItem: AllControlItemComponentTokensProvider
106106

107-
/// All components tokens related to radio button and checkboxes components like `OUDSRadioButton`, `OUDSCheckbox` and `OUDSCheckboxItem`
107+
/// All components tokens related to checkboxes components like `OUDSCheckbox` and `OUDSCheckboxItem`
108108
public let checkbox: AllCheckboxComponentTokensProvider
109109

110+
/// All components tokens related to checkboxes components like `OUDSRadioButton` and `OUDSRadioButtonItem`
111+
public let radioButton: AllRadioButtonComponentTokensProvider
112+
110113
// NOTE: Add new component tokens provider here
111114

112115
// MARK: - Initializers
@@ -136,6 +139,7 @@ open class OUDSTheme: @unchecked Sendable {
136139
/// - badge: All component tokens for badge
137140
/// - controlItem: All component tokens for control item
138141
/// - checkbox: All component tokens for checkbox
142+
/// - radioButton: All component tokens for radio buttons
139143
/// - fontFamily: Set `nil` if system font to use, otherwise use the `FontFamilySemanticToken` you want to apply
140144
public init(colors: AllColorSemanticTokensProvider,
141145
borders: AllBorderSemanticTokensProvider,
@@ -159,6 +163,7 @@ open class OUDSTheme: @unchecked Sendable {
159163
badge: AllBadgeComponentTokensProvider,
160164
controlItem: AllControlItemComponentTokensProvider,
161165
checkbox: AllCheckboxComponentTokensProvider,
166+
radioButton: AllRadioButtonComponentTokensProvider,
162167
fontFamily: FontFamilySemanticToken? = nil) {
163168

164169
// Save semantic tokens providers
@@ -186,6 +191,7 @@ open class OUDSTheme: @unchecked Sendable {
186191
self.badge = badge
187192
self.controlItem = controlItem
188193
self.checkbox = checkbox
194+
self.radioButton = radioButton
189195
// NOTE: Add new component tokens provider here
190196

191197
// Load other configuration elements

OUDS/Core/OUDS/Sources/OUDSTheme/TokensProviders.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public protocol AllBadgeComponentTokensProvider: TokensProvider, BadgeComponentT
8787
/// Something which provides all component tokens for control-item-layout-based components
8888
public protocol AllControlItemComponentTokensProvider: TokensProvider, ControlItemComponentTokens { }
8989

90-
/// Something which provides all component tokens of checkboxes and radio buttons
90+
/// Something which provides all component tokens of checkboxes
9191
public protocol AllCheckboxComponentTokensProvider: TokensProvider, CheckboxComponentTokens { }
9292

93+
/// Something which provides all component tokens of radio buttons
94+
public protocol AllRadioButtonComponentTokensProvider: TokensProvider, RadioButtonComponentTokens { }
95+
9396
// NOTE: Add new definitions of protocols here

OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
9191
/// - opacities: All semantic tokens of opacity
9292
/// - sizes: All semantic tokens of sizes
9393
/// - spaces: All semantic tokens of spaces
94-
/// - button: All component tokens for button
95-
/// - link: All component tokens for link
94+
/// - button: All component tokens for button like `OUDSButton`
95+
/// - link: All component tokens for link like `OUDSLink`
9696
/// - select: All component tokens for select
9797
/// - skeleton: All component tokens for skeleton
9898
/// - tag: All component tokens for tag
@@ -104,7 +104,8 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
104104
/// - inputText: All component tokens for input text
105105
/// - badge: All component tokens for badge
106106
/// - controlItem: All component tokens for control item
107-
/// - checkbox: All component tokens for checkbox
107+
/// - radioButton: All component tokens for radio buttons like `OUDSRadioButton` and `OUDSRadioButtonItem`
108+
/// - checkbox: All component tokens for checkbox like `OUDSCheckbox` and `OUDSCheckboxItem`
108109
/// - fontFamily: Set `nil` if system font to use, otherwise use the `FontFamilySemanticToken` you want to apply
109110
override public init(
110111
colors: AllColorSemanticTokensProvider? = nil,
@@ -129,6 +130,7 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
129130
badge: AllBadgeComponentTokensProvider? = nil,
130131
controlItem: AllControlItemComponentTokensProvider? = nil,
131132
checkbox: AllCheckboxComponentTokensProvider? = nil,
133+
radioButton: AllRadioButtonComponentTokensProvider? = nil,
132134
fontFamily: FontFamilySemanticToken? = nil) {
133135

134136
let colors = (colors ?? OrangeThemeColorSemanticTokensProvider())
@@ -154,6 +156,7 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
154156
let badge = (badge ?? OrangeThemeBadgeComponentTokensProvider(sizes: sizes, borders: borders, spaces: spaces))
155157
let controlItem = (controlItem ?? OrangeThemeControlItemComponentTokensProvider(sizes: sizes, colors: colors, spaces: spaces))
156158
let checkbox = (checkbox ?? OrangeThemeCheckboxComponentTokensProvider(sizes: sizes, borders: borders))
159+
let radioButton = (radioButton ?? OrangeThemeRadioButtonComponentTokensProvider(sizes: sizes, borders: borders))
157160

158161
super.init(colors: colors,
159162
borders: borders,
@@ -177,6 +180,7 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable {
177180
badge: badge,
178181
controlItem: controlItem,
179182
checkbox: checkbox,
183+
radioButton: radioButton,
180184
fontFamily: fontFamily)
181185
}
182186

OUDS/Core/Themes/Orange/Sources/Providers/ComponentTokens/OrangeThemeCheckboxComponentTokensProvider.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ import OUDSTokensSemantic
1717

1818
// swiftlint:disable type_name
1919

20-
/// A class which wraps all **component tokens of checkbox and radio button** for *radio button* and *checkboxes* objects
21-
/// like `OUDSRadioButton`, `OUDSCheckbox` and `OUDSCheckboxItem`.
20+
/// A class which wraps all **component tokens of checkbox** for *checkboxes* objects
21+
/// like `OUDSCheckbox` and `OUDSCheckboxItem`.
2222
/// Contains also references to semantic tokens providers so as to be able to use them to define the component tokens.
2323
/// This provider should be integrated as a `AllCheckboxComponentTokensProvider` implementation inside `OUDSTheme` so as to provide all tokens to the users.
2424
/// It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
2525
/// Custom themes can use subclass of ``OrangeThemeCheckboxComponentTokensProvider`` and apply the provider they need.
26-
/// It implements also the protocol `CheckboxComponentTokens` so as to expose the component tokens for *radio button* and *checkboxes* through any `OUDSTheme`.
27-
/// *Radio button* and *checkboxes* components tokens are defined with raw and semantic tokens of sizes (from `SizeSemanticToken`) and
26+
/// It implements also the protocol `CheckboxComponentTokens` so as to expose the component tokens for *checkboxes* through any `OUDSTheme`.
27+
/// *Checkboxes* components tokens are defined with raw and semantic tokens of sizes (from `SizeSemanticToken`) and
2828
/// borders (`BorderRadiusSemanticToken`, `BorderWidthSemanticToken`).
2929
/// These components share the same type of tokens which are all gather edhere.
3030
///
3131
/// ```swift
32-
/// // Define your own provider for radio / checkbox component tokens
32+
/// // Define your own provider for checkbox component tokens
3333
/// // by inheriting from existing provider
3434
/// class CustomCheckboxComponentTokensProvider: OrangeThemeCheckboxComponentTokensProvider {
3535
///
36-
/// // Then override the radio / checkbox component tokens you want.
36+
/// // Then override the checkbox component tokens you want.
3737
///
3838
/// override var checkboxSizeMinWidth: SizeSemanticToken { sizes.sizeIconWithLabelLargeSizeXl }
3939
///
@@ -45,7 +45,7 @@ import OUDSTokensSemantic
4545
/// // Or define your own provider from scratch
4646
/// class CustomCheckboxComponentTokensProvider: CheckboxComponentTokens {
4747
///
48-
/// // And implement hunders of tokens.
48+
/// // And implement hundreds of tokens.
4949
/// // You are allowed to give semantic tokens providers if you want to define values.
5050
/// }
5151
/// ```
@@ -83,13 +83,13 @@ import OUDSTokensSemantic
8383
/// - Since: 0.10.0
8484
open class OrangeThemeCheckboxComponentTokensProvider: AllCheckboxComponentTokensProvider {
8585

86-
/// Provider of size semantic tokens to use for check / radio sizes
86+
/// Provider of size semantic tokens to use for checkbox sizes
8787
public let sizes: AllSizeSemanticTokensProvider
8888

89-
/// Provider of border semantic tokens to use for check / radio borders
89+
/// Provider of border semantic tokens to use for checkbox borders
9090
public let borders: AllBorderSemanticTokensProvider
9191

92-
/// Defines a provider of component tokens dedicated to `OUDSCheckbox` and `OUDSRadioButton`
92+
/// Defines a provider of component tokens dedicated to `OUDSCheckbox` and `OUDSCheckboxItem`
9393
/// - Parameters:
9494
/// - sizes: Provider for size semantic tokens. If nil, a default one will be used (``OrangeThemeSizeSemanticTokensProvider``)
9595
/// - borders: Provider for border semantic tokens. If nil, a default one will be used (``OrangeThemeBorderSemanticTokensProvider``)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
//
2+
// Software Name: OUDS iOS
3+
// SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
// SPDX-License-Identifier: MIT
5+
//
6+
// This software is distributed under the MIT license,
7+
// the text of which is available at https://opensource.org/license/MIT/
8+
// or see the "LICENSE" file for more details.
9+
//
10+
// Authors: See CONTRIBUTORS.txt
11+
// Software description: A SwiftUI components library with code examples for Orange Unified Design System
12+
//
13+
14+
import OUDS
15+
import OUDSFoundations
16+
import OUDSTokensSemantic
17+
18+
// swiftlint:disable type_name
19+
20+
/// A class which wraps all **component tokens of radio button** for *radios* objects
21+
/// like `OUDSRadioButton` and `OUDSRadioButtonItem`.
22+
/// Contains also references to semantic tokens providers so as to be able to use them to define the component tokens.
23+
/// This provider should be integrated as a `AllRadioButtonComponentTokensProvider` implementation inside `OUDSTheme` so as to provide all tokens to the users.
24+
/// It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
25+
/// Custom themes can use subclass of ``OrangeThemeRadioButtonComponentTokensProvider`` and apply the provider they need.
26+
/// It implements also the protocol `RadioButtonComponentTokens` so as to expose the component tokens for *radio buttons* through any `OUDSTheme`.
27+
/// *Radio buttons* components tokens are defined with raw and semantic tokens of sizes (from `SizeSemanticToken`) and
28+
/// borders (`BorderRadiusSemanticToken`, `BorderWidthSemanticToken`).
29+
/// These components share the same type of tokens which are all gathered here.
30+
///
31+
/// ```swift
32+
/// // Define your own provider for radio button component tokens
33+
/// // by inheriting from existing provider
34+
/// class CustomRadioButtonComponentTokensProvider: OrangeThemeRadioButtonComponentTokensProvider {
35+
///
36+
/// // Then override the radio button component tokens you want.
37+
///
38+
/// override var checkboxSizeMinWidth: SizeSemanticToken { sizes.sizeIconWithLabelLargeSizeXl }
39+
///
40+
/// override var checkboxBorderWidthSelected: BorderWidthSemanticToken { borders.borderWidthThin }
41+
///
42+
/// // ...
43+
/// }
44+
///
45+
/// // Or define your own provider from scratch
46+
/// class CustomRadioButtonComponentTokensProvider: RadioButtonComponentTokens {
47+
///
48+
/// // And implement hundreds of tokens.
49+
/// // You are allowed to give semantic tokens providers if you want to define values.
50+
/// }
51+
/// ```
52+
///
53+
/// Then, you can give this `CustomRadioButtonComponentTokensProvider` to your own theme implementation:
54+
///
55+
/// ```swift
56+
/// class LocalTheme: OrangeTheme {
57+
///
58+
/// override init() {
59+
/// super.init(radioButton: CustomRadioButtonComponentTokensProvider())
60+
/// }
61+
/// }
62+
/// ```
63+
///
64+
/// or to an already existing theme for example:
65+
///
66+
/// ```swift
67+
/// OrangeTheme(radioButton: CustomRadioButtonComponentTokensProvider())
68+
/// ```
69+
///
70+
/// It is also possible to use your own semantic tokens providers for this component tokens providers:
71+
///
72+
/// ```swift
73+
/// // Uses by default here:
74+
/// // - OrangeThemeSizeSemanticTokensProvider for sizes
75+
/// // - OrangeThemeBorderSemanticTokensProvider for borders
76+
/// let radioButtonComponentTokensProvider = OrangeThemeRadioButtonComponentTokensProvider()
77+
///
78+
/// // Or use your own size, border, color and opacity semantic tokens providers (or only some)
79+
/// let radioButtonComponentTokensProvider = OrangeThemeRadioButtonComponentTokensProvider(
80+
/// sizes: CustomSizeSemanticTokensProvider(),
81+
/// borders: CustomBorderSemanticTokensProvider()))
82+
/// ```
83+
/// - Since: 0.12.0
84+
open class OrangeThemeRadioButtonComponentTokensProvider: AllRadioButtonComponentTokensProvider {
85+
86+
/// Provider of size semantic tokens to use for check / radio sizes
87+
public let sizes: AllSizeSemanticTokensProvider
88+
89+
/// Provider of border semantic tokens to use for check / radio borders
90+
public let borders: AllBorderSemanticTokensProvider
91+
92+
/// Defines a provider of component tokens dedicated to `OUDSRadioButton` and `OUDSRadioButtonItem`.
93+
/// - Parameters:
94+
/// - sizes: Provider for size semantic tokens. If nil, a default one will be used (``OrangeThemeSizeSemanticTokensProvider``)
95+
/// - borders: Provider for border semantic tokens. If nil, a default one will be used (``OrangeThemeBorderSemanticTokensProvider``)
96+
public init(sizes: AllSizeSemanticTokensProvider? = nil,
97+
borders: AllBorderSemanticTokensProvider? = nil) {
98+
OL.debug("Init of OrangeThemeRadioButtonComponentTokensProvider")
99+
self.sizes = (sizes ?? OrangeThemeSizeSemanticTokensProvider())
100+
self.borders = (borders ?? OrangeThemeBorderSemanticTokensProvider())
101+
}
102+
103+
deinit { }
104+
105+
// ଘ( ・ω・)_/゚・:*:・。☆
106+
// Note: So as to help the integration of generated code produced by the tokenator
107+
// the implemention of RadioButtonComponentTokens is not here but in Core/Themes/Orange/Values/ComponentTokens/OrangeTheme+RadioButtonComponentTokens.swift
108+
// This declaration of OrangeThemeRadioButtonComponentTokensProvider is here also to allow to write documentation.
109+
}
110+
111+
// swiftlint:enable type_name
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Software Name: OUDS iOS
3+
// SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
// SPDX-License-Identifier: MIT
5+
//
6+
// This software is distributed under the MIT license,
7+
// the text of which is available at https://opensource.org/license/MIT/
8+
// or see the "LICENSE" file for more details.
9+
//
10+
// Authors: See CONTRIBUTORS.txt
11+
// Software description: A SwiftUI components library with code examples for Orange Unified Design System
12+
//
13+
14+
import Foundation
15+
import OUDSTokensComponent
16+
import OUDSTokensRaw
17+
import OUDSTokensSemantic
18+
19+
// 🧱 Tokens version: 0.7.0
20+
// 🤖 Generated by Tokenator
21+
22+
extension OrangeThemeRadioButtonComponentTokensProvider: RadioButtonComponentTokens {
23+
@objc open var radioButtonSizeMaxHeight: SizeSemanticToken { DimensionRawTokens.dimension600 }
24+
@objc open var radioButtonSizeMinHeight: SizeSemanticToken { DimensionRawTokens.dimension600 }
25+
@objc open var radioButtonSizeMinWidth: SizeSemanticToken { DimensionRawTokens.dimension600 }
26+
@objc open var radioButtonBorderRadius: BorderRadiusSemanticToken { borders.borderRadiusPill }
27+
@objc open var radioButtonBorderWidthSelected: BorderWidthSemanticToken { borders.borderWidthMedium }
28+
@objc open var radioButtonBorderWidthSelectedFocus: BorderWidthSemanticToken { borders.borderWidthMedium }
29+
@objc open var radioButtonBorderWidthSelectedHover: BorderWidthSemanticToken { borders.borderWidthMedium }
30+
@objc open var radioButtonBorderWidthSelectedPressed: BorderWidthSemanticToken { borders.borderWidthMedium }
31+
@objc open var radioButtonBorderWidthUnselected: BorderWidthSemanticToken { borders.borderWidthThin }
32+
@objc open var radioButtonBorderWidthUnselectedFocus: BorderWidthSemanticToken { borders.borderWidthMedium }
33+
@objc open var radioButtonBorderWidthUnselectedHover: BorderWidthSemanticToken { borders.borderWidthMedium }
34+
@objc open var radioButtonBorderWidthUnselectedPressed: BorderWidthSemanticToken { borders.borderWidthMedium }
35+
@objc open var radioButtonSizeIndicator: SizeSemanticToken { sizes.sizeIconWithLabelLargeSizeXs }
36+
}

OUDS/Core/Themes/Orange/Tests/Providers/ComponentTokens/OrangeThemeCheckboxComponentTokensProviderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Testing
1616

1717
// swiftlint:disable type_name
1818

19-
/// Check if the component tokens provider under testsh as the default semantic token providers with the expected types.
19+
/// Check if the component tokens provider under test as the default semantic token providers with the expected types.
2020
struct OrangeThemeCheckboxComponentTokensProviderTests {
2121

2222
private var provider: OrangeThemeCheckboxComponentTokensProvider
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// Software Name: OUDS iOS
3+
// SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
// SPDX-License-Identifier: MIT
5+
//
6+
// This software is distributed under the MIT license,
7+
// the text of which is available at https://opensource.org/license/MIT/
8+
// or see the "LICENSE" file for more details.
9+
//
10+
// Authors: See CONTRIBUTORS.txt
11+
// Software description: A SwiftUI components library with code examples for Orange Unified Design System
12+
//
13+
14+
import OUDSThemesOrange
15+
import Testing
16+
17+
// swiftlint:disable type_name
18+
19+
/// Check if the component tokens provider under test as the default semantic token providers with the expected types.
20+
struct OrangeThemeRadioButtonComponentTokensProviderTests {
21+
22+
private var provider: OrangeThemeRadioButtonComponentTokensProvider
23+
24+
init() {
25+
provider = OrangeThemeRadioButtonComponentTokensProvider()
26+
}
27+
28+
// MARK: - Tests
29+
30+
@Test func defaultSizeSemanticTokensProvider() throws {
31+
#expect(provider.sizes is OrangeThemeSizeSemanticTokensProvider)
32+
}
33+
34+
@Test func defaultBorderSemanticTokensProvider() throws {
35+
#expect(provider.borders is OrangeThemeBorderSemanticTokensProvider)
36+
}
37+
}
38+
39+
// swiftlint:enable type_name

OUDS/Core/Themes/Orange/Tests/Values/ComponentTokens/MockTheme/MockTheme+AllCheckboxComponentTokens.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class MockThemeCheckboxComponentTokenProvider: OrangeThemeCheckboxComponen
3333
super.init(sizes: sizes, borders: borders)
3434
}
3535

36-
// MARK: - Badge component tokens
36+
// MARK: - Radio button component tokens
3737

3838
// MARK: - Sizes
3939

0 commit comments

Comments
 (0)