-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API overhaul (v1.0.0 preview) #15
base: master
Are you sure you want to change the base?
Conversation
Please see below repo which use j2c to manage CSS themes: https://github.com/mithriljs-cn/m_j2c and a simple demo here maybe can give you some ideas? For now we use j2c to generate sheets from js obj, get new class names, and save internally for setNS/add/remove +1 for |
@mithriljs-cn good stuff... You may want to avoid having Some progress on the v1 front... I realize that I'm likely to be the only one to use the plugin interface, at least at first, but I still like to at least expose my plans for it: I've added the ability to tap into the buffer population on the fly rather than iterating over the buffer after the fact. It may or may not add a small overhead (the result vary from run to run), but it gives a much better interface, because you can target selectors, declarations and at-rules separately without any additional logic (I provide different hooks for these scenarios). With the buffer post-processor, you had to carefully walk the buffer and detect whether you were facing an at rule (with or without block), a selector or a declaration. The new approach may faster too since you won't have to iterate over the buffer several times. It adds function call overheads, though, but I'm not sure they are significant. |
d809936
to
5172215
Compare
a5d6b49
to
63a701c
Compare
Sorry for the noise, that was a badly configured bot... |
9b54924
to
b4a16ce
Compare
Progress report on the
In parallel, I've been working on a ((synchronous PostCSS plugin) to ( At last, I've made progress on the PrefixFree port, which was harder to adapt (RegExps, two problems, yeah!), and isn't finisehd yet.The original builds RegExps dynamically for each invocation, which may not matter much when you're matching whole style sheets, but is not suitable when you match individual properties and selectors. Also, it ignores strings and comments and may accidentally modify their content. The likelihood of that causing problems is low but non-null, so better handling is necessary. So now that the API is stable, I'll update the docs and release a beta. The final v1 will be released when the |
c096f03
to
e6eb834
Compare
d4f2e79
to
a848a64
Compare
Codecov Report
@@ Coverage Diff @@
## master #15 +/- ##
=========================================
Coverage ? 99.87%
=========================================
Files ? 9
Lines ? 770
Branches ? 209
=========================================
Hits ? 769
Misses ? 1
Partials ? 0
Continue to review full report at Codecov.
|
…words and at-rules)
… what for webcompat reasons
I'll rebase this branch on top of the main one, thanks for the PR |
…on par with declarations
… a test for multiple animations
This is the API rewrite I've already mentioned on Gitter, I'd love to get feedback on this before I merge it in.
Here are the main changes:
j2c
instances.j2c.sheet()
returns a plain string, not a wrappednew String()
.j2c.names
.j2c.inine
shares the same namespace for animations._j2c = j2c([ plugins | options]...)
is aj2c
instance factory._j2c.use([plugins | options]...)
works exaclty like the factory. The defaultj2c
instance doesn't haveuse()
.Pulgins work like this. A plugin can either be a function or an object, or an array of plugins (thus nested arrays are supported).
If it is a function, it is called with the instance as a sole argument, and can thus read and modify it. If it returns an object, that result is treated as if it were an object plugin.
If the plugin is an object, we iterate over its properties.
names
is found, use the corresponding value to define names in the local namespace. Preexisting names are not overwritten (_.default
stlye).postprocess
is found, push the corresponding value in thepostprocessors
array.j2c-color
touse
would add all the color methods wo the instance.The idea is to put everytihng style-related inside the
j2c
instance, so that you can build it in one place, and justimport
/require
one thing in your modules.I'd imagine
mithril-j2c
for that version as a plugin that spies onsheet
(wrap it) and add aview
function to thej2c
instance, for example.What do you guys think?