Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ShowkaseBrowserComponent (and color and typography) in PaparazziShowkaseTestPreview #320

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ fun PreviewCustomButtonSmall() {
)
}


@Suppress("MatchingDeclarationName")
enum class ButtonSize {
Large,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import com.airbnb.android.showkase.annotation.ShowkaseScreenshot
import com.airbnb.android.showkase.screenshot.testing.paparazzi.PaparazziShowkaseScreenshotTest

@ShowkaseScreenshot(rootShowkaseClass = PaparazziSampleRootModule::class)
abstract class MyPaparazziShowkaseScreenshotTest: PaparazziShowkaseScreenshotTest {
companion object: PaparazziShowkaseScreenshotTest.CompanionObject
abstract class MyPaparazziShowkaseScreenshotTest : PaparazziShowkaseScreenshotTest {
companion object : PaparazziShowkaseScreenshotTest.CompanionObject
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import app.cash.paparazzi.Paparazzi
import com.airbnb.android.showkase.annotation.ShowkaseScreenshot
import com.airbnb.android.showkase.models.ShowkaseBrowserColor
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
import com.airbnb.android.showkase.models.ShowkaseBrowserElement
import com.airbnb.android.showkase.models.ShowkaseBrowserTypography
import com.airbnb.android.showkase.ui.padding4x
import com.android.ide.common.rendering.api.SessionParams
Expand Down Expand Up @@ -133,6 +134,8 @@ interface PaparazziShowkaseScreenshotTest {
}

interface PaparazziShowkaseTestPreview {
val showkaseBrowserElement: ShowkaseBrowserElement
andersu marked this conversation as resolved.
Show resolved Hide resolved

@Composable
fun Content()
}
Expand All @@ -142,9 +145,11 @@ private const val DELIM = "**"
class ComponentPaparazziShowkaseTestPreview(
private val showkaseBrowserComponent: ShowkaseBrowserComponent,
) : PaparazziShowkaseTestPreview {
override val showkaseBrowserElement: ShowkaseBrowserElement = showkaseBrowserComponent

@Composable
override fun Content() = showkaseBrowserComponent.component()

override fun toString(): String =
"${showkaseBrowserComponent.group}${DELIM}${showkaseBrowserComponent.componentName}${DELIM}" +
"${showkaseBrowserComponent.styleName}"
Expand All @@ -153,6 +158,8 @@ class ComponentPaparazziShowkaseTestPreview(
class ColorPaparazziShowkaseTestPreview(
private val showkaseBrowserColor: ShowkaseBrowserColor
) : PaparazziShowkaseTestPreview {
override val showkaseBrowserElement: ShowkaseBrowserElement = showkaseBrowserColor

@Composable
override fun Content() {
Box(
Expand All @@ -170,6 +177,8 @@ class ColorPaparazziShowkaseTestPreview(
class TypographyPaparazziShowkaseTestPreview(
private val showkaseBrowserTypography: ShowkaseBrowserTypography
) : PaparazziShowkaseTestPreview {
override val showkaseBrowserElement: ShowkaseBrowserElement = showkaseBrowserTypography

@Composable
override fun Content() {
BasicText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ data class ShowkaseBrowserColor(
val colorName: String,
val colorKDoc: String,
val color: Color
)
) : ShowkaseBrowserElement {
override val group: String = colorGroup
override val name: String = colorName
override val kDoc: String = colorKDoc
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.compose.runtime.Composable
// TODO(vinaygaba): Move it to a different module that has Android/Compose dependencies hoooked up.
// This was added here only because this module has compose dependencies.
data class ShowkaseBrowserComponent(
val componentKey: String,
val group: String,
val componentKey: String,
override val group: String,
val componentName: String,
val componentKDoc: String,
val component: @Composable () -> Unit,
Expand All @@ -16,4 +16,7 @@ data class ShowkaseBrowserComponent(
val heightDp: Int? = null,
val tags: List<String> = emptyList(),
val extraMetadata: List<String> = emptyList()
)
) : ShowkaseBrowserElement {
override val name: String = componentName
override val kDoc: String = componentKDoc
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.airbnb.android.showkase.models

sealed interface ShowkaseBrowserElement {
val group: String
val name: String
val kDoc: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ data class ShowkaseBrowserTypography(
val typographyName: String,
val typographyKDoc: String,
val textStyle: TextStyle,
)
) : ShowkaseBrowserElement {
override val group: String = typographyGroup
override val name: String = typographyName
override val kDoc: String = typographyKDoc
}