-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Reviewed-by: Pierre-Yves Lapersonne <[email protected]>
- Loading branch information
Showing
11 changed files
with
290 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Showcase/Showcase.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Showcase/Showcase/Pages/Tokens/Dimension/DimensionTokenElement.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct DimensionTokenElement: TokenElement { | ||
let name: String | ||
let imageName: String | ||
let description: String | ||
let pageDescription: AnyView | ||
|
||
let variants: [TokenElement] = [ | ||
SpacingTokenElement() | ||
] | ||
|
||
init() { | ||
name = "app_tokens_dimension_label" | ||
imageName = "ic_dimension" | ||
description = "app_tokens_dimension_description_text" | ||
pageDescription = AnyView(ShowcaseVariantElement(elements: variants)) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Showcase/Showcase/Pages/Tokens/Dimension/Spacing/SpacingTokenElement.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SpacingTokenElement: TokenElement { | ||
let name: String | ||
let imageName: String | ||
let description: String | ||
let pageDescription: AnyView | ||
|
||
init() { | ||
name = "app_tokens_dimension_spacing_label" | ||
imageName = "ic_dimension" | ||
description = "app_tokens_dimension_spacing_description_text" | ||
pageDescription = AnyView(SpacingTokenPage()) | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
Showcase/Showcase/Pages/Tokens/Dimension/Spacing/SpacingTokenPage.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import OUDS | ||
import OUDSTokensSemantic | ||
import SwiftUI | ||
|
||
struct SpacingTokenPage: View { | ||
|
||
@Environment(\.theme) private var theme | ||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass | ||
@Environment(\.verticalSizeClass) private var verticalSizeClass | ||
@Environment(\.colorScheme) private var colorScheme | ||
|
||
// MARK: Body | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: theme.spaceFixedNone) { | ||
ForEach(NamedSpacing.allCases, id: \.rawValue) { spacingName in | ||
illustration(for: spacingName) | ||
} | ||
} | ||
.frame(maxWidth: .infinity) | ||
.padding(.horizontal, theme.spaceFixedMedium) | ||
} | ||
|
||
// MARK: Private helpers | ||
|
||
private func illustration(for spacingName: NamedSpacing) -> some View { | ||
illustration(for: spacingName.token(from: theme), named: spacingName.rawValue) | ||
} | ||
|
||
private func illustration(for spacingSementicToken: MultipleSpacingTokens, named: String) -> some View { | ||
|
||
let horizontalDimensionRawToken = spacingSementicToken.dimension(for: horizontalSizeClass ?? .regular) | ||
let verticalDimensionRawToken = spacingSementicToken.dimension(for: verticalSizeClass ?? .regular) | ||
return HStack(alignment: .center, spacing: theme.spaceFixedMedium) { | ||
ZStack { | ||
Rectangle() | ||
.fill((theme.colorBackgroundEmphasizedPrimary?.color(for: colorScheme))!) | ||
.frame(width: 64, height: 64, alignment: .center) | ||
Rectangle() | ||
// .fill((theme.colorBackgroundStatusAttractiveEmphasized?.color(for: colorScheme))!) // TODO: Update when color is available | ||
.fill(.blue) | ||
.frame(width: horizontalDimensionRawToken, height: 64, alignment: .center) | ||
} | ||
VStack(alignment: .leading) { | ||
Text(named).typeBodyStrongLarge(theme) | ||
Text("horizontal \(horizontalSizeClass == .regular ? "regular" : "compact") \(horizontalDimensionRawToken, specifier: "%.0f") pt") | ||
Text("vertical \(verticalSizeClass == .regular ? "regular" : "compact") \(verticalDimensionRawToken, specifier: "%.0f") pt") | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.foregroundColor(theme.colorContentDefault?.color(for: colorScheme)) | ||
} | ||
.padding(.vertical, theme.spaceFixedShorter) | ||
} | ||
} | ||
|
||
// MARK: - Named Spacing | ||
|
||
private enum NamedSpacing: String, CaseIterable { | ||
case spaceScaledNone | ||
case spaceScaledSmash | ||
case spaceScaledShortest | ||
case spaceScaledShorter | ||
case spaceScaledShort | ||
case spaceScaledMedium | ||
case spaceScaledTall | ||
case spaceScaledTaller | ||
case spaceScaledTallest | ||
case spaceScaledSpacious | ||
|
||
func token(from theme: OUDSTheme) -> MultipleSpacingTokens { | ||
switch self { | ||
case .spaceScaledNone: | ||
return theme.spaceScaledNone | ||
case .spaceScaledSmash: | ||
return theme.spaceScaledSmash | ||
case .spaceScaledShortest: | ||
return theme.spaceScaledShortest | ||
case .spaceScaledShorter: | ||
return theme.spaceScaledShorter | ||
case .spaceScaledShort: | ||
return theme.spaceScaledShort | ||
case .spaceScaledMedium: | ||
return theme.spaceScaledMedium | ||
case .spaceScaledTall: | ||
return theme.spaceScaledTall | ||
case .spaceScaledTaller: | ||
return theme.spaceScaledTaller | ||
case .spaceScaledTallest: | ||
return theme.spaceScaledTallest | ||
case .spaceScaledSpacious: | ||
return theme.spaceScaledSpacious | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Showcase/Showcase/Pages/Utils/ShowcaseVariantElement.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import OUDS | ||
import OUDSTokensSemantic | ||
import SwiftUI | ||
|
||
struct ShowcaseVariantElement: View { | ||
|
||
@Environment(\.theme) private var theme | ||
@Environment(\.colorScheme) private var colorScheme | ||
|
||
// MARK: Stored properties | ||
|
||
let elements: [ShowcaseElement] | ||
|
||
// MARK: Body | ||
|
||
var body: some View { | ||
VStack(alignment: .center, spacing: theme.spaceFixedMedium) { | ||
ForEach(elements, id: \.id) { element in | ||
NavigationLink { | ||
ShowcaseElementPage(element: element) | ||
} label: { | ||
Text(LocalizedStringKey(element.name)) | ||
.typeHeadingMedium(theme) | ||
.padding(.vertical, theme.spaceFixedShorter) | ||
} | ||
} | ||
} | ||
.padding(.horizontal, theme.spaceFixedMedium) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Showcase/Showcase/Resources/Assets.xcassets/Tokens/ic_dimension.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "ic_dimension.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.