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

Globally define preview appearance #71

Open
markst opened this issue Aug 28, 2024 · 1 comment
Open

Globally define preview appearance #71

markst opened this issue Aug 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@markst
Copy link
Contributor

markst commented Aug 28, 2024

Context πŸ•΅οΈβ€β™€οΈ

Most of our previews look fine in preview without any additional attributes:

#Preview {
  ShowMetaStack(
    showModel: ShowModel.featureMockData,
    nowNextModel: .success(.init()),
    actionsRowModel: .withReminderMockData,
    playButtonAction: {
    },
    actions: .init(
      shareAction: nil,
      watchlistAction: nil,
      reminderAction: nil
    )
  )
  .preferredColorScheme(.dark)
}

What 🌱

Our generated snapshots appear with white background and default device resolution:

test_ShowMetaStack_0_Preview ShowMetaStack_0

Proposal πŸŽ‰

Without needing to apply preview layout and background colours too all our previews:

  .previewLayout(.sizeThatFits)
  .background(.red)

I wonder if can add to the config in order to apply global attributes to all our previews which generate snapshots

@BarredEwe BarredEwe added the enhancement New feature or request label Aug 28, 2024
@markst
Copy link
Contributor Author

markst commented Aug 29, 2024

Ah actually might add that the new syntax is:

#Preview(traits: .sizeThatFitsLayout) {
  VStack {
    ActionButtonsRow(

Does actually pump out assets right size:

@github-staff github-staff deleted a comment from ViniciusSCG Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
@markst @BarredEwe and others