Skip to content

Commit

Permalink
Merge pull request #272 from adevinta/feature/components/intents
Browse files Browse the repository at this point in the history
[Colors] Rename some intents name
  • Loading branch information
robergro authored Jul 28, 2023
2 parents 5a83044 + fa08f79 commit 8cd10ed
Show file tree
Hide file tree
Showing 58 changed files with 141 additions and 154 deletions.
6 changes: 3 additions & 3 deletions core/Demo/Classes/BadgeUIView_Previews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct BadgeUIView_Previews: PreviewProvider {
),
BadgeUIView(
theme: SparkTheme.shared,
intent: .primary,
intent: .main,
size: .normal,
value: 22,
format: .overflowCounter(maxValue: 20)
Expand All @@ -96,7 +96,7 @@ struct BadgeUIView_Previews: PreviewProvider {
),
BadgeUIView(
theme: SparkTheme.shared,
intent: .primary
intent: .main
),
BadgeUIView(
theme: SparkTheme.shared,
Expand All @@ -105,7 +105,7 @@ struct BadgeUIView_Previews: PreviewProvider {
),
BadgeUIView(
theme: SparkTheme.shared,
intent: .secondary,
intent: .support,
value: 23
),
BadgeUIView(
Expand Down
8 changes: 4 additions & 4 deletions core/Demo/Classes/BadgeView_Previews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct BadgeView_Previews: PreviewProvider {
smallCustomBadgeValue = 18
smallCustomBadgeSize = .normal
smallCustomBadgeIsOutlined.toggle()
smallCustomBadgeType = .primary
smallCustomBadgeType = .main
}
Button("Change Dange Badge") {
standartDangerBadgeType = .neutral
Expand All @@ -61,7 +61,7 @@ struct BadgeView_Previews: PreviewProvider {
Text("Default Badge")
BadgeView(
theme: theme,
intent: .primary,
intent: .main,
value: 3
)
.format(badgeFormat)
Expand Down Expand Up @@ -118,14 +118,14 @@ struct BadgeView_Previews: PreviewProvider {
Text("Text")
BadgeView(
theme: SparkTheme.shared,
intent: .primary
intent: .main
)
}
HStack {
Text("Text")
BadgeView(
theme: SparkTheme.shared,
intent: .secondary
intent: .support
)
}
HStack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum BadgeIntentType: CaseIterable {
case danger
case info
case neutral
case primary
case secondary
case main
case support
case success
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ final class BadgeGetIntentColorsUseCase: BadgeGetIntentColorsUseCaseable {
borderColor: surfaceColor,
foregroundColor: colors.feedback.onNeutral
)
case .primary:
case .main:
return BadgeColors(
backgroundColor: colors.main.main,
borderColor: surfaceColor,
foregroundColor: colors.main.onMain
)
case .secondary:
case .support:
return BadgeColors(
backgroundColor: colors.support.support,
borderColor: surfaceColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ final class BadgeGetColorsUseCaseTests: XCTestCase {
expectedTextToken: mockedExpectedColors.feedback.onNeutral
),
.init(
givenIntent: .primary,
givenIntent: .main,
expectedBackgroundToken: mockedExpectedColors.main.main,
expectedBorderToken: mockedExpectedSurfaceColor,
expectedTextToken: mockedExpectedColors.main.onMain
),
.init(
givenIntent: .secondary,
givenIntent: .support,
expectedBackgroundToken: mockedExpectedColors.support.support,
expectedBorderToken: mockedExpectedSurfaceColor,
expectedTextToken: mockedExpectedColors.support.onSupport
Expand Down
17 changes: 2 additions & 15 deletions core/Sources/Components/Button/Enum/ButtonIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,11 @@ import Foundation
/// A button intent is used to apply a color scheme to a button.
@frozen
public enum ButtonIntent: CaseIterable {
/// Intent used for warning-feedback.
case alert

/// Intent used for error-feedback.
case danger

/// Intent used for neutral-feedback.
case main
case neutral

/// Defines a primary button with primary colors.
case primary

/// Defines a secondary button with secondary colors.
case secondary

/// Intent used for success-feedback.
case success

/// Intent used for surface-buttons.
case support
case surface
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class ButtonGetColorsUseCaseTests: XCTestCase {
let intentsMock = ButtonColors.mocked()

return GetColors(
givenIntent: .primary,
givenIntent: .main,
givenVariant: $0,
givenColors: intentsMock,
expectedforegroundColorToken: intentsMock.foregroundColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ struct ButtonVariantGetContrastUseCase: ButtonGetVariantUseCaseable {
let backgroundColor = colors.base.surface

switch intent {
case .primary:
case .main:
return .init(
foregroundColor: colors.main.main,
backgroundColor: backgroundColor,
pressedBackgroundColor: colors.states.mainContainerPressed,
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
case .secondary:
case .support:
return .init(
foregroundColor: colors.support.support,
backgroundColor: backgroundColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .primary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .main, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand All @@ -40,7 +40,7 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .secondary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .support, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ struct ButtonGetVariantFilledUseCase: ButtonGetVariantUseCaseable {
let pressedBorderColor = ColorTokenDefault.clear

switch intent {
case .primary:
case .main:
return .init(
foregroundColor: colors.main.onMain,
backgroundColor: colors.main.main,
pressedBackgroundColor: colors.states.mainPressed,
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
case .secondary:
case .support:
return .init(
foregroundColor: colors.support.onSupport,
backgroundColor: colors.support.support,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ButtonGetVariantFilledUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .primary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .main, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand All @@ -40,7 +40,7 @@ final class ButtonGetVariantFilledUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .secondary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .support, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ struct ButtonGetVariantGhostUseCase: ButtonGetVariantUseCaseable {
let dim5 = dims.dim5

switch intent {
case .primary:
case .main:
return .init(
foregroundColor: colors.main.main,
backgroundColor: ColorTokenDefault.clear,
pressedBackgroundColor: colors.main.main.opacity(dim5),
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
case .secondary:
case .support:
return .init(
foregroundColor: colors.support.support,
backgroundColor: ColorTokenDefault.clear,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .primary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .main, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand All @@ -40,7 +40,7 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .secondary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .support, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable {
let backgroundColor = colors.base.surface

switch intent {
case .primary:
case .main:
return .init(
foregroundColor: colors.main.main,
backgroundColor: backgroundColor,
pressedBackgroundColor: colors.main.main.opacity(dim5),
borderColor: colors.main.main,
pressedBorderColor: colors.main.main
)
case .secondary:
case .support:
return .init(
foregroundColor: colors.support.support,
backgroundColor: backgroundColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ButtonGetVariantOutlinedUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .primary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .main, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand All @@ -40,7 +40,7 @@ final class ButtonGetVariantOutlinedUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .secondary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .support, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ struct ButtonGetVariantTintedUseCase: ButtonGetVariantUseCaseable {
let pressedBorderColor = ColorTokenDefault.clear

switch intent {
case .primary:
case .main:
return .init(
foregroundColor: colors.main.onMainContainer,
backgroundColor: colors.main.mainContainer,
pressedBackgroundColor: colors.states.mainContainerPressed,
borderColor: borderColor,
pressedBorderColor: pressedBorderColor
)
case .secondary:
case .support:
return .init(
foregroundColor: colors.support.onSupportContainer,
backgroundColor: colors.support.supportContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ButtonGetVariantTintedUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .primary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .main, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand All @@ -40,7 +40,7 @@ final class ButtonGetVariantTintedUseCaseTests: ButtonVariantUseCaseTests {
let sut = self.sut()

// When
let colors = sut.execute(intent: .secondary, colors: self.theme.colors, dims: self.theme.dims)
let colors = sut.execute(intent: .support, colors: self.theme.colors, dims: self.theme.dims)

// Then
XCTAssertEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct ButtonSutTests {
return sizePossibilities.flatMap { size in
shapePossibilities.map { shape in
.init(
intent: .primary,
intent: .main,
variant: .filled,
size: size,
shape: shape,
Expand Down Expand Up @@ -112,7 +112,7 @@ struct ButtonSutTests {

return items.map { item in
.init(
intent: .primary,
intent: .main,
variant: .filled,
size: .medium,
shape: .rounded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ final class ButtonViewModelTests: XCTestCase {

func test_published_properties_on_load() throws {
// GIVEN
let intentMock: ButtonIntent = .secondary
let intentMock: ButtonIntent = .support
let variantMock: ButtonVariant = .outlined
let sizeMock: ButtonSize = .medium
let shapeMock: ButtonShape = .rounded
Expand Down Expand Up @@ -403,7 +403,7 @@ final class ButtonViewModelTests: XCTestCase {
// GIVEN
let newThemeMock = themeMock

let intentMock: ButtonIntent = .secondary
let intentMock: ButtonIntent = .support
let variantMock: ButtonVariant = .outlined
let sizeMock: ButtonSize = .medium
let shapeMock: ButtonShape = .rounded
Expand Down Expand Up @@ -491,12 +491,12 @@ final class ButtonViewModelTests: XCTestCase {
func test_set_intent_with_new_value() {
self.testSetIntent(
givenValue: .danger,
givenNewValue: .primary
givenNewValue: .main
)
}

func test_set_intent_without_new_value() {
let valueMock: ButtonIntent = .primary
let valueMock: ButtonIntent = .main
self.testSetIntent(
givenValue: valueMock,
givenNewValue: valueMock
Expand Down Expand Up @@ -1120,7 +1120,7 @@ final class ButtonViewModelTests: XCTestCase {
private extension ButtonViewModelTests {

private func classToTest(
intent: ButtonIntent = .primary,
intent: ButtonIntent = .main,
variant: ButtonVariant = .tinted,
size: ButtonSize = .medium,
shape: ButtonShape = .rounded,
Expand Down
4 changes: 2 additions & 2 deletions core/Sources/Components/Chip/Enum/ChipIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Foundation

/// The various intent color a chip may have.
public enum ChipIntent: CaseIterable {
case primary
case secondary
case main
case support
case surface
case success
case danger
Expand Down
Loading

0 comments on commit 8cd10ed

Please sign in to comment.