Skip to content

Commit

Permalink
[Colors/NewTokens#263] Added Basic and Accent tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisBorleeAdevinta committed Aug 1, 2023
1 parent d91f7f0 commit bdc67cc
Show file tree
Hide file tree
Showing 41 changed files with 836 additions and 181 deletions.
2 changes: 2 additions & 0 deletions core/Sources/Theming/Content/Colors/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import SwiftUI
public protocol Colors {
var main: ColorsMain { get }
var support: ColorsSupport { get }
var accent: ColorsAccent { get }
var basic: ColorsBasic { get }
var base: ColorsBase { get }
var feedback: ColorsFeedback { get }
var states: ColorsStates { get }
Expand Down
6 changes: 6 additions & 0 deletions core/Sources/Theming/Content/Colors/ColorsDefault.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public struct ColorsDefault: Colors {

public let main: ColorsMain
public let support: ColorsSupport
public let accent: ColorsAccent
public let basic: ColorsBasic
public let base: ColorsBase
public let feedback: ColorsFeedback
public let states: ColorsStates
Expand All @@ -23,11 +25,15 @@ public struct ColorsDefault: Colors {

public init(main: ColorsMain,
support: ColorsSupport,
accent: ColorsAccent,
basic: ColorsBasic,
base: ColorsBase,
feedback: ColorsFeedback,
states: ColorsStates) {
self.main = main
self.support = support
self.accent = accent
self.basic = basic
self.base = base
self.feedback = feedback
self.states = states
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ColorsAccent.swift
// Spark
//
// Created by louis.borlee on 01/08/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

// sourcery: AutoMockable
public protocol ColorsAccent {
var accent: any ColorToken { get }
var onAccent: any ColorToken { get }
var accentVariant: any ColorToken { get }
var onAccentVariant: any ColorToken { get }
var accentContainer: any ColorToken { get }
var onAccentContainer: any ColorToken { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// ColorsAccentDefault.swift
// SparkCore
//
// Created by louis.borlee on 01/08/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

public struct ColorsAccentDefault: ColorsAccent {

// MARK: - Properties

public let accent: any ColorToken
public let onAccent: any ColorToken
public let accentVariant: any ColorToken
public let onAccentVariant: any ColorToken
public let accentContainer: any ColorToken
public let onAccentContainer: any ColorToken

// MARK: - Init

public init(accent: any ColorToken,
onAccent: any ColorToken,
accentVariant: any ColorToken,
onAccentVariant: any ColorToken,
accentContainer: any ColorToken,
onAccentContainer: any ColorToken) {
self.accent = accent
self.onAccent = onAccent
self.accentVariant = accentVariant
self.onAccentVariant = onAccentVariant
self.accentContainer = accentContainer
self.onAccentContainer = onAccentContainer
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ColorsAccentGeneratedMock+ExtensionTests.swift
// SparkCore
//
// Created by robin.lemaire on 11/04/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

@testable import SparkCore

extension ColorsAccentGeneratedMock {

// MARK: - Methods

static func mocked() -> ColorsAccentGeneratedMock {
let mock = ColorsAccentGeneratedMock()

mock.underlyingAccent = ColorTokenGeneratedMock.random()
mock.underlyingOnAccent = ColorTokenGeneratedMock.random()

mock.underlyingAccentVariant = ColorTokenGeneratedMock.random()
mock.underlyingOnAccentVariant = ColorTokenGeneratedMock.random()

mock.underlyingAccentContainer = ColorTokenGeneratedMock.random()
mock.underlyingOnAccentContainer = ColorTokenGeneratedMock.random()

return mock
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ColorsBasic.swift
// Spark
//
// Created by louis.borlee on 01/08/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

// sourcery: AutoMockable
public protocol ColorsBasic {
var basic: any ColorToken { get }
var onBasic: any ColorToken { get }
var basicContainer: any ColorToken { get }
var onBasicContainer: any ColorToken { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ColorsBasicDefault.swift
// SparkCore
//
// Created by louis.borlee on 01/08/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

public struct ColorsBasicDefault: ColorsBasic {

// MARK: - Properties

public let basic: any ColorToken
public let onBasic: any ColorToken
public let basicContainer: any ColorToken
public let onBasicContainer: any ColorToken

// MARK: - Init

public init(basic: any ColorToken,
onBasic: any ColorToken,
basicContainer: any ColorToken,
onBasicContainer: any ColorToken) {
self.basic = basic
self.onBasic = onBasic
self.basicContainer = basicContainer
self.onBasicContainer = onBasicContainer
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// ColorsBasicGeneratedMock+ExtensionTests.swift
// SparkCore
//
// Created by robin.lemaire on 11/04/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

@testable import SparkCore

extension ColorsBasicGeneratedMock {

// MARK: - Methods

static func mocked() -> ColorsBasicGeneratedMock {
let mock = ColorsBasicGeneratedMock()

mock.underlyingBasic = ColorTokenGeneratedMock.random()
mock.underlyingOnBasic = ColorTokenGeneratedMock.random()

mock.underlyingBasicContainer = ColorTokenGeneratedMock.random()
mock.underlyingOnBasicContainer = ColorTokenGeneratedMock.random()

return mock
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import SparkCore
enum ColorSectionType: CaseIterable {
case main
case support
case accent
case basic
case base
case feedback
case states
Expand All @@ -24,6 +26,10 @@ enum ColorSectionType: CaseIterable {
return ColorSectionMainViewModel(color: colors.main)
case .support:
return ColorSectionSupportViewModel(color: colors.support)
case .accent:
return ColorSectionAccentViewModel(color: colors.accent)
case .basic:
return ColorSectionBasicViewModel(color: colors.basic)
case .base:
return ColorSectionBaseViewModel(color: colors.base)
case .feedback:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ColorSectionAccentViewModel.swift
// SparkDemo
//
// Created by louis.borlee on 01/08/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

import SparkCore

struct ColorSectionAccentViewModel: ColorSectionViewModelable {

// MARK: - Properties

let name: String
let itemViewModels: [[ColorItemViewModel]]

// MARK: - Initialization

init(color: ColorsAccent) {
self.name = "accent"
self.itemViewModels = [
[
.init(name: "accent", colorToken: color.accent),
.init(name: "onAccent", colorToken: color.onAccent),
.init(name: "accentVariant", colorToken: color.accentVariant),
.init(name: "onAccentVariant", colorToken: color.onAccentVariant),
.init(name: "accentContainer", colorToken: color.accentContainer),
.init(name: "onAccentContainer", colorToken: color.onAccentContainer)
]
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// ColorSectionBasicViewModel.swift
// SparkDemo
//
// Created by louis.borlee on 01/08/2023.
// Copyright © 2023 Adevinta. All rights reserved.
//

import SparkCore

struct ColorSectionBasicViewModel: ColorSectionViewModelable {

// MARK: - Properties

let name: String
let itemViewModels: [[ColorItemViewModel]]

// MARK: - Initialization

init(color: ColorsBasic) {
self.name = "basic"
self.itemViewModels = [
[
.init(name: "basic", colorToken: color.basic),
.init(name: "onBasic", colorToken: color.onBasic),
.init(name: "basicContainer", colorToken: color.basicContainer),
.init(name: "onBasicContainer", colorToken: color.onBasicContainer)
]
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.043",
"green" : "0.047",
"red" : "0.047"
"blue" : "0xFF",
"green" : "0xD5",
"red" : "0xEA"
}
},
"idiom" : "universal"
Expand All @@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.043",
"green" : "0.047",
"red" : "0.047"
"blue" : "0xBB",
"green" : "0x64",
"red" : "0x8D"
}
},
"idiom" : "universal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.047",
"green" : "0.047",
"red" : "0.702"
"blue" : "0x77",
"green" : "0x38",
"red" : "0x51"
}
},
"idiom" : "universal"
Expand All @@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.843",
"green" : "0.843",
"red" : "1.000"
"blue" : "0xFF",
"green" : "0xB7",
"red" : "0xDB"
}
},
"idiom" : "universal"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0x99",
"red" : "0xCC"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0x99",
"red" : "0xCC"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
"blue" : "0x55",
"green" : "0x25",
"red" : "0x36"
}
},
"idiom" : "universal"
Expand All @@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.043",
"green" : "0.047",
"red" : "0.047"
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
Expand Down
Loading

0 comments on commit bdc67cc

Please sign in to comment.