geolessel / react-phoenix

Make rendering React.js components in Phoenix easy
http://reactphoenix.com
MIT License
504 stars 38 forks source link

feature(react_component): allow `html_element` and other options #45

Closed geolessel closed 4 years ago

geolessel commented 4 years ago

This will allow the user to more precisely configure the rendered HTML output from react_component/3.

html_element

By default, react_component renders the react component inside a div container. If you pass a value to html_element as an option to react_component/3, it will render the component inside the specified HTML element. For example, to render the component in a span instead of a div, you can run

react_component("MyComponent", %{}, html_element: "span")

Other options

Anything else passed into react_component/3 will be passed through directly to the component's HTML output. This could be a class name, styles, or anything else.

react_component("MyComponent", %{aProp: "hello"}, style: "border-bottom: 1px solid #888")

This takes care of the request in #42.

geolessel commented 4 years ago

@andrewmurph @lustrousgorilla Are these changes still ok for you two? Nothing really changed since I last asked in #42 but I thought I'd re-check in with you. Sorry this took so long!

andrewmurph commented 4 years ago

@andrewmurph @lustrousgorilla Are these changes still ok for you two? Nothing really changed since I last asked in #42 but I thought I'd re-check in with you. Sorry this took so long!

Looks fantastic @geolessel ! Thank you 😄