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

Futurize ViewComponents #36

Open
julianrubisch opened this issue Aug 2, 2020 · 2 comments
Open

Futurize ViewComponents #36

julianrubisch opened this issue Aug 2, 2020 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@julianrubisch
Copy link
Contributor

Feature Request

Make futurism VC-proof

Is your feature request related to a problem?

It would be nice to be able to futurize VC just like partials.

@julianrubisch julianrubisch added the enhancement New feature or request label Aug 5, 2020
@julianrubisch julianrubisch added this to the 0.6.0 milestone Sep 22, 2020
@rickychilcott
Copy link
Contributor

rickychilcott commented Oct 9, 2020

@julianrubisch would you want to pair on this some?

I'm not sure

<%= futurize ItemCardComponent.new(card, arbitrary: :value), extends: :div do %>
  <div class="spinner"></div>
<% end %>

would be supportable for an API unless you have some ideas about how we could hook into the view_component's instantiation step to capture raw arguments to deep transform them down the wire.

Something like the following could be workable:

<%= futurize component: ItemCardComponent, collection: @cards, extends: :div do %>
  <div class="spinner"></div>
<% end %>

which would call render(ItemCardComponent.with_collection(@cards)) under the hood. I suppose we could also expand it out to multiple <futurize-element> tags and handle the collection ourselves.

<%= futurize @card, component: ItemCardComponent, extends: :div do %>
  <div class="spinner"></div>
<% end %>

which would call: render(ItemCardComponent.new(@card) under the hood

I'm not sure the API we'd want to support for arbitrary parameters, maybe something like:

<%= futurize component: ItemCardComponent, locals: [@card, yes: :no], extends: :div do %>
  <div class="spinner"></div>
<% end %>

which would call: render(ItemCardComponent.new(@card, yes: :no) under the hood?

I think we have to strike a balance between fully supporting ViewComponents while also making it easy to transmit down the wire lazily. This could be a little tricky.

Also, as much as I'd like to be able to support something like:

<%= futurize_component @cards, extends: :div do %>
  <div class="spinner"></div>
<% end %>

to generate a collection of components, ViewComponent/view_component#129 supported to_component_class and it appears to be removed in
ViewComponent/view_component#268

@julianrubisch julianrubisch modified the milestones: 0.7.0, 0.8.0 Nov 30, 2020
@adambedford
Copy link

👍 ++ For this feature. I'd love to see ViewComponent support. I'm just discovering this library in tandem with adopting components.

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