Closed borsini closed 1 year ago
HI @borsini, thanks for raising this! I mentioned something similar couple of days back.
To work this around I did two things:
PreviewXYZ
(e.g. PreviewIconButton). This way whenever someone looks up for typical library methods in IDE with autocompletion, the preview methods won't list up because the name starts with Preview..
but the usable components in my case start with EGDS..
which is what they usually type in.@RequiresOptIn(
level = RequiresOptIn.Level.WARNING,
message = "This is internal preview for EGDS snapshot tests, please don't use it."
)
annotation class InternalEGDSPreview
and annotated all my public previews with it:
@InternalEGDSPreview
@Preview
@Composable
fun PreviewIconButton() { ... }
This deters consumers from using Preview methods because now they have to explicitly optin to be able to use them on their side.
Thanks @iamutkarshtiwari , that would be an alternative. We ended up excluding our Previews from the IDE autocompletion-list.
Regarding my first question, does anyone have a clue? maybe @vinaygaba ? Having multiple ShowkaseRoot would help isolate previews and keep them internal
Does it mean that we can only have one @ShowkaseRootModule per project?
Also looking for a solution for this problem.
Would it be possible to add a configuration option to opt-out from auto including @Preview
annotation from ShowkaseModule? To just include @ShowkaseComposable(skip = false)
annotated functions?
A recent change that I made now enables creating previews that are internal
instead of public
. It's part of the 1.0.0-beta17
release. I think this should fix the problem that you originally raised. What do you think @borsini?
Does it mean that we can only have one @ShowkaseRootModule per project?
ShowkaseRootModule
are essentially meant to represent a collection previews based on the dependencies of the module where its declared. So in theory, it's possible to have multiple ShowkaseRootModule
in a project. However, for the purpose of the original issue, I don't think we will need this anymore as Showkase now supports internal
previews and it doesn't force your previews to be public.
Going to close this as the 1.0.0-beta17
release fixes this issue 🥳
The documentation states that
Does it mean that we can only have one
@ShowkaseRootModule
per project?Setting all the composables to render with a public visibility adds unnecessary items to the auto-completion list. Do you have an idea to help mitigate this?
Many thanks!