Skip to content

Commit

Permalink
[RadioButton#449] Updated RadioButton colors for intents danger, aler…
Browse files Browse the repository at this point in the history
…t and success.
  • Loading branch information
michael-zimmermann committed Oct 30, 2023
1 parent 64e13de commit a564b4d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,19 @@ private extension SparkCore.Colors {
func buttonColor(
intent: RadioButtonIntent,
isSelected: Bool) -> any ColorToken {
return isSelected ? self.selectedColor(intent: intent) : self.base.outline
return isSelected ? self.selectedColor(intent: intent) : self.outlineColor(intent: intent)
}

private func outlineColor(intent: RadioButtonIntent) -> any ColorToken {
switch intent {
case .danger:
return self.feedback.error
case .alert:
return self.feedback.alert
case .success:
return self.feedback.success
default: return self.base.outline
}
}

private func selectedColor(intent: RadioButtonIntent) -> any ColorToken {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class RadioButtonGetColorsUseCaseTests: XCTestCase {
// Given
let colors = self.theme.colors
let expectedColors = RadioButtonColors(
button: colors.base.outline,
button: colors.feedback.error,
label: colors.base.onBackground,
halo: colors.feedback.errorContainer,
fill: ColorTokenDefault.clear,
Expand Down Expand Up @@ -92,11 +92,32 @@ final class RadioButtonGetColorsUseCaseTests: XCTestCase {
XCTAssertEqual(givenColors, expectedColors)
}

func test_alert_colors_when_button_is_not_selected() throws {
// Given
let colors = self.theme.colors
let expectedColors = RadioButtonColors(
button: colors.feedback.alert,
label: colors.base.onBackground,
halo: colors.feedback.alertContainer,
fill: ColorTokenDefault.clear,
surface: colors.feedback.onAlert
)

// When
let givenColors = self.sut.execute(
theme: self.theme,
intent: .alert,
isSelected: false)

// Then
XCTAssertEqual(givenColors, expectedColors)
}

func test_success_colors_when_button_is_not_selected() throws {
// Given
let colors = self.theme.colors
let expectedColors = RadioButtonColors(
button: colors.base.outline,
button: colors.feedback.success,
label: colors.base.onBackground,
halo: colors.feedback.successContainer,
fill: ColorTokenDefault.clear,
Expand Down

0 comments on commit a564b4d

Please sign in to comment.