Coder Social home page Coder Social logo

Comments (5)

mxstbr avatar mxstbr commented on May 19, 2024 1

Now that @jlongster made prettier to help him write JSX for styled-components and nobody else has asked for this use case I'll close this issue!

from styled-components.

jlongster avatar jlongster commented on May 19, 2024

fwiw, don't do this just for me, as I'm likely to stick to glamor for the time being. Let's see if there are any other non-JSX users. I'm still surprised there aren't more of them.

from styled-components.

geelen avatar geelen commented on May 19, 2024

I think this would actually be pretty straightforward, right? This is where we define all our shorthands:

https://github.com/styled-components/styled-components/blob/master/src/constructors/styled.js

The important thing is here:

  const styled = (tag: Target) =>
    (strings: Array<string>, ...interpolations: Array<Interpolation>) =>
      styledComponent(tag, css(strings, ...interpolations))

If we made line 3 return React.createFactory(styledComponent(tag, css(strings, ...interpolations))) wouldn't that be enough? Wanna fork it and give it a go, see if you end up liking use it?

from styled-components.

poke avatar poke commented on May 19, 2024

I think @jlongster would want to avoid having to call React.createFactory here (directly or indirectly). Something like this would be nice:

dom.div(css`
    border: 1px solid black;
`, children)

Or maybe a different syntax to allow passing other props.

But I can see this quickly become a performance problem. If the component style is created within a render function, it would probably become rather difficult to enable reuse of the style definitions. So I guess you would still want to define the components outside.

from styled-components.

geelen avatar geelen commented on May 19, 2024

Why would calling React.createFactory be a bad thing if it was hidden inside the library? @jlongster maybe you could weigh in here?

from styled-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.