Skip to content

Commit

Permalink
Merge pull request #218 from tarkalabs/ms/btn_color
Browse files Browse the repository at this point in the history
TUIButton: Custom style added.
  • Loading branch information
rajajawahar authored Apr 1, 2024
2 parents 262b9d0 + 2fbe834 commit efd176d
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 69 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.tarkalabs.tarkaui.components.base.ButtonStyle.SECONDARY
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Secondary
import com.tarkalabs.tarkaui.components.base.TUIButton
import com.tarkalabs.tarkaui.components.base.TUIButtonTags
import org.junit.Rule
Expand All @@ -20,7 +20,7 @@ class TUIButtonTest {

@Test fun button_Displayed() {
composable.setContent {
TUIButton(label = "Button", tags = tags, onClick = { }, buttonStyle = SECONDARY)
TUIButton(label = "Button", tags = tags, onClick = { }, buttonStyle = Secondary)
}
composable.onNodeWithText("Button").assertIsDisplayed()
}
Expand All @@ -32,7 +32,7 @@ class TUIButtonTest {
TUIButton(
label = "Button",
onClick = onClick,
buttonStyle = SECONDARY
buttonStyle = Secondary
)
}
composable.onNodeWithText("Button").performClick()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.tarkalabs.uicomponents.screenshots

import com.tarkalabs.tarkaui.components.base.ButtonSize.L
import com.tarkalabs.tarkaui.components.base.ButtonStyle.ERROR
import com.tarkalabs.tarkaui.components.base.ButtonStyle.GHOST
import com.tarkalabs.tarkaui.components.base.ButtonStyle.OUTLINE
import com.tarkalabs.tarkaui.components.base.ButtonStyle.PRIMARY
import com.tarkalabs.tarkaui.components.base.ButtonStyle.SECONDARY
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Custom
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Error
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Ghost
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Outline
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Primary
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Secondary
import com.tarkalabs.tarkaui.components.base.TUIButton
import com.tarkalabs.tarkaui.theme.TUITheme
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
Expand All @@ -31,22 +33,29 @@ class TUIButtonScreenShotTest(
}

@Test fun primaryButtonTest() = compareScreenshotFor(darkTheme, "_primaryButtonTest_$testName") {
TUIButton(label = "Primary button", buttonStyle = PRIMARY, height = L, onClick = {})
TUIButton(label = "Primary button", buttonStyle = Primary, height = L, onClick = {})
}

@Test fun secondaryButtonTest() = compareScreenshotFor(darkTheme, "_secondaryButtonTest_$testName") {
TUIButton(label = "Secondary button", buttonStyle = SECONDARY, height = L, onClick = {})
TUIButton(label = "Secondary button", buttonStyle = Secondary, height = L, onClick = {})
}

@Test fun ghostButtonTest() = compareScreenshotFor(darkTheme, "_ghostButtonTest_$testName") {
TUIButton(label = "Ghost button", buttonStyle = GHOST, height = L, onClick = {})
TUIButton(label = "Ghost button", buttonStyle = Ghost, height = L, onClick = {})
}

@Test fun errorButtonTest() = compareScreenshotFor(darkTheme, "_errorButtonTest_$testName"){
TUIButton(label = "Error button", buttonStyle = ERROR, height = L, onClick = {})
TUIButton(label = "Error button", buttonStyle = Error, height = L, onClick = {})
}

@Test fun outlineButtonTest() = compareScreenshotFor(darkTheme, "_outlineButtonTest_$testName"){
TUIButton(label = "Outline button", buttonStyle = OUTLINE, height = L, onClick = {})
TUIButton(label = "Outline button", buttonStyle = Outline, height = L, onClick = {})
}

@Test fun customButtonTest() = compareScreenshotFor(darkTheme, "_customButtonTest_$testName"){
TUIButton(
label = "Custom button", buttonStyle = Custom(
containerColor = TUITheme.colors.secondaryAlt, contentColor = TUITheme.colors.onSecondaryAlt
), height = L, onClick = {})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import com.tarkalabs.tarkaui.icons.ChevronDown24
import com.tarkalabs.tarkaui.icons.TarkaIcon
import com.tarkalabs.tarkaui.icons.TarkaIcons.Regular
import com.tarkalabs.tarkaui.components.base.ButtonSize.XL
import com.tarkalabs.tarkaui.components.base.ButtonStyle.OUTLINE
import com.tarkalabs.tarkaui.components.base.ButtonStyle.PRIMARY
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Outline
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Primary
import com.tarkalabs.tarkaui.components.base.TUIButton
import com.tarkalabs.tarkaui.components.base.TUIButtonTags
import com.tarkalabs.tarkaui.theme.TUITheme
Expand Down Expand Up @@ -61,7 +61,7 @@ fun TUIMobileButtonBlock(
height = XL,
label = outlineButtonLabel,
onClick = { outlineButtonOnClick?.invoke() },
buttonStyle = OUTLINE,
buttonStyle = Outline,
leadingIcon = outlineLeadingIcon,
trailingIcon = outlineTrailingIcon,
modifier = if (primaryButtonWeight == null) Modifier.weight(1f) else Modifier.wrapContentWidth(),
Expand All @@ -74,7 +74,7 @@ fun TUIMobileButtonBlock(
height = XL,
label = it,
onClick = { primaryButtonOnClick?.invoke() },
buttonStyle = PRIMARY,
buttonStyle = Primary,
leadingIcon = primaryLeadingIcon,
trailingIcon = primaryTrailingIcon,
modifier = Modifier.weight(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.tarkalabs.tarkaui.components.base.ButtonStyle.ERROR
import com.tarkalabs.tarkaui.components.base.ButtonStyle.OUTLINE
import com.tarkalabs.tarkaui.components.base.ButtonStyle
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Error
import com.tarkalabs.tarkaui.components.base.ButtonStyle.Outline
import com.tarkalabs.tarkaui.components.base.IconButtonStyle
import com.tarkalabs.tarkaui.components.base.TUIButton
import com.tarkalabs.tarkaui.components.base.TUIIconButton
Expand Down Expand Up @@ -134,14 +135,14 @@ fun TUIMobileOverlayFooterPreview() {
TUIButton(
label = "Cancel",
onClick = {},
buttonStyle = OUTLINE
buttonStyle = Outline
)
},
rightContent = {
TUIButton(
label = "Delete",
onClick = {},
buttonStyle = ERROR
buttonStyle = Error
)
}
)
Expand All @@ -155,14 +156,14 @@ fun TUIMobileOverlayFooterPreview() {
TUIButton(
label = "Cancel",
onClick = {},
buttonStyle = OUTLINE
buttonStyle = Outline
)
},
rightContent = {
TUIButton(
label = "Delete",
onClick = {},
buttonStyle = ERROR
buttonStyle = ButtonStyle.Error
)
}
)
Expand All @@ -173,7 +174,7 @@ fun TUIMobileOverlayFooterPreview() {
TUIButton(
label = "Delete",
onClick = {},
buttonStyle = ERROR
buttonStyle = Error
)
}
)
Expand All @@ -184,7 +185,7 @@ fun TUIMobileOverlayFooterPreview() {
TUIButton(
label = "Cancel",
onClick = {},
buttonStyle = OUTLINE
buttonStyle = Outline
)
}
)
Expand Down
Loading

0 comments on commit efd176d

Please sign in to comment.