Skip to content

Commit

Permalink
refactor: objects and files of demo app (#85)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp committed Jan 20, 2025
1 parent 540bb3f commit 23cfdd7
Show file tree
Hide file tree
Showing 36 changed files with 123 additions and 123 deletions.
104 changes: 52 additions & 52 deletions DesignToolbox/DesignToolbox.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import OUDS
import SwiftUI

@main
struct Showcase: App {
struct DesignToolbox: App {
@StateObject var themeProvider = ThemeProvider()

var body: some Scene {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct ButtonElement: ShowcaseElement {
struct ButtonElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_border_label"
imageName = "ic_border"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: nil,
description: "app_tokens_border_description_text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import SwiftUI

struct ComponentsPage: View {

// let componentElements: [ShowcaseElement] = [
// let componentElements: [DesignToolboxElement] = [
// ButtonElement()
// ]

var body: some View {
NavigationView {
EmptyState()
// ShowcaseElementsPage(elements: componentElements)
// DesignToolboxElementsPage(elements: componentElements)
.oudsNavigationTitle("app_bottomBar_components_label")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ struct ComponentConfigurationView<Component, Configuration>: View where Componen
componentView(configuration)
// No padding here, the component erea keep all the frame horizontaly

ShowcaseConfiguration {
DesignToolboxConfiguration {
configurationView(configuration)
}
.padding(.horizontal, theme.spaces.spaceFixedMedium)

ShowcaseCode(code: configuration.code, titleText: "app_components_common_viewCodeExample_label")
DesignToolboxCode(code: configuration.code, titleText: "app_components_common_viewCodeExample_label")
.padding(.horizontal, theme.spaces.spaceFixedMedium)
}
.padding(.bottom, theme.spaces.spaceFixedMedium)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct BorderTokenElement: ShowcaseElement {
struct BorderTokenElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_border_label"
imageName = "ic_border"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_border_description_text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct BorderTokenPage: View {
VStack(alignment: .leading, spacing: theme.spaces.spaceFixedMedium) {
Section {
VStack(alignment: .leading, spacing: theme.spaces.spaceFixedNone) {
ShowcaseCode(code: "theme.borders.borderWidthDefault", titleText: "app_tokens_common_viewCodeExample_label")
DesignToolboxCode(code: "theme.borders.borderWidthDefault", titleText: "app_tokens_common_viewCodeExample_label")
}
}
Section {
Expand Down Expand Up @@ -90,7 +90,7 @@ struct BorderTokenPage: View {
let name = namedWidth.rawValue
let value = String(format: "%.2f pt", token)

ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
RectangleBackground()
.oudsBorder(style: theme.borders.borderStyleDefault,
width: token,
Expand All @@ -110,7 +110,7 @@ struct BorderTokenPage: View {
let name = namedRadius.rawValue
let value = String(format: "%.2f pt", token)

ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
RectangleBackground()
.oudsBorder(style: theme.borders.borderStyleDefault,
width: theme.borders.borderWidthDefault,
Expand All @@ -130,7 +130,7 @@ struct BorderTokenPage: View {
let name = namedStyle.rawValue
let value = token

ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
RectangleBackground()
.oudsBorder(style: token,
width: theme.borders.borderWidthDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct ColorTokenElement: ShowcaseElement {
struct ColorTokenElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_color_label"
imageName = "ic_palette"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_color_description_text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ColorTokenPage: View {
var body: some View {
Group {
Section {
ShowcaseCode(code: "theme.colors.colorBgPrimary.color(for: colorScheme)", titleText: "app_tokens_common_viewCodeExample_label")
DesignToolboxCode(code: "theme.colors.colorBgPrimary.color(for: colorScheme)", titleText: "app_tokens_common_viewCodeExample_label")
}
Section { illustrationForAction() } header: { header("Action") }
Section { illustrationForAlways() } header: { header("Always") }
Expand All @@ -45,7 +45,7 @@ struct ColorTokenPage: View {
// MARK: Private helpers

private func header(_ text: String) -> some View {
Text(text).showcaseSectionHeaderStyle()
Text(text).designToolboxSectionHeaderStyle()
}

private func illustrationForBackground() -> some View {
Expand Down Expand Up @@ -147,7 +147,7 @@ struct ColorTokenPage: View {
var body: some View {
let colorRawToken = colorScheme == .dark ? token.dark : token.light

ShowcaseTokenIllustration(tokenName: name, tokenValue: colorRawToken) {
DesignToolboxTokenIllustration(tokenName: name, tokenValue: colorRawToken) {
Rectangle()
.fill(colorRawToken.color)
.frame(width: 64, height: 64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@

import SwiftUI

struct DimensionTokenElement: ShowcaseElement {
struct DimensionTokenElement: DesignToolboxElement {

let name: String
let imageName: String
let pageDescription: AnyView

init() {
let variants: [ShowcaseElement] = [
let variants: [DesignToolboxElement] = [
SizeTokenElement(),
SpaceTokenElement(),
]

name = "app_tokens_dimension_label"
imageName = "ic_dimension"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_dimension_description_text",
illustration: AnyView(ShowcaseVariantElement(elements: variants))))
illustration: AnyView(DesignToolboxVariantElement(elements: variants))))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct SizeTokenElement: ShowcaseElement {
struct SizeTokenElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_dimension_size_label"
imageName = "ic_dimension"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_dimension_size_description_text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct SizeTokenPage: View {
var body: some View {
Group {
Section {
ShowcaseCode(code: "theme.sizeIconWithHeadingXLargeShort.dimension(for: horizontalSizeClass ?? .regular)", titleText: "app_tokens_common_viewCodeExample_label")
DesignToolboxCode(code: "theme.sizeIconWithHeadingXLargeShort.dimension(for: horizontalSizeClass ?? .regular)", titleText: "app_tokens_common_viewCodeExample_label")
}
Section {
VStack(alignment: .center, spacing: theme.spaces.spaceFixedNone) {
Expand Down Expand Up @@ -62,7 +62,7 @@ struct SizeTokenPage: View {
let name = namedSize.rawValue
let value = String(format: "%.2f pt", token)

ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
ZStack {
Rectangle()
.fill(theme.colors.colorSurfaceStatusNeutralMuted.color(for: colorScheme))
Expand Down Expand Up @@ -96,7 +96,7 @@ struct SizeTokenPage: View {
let name = namedSize.sizeDescription
let value = String(format: "%.2f pt", token)

ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
ZStack {
Rectangle()
.fill(theme.colors.colorSurfaceStatusNeutralMuted.color(for: colorScheme))
Expand Down Expand Up @@ -171,7 +171,7 @@ struct SizeTokenPage: View {
}

private func sectionHeader(_ text: LocalizedStringKey) -> some View {
Text(text).showcaseSectionHeaderStyle()
Text(text).designToolboxSectionHeaderStyle()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct ScaledSpaceProperty: View {
verticalSizeClass == .regular ? "regular" : "compact",
verticalDimensionRawToken)

return ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
return DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
SpaceScaledIllustration(horizontalDimension: horizontalDimensionRawToken, verticalDimension: verticalDimensionRawToken)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct SpaceTokenVariant<TokenIllustration>: View where TokenIllustration: View
let name = namedSpaceToken.name
let value = String(format: "%.2f pt", token)

return ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
return DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
illustration(token)
}
}
Expand Down Expand Up @@ -107,11 +107,11 @@ struct SpaceCommonIllustration: View {
var body: some View {
ZStack(alignment: zStackAlignment) {
// Background color
ShowcaseTokenIllustrationBackground()
DesignToolboxTokenIllustrationBackground()

switch padding {
case .topLeading: // ZStack topleading
ShowcaseTokenIllustrationBackground()
DesignToolboxTokenIllustrationBackground()
.padding(.top, dimension)
.padding(.leading, dimension)
.background(theme.colors.colorContentStatusInfo.color(for: colorScheme))
Expand Down Expand Up @@ -171,7 +171,7 @@ struct SpaceScaledIllustration: View {
var body: some View {
ZStack(alignment: .center) {
// Background color
ShowcaseTokenIllustrationBackground()
DesignToolboxTokenIllustrationBackground()

// Illustration
SpaceIllustrationRectangle(width: horizontalDimension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct SpaceTokenElement: ShowcaseElement {
struct SpaceTokenElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_dimension_space_label"
imageName = "ic_dimension"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_dimension_space_description_text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct SpaceTokenPage: View {
var body: some View {
Group {
Section {
ShowcaseCode(code: "theme.spaceScaledMedium.dimension(for: horizontalSizeClass ?? .regular)", titleText: "app_tokens_common_viewCodeExample_label")
DesignToolboxCode(code: "theme.spaceScaledMedium.dimension(for: horizontalSizeClass ?? .regular)", titleText: "app_tokens_common_viewCodeExample_label")
}
// Basic Space Tokens
Section { ScaledSpaceProperty() } header: {
Expand Down Expand Up @@ -58,7 +58,7 @@ struct SpaceTokenPage: View {
// MARK: Common helpers

private func header(_ text: LocalizedStringKey) -> some View {
Text(text).showcaseSectionHeaderStyle()
Text(text).designToolboxSectionHeaderStyle()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct ElevationTokenElement: ShowcaseElement {
struct ElevationTokenElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_elevation_label"
imageName = "ic_layers"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_elevation_description_text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ElevationTokenPage: View {
var body: some View {
VStack(alignment: .leading, spacing: theme.spaces.spaceFixedNone) {
Section {
ShowcaseCode(code: "theme.elevations.elevationNone.elevation(for: colorScheme)", titleText: "app_tokens_common_viewCodeExample_label")
DesignToolboxCode(code: "theme.elevations.elevationNone.elevation(for: colorScheme)", titleText: "app_tokens_common_viewCodeExample_label")
}

Spacer().frame(height: theme.spaces.spaceFixedMedium)
Expand All @@ -49,7 +49,7 @@ struct ElevationTokenPage: View {
let name = namedElevation.rawValue
let value = String(format: "x: %.2f, y: %.2f, radius: %.2f\nColor: %@", token.x, token.y, token.radius, token.color)

ShowcaseTokenIllustration(tokenName: name, tokenValue: value) {
DesignToolboxTokenIllustration(tokenName: name, tokenValue: value) {
Rectangle()
.frame(width: theme.sizes.sizeIconDecorative2xl, height: theme.sizes.sizeIconDecorative2xl)
.foregroundColor(theme.colors.colorBgSecondary.color(for: colorScheme))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct FontTokenElement: ShowcaseElement {
struct FontTokenElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_typography_label"
imageName = "ic_typography"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_typography_description_text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct FontTokenPage: View {
var body: some View {
VStack(alignment: .leading, spacing: theme.spaces.spaceFixedNone) {
Section {
ShowcaseCode(code: "theme.typeBodyStrongLarge(theme)", titleText: "app_tokens_common_viewCodeExample_label")
DesignToolboxCode(code: "theme.typeBodyStrongLarge(theme)", titleText: "app_tokens_common_viewCodeExample_label")
}

Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import SwiftUI

struct GridTokenElement: ShowcaseElement {
struct GridTokenElement: DesignToolboxElement {
let name: String
let imageName: String
let pageDescription: AnyView

init() {
name = "app_tokens_grid_label"
imageName = "ic_grid"
pageDescription = AnyView(ShowcaseElementPage(
pageDescription = AnyView(DesignToolboxElementPage(
name: name,
imageName: imageName,
description: "app_tokens_grid_description_text",
Expand Down
Loading

0 comments on commit 23cfdd7

Please sign in to comment.