r/reactjs • • Jul 28 '19

Show /r/reactjs ScriptUI: Write React without JSX

https://github.com/anater/ScriptUI
3 Upvotes

26 comments sorted by

View all comments

1

u/ibasiba Jul 28 '19

Can we use this with Styled Components?

2

u/[deleted] Jul 28 '19 edited Jul 28 '19

Not at this time. It’s a proof of concept so I can learn if it’s a good idea and how to improve it. Right now you need to use Emotion which is very similar to Styled Components. This allows me to create modifiers which apply styles to an element:

const Button => 
  View("button")("My button")
    .color("white")
    .background("red")
    .radius(".25em")
    .border("none");

Each of these (color, radius, etc.) is a modifier in ScriptUI which will change the props. In this case, they apply a class from Emotion with the style you defined. You could use .css(styleObject) to pass any styles and apply it as a class too.

I intend to package a slim version that doesn't depend on emotion and allows for more broad use with other style systems. The goal here is to minimize time to development and so building it in as a requirement made sense to achieve this kind of interface.