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

feat: Access params ActionMailer::Preview style #1970

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ixti
Copy link

@ixti ixti commented Jan 10, 2024

What are you trying to accomplish?

Make ViewComponent::Preview API more similar to ActionMailer::Preview

What approach did you choose and why?

In ActionMailer::Preview, params are accessible as params, thus it would be nice to have same API in ViewComponent::Preview

class ButtonComponentPreview < ViewComponent::Preview
  def default
    render(ButtonComponent.new(root_path, size: :standard)) { params.fetch(:text, "Button") }
  end
end

Anything you want to highlight for special attention from reviewers?

This is a topic-starter, not a real PR. If the idea is approved - I can work on specs.

@joelhawksley
Copy link
Member

@ixti this makes sense to me! ViewComponent previews are meant to mimic ActionMailer previews. Are you up for writing the PR?

@ixti
Copy link
Author

ixti commented Jan 10, 2024

@ixti this makes sense to me! ViewComponent previews are meant to mimic ActionMailer previews. Are you up for writing the PR?

Sure. Just wanted to make sure the change could be ever considered before I spent more time on it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants