Skip to content

Commit eb93f6a

Browse files
committed
docs: add more details about view modifiers and components in AGENTS.md
Signed-off-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com>
1 parent c457c5e commit eb93f6a

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

AGENTS.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,39 @@ Use effects (semantic tokens) defined in a theme:
322322
theme.effects
323323
```
324324

325+
### Use helpers and view modifiers
326+
327+
#### Apply typography
328+
329+
OUDS framework provides SwiftUI view modifiers to apply typography on texts (using a token).
330+
For example, if a user wants to apply typography `theme.fonts.bodyDefaultMedium` he must not use the `font()` method from SwiftUI but instead
331+
the dedicated OUDS view modifier with the same name as the typography, i.e. `bodyDefaultMedium(theme)`.
332+
333+
#### Background and foreground color
334+
335+
OUDS framework provides a SwiftUI view modifier to apply foreground color (using a token).
336+
For example if a user want to apply in foreground the color `theme.colors.contentDefault`, he must not use the `foregroundColor()` method from SwiftUI but instead
337+
the dedicated OUDS view modifier `oudsForegroundColor(color)`.
338+
339+
The logic is the same for `backgroundColor` which must be replaced by `oudsBackground(color)`.
340+
341+
#### Add border
342+
343+
Border can be defined using the OUDS view modifier `oudsBorder(style:width:radius:color)` with tokens in parameters like:
344+
```swift
345+
.oudsBorder(style: theme.borders.styleDefault,
346+
width: theme.borders.widthThin,
347+
radius: theme.borders.radiusMedium,
348+
color: theme.colors.actionEnabled)
349+
```
350+
351+
#### Add shadow / elevation effect
352+
353+
Elevations effets or box shadows can be applied to view with a dedicated view modifier `oudsShadow(elevation)` with an elevation token like:
354+
```swift
355+
.oudsShadow(theme.elevations.emphasized)
356+
```
357+
325358
### Use components
326359

327360
#### Actions
@@ -336,6 +369,11 @@ Button can be intantiated like:
336369
OUDSButton(text: "Some text", appearance: .default, style: .default) { /* the action to process */ }
337370
```
338371

372+
or in loading state:
373+
```swift
374+
OUDSButton(text: "Some text", appearance: .default, style: .loading) { /* the action to process */ }
375+
```
376+
339377
or with an image and a text inside:
340378
```swift
341379
OUDSButton(text: "Some text", icon: Image("image_name"), appearance: .default) { /* the action to process */ }
@@ -444,7 +482,7 @@ var someDataToPopulate: [OUDSRadioPickerData<String>] {
444482
@State var selection: String = "Choice_1"
445483

446484
// Here the picker is vertical
447-
OUDSRadioPicker(selection: $selection, radios: someDataToPopulate)
485+
OUDSRadioPicker(selection: $selection, radios: someDataToPopulate, placement: .vertical)
448486
```
449487

450488
##### Switch / toggle
@@ -561,16 +599,28 @@ OUDSTextInput(label: "Some label", text: $text)
561599
or with a prefix and/or a suffix to bring more context to the user:
562600
```swift
563601
@State var text: String = ""
564-
OUDSTextInput(label: "Some label", text: $text, prefix: "Prefix", suffix: "Suffix")
602+
OUDSTextInput(label: "Some label", text: $text, placeholder: "Placeholder", prefix: "Prefix", suffix: "Suffix")
565603
```
566604

567605
or with a trailing action button:
568606
```swift
569607
@State var text: String = ""
570-
let trailingAction = OUDSTextInput.TrailingAction(icon: Image("image_name"), accessibilityLabel: "Some label") { /* Action to process */ }
608+
let trailingAction = OUDSTextInput.TrailingAction(icon: Image("image_name"), actionHint: "Some label") { /* Action to process */ }
571609
OUDSTextInput(label: "Label", text: $text, trailingAction: trailingAction)
572610
```
573611

612+
Text input can also manage errors like:
613+
```swift
614+
OUDSTextInput(label: "Label",
615+
text: $text,
616+
status: .error(message: "Error message"))
617+
```
618+
619+
or have also a leading icon:
620+
```swift
621+
OUDSTextInput(label: "Label", text: $text, leadingIcon: Image("image_name"))
622+
```
623+
574624
#### Indicators
575625

576626
##### Badge

0 commit comments

Comments
 (0)