postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
596 stars 77 forks source link

Add `preserve: "computed"` and `append` option #25

Closed hgl closed 9 years ago

hgl commented 9 years ago

After something contemplation, I decide to go with preserve: "computed"

preserve: "computed" only preserves the computed custom properties definitions and usages. There are no preserve: "specified" and preserve: "all".

append appends the js defined custom properties to the root node, so the final computed values can be picked up by cssnext (for the extract option)

hgl commented 9 years ago

I implemented this before I decided to implement strict: false. Hopefully this can be merged too so I don't have rebase and resolve conflicts.

hgl commented 9 years ago

Will update readme & changelog once you think it's good.

MoOx commented 9 years ago

You should write README + CHANGELOG before coding, it helps thinking about how to implement. I will handle this since I am working on strict option.

MoOx commented 9 years ago

I am renaming append to appendVariables to make this option clear

hgl commented 9 years ago

I usually understand the problem better when I write the actual code (e,g, that's how I realized preserve: "specified" is a no-op). But sure, adding README + CHANGELOG can make better communication. Will do so next time.

I am renaming append to appendVariables

Sounds reasonable.

Btw, once strict: false is implemented, I believe if (variable.resolved) { val = val[val.length - 1] } can be changed to if (variable.resolved) { val = val[0] }, since there won't be multiple computed values anymore.

hgl commented 9 years ago

NM, strict and preserve are separate options. I was wrong about using val[0].