cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.08k stars 399 forks source link

[glamor-jss] glamor api for jss #359

Closed kof closed 7 years ago

kof commented 7 years ago

People seem to like glamor api, lets provide them a one using jss. It will be similar to aphrodisiac minimum lines of code.

giuseppeg commented 7 years ago

...and glamor seem to like styled-components :D

kof commented 7 years ago

Yes, styled-components also uses a part of glamor. Its just about providing different interfaces to people and make it more convenient. A much harder part is the entire dsl and testing and rendering. But people tend to pick the library just based on its public interface, so its important to provide different interfaces for different tastes.

giuseppeg commented 7 years ago

yeah we'd need to find or write a super efficient parser to convert strings and from there jss would take over the preprocessing.

kof commented 7 years ago

To clarify: this is not about an api with tagged template string literals. Its about the default glamor api, basically its just this, but mapped to higher level glamor api.

const sheet = jss.createStyleSheet()

const rule = sheet.addRule({
  color: 'red'
})

<div className={rule.className}></div>
kof commented 7 years ago

I think styled-components api #341 is more important, we may reopen this one if it becomes relevant.

dan-lee commented 6 years ago

@kof I really love JSS and the way it's working! We'd really like to use it in our project. We have quite a large code base and used glamor so far. But I fear that it's not actively developed anymore. And this is a risk for us. I'd really like to write a plugin for JSS which enables us to use the same API as glamor, so that we don't need to refactor our whole code base.

We're using glamor in this kind of fashion:

<div {...css({ color: 'red' } />
// or 
<div {...stylemap.container} />

Could you give me a hint on how to approach this? Are there potential performance problems?

Thanks!

kof commented 6 years ago

@dan-lee yes sure, I think it is better to have a chat, ping me on gitter or twitter

dan-lee commented 6 years ago

For anyone interested, I created glamor-jss!

kof commented 6 years ago

Please submit it to https://github.com/cssinjs/jss/blob/master/docs/projects.md