-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create small variant size for tags (#64)
* feat(tags): Create small variant size. * tests(tag): Create snapshot tests with Paparazzi
- Loading branch information
1 parent
6f6bc61
commit 0dd9529
Showing
14 changed files
with
271 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
tags/src/test/kotlin/com/decathlon/vitamin/compose/tags/VitaminTagsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
package com.decathlon.vitamin.compose.tags | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.Scaffold | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import app.cash.paparazzi.Paparazzi | ||
import com.decathlon.vitamin.compose.foundation.VitaminTheme | ||
import com.decathlon.vitamin.compose.tags.utils.Theme | ||
import com.decathlon.vitamin.compose.tags.utils.Variant | ||
import com.google.testing.junit.testparameterinjector.TestParameter | ||
import com.google.testing.junit.testparameterinjector.TestParameterInjector | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(TestParameterInjector::class) | ||
class VitaminTagsTest( | ||
@TestParameter val variant: Variant | ||
) { | ||
@get:Rule | ||
val paparazzi = Paparazzi() | ||
|
||
@Test | ||
fun medium(@TestParameter theme: Theme) { | ||
paparazzi.snapshot { | ||
VitaminTheme(theme == Theme.Dark) { | ||
Scaffold { padding -> | ||
Column( | ||
modifier = Modifier | ||
.padding(padding) | ||
.padding(horizontal = 16.dp, vertical = 16.dp), | ||
verticalArrangement = Arrangement.spacedBy(8.dp) | ||
) { | ||
Tags( | ||
variant = variant, | ||
sizes = VitaminTagSizes.medium() | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun small(@TestParameter theme: Theme) { | ||
paparazzi.snapshot { | ||
VitaminTheme(theme == Theme.Dark) { | ||
Scaffold { padding -> | ||
Column( | ||
modifier = Modifier | ||
.padding(padding) | ||
.padding(horizontal = 16.dp, vertical = 16.dp), | ||
verticalArrangement = Arrangement.spacedBy(8.dp) | ||
) { | ||
Tags( | ||
variant = variant, | ||
sizes = VitaminTagSizes.small() | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Suppress("LongMethod") | ||
@Composable | ||
fun Tags( | ||
variant: Variant, | ||
sizes: TagSizes | ||
) { | ||
val onClick: (() -> Unit)? = if (variant == Variant.Interactive) { {} } else null | ||
Text(text = variant.name, style = VitaminTheme.typography.subtitle1) | ||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { | ||
VitaminTags.Accent(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.Alert(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.Brand(label = "Tag", sizes = sizes, onClick = onClick) | ||
} | ||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { | ||
VitaminTags.Accent( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.Alert( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.Brand( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
} | ||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { | ||
VitaminTags.DecorativeEmerald(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.DecorativeAmethyst(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.DecorativeBrick(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.DecorativeGold(label = "Tag", sizes = sizes, onClick = onClick) | ||
} | ||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { | ||
VitaminTags.DecorativeEmerald( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.DecorativeAmethyst( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.DecorativeBrick( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.DecorativeGold( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
} | ||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { | ||
VitaminTags.DecorativeCobalt(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.DecorativeGravel(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.DecorativeJade(label = "Tag", sizes = sizes, onClick = onClick) | ||
VitaminTags.DecorativeSaffron(label = "Tag", sizes = sizes, onClick = onClick) | ||
} | ||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { | ||
VitaminTags.DecorativeCobalt( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.DecorativeGravel( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.DecorativeJade( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
VitaminTags.DecorativeSaffron( | ||
label = "Tag", | ||
iconPainter = painterResource(id = R.drawable.ic_vtmn_football_line), | ||
sizes = sizes, | ||
onClick = onClick | ||
) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tags/src/test/kotlin/com/decathlon/vitamin/compose/tags/utils/Theme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.decathlon.vitamin.compose.tags.utils | ||
|
||
enum class Theme { Light, Dark } |
5 changes: 5 additions & 0 deletions
5
tags/src/test/kotlin/com/decathlon/vitamin/compose/tags/utils/Variant.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.decathlon.vitamin.compose.tags.utils | ||
|
||
enum class Variant { | ||
Default, Interactive | ||
} |
Binary file added
BIN
+40.2 KB
...ges/com.decathlon.vitamin.compose.tags_VitaminTagsTest_medium[Default,Dark].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.6 KB
...es/com.decathlon.vitamin.compose.tags_VitaminTagsTest_medium[Default,Light].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.4 KB
...com.decathlon.vitamin.compose.tags_VitaminTagsTest_medium[Interactive,Dark].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.6 KB
...om.decathlon.vitamin.compose.tags_VitaminTagsTest_medium[Interactive,Light].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.6 KB
...ages/com.decathlon.vitamin.compose.tags_VitaminTagsTest_small[Default,Dark].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.8 KB
...ges/com.decathlon.vitamin.compose.tags_VitaminTagsTest_small[Default,Light].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.5 KB
.../com.decathlon.vitamin.compose.tags_VitaminTagsTest_small[Interactive,Dark].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.8 KB
...com.decathlon.vitamin.compose.tags_VitaminTagsTest_small[Interactive,Light].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.