Skip to content

Commit

Permalink
Merge pull request #35 from gabrieldrn/component/button/fix_icon_butt…
Browse files Browse the repository at this point in the history
…on_color

Fix icon color for icon buttons
  • Loading branch information
gabrieldrn authored Nov 9, 2024
2 parents 96fd19e + 0d49bbe commit 744b3b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package com.gabrieldrn.carbon
object Configuration {
const val majorVersion = 0
const val minorVersion = 3
const val patchVersion = 0
const val patchVersion = 1
const val versionName = "$majorVersion.$minorVersion.$patchVersion"
const val versionCode = 1
const val versionCode = 4
const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT"
const val artifactGroup = "io.github.gabrieldrn"
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,13 @@ internal class ButtonColors private constructor(
else -> theme.textOnColorDisabled
}

val iconColor: Color = if (isIconButton) {
theme.iconPrimary
} else {
when (buttonType) {
ButtonType.Tertiary -> theme.buttonTertiary
ButtonType.Ghost -> theme.linkPrimary
ButtonType.PrimaryDanger -> theme.iconOnColor
ButtonType.TertiaryDanger,
ButtonType.GhostDanger -> theme.buttonDangerSecondary
else -> theme.iconOnColor
}
val iconColor: Color = when (buttonType) {
ButtonType.Tertiary -> theme.buttonTertiary
ButtonType.Ghost -> if (isIconButton) theme.iconPrimary else theme.linkPrimary
ButtonType.PrimaryDanger -> theme.iconOnColor
ButtonType.TertiaryDanger,
ButtonType.GhostDanger -> theme.buttonDangerSecondary
else -> theme.iconOnColor
}

val iconActiveColor: Color = if (isIconButton) {
Expand All @@ -150,7 +146,7 @@ internal class ButtonColors private constructor(
ButtonType.Primary,
ButtonType.Secondary,
ButtonType.PrimaryDanger -> theme.iconOnColorDisabled
else -> theme.iconDisabled // Issue in documentation for Ghost?
else -> theme.iconDisabled
}

override fun equals(other: Any?): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,13 @@ class ButtonColorsTest : BaseColorsTest() {
)

assertEquals(
expected = if (isIconButton) {
theme.iconPrimary
} else {
when (buttonType) {
ButtonType.Tertiary -> theme.buttonTertiary
ButtonType.Ghost -> theme.linkPrimary
ButtonType.PrimaryDanger -> theme.iconOnColor
ButtonType.TertiaryDanger,
ButtonType.GhostDanger -> theme.buttonDangerSecondary
else -> theme.iconOnColor
}
expected = when (buttonType) {
ButtonType.Tertiary -> theme.buttonTertiary
ButtonType.Ghost -> if (isIconButton) theme.iconPrimary else theme.linkPrimary
ButtonType.PrimaryDanger -> theme.iconOnColor
ButtonType.TertiaryDanger,
ButtonType.GhostDanger -> theme.buttonDangerSecondary
else -> theme.iconOnColor
},
actual = colors.iconColor
)
Expand Down Expand Up @@ -194,7 +190,7 @@ class ButtonColorsTest : BaseColorsTest() {
ButtonType.Primary,
ButtonType.Secondary,
ButtonType.PrimaryDanger -> theme.iconOnColorDisabled
else -> theme.iconDisabled // Issue in documentation for Ghost
else -> theme.iconDisabled
},
actual = colors.iconDisabledColor
)
Expand Down

0 comments on commit 744b3b6

Please sign in to comment.