Skip to content

Commit

Permalink
feat: add borders for color squares in demo app color screen (#280) (#…
Browse files Browse the repository at this point in the history
…281)

Reviewed-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
ludovic35 authored Nov 15, 2024
1 parent 22e215e commit 5e58567
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- [DemoApp] Update color screen to add a border on color illustration square ([#280](https://github.com/Orange-OpenSource/ouds-ios/issues/280))
- [DemoApp] Add grid tokens screen in demo app ([#151](https://github.com/Orange-OpenSource/ouds-ios/issues/151))
- [Tool] GitHub Action to run SwiftLint for *main* and *develop* branches

Expand Down
30 changes: 4 additions & 26 deletions Showcase/Showcase/Pages/Tokens/Color/ColorTokenPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,33 +127,11 @@ struct ColorTokenPage: View {
Rectangle()
.fill(colorRawToken.color)
.frame(width: 64, height: 64)
.modifier(ExtraBorderModifier(color: colorRawToken))
.oudsBorder(style: theme.borderStyleDefault,
width: theme.borderWidthThin,
radius: theme.borderRadiusNone,
color: theme.colorBorderDefault)
}
}
}
}

// MARK: - Extra border modifier

// Add a border if color defined by token is equal to default background color of the root view
private struct ExtraBorderModifier: ViewModifier {

@Environment(\.theme) private var theme
@Environment(\.colorScheme) private var colorScheme

let color: ColorRawToken

func body(content: Content) -> some View {
let defaultContentBackground = theme.colorBgPrimary.color(for: colorScheme)
let addBorder = color.color == defaultContentBackground

if addBorder {
content.oudsBorder(style: theme.borderStyleDefault,
width: theme.borderWidthThin,
radius: theme.borderRadiusNone,
color: theme.colorContentDefault)
} else {
content
}
}
}

0 comments on commit 5e58567

Please sign in to comment.