Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovic35 committed Feb 3, 2025
1 parent a238927 commit c2f93f9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
20 changes: 14 additions & 6 deletions OUDS/Core/Components/Sources/Switch/OUDSSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,27 @@ import SwiftUI

// MARK: - OUDS Button

/// The ``OUDSSwitch`` proposes layout with text only, icon only or text with icon.
///
/// The ``OUDSSwitch`` proposes a layout as a nested element.
/// It also propose a more complex layout with text, icon and divider. For this layout,
/// if switch is in form it is possible to set it in error state.
///
/// ## Code samples
///
/// ```swift
/// // Switch as nested element (with no text)
/// OUDSSwitch(isOn $isOn)
///
/// // Text, icon and divider
/// OUDSSwtcih(isOn $isOn, label: "Allow notifications", icon: Image("ic_heart"), divider: true)
///
/// // Text, icon and divider with error in form
/// OUDSSwtcih(isOn $isOn, label: "Allow notifications", icon: Image("ic_heart"), onError: true, divider: true)
/// ```
///
/// ## Design documentation
///
/// See
/// See [#TODO]
///
/// - Since: 0.10.0
/// - Since: 0.11.0
public struct OUDSSwitch: View {

// MARK: Stored Properties
Expand All @@ -53,7 +61,7 @@ public struct OUDSSwitch: View {
self.layout = .nested
}

/// Creates a switch with label and optional helper text.
/// Creates a switch with label and optional helper text, icon, divider.
///
/// - Parameters:
/// - isOn: A binding to a property that determines whether the switch is on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ The link can be displayed in `small` or `medium` size.
OUDSLink(text: "Back", arrow: .back, size: .medium) { /* the action to process */ }
```

### Switch

The ``OUDSSwitch`` proposes a layout as a nested element.
It also propose a more complex layout with text, icon and divider. For this layout,
if switch is in form it is possible to set it in error state.

```swift
// Switch as nested element (with no text)
OUDSSwitch(isOn $isOn)

// Text, icon and divider
OUDSSwtcih(isOn $isOn, label: "Allow notifications", icon: Image("ic_heart"), divider: true)

// Text, icon and divider with error in form
OUDSSwtcih(isOn $isOn, label: "Allow notifications", icon: Image("ic_heart"), onError: true, divider: true)
```

## Customize components

### Apply a specific shadow effect (elevation tokens)
Expand Down

0 comments on commit c2f93f9

Please sign in to comment.