Skip to content

Commit 4a8d927

Browse files
committed
refactor(review): update doc, update minimap MARKs, rmeove typos
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 6a0a1fa commit 4a8d927

File tree

15 files changed

+101
-108
lines changed

15 files changed

+101
-108
lines changed

OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+BackgroundMofifier.swift renamed to OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+BackgroundModifier.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ struct ButtonBackgroundModifier: ViewModifier {
3131
// MARK: Body
3232

3333
func body(content: Content) -> some View {
34-
content.background(colorToken.color(for: colorScheme))
34+
content.background(appliedColor.color(for: colorScheme))
3535
}
3636

3737
// MARK: Private helpers
3838

39-
private var colorToken: MultipleColorSemanticTokens {
39+
private var appliedColor: MultipleColorSemanticTokens {
4040
switch state {
4141
case .enabled:
42-
return enabledToken
42+
return enabledColor
4343
case .hover:
44-
return hoverToken
44+
return hoverColor
4545
case .pressed:
46-
return pressedToken
46+
return pressedColor
4747
case .loading:
48-
return loadingToken
48+
return loadingColor
4949
case .disabled:
50-
return disbledToken
50+
return disabledColor
5151
}
5252
}
5353

54-
private var enabledToken: MultipleColorSemanticTokens {
54+
private var enabledColor: MultipleColorSemanticTokens {
5555
switch hierarchy {
5656
case .default:
5757
onColoredSurface ? theme.button.buttonColorBgDefaultEnabledMono : theme.button.buttonColorBgDefaultEnabled
@@ -64,7 +64,7 @@ struct ButtonBackgroundModifier: ViewModifier {
6464
}
6565
}
6666

67-
private var hoverToken: MultipleColorSemanticTokens {
67+
private var hoverColor: MultipleColorSemanticTokens {
6868
switch hierarchy {
6969
case .default:
7070
onColoredSurface ? theme.button.buttonColorBgDefaultHoverMono : theme.button.buttonColorBgDefaultHover
@@ -77,7 +77,7 @@ struct ButtonBackgroundModifier: ViewModifier {
7777
}
7878
}
7979

80-
private var pressedToken: MultipleColorSemanticTokens {
80+
private var pressedColor: MultipleColorSemanticTokens {
8181
switch hierarchy {
8282
case .default:
8383
onColoredSurface ? theme.button.buttonColorBgDefaultPressedMono : theme.button.buttonColorBgDefaultPressed
@@ -90,7 +90,7 @@ struct ButtonBackgroundModifier: ViewModifier {
9090
}
9191
}
9292

93-
private var loadingToken: MultipleColorSemanticTokens {
93+
private var loadingColor: MultipleColorSemanticTokens {
9494
switch hierarchy {
9595
case .default:
9696
onColoredSurface ? theme.button.buttonColorBgDefaultLoadingMono : theme.button.buttonColorBgDefaultLoading
@@ -103,7 +103,7 @@ struct ButtonBackgroundModifier: ViewModifier {
103103
}
104104
}
105105

106-
private var disbledToken: MultipleColorSemanticTokens {
106+
private var disabledColor: MultipleColorSemanticTokens {
107107
switch hierarchy {
108108
case .default:
109109
onColoredSurface ? theme.button.buttonColorBgDefaultDisabledMono : theme.button.buttonColorBgDefaultDisabled

OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+BorderMofifier.swift renamed to OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+BorderModifier.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ struct ButtonBorderModifier: ViewModifier {
6161
}
6262
}
6363

64-
// MARK: Private helpers
65-
6664
// MARK: Default hierarchy
65+
6766
private var defaultWidth: BorderWidthSemanticToken {
6867
switch state {
6968
case .enabled:
@@ -95,6 +94,7 @@ struct ButtonBorderModifier: ViewModifier {
9594
}
9695

9796
// MARK: Minimal hierarchy
97+
9898
private var minimalWidth: BorderWidthSemanticToken {
9999
switch state {
100100
case .enabled:
@@ -126,6 +126,7 @@ struct ButtonBorderModifier: ViewModifier {
126126
}
127127

128128
// MARK: Strong hierarchy
129+
129130
private var strongColor: MultipleColorSemanticTokens {
130131
switch state {
131132
case .enabled:

OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+ForegroundMofifier.swift renamed to OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+ForegroundModifier.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import OUDSTokensComponent
1616
import OUDSTokensSemantic
1717
import SwiftUI
1818

19-
/// Used to apply the right forgeround color associated to the hierarchy and state
19+
/// Used to apply the right forground color associated to the hierarchy and state
2020
struct ButtonForegroundModifier: ViewModifier {
2121

2222
@Environment(\.theme) private var theme
@@ -31,29 +31,29 @@ struct ButtonForegroundModifier: ViewModifier {
3131
// MARK: Body
3232

3333
func body(content: Content) -> some View {
34-
content.foregroundStyle(colorToken)
34+
content.foregroundStyle(appliedColor)
3535
}
3636

3737
// MARK: Private helpers
3838

39-
private var colorToken: Color {
39+
private var appliedColor: Color {
4040
switch state {
4141
case .enabled:
42-
enabledToken.color(for: colorScheme)
42+
enabledColor.color(for: colorScheme)
4343
case .hover:
44-
hoverToken.color(for: colorScheme)
44+
hoverColor.color(for: colorScheme)
4545
case .pressed:
46-
pressedToken.color(for: colorScheme)
46+
pressedColor.color(for: colorScheme)
4747
case .loading:
4848
// Hide the content because it is replaced by the loading indicator.
49-
// However the content is nedded to get the size the button in loading state.
49+
// However the content is needed to get the size of the button in loading state.
5050
Color.clear.opacity(0)
5151
case .disabled:
52-
disabledToken.color(for: colorScheme)
52+
disabledColor.color(for: colorScheme)
5353
}
5454
}
5555

56-
private var enabledToken: MultipleColorSemanticTokens {
56+
private var enabledColor: MultipleColorSemanticTokens {
5757
switch hierarchy {
5858
case .default:
5959
onColoredSurface ? theme.button.buttonColorContentDefaultEnabledMono : theme.button.buttonColorContentDefaultEnabled
@@ -66,7 +66,7 @@ struct ButtonForegroundModifier: ViewModifier {
6666
}
6767
}
6868

69-
private var hoverToken: MultipleColorSemanticTokens {
69+
private var hoverColor: MultipleColorSemanticTokens {
7070
switch hierarchy {
7171
case .default:
7272
onColoredSurface ? theme.button.buttonColorContentDefaultHoverMono : theme.button.buttonColorContentDefaultHover
@@ -79,7 +79,7 @@ struct ButtonForegroundModifier: ViewModifier {
7979
}
8080
}
8181

82-
private var pressedToken: MultipleColorSemanticTokens {
82+
private var pressedColor: MultipleColorSemanticTokens {
8383
switch hierarchy {
8484
case .default:
8585
onColoredSurface ? theme.button.buttonColorContentDefaultPressedMono : theme.button.buttonColorContentDefaultPressed
@@ -92,7 +92,7 @@ struct ButtonForegroundModifier: ViewModifier {
9292
}
9393
}
9494

95-
private var disabledToken: MultipleColorSemanticTokens {
95+
private var disabledColor: MultipleColorSemanticTokens {
9696
switch hierarchy {
9797
case .default:
9898
onColoredSurface ? theme.button.buttonColorContentDefaultDisabledMono : theme.button.buttonColorContentDefaultDisabled

OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+LoadingModifiers.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ import OUDSTokensComponent
1616
import OUDSTokensSemantic
1717
import SwiftUI
1818

19-
// MARK: Loading modifier
19+
// MARK: - Loading indicator
2020

2121
private struct LoagingIndicator: View {
2222

2323
// MARK: Stored Properties
2424

25-
@State private var isAnimating = false
2625
let color: Color
2726

27+
@State private var isAnimating = false
28+
2829
// MARK: Body
2930

3031
var body: some View {
@@ -40,7 +41,9 @@ private struct LoagingIndicator: View {
4041
}
4142
}
4243

43-
/// Used to add a Progress indicator instead of conent (Text, Icon)
44+
// MARK: - Button Loading Content Modifier
45+
46+
/// Used to add a progress indicator instead of content (Text, Icon)
4447
/// As the button must keep the size of the content, the indicator is
4548
/// added as overlay on top, and the content is hidden applying an opacity.
4649
struct ButtonLoadingContentModifier: ViewModifier {

OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle+NormalModifier.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ import OUDS
1515
import OUDSTokensSemantic
1616
import SwiftUI
1717

18-
/// The internal state used by modifiers to handle all
19-
/// states of the button.
18+
/// The internal state used by modifiers to handle all states of the button.
2019
enum InternalButtonState {
2120
case enabled, hover, pressed, loading, disabled
2221
}
2322

24-
// MARK: - General modifier
23+
// MARK: - Button View Modifier
2524

26-
/// This modifier has in charge to :
27-
/// - compute the internal state based on `isEnabled`, `isPreessed` and `isHover` flags
25+
/// This modifier has in charge to:
26+
/// - compute the internal state based on `isEnabled`, `isPressed` and `isHover` flags
2827
/// - apply foreground, background colors and add a border (width, radius and color) associated to the hierarchy and according to the internal state
2928
struct ButtonViewModifier: ViewModifier {
3029

OUDS/Core/Components/Sources/Buttons/Internal/OUDSButtonStyle.swift

+10-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import OUDS
1515
import OUDSTokensSemantic
1616
import SwiftUI
1717

18-
/// Used to apply the right style on a `OUDSButton` according to the `hierarchy`
18+
/// Used to apply the right style on an ``OUDSButton`` according to the `hierarchy`
1919
/// and the `style`.
2020
///
2121
/// Four hierarchies are proposed:
@@ -29,25 +29,27 @@ import SwiftUI
2929
/// - negative: Negative buttons should be used sparingly to warn of a destructive action, for example, delete or remove, typically
3030
/// resulting in the opening of a confirmation dialog.
3131
///
32-
/// Three styles are available:
32+
/// Two styles are available:
3333
/// - normal: is the normal state of a button which can be disabled, pressed, hovered or normal (i.e. enabled)
3434
/// - loading: the style used after button was clicked and probably data are requested before navigate to a next screen or get updated data.
3535
///
3636
struct OUDSButtonStyle: ButtonStyle {
3737

38+
@Environment(\.isEnabled) private var isEnabled
39+
40+
@State private var isHover: Bool
41+
3842
// MARK: Stored Properties
3943

40-
@Environment(\.isEnabled) private var isEnable
41-
private let style: OUDSButton.Style
4244
private let hierarchy: OUDSButton.Hierarchy
43-
@State private var isHover: Bool
45+
private let style: OUDSButton.Style
4446

4547
// MARK: Initializer
4648

4749
/// Initialize the `OUDSButtonStyle` for the `hierarchy`
4850
/// in the `state` of the `OUDSButton`.
4951
///
50-
/// - Parameters:
52+
/// - Parameters:
5153
/// - hierarchy: The button hierarchy
5254
/// - style: The button style
5355
public init(hierarchy: OUDSButton.Hierarchy, style: OUDSButton.Style) {
@@ -73,8 +75,8 @@ struct OUDSButtonStyle: ButtonStyle {
7375
}
7476
}
7577

76-
func internalState(isPressed: Bool) -> InternalButtonState {
77-
if !isEnable {
78+
private func internalState(isPressed: Bool) -> InternalButtonState {
79+
if !isEnabled {
7880
return .disabled
7981
}
8082

OUDS/Core/Components/Sources/Buttons/OUDSButton.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SwiftUI
1717
///
1818
/// ## Hierarchies
1919
///
20-
/// Four hieraries are proposed for all layouts:
20+
/// Four hierarchies are proposed for all layouts:
2121
///
2222
/// - **default**: Default buttons are used for actions which are not mandatory or essential for the user.
2323
///
@@ -28,9 +28,9 @@ import SwiftUI
2828
///
2929
/// - **negative**: Negative buttons should be used sparingly to warn of a destructive action,
3030
/// for example, delete or remove, typically resulting in the opening of a confirmation dialog.
31-
/// A button with [OUDSButton.Hierarchy.Negative] hierarchy is not allowed as a direct or indirect child of an [OUDSColoredSurface].
31+
/// A button with `OUDSButton.Hierarchy.Negative` hierarchy is not allowed as a direct or indirect child of an `OUDSColoredSurface`.
3232
///
33-
/// ```
33+
/// ```swift
3434
/// // Icon only with default hierarchy
3535
/// OUDSButton(hierarchy: .default, icon: Image("ic_heart")) {}
3636
///
@@ -39,7 +39,6 @@ import SwiftUI
3939
///
4040
/// // Text and icon with strong hierarchy
4141
/// OUDSButton(hierarchy: .strong, icon: Image("ic_heart"), text: "Validate") {}
42-
///
4342
/// ```
4443
///
4544
/// ## Styles
@@ -51,10 +50,11 @@ import SwiftUI
5150
///
5251
/// ## Colored Surface
5352
///
54-
/// If button is placed on colored surface using `OUDSColoredSurface`, the default colors (content, background and border) are automatically adjusted to switch to monochrom.
55-
///
56-
/// **Remark: Today it is not allowed to placed a Negative button on a colored surface.
53+
/// If button is placed on colored surface using ``OUDSColoredSurface``, the default colors (content, background and border) are automatically adjusted to switch to monochrom.
5754
///
55+
/// **Remark: Today it is not allowed to place a Negative button on a colored surface.**
56+
///
57+
/// - Since: 0.10.0
5858
public struct OUDSButton: View {
5959

6060
// MARK: Stored Properties

OUDS/Core/Components/Sources/_OUDSComponents.docc/OUDSComponents.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ The catalog of all components provided by OUDS. It contains also `View` extensio
44

55
## Overview
66

7-
❗More details coming soon.❗
7+
### Buttons
8+
9+
The ``OUDSButton`` propose layout with text only, icon only or text and icon.
10+
Four hierarchies are proposed for all layouts: *default*, *strong*, *minimal* and *negative*.
11+
Two style are available: *default* and *loading*.
12+
If button is placed on colored surface using `OUDSColoredSurface`, the default colors (content, background and border) are automatically adjusted to switch to monochrom.
13+
A button with `OUDSButton.Hierarchy.Negative` hierarchy is not allowed as a direct or indirect child of an `OUDSColoredSurface`.
14+
15+
```swift
16+
// Icon only with default hierarchy
17+
OUDSButton(hierarchy: .default, icon: Image("ic_heart")) {}
18+
19+
// Text only with negative hierarchy
20+
OUDSButton(hierarchy: .negative, text: "Delete") {}
21+
22+
// Text and icon with strong hierarchy
23+
OUDSButton(hierarchy: .strong, icon: Image("ic_heart"), text: "Validate") {}
24+
```
825

926
## Customize components
1027

@@ -85,3 +102,6 @@ The helper is available through `View`, and tokens through the provider of the t
85102
## Topics
86103

87104
### Group
105+
106+
- ``OUDSColoredSurface``
107+
- ``OUDSButton``

0 commit comments

Comments
 (0)