postcss / postcss-js

PostCSS for React Inline Styles, Free Style and other CSS-in-JS
MIT License
657 stars 25 forks source link

Better usage documentation. #31

Closed colshacol closed 6 years ago

colshacol commented 6 years ago

I am looking for a CSS to JS transpiler tonight and I believe that postcss-js may be what I am looking for. :+1:

I've only dabbled in using PostCSS programmatically a few times, so I do not have much common-knowledge in this domain.

Thus, at first glance, I have found myself stumped as to how I will import this tool when I go to use it in a few minutes.

let css  = '@media screen { z-index: 1 }'
let root = postcss.parse(css);

postcssJs.objectify(root) //=> { '@media screen': { zIndex: '1' } }

I am oblivious as to whether I should const postcssJs = require('postcss-js') or const { postcssJs } = require('postcss-js'), etc.

Not a big problem, no. I'll figure it out quickly if a default require fails. Or I could even read the source to see what is exported and how it is exported. Nonetheless, it isn't intuitive just from reading the samples. -- Somebody with less tinkering experience than I may be blocked by this.

(I do believe that your documentation on how to use it is adequate!)

ai commented 6 years ago

Hi. Good question. Docs are always a problem for creator.

First, PostCSS community doesn't believe in tree shaking. As result, it is always const postcssJs =.

Second, do you want to send PR. As a person who study PostCSS you have a great opportunity to write docs better that a creator (really, I know PostCSS too well, as result my bias is making hard to write good docs. It is always the best idea to ask for new developer to write a docs).

colshacol commented 6 years ago

Yeah, I'll absolutely submit a PR.

You make a good point, too. When we are veterans in specific domains we can lose the ability to gauge what is common-sense, what is trivial, and what information may be necessary to provide for less-experienced people to understand.

Appreciate you, friend!