Zoltan Demant
01/24/2024, 10:15 AM@Preview
externally?
My design system is used in 3 different projects, each with its own set of colors, shapes, etc. It would be really nice to be able to just declare the theme to be used, and have all the previews just work.Joel Denke
01/24/2024, 10:58 AMZoltan Demant
01/24/2024, 11:06 AMJoel Denke
01/24/2024, 11:07 AMJoel Denke
01/24/2024, 11:09 AMCompositionLocalProvider(
LocalColorTheme provides colorTheme,
) {
PreviewCOmposable()
}
?Joel Denke
01/24/2024, 11:10 AMJoel Denke
01/24/2024, 11:10 AMZoltan Demant
01/24/2024, 11:36 AM@Composable
fun Themed(
palette: Palette = Theme.palette,
structure: Structure = Theme.structure,
type: Type = Theme.type,
content: @Composable () -> Unit,
)
And a bunch of @Preview
like this:
@AllPreviews
@Composable
fun Buttons() {
Themed(
palette = // I need this from my OTHER project
content = { .. }
)
}
What Id like to be able to do is include the design system library in each of my projects, and somehow declare that the palette the previews should use is x, y, z, etc.
Dunno if that makes more sense? Maybe preview parameters can work for this, but Im also not sure if I can supply the providers from my other project?Zoltan Demant
01/24/2024, 11:44 AM@Preview
Joel Denke
01/24/2024, 12:36 PMZach Klippenstein (he/him) [MOD]
01/24/2024, 2:41 PMJoel Denke
01/24/2024, 2:43 PM@Retention(AnnotationRetention.BINARY)
@Target(
AnnotationTarget.ANNOTATION_CLASS,
AnnotationTarget.FUNCTION
)
@Preview(name = "Light")
@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL)
annotation class PreviewLightDark
Source from androidx compose ui tooling ๐Joel Denke
01/24/2024, 2:44 PMZoltan Demant
01/24/2024, 3:39 PMJoel Denke
01/24/2024, 3:42 PMZoltan Demant
01/24/2024, 4:02 PM