Polaris-react: Polaris + Rails: First Class Support

Created on 16 Dec 2017  路  5Comments  路  Source: Shopify/polaris-react

Issue summary

Thank you for making Polaris! I would love to adopt it for ZEN.AI, but to get a first class experience, Polaris assumes you're using React.

I considered adding React to my Rails app, but part of the app is already written in Ember and it would be a bit insane to add React into the mix.

I looked at HTML as an option but it's less than ideal. The HTML route assumes you're willing to hook up and maintain the fundamental interactions yourself. And there's a bunch of little things like embedded SVGs that would need tidying up. The raw HTML can be pretty noisy.

Expected behavior

What I would love to see is a gem that is a series of helper methods for Rails that generates the HTML components. Here's a quick example:

<%= polaris_button_to 'Add product', new_product_path, primary: true %>

Would output:

<form method="post" action="/products/new">
<button type="button" class="Polaris-Button Polaris-Button--primary"><span class="Polaris-Button__Content"><span>Add product</span></span></button>
</form>

Very similar to button_to in Rails.

As a bonus, this would include some JS that provided partial functionality where it makes sense. This would work well with components like an Action list. I should be able to click the action list to toggle the dropdown. But when it comes to clicking one of the actions, it would just trigger off a plain link.

Most helpful comment

This would be great to see. I am working on an app now where I tried utilizing react-rails with Polaris and shopify_app gem. It worked well but I eventually started over building with Polaris html, Stimulus, and leveraging Turbolinks. So far in dev the app flys and is fun to work on. I am far enough along where I think I will extract the things built with Into a Polaris-rails starter or maybe a generator that connects all this up. Anybody interested in helping? This is my first app in rails and would appreciate any feedback or help!

All 5 comments

Hi @djones, thanks for your interest in this! We, in fact, currently use Polaris Rails components internally for many of our applications and much of the Shopify Admin. The Rails components are the forerunners to our React components. Although, we are moving away from the Rails components to React so there are no plans to release the Rails components.

Hi @djones, Any news with this idea? I like Polaris too and currently thinking how to rewrite the admin UI of Refinery CMS ;)

oh hey @bricesanchez, my current understanding is if you want to do that with Polaris, you'll want to use React.

This would be great to see. I am working on an app now where I tried utilizing react-rails with Polaris and shopify_app gem. It worked well but I eventually started over building with Polaris html, Stimulus, and leveraging Turbolinks. So far in dev the app flys and is fun to work on. I am far enough along where I think I will extract the things built with Into a Polaris-rails starter or maybe a generator that connects all this up. Anybody interested in helping? This is my first app in rails and would appreciate any feedback or help!

Hey @JWeis, what made you decide to ditch the React components and start over with Stimulus? (No judgment coming from me - personally I love Stimulus!)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cgenevier picture cgenevier  路  3Comments

andrewpye picture andrewpye  路  3Comments

danrosenthal picture danrosenthal  路  3Comments

greghesp picture greghesp  路  3Comments

MateusJabour picture MateusJabour  路  3Comments