Skip to content

Commit 7514175

Browse files
committed
docs: update documentation in DocC catalogs and sources about colors (#124)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent ad6c749 commit 7514175

File tree

8 files changed

+43
-21
lines changed

8 files changed

+43
-21
lines changed

OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+ColorSemanticTokens.swift

+17-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import OUDSTokensSemantic
2525

2626
/// Defines basic values common to all themes for `ColorSemanticTokens`.
2727
/// These values can be overriden inside `OUDSTheme` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination.
28+
/// Some tokens do not have values assigned in the design system, and must be overriden.
29+
/// Some tokens must be overiden in `OrangeTheme` side because they rely on Oange brand colors.
2830
extension OUDSTheme: ColorSemanticTokens {
2931

3032
// MARK: Semantic token - Colors - Background
@@ -33,12 +35,12 @@ extension OUDSTheme: ColorSemanticTokens {
3335

3436
@objc open var colorBackgroundSecondary: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalLightGray80, dark: ColorRawTokens.colorFunctionalDarkGray800) }
3537

36-
// WARNING: #124 - Colors to use are part of OUDSOran MultipleColorTokens(light: ColorRawTokens., dark: ColorRawTokens.)heme so are not reachable at this level, as a workaround add raw values
38+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
3739
@objc open var colorBackgroundTertiary: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorBackgroundBrandSecondary!") }
3840

3941
@objc open var colorBackgroundEmphasized: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalDarkGray880, dark: ColorRawTokens.colorFunctionalDarkGray640) }
4042

41-
// WARNING: #124 - Colors to use are part of OUDSOran MultipleColorTokens(light: ColorRawTokens., dark: ColorRawTokens.)heme so are not reachable at this level, as a workaround add raw values
43+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
4244
@objc open var colorBackgroundBrandPrimary: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorBackgroundBrandPrimary!") }
4345

4446
@objc open var colorBackgroundBrandSecondary: ColorSemanticToken { fatalError("🤖 No value defined for colorBackgroundBrandSecondary!") }
@@ -73,8 +75,10 @@ extension OUDSTheme: ColorSemanticTokens {
7375

7476
@objc open var colorBackgroundStatusNegativeEmphasized: ColorSemanticToken { MultipleColorTokens(ColorRawTokens.colorFunctionalScarlet600) }
7577

78+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
7679
@objc open var colorBackgroundStatusAccentMuted: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorBackgroundStatusAccentMuted!") }
7780

81+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
7882
@objc open var colorBackgroundStatusAccentMutedOnBackgroundEmphasized: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorBackgroundStatusAccentMutedOnBackgroundEmphasized!") }
7983

8084
@objc open var colorBackgroundStatusAccentEmphasized: ColorSemanticToken { MultipleColorTokens(ColorRawTokens.colorFunctionalSun500) }
@@ -93,6 +97,7 @@ extension OUDSTheme: ColorSemanticTokens {
9397

9498
@objc open var colorContentContentDisabledOnBackgroundEmphasized: ColorSemanticToken { MultipleColorTokens(ColorRawTokens.colorFunctionalDarkGray400) }
9599

100+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
96101
@objc open var colorContentBrandPrimary: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorContentBrandPrimary!") }
97102

98103
@objc open var colorContentBrandSecondary: ColorSemanticToken { fatalError("🤖 No value defined for colorContentBrandSecondary!") }
@@ -159,8 +164,10 @@ extension OUDSTheme: ColorSemanticTokens {
159164

160165
@objc open var colorBorderFocus: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalWhite, dark: ColorRawTokens.colorFunctionalDarkGray880) }
161166

167+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
162168
@objc open var colorBorderBrandPrimaryOnBackgroundEmphasized: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorBorderBrandPrimaryOnBackgroundEmphasized!") }
163169

170+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
164171
@objc open var colorBorderBrandPrimary: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorBorderBrandPrimary!") }
165172

166173
@objc open var colorBorderBrandSecondary: ColorSemanticToken { fatalError("🤖 No value defined for colorBorderBrandSecondary!") }
@@ -185,8 +192,10 @@ extension OUDSTheme: ColorSemanticTokens {
185192

186193
// MARK: Semantic token - Colors - Action
187194

195+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
188196
@objc open var colorActionSelected: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorActionSelected!") }
189197

198+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
190199
@objc open var colorActionSelectedOnBackgroundEmphasized: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorActionSelectedOnBackgroundEmphasized!") }
191200

192201
@objc open var colorActionDisabled: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalLightGray400, dark: ColorRawTokens.colorFunctionalDarkGray400) }
@@ -205,12 +214,16 @@ extension OUDSTheme: ColorSemanticTokens {
205214

206215
@objc open var colorActionPrimaryHoverOnBackgroundEmphasized: ColorSemanticToken { MultipleColorTokens(ColorRawTokens.colorFunctionalLightGray400) }
207216

217+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
208218
@objc open var colorActionPrimaryPressed: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorActionPrimaryPressed!") }
209219

220+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
210221
@objc open var colorActionPrimaryPressedOnBackgroundEmphasized: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorActionPrimaryPressedOnBackgroundEmphasized!") }
211222

223+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
212224
@objc open var colorActionPrimaryLoading: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorActionPrimaryLoading!") }
213225

226+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
214227
@objc open var colorActionPrimaryLoadingOnBackgroundEmphasized: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorActionPrimaryLoadingOnBackgroundEmphasized!") }
215228

216229
@objc open var colorActionPrimaryFocus: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalDarkGray400, dark: ColorRawTokens.colorFunctionalLightGray400) }
@@ -357,6 +370,7 @@ extension OUDSTheme: ColorSemanticTokens {
357370

358371
// MARK: Semantic token - Colors - Decorative
359372

373+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
360374
@objc open var colorDecorativeBrandPrimary: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorDecorativeBrandPrimary!") }
361375

362376
@objc open var colorDecorativeBrandPrimaryMuted: ColorSemanticToken { fatalError("🤖 No value defined for colorDecorativeBrandPrimaryMuted!") }
@@ -433,6 +447,7 @@ extension OUDSTheme: ColorSemanticTokens {
433447

434448
@objc open var colorChartCategoricalNeutral: ColorSemanticToken { MultipleColorTokens(light: ColorRawTokens.colorFunctionalLightGray160, dark: ColorRawTokens.colorFunctionalDarkGray720) }
435449

450+
// WARNING: #124 - Colors to use are part of Orange Theme so are not reachable at this level, as a workaround add raw values
436451
@objc open var colorChartCategoricalBrand: ColorSemanticToken { fatalError("🤖 Raw token unavailable for colorChartCategoricalBrand!") }
437452

438453
@objc open var colorChartCategoricalPositive: ColorSemanticToken { MultipleColorTokens(ColorRawTokens.colorFunctionalMalachite500) }

OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ extension YourCustomTheme {
4040
override var ftiBorderWidth: BorderWidthSemanticToken { borderWidthThick }
4141

4242
// Override colors semantic tokens if needed
43-
override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun500 }
44-
override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun800 }
43+
override var colorBackgroundPrimary: ColorSemanticToken {
44+
MultipleColorTokens(light: ColorRawTokens.ColorRawTokens.colorFunctionalSun500, dark: ColorRawTokens.ColorRawTokens.colorFunctionalSun800)
45+
}
4546

4647
// Etc.
4748
}
@@ -79,10 +80,9 @@ extension OrangeCustomTheme { // For FormsTextInputComponentTokens, used in comp
7980
override public var ftiSubtitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelMedium }
8081
override public var ftiSubtitleColor: ColorSemanticToken { ColorRawTokens.colorFunctionalMalachite500 }
8182

82-
override public var ftiBackgroundColorLight: ColorSemanticToken { colorBackgroundDefaultPrimaryLight }
83-
override public var ftiBackgroundColorDark: ColorSemanticToken { colorBackgroundDefaultPrimaryDark }
83+
override public var ftiBackgroundColor: ColorSemanticToken { colorBackgroundDefault }
8484

85-
override public var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedDark ?? MyThemeColorRawTokens.someAwesomeThemeExclusiveColor }
85+
override public var ftiBorderColor: ColorSemanticToken { colorBorderEmphasized }
8686

8787
override public var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDrag }
8888

@@ -91,8 +91,9 @@ extension OrangeCustomTheme { // For FormsTextInputComponentTokens, used in comp
9191

9292
extension OrangeCustomTheme { // For ColorSemanticTokens using anywhere
9393

94-
override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun500 }
95-
override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun800 }
94+
override var colorBackgroundPrimary: ColorSemanticToken {
95+
MultipleColorTokens(light: ColorRawTokens.ColorRawTokens.colorFunctionalSun500, dark: ColorRawTokens.ColorRawTokens.colorFunctionalSun800)
96+
}
9697
}
9798
```
9899

OUDS/Core/OUDS/Sources/_OUDS.docc/Tokens.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct OUDSFormsTextInput: View {
6363

6464
// ...
6565
@Environment(\.theme) var theme
66+
@Environment(\.colorScheme) var colorScheme
6667

6768
public var body: some View {
6869
VStack(spacing: theme.spacePaddingBlockComponentTall) {
@@ -82,8 +83,8 @@ struct OUDSFormsTextInput: View {
8283
TextField(placeholder, text: $value)
8384
}
8485
.padding(theme.spacePaddingBlockComponentTall)
85-
.background(colorScheme == .light ? theme.ftiBackgroundColorLight.color : theme.ftiBackgroundColorDark.color)
86-
.border(theme.ftiBorderColor.color, width: theme.ftiBorderWidth)
86+
.background(theme.ftiBorderColor.color(for: colorScheme))
87+
.border(theme.ftiBorderColor.color(for: colorScheme), width: theme.ftiBorderWidth)
8788
}
8889
}
8990
```

OUDS/Core/Themes/Inverse/Sources/InverseTheme+ColorSemanticTokens.swift

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import OUDSTokensSemantic
2424
// swiftlint:disable file_length
2525

2626
/// Overrides some colors using values defined in extension of `ColorRawTokens` in this current module.
27+
/// Some tokens do not have values assigned in the design system, and must be overriden.
2728
extension InverseTheme {
2829

2930
// MARK: Semantic token - Colors - Background

OUDS/Core/Themes/Inverse/Sources/_OUDSThemesInverse.docc/OUDSThemesInverse.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This theme overrides the [Orange theme](https://ios.unified-design-system.orange
77
This is an override of the [Orange theme](https://ios.unified-design-system.orange.com/documentation/oudsthemesorange/) with some inverted colors.
88
It can override any properties from its superclass, and can be derived too.
99

10+
The aim of the theme is to provide a particular set of colors for dedicated applications and use cases, like for example B2B apps or teams needing eye comfort. It can be seen as an extended dark mode.
11+
1012
**More details coming soon.**
1113

1214
## Topics

OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ The Orange theme overrides some tokens from the basic `OUDSTheme` and should be
44

55
## Overview
66

7-
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.
7+
It defines its own colors and override the semantic tokens to use the right colors.
8+
This is the default theme any app should use, and can be subclassed to define for example themes dedicated to countries.
9+
It embeds also in its target the brand colors which are not shared not exposed in lower level targets.
810

911
## Topics
1012

OUDS/Core/Tokens/ComponentTokens/Sources/_OUDSTokensComponent.docc/OUDSTokensComponent.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ struct OUDSFormsTextInput: View {
6161
TextField(placeholder, text: $value)
6262
}
6363
.padding(theme.spacePaddingBlockComponentTall)
64-
.background(colorScheme == .light ? theme.ftiBackgroundColorLight.color : theme.ftiBackgroundColorDark.color)
65-
.border(theme.ftiBorderColor.color, width: theme.ftiBorderWidth)
64+
.background(theme.ftiBorderColor.color(for: colorScheme))
65+
.border(theme.ftiBorderColor.color(for: colorScheme), width: theme.ftiBorderWidth)
6666
}
6767
}
6868
```

OUDS/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ struct OUDSFormsTextInput: View {
116116
TextField(placeholder, text: $value)
117117
}
118118
.padding(theme.spacePaddingBlockComponentTall)
119-
.background(colorScheme == .light ? theme.ftiBackgroundColorLight.color : theme.ftiBackgroundColorDark.color)
120-
.border(theme.ftiBorderColor.color, width: theme.ftiBorderWidth)
119+
.background(theme.ftiBorderColor.color(for: colorScheme))
120+
.border(theme.ftiBorderColor.color(for: colorScheme), width: theme.ftiBorderWidth)
121121
}
122122
}
123123
```
@@ -246,10 +246,9 @@ extension OrangeCustomTheme { // For FormsTextInputComponentTokens, used in comp
246246
override public var ftiSubtitleFontSize: TypographyFontSizeSemanticToken { fontSizeLabelMedium }
247247
override public var ftiSubtitleColor: ColorSemanticToken { ColorRawTokens.colorFunctionalMalachite500 }
248248

249-
override public var ftiBackgroundColorLight: ColorSemanticToken { colorBackgroundDefaultPrimaryLight }
250-
override public var ftiBackgroundColorDark: ColorSemanticToken { colorBackgroundDefaultPrimaryDark }
249+
override public var ftiBackgroundColor: ColorSemanticToken { colorBackgroundPrimary }
251250

252-
override public var ftiBorderColor: ColorSemanticToken { colorBorderEmphasizedDark ?? MyThemeColorRawTokens.someAwesomeThemeExclusiveColor }
251+
override public var ftiBorderColor: ColorSemanticToken { colorBorderEmphasized }
253252

254253
override public var ftiBorderStyle: BorderStyleSemanticToken { borderStyleDrag }
255254

@@ -258,8 +257,9 @@ extension OrangeCustomTheme { // For FormsTextInputComponentTokens, used in comp
258257

259258
extension OrangeCustomTheme { // For ColorSemanticTokens using anywhere
260259

261-
override var colorBackgroundDefaultPrimaryLight: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun500 }
262-
override var colorBackgroundDefaultPrimaryDark: ColorSemanticToken! { ColorRawTokens.colorFunctionalSun800 }
260+
override var colorBackgroundPrimary: ColorSemanticToken {
261+
MultipleColorTokens(light: ColorRawTokens.ColorRawTokens.colorFunctionalSun500, dark: ColorRawTokens.ColorRawTokens.colorFunctionalSun800)
262+
}
263263
}
264264
```
265265

0 commit comments

Comments
 (0)