From b5043d340735cf6bbf3af95cdab6fb1180ceaece Mon Sep 17 00:00:00 2001 From: "louis.borlee" Date: Wed, 6 Sep 2023 14:19:57 +0200 Subject: [PATCH] [Button#1377] Added info intent --- .../Components/Button/Enum/ButtonIntent.swift | 3 ++- .../ButtonGetVariantContrastUseCase.swift | 8 +++++++ ...ButtonGetVariantContrastUseCaseTests.swift | 22 +++++++++++++++++++ .../ButtonGetVariantFilledUseCase.swift | 8 +++++++ .../ButtonGetVariantFilledUseCaseTests.swift | 22 +++++++++++++++++++ .../ButtonGetVariantGhostUseCase.swift | 8 +++++++ .../ButtonGetVariantGhostUseCaseTests.swift | 22 +++++++++++++++++++ .../ButtonGetVariantOutlinedUseCase.swift | 8 +++++++ ...ButtonGetVariantOutlinedUseCaseTests.swift | 22 +++++++++++++++++++ .../ButtonGetVariantTintedUseCase.swift | 8 +++++++ .../ButtonGetVariantTintedUseCaseTests.swift | 22 +++++++++++++++++++ 11 files changed, 152 insertions(+), 1 deletion(-) diff --git a/core/Sources/Components/Button/Enum/ButtonIntent.swift b/core/Sources/Components/Button/Enum/ButtonIntent.swift index 344baef33..247aaffad 100644 --- a/core/Sources/Components/Button/Enum/ButtonIntent.swift +++ b/core/Sources/Components/Button/Enum/ButtonIntent.swift @@ -12,9 +12,10 @@ import Foundation @frozen public enum ButtonIntent: CaseIterable { case accent - case basic case alert + case basic case danger + case info case main case neutral case success diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift index 1ea0ba4f2..e5a05e11a 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCase.swift @@ -94,6 +94,14 @@ struct ButtonVariantGetContrastUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .info: + return .init( + foregroundColor: colors.feedback.info, + backgroundColor: backgroundColor, + pressedBackgroundColor: colors.states.infoContainerPressed, + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) } } } diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift index 8ef2a96ab..cfcc6eba5 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantContrastUseCaseTests.swift @@ -167,6 +167,28 @@ final class ButtonVariantGetContrastUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_info_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .info, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.feedback.info, + self.theme.colors.base.surface, + self.theme.colors.states.infoContainerPressed, + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + // MARK: - Helper Functions func sut() -> ButtonVariantGetContrastUseCase { return ButtonVariantGetContrastUseCase() diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift index f7ff53487..67ff48fd5 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCase.swift @@ -93,6 +93,14 @@ struct ButtonGetVariantFilledUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .info: + return .init( + foregroundColor: colors.feedback.onInfo, + backgroundColor: colors.feedback.info, + pressedBackgroundColor: colors.states.infoPressed, + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) } } } diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift index 2e75ad6b5..51b1b5a68 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantFilledUseCaseTests.swift @@ -167,6 +167,28 @@ final class ButtonGetVariantFilledUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_info_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .info, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.feedback.onInfo, + self.theme.colors.feedback.info, + self.theme.colors.states.infoPressed, + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + // MARK: - Helper Functions func sut() -> ButtonGetVariantFilledUseCase { return ButtonGetVariantFilledUseCase() diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift index 2bb6f64db..f7c24cc11 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCase.swift @@ -95,6 +95,14 @@ struct ButtonGetVariantGhostUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .info: + return .init( + foregroundColor: colors.feedback.info, + backgroundColor: ColorTokenDefault.clear, + pressedBackgroundColor: colors.feedback.info.opacity(dim5), + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) } } } diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift index e90a488fd..26ed12f2c 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantGhostUseCaseTests.swift @@ -167,6 +167,28 @@ final class ButtonGetVariantGhostUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_info_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .info, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.feedback.info, + ColorTokenDefault.clear, + self.theme.colors.feedback.info.opacity(self.theme.dims.dim5), + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + // MARK: - Helper Functions func sut() -> ButtonGetVariantGhostUseCase { return ButtonGetVariantGhostUseCase() diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift index f623ddb79..32f3b20cb 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCase.swift @@ -94,6 +94,14 @@ struct ButtonGetVariantOutlinedUseCase: ButtonGetVariantUseCaseable { borderColor: colors.base.surface, pressedBorderColor: colors.base.surface ) + case .info: + return .init( + foregroundColor: colors.feedback.info, + backgroundColor: backgroundColor, + pressedBackgroundColor: colors.feedback.info.opacity(dim5), + borderColor: colors.feedback.info, + pressedBorderColor: colors.feedback.info + ) } } } diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift index 5657dc513..8bed463d3 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantOutlinedUseCaseTests.swift @@ -167,6 +167,28 @@ final class ButtonGetVariantOutlinedUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_info_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .info, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.feedback.info, + self.theme.colors.base.surface, + self.theme.colors.feedback.info.opacity(self.theme.dims.dim5), + self.theme.colors.feedback.info, + self.theme.colors.feedback.info + ].map(\.color)) + } + // MARK: - Helper Functions func sut() -> ButtonGetVariantOutlinedUseCase { return ButtonGetVariantOutlinedUseCase() diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift index b4e2b4013..393873fa2 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCase.swift @@ -93,6 +93,14 @@ struct ButtonGetVariantTintedUseCase: ButtonGetVariantUseCaseable { borderColor: borderColor, pressedBorderColor: pressedBorderColor ) + case .info: + return .init( + foregroundColor: colors.feedback.onInfoContainer, + backgroundColor: colors.feedback.infoContainer, + pressedBackgroundColor: colors.states.infoContainerPressed, + borderColor: borderColor, + pressedBorderColor: pressedBorderColor + ) } } } diff --git a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift index 43d425a70..cc00b7919 100644 --- a/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift +++ b/core/Sources/Components/Button/UseCase/GetVariants/ButtonGetVariantTintedUseCaseTests.swift @@ -167,6 +167,28 @@ final class ButtonGetVariantTintedUseCaseTests: ButtonVariantUseCaseTests { ].map(\.color)) } + func test_info_colors() throws { + // Given + let sut = self.sut() + + // When + let colors = sut.execute(intent: .info, colors: self.theme.colors, dims: self.theme.dims) + + // Then + XCTAssertEqual( + [colors.foregroundColor, + colors.backgroundColor, + colors.pressedBackgroundColor, + colors.borderColor, + colors.pressedBorderColor].map(\.color), + [self.theme.colors.feedback.onInfoContainer, + self.theme.colors.feedback.infoContainer, + self.theme.colors.states.infoContainerPressed, + ColorTokenDefault.clear, + ColorTokenDefault.clear + ].map(\.color)) + } + // MARK: - Helper Functions func sut() -> ButtonGetVariantTintedUseCase { return ButtonGetVariantTintedUseCase()