Skip to content

Commit

Permalink
Merge pull request #271 from adevinta/feature/theme/colors
Browse files Browse the repository at this point in the history
[Colors-260] Rename some colors
  • Loading branch information
robergro authored Jul 27, 2023
2 parents 5ac238e + 0860589 commit 5a83044
Show file tree
Hide file tree
Showing 111 changed files with 559 additions and 655 deletions.
2 changes: 1 addition & 1 deletion core/Demo/Classes/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ContentView: View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(theme.colors.secondary.secondary.color)
.foregroundColor(theme.colors.support.support.color)
Text("Hello, Spark Core Demo!")
.font(theme.typography.display1.font)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ final class BadgeGetIntentColorsUseCase: BadgeGetIntentColorsUseCaseable {
)
case .primary:
return BadgeColors(
backgroundColor: colors.primary.primary,
backgroundColor: colors.main.main,
borderColor: surfaceColor,
foregroundColor: colors.primary.onPrimary
foregroundColor: colors.main.onMain
)
case .secondary:
return BadgeColors(
backgroundColor: colors.secondary.secondary,
backgroundColor: colors.support.support,
borderColor: surfaceColor,
foregroundColor: colors.secondary.onSecondary
foregroundColor: colors.support.onSupport
)
case .success:
return BadgeColors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ final class BadgeGetColorsUseCaseTests: XCTestCase {
),
.init(
givenIntent: .primary,
expectedBackgroundToken: mockedExpectedColors.primary.primary,
expectedBackgroundToken: mockedExpectedColors.main.main,
expectedBorderToken: mockedExpectedSurfaceColor,
expectedTextToken: mockedExpectedColors.primary.onPrimary
expectedTextToken: mockedExpectedColors.main.onMain
),
.init(
givenIntent: .secondary,
expectedBackgroundToken: mockedExpectedColors.secondary.secondary,
expectedBackgroundToken: mockedExpectedColors.support.support,
expectedBorderToken: mockedExpectedSurfaceColor,
expectedTextToken: mockedExpectedColors.secondary.onSecondary
expectedTextToken: mockedExpectedColors.support.onSupport
),
.init(
givenIntent: .success,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ final class BadgeUIViewTests: UIKitComponentTestCase {

private func createAttachTestView(badge: BadgeUIView, position: BadgePosition) -> UIView {
let containerView = UIView(frame: .init(x: 0, y: 0, width: 200, height: 200))
containerView.backgroundColor = self.theme.colors.primary.primaryContainer.uiColor
containerView.backgroundColor = self.theme.colors.main.mainContainer.uiColor
let view = UIView(frame: .init(x: 50, y: 50, width: 100, height: 100))
view.backgroundColor = self.theme.colors.primary.primary.uiColor
view.backgroundColor = self.theme.colors.main.main.uiColor
view.layer.cornerRadius = self.theme.border.radius.small
containerView.addSubview(view)
containerView.addSubview(badge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ final class ButtonColorsTests: XCTestCase {
func test_buttonColors_equal() {
let colors = SparkTheme.shared.colors
let given1 = ButtonColors(
foregroundColor: colors.primary.primary,
foregroundColor: colors.main.main,
backgroundColor: colors.base.background,
pressedBackgroundColor: colors.base.backgroundVariant,
borderColor: colors.base.background,
pressedBorderColor: colors.states.primaryPressed)
pressedBorderColor: colors.states.mainPressed)
let given2 = ButtonColors(
foregroundColor: colors.primary.primary,
foregroundColor: colors.main.main,
backgroundColor: colors.base.background,
pressedBackgroundColor: colors.base.backgroundVariant,
borderColor: colors.base.background,
pressedBorderColor: colors.states.primaryPressed)
pressedBorderColor: colors.states.mainPressed)

XCTAssertEqual(given1, given2)
}

func test_buttonColors_not_equal() {
let colors = SparkTheme.shared.colors
let given1 = ButtonColors(
foregroundColor: colors.primary.primary,
foregroundColor: colors.main.main,
backgroundColor: colors.base.background,
pressedBackgroundColor: colors.base.backgroundVariant,
borderColor: colors.base.background,
pressedBorderColor: colors.states.primaryPressed)
pressedBorderColor: colors.states.mainPressed)
let given2 = ButtonColors(
foregroundColor: colors.primary.primary,
foregroundColor: colors.main.main,
backgroundColor: colors.base.background,
pressedBackgroundColor: colors.base.backgroundVariant,
borderColor: colors.base.background,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ final class ButtonCurrentColorsTests: XCTestCase {
iconTintColor: colors.base.onSurface,
textColor: colors.base.onSurfaceInverse,
backgroundColor: colors.base.backgroundVariant,
borderColor: colors.primary.primary)
borderColor: colors.main.main)

let given2 = ButtonCurrentColors(
iconTintColor: colors.base.onSurface,
textColor: colors.base.onSurfaceInverse,
backgroundColor: colors.base.backgroundVariant,
borderColor: colors.primary.primary)
borderColor: colors.main.main)

XCTAssertEqual(given1, given2)
}
Expand All @@ -39,13 +39,13 @@ final class ButtonCurrentColorsTests: XCTestCase {
iconTintColor: colors.base.surface,
textColor: colors.base.surfaceInverse,
backgroundColor: colors.base.backgroundVariant,
borderColor: colors.primary.primary)
borderColor: colors.main.main)

let given2 = ButtonCurrentColors(
iconTintColor: colors.base.onSurface,
textColor: colors.base.onSurfaceInverse,
backgroundColor: colors.base.backgroundVariant,
borderColor: colors.primary.onPrimary)
borderColor: colors.main.onMain)

XCTAssertNotEqual(given1, given2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class ButtonGetColorsUseCaseTests: XCTestCase {

for item in items {
let themeColorsMock = ColorsGeneratedMock()
themeColorsMock.primary = ColorsPrimaryGeneratedMock.mocked()
themeColorsMock.main = ColorsMainGeneratedMock.mocked()
themeColorsMock.states = ColorsStatesGeneratedMock.mocked()

let dimsMock = DimsGeneratedMock.mocked()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ struct ButtonVariantGetContrastUseCase: ButtonGetVariantUseCaseable {
switch intent {
case .primary:
return .init(
foregroundColor: colors.primary.primary,
foregroundColor: colors.main.main,
backgroundColor: backgroundColor,
pressedBackgroundColor: colors.states.primaryContainerPressed,
pressedBackgroundColor: colors.states.mainContainerPressed,
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
case .secondary:
return .init(
foregroundColor: colors.secondary.secondary,
foregroundColor: colors.support.support,
backgroundColor: backgroundColor,
pressedBackgroundColor: colors.states.secondaryContainerPressed,
pressedBackgroundColor: colors.states.supportContainerPressed,
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SwiftUI
final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests {

// MARK: - Tests
func test_primary_colors() throws {
func test_main_colors() throws {
// Given
let sut = self.sut()

Expand All @@ -27,15 +27,15 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests {
colors.pressedBackgroundColor,
colors.borderColor,
colors.pressedBorderColor].map(\.color),
[self.theme.colors.primary.primary,
[self.theme.colors.main.main,
self.theme.colors.base.surface,
self.theme.colors.states.primaryContainerPressed,
self.theme.colors.states.mainContainerPressed,
ColorTokenDefault.clear,
ColorTokenDefault.clear
].map(\.color))
}

func test_secondary_colors() throws {
func test_support_colors() throws {
// Given
let sut = self.sut()

Expand All @@ -49,9 +49,9 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests {
colors.pressedBackgroundColor,
colors.borderColor,
colors.pressedBorderColor].map(\.color),
[self.theme.colors.secondary.secondary,
[self.theme.colors.support.support,
self.theme.colors.base.surface,
self.theme.colors.states.secondaryContainerPressed,
self.theme.colors.states.supportContainerPressed,
ColorTokenDefault.clear,
ColorTokenDefault.clear
].map(\.color))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ struct ButtonGetVariantFilledUseCase: ButtonGetVariantUseCaseable {
switch intent {
case .primary:
return .init(
foregroundColor: colors.primary.onPrimary,
backgroundColor: colors.primary.primary,
pressedBackgroundColor: colors.states.primaryPressed,
foregroundColor: colors.main.onMain,
backgroundColor: colors.main.main,
pressedBackgroundColor: colors.states.mainPressed,
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
case .secondary:
return .init(
foregroundColor: colors.secondary.onSecondary,
backgroundColor: colors.secondary.secondary,
pressedBackgroundColor: colors.states.secondaryPressed,
foregroundColor: colors.support.onSupport,
backgroundColor: colors.support.support,
pressedBackgroundColor: colors.states.supportPressed,
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SwiftUI
final class ButtonGetVariantFilledUseCaseTests: ButtonVariantUseCaseTests {

// MARK: - Tests
func test_primary_colors() throws {
func test_main_colors() throws {
// Given
let sut = self.sut()

Expand All @@ -27,15 +27,15 @@ final class ButtonGetVariantFilledUseCaseTests: ButtonVariantUseCaseTests {
colors.pressedBackgroundColor,
colors.borderColor,
colors.pressedBorderColor].map(\.color),
[self.theme.colors.primary.onPrimary,
self.theme.colors.primary.primary,
self.theme.colors.states.primaryPressed,
[self.theme.colors.main.onMain,
self.theme.colors.main.main,
self.theme.colors.states.mainPressed,
ColorTokenDefault.clear,
ColorTokenDefault.clear
].map(\.color))
}

func test_secondary_colors() throws {
func test_support_colors() throws {
// Given
let sut = self.sut()

Expand All @@ -49,9 +49,9 @@ final class ButtonGetVariantFilledUseCaseTests: ButtonVariantUseCaseTests {
colors.pressedBackgroundColor,
colors.borderColor,
colors.pressedBorderColor].map(\.color),
[self.theme.colors.secondary.onSecondary,
self.theme.colors.secondary.secondary,
self.theme.colors.states.secondaryPressed,
[self.theme.colors.support.onSupport,
self.theme.colors.support.support,
self.theme.colors.states.supportPressed,
ColorTokenDefault.clear,
ColorTokenDefault.clear
].map(\.color))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ struct ButtonGetVariantGhostUseCase: ButtonGetVariantUseCaseable {
switch intent {
case .primary:
return .init(
foregroundColor: colors.primary.primary,
foregroundColor: colors.main.main,
backgroundColor: ColorTokenDefault.clear,
pressedBackgroundColor: colors.primary.primary.opacity(dim5),
pressedBackgroundColor: colors.main.main.opacity(dim5),
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
case .secondary:
return .init(
foregroundColor: colors.secondary.secondary,
foregroundColor: colors.support.support,
backgroundColor: ColorTokenDefault.clear,
pressedBackgroundColor: colors.secondary.secondary.opacity(dim5),
pressedBackgroundColor: colors.support.support.opacity(dim5),
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SwiftUI
final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests {

// MARK: - Tests
func test_primary_colors() throws {
func test_main_colors() throws {
// Given
let sut = self.sut()

Expand All @@ -27,15 +27,15 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests {
colors.pressedBackgroundColor,
colors.borderColor,
colors.pressedBorderColor].map(\.color),
[self.theme.colors.primary.primary,
[self.theme.colors.main.main,
ColorTokenDefault.clear,
self.theme.colors.primary.primary.opacity(self.theme.dims.dim5),
self.theme.colors.main.main.opacity(self.theme.dims.dim5),
ColorTokenDefault.clear,
ColorTokenDefault.clear
].map(\.color))
}

func test_secondary_colors() throws {
func test_support_colors() throws {
// Given
let sut = self.sut()

Expand All @@ -49,9 +49,9 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests {
colors.pressedBackgroundColor,
colors.borderColor,
colors.pressedBorderColor].map(\.color),
[self.theme.colors.secondary.secondary,
[self.theme.colors.support.support,
ColorTokenDefault.clear,
self.theme.colors.secondary.secondary.opacity(self.theme.dims.dim5),
self.theme.colors.support.support.opacity(self.theme.dims.dim5),
ColorTokenDefault.clear,
ColorTokenDefault.clear
].map(\.color))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable {
switch intent {
case .primary:
return .init(
foregroundColor: colors.primary.primary,
foregroundColor: colors.main.main,
backgroundColor: backgroundColor,
pressedBackgroundColor: colors.primary.primary.opacity(dim5),
borderColor: colors.primary.primary,
pressedBorderColor: colors.primary.primary
pressedBackgroundColor: colors.main.main.opacity(dim5),
borderColor: colors.main.main,
pressedBorderColor: colors.main.main
)
case .secondary:
return .init(
foregroundColor: colors.secondary.secondary,
foregroundColor: colors.support.support,
backgroundColor: backgroundColor,
pressedBackgroundColor: colors.secondary.secondary.opacity(dim5),
borderColor: colors.secondary.secondary,
pressedBorderColor: colors.secondary.secondary
pressedBackgroundColor: colors.support.support.opacity(dim5),
borderColor: colors.support.support,
pressedBorderColor: colors.support.support
)
case .neutral:
return .init(
Expand Down
Loading

0 comments on commit 5a83044

Please sign in to comment.