You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently writing a plugin that converts CSS logical properties to directional properties inside a rule with a selector for the direction attribute Example
from:
serialize(compile(`.user{padding-inline-start: 50px;}`),middleware([(node,index,children,callback)=>{if(node.type==="decl"){// handle your node, probably insert extra nodes at children[index + 1]// node.props holds your property name, so "padding-inline-start" in this case}},stringify,]));
You might need to create nodes using node appropriately, copy might also come useful.
I've been trying at this for a while, but I am facing some issues.
I wasn't sure how to add a new rule when the current node had the type decl so I tried changing the condition to check for the type rule.
I then would return a string that had the rules that I wanted which worked fine but when I tried passing the plugin to stylisPlugin in emotion@11.x it didn't seem to work.
I am not sure how to approach writing this middleware, is there some sort of guide on how to write one?
I am currently writing a plugin that converts CSS logical properties to directional properties inside a rule with a selector for the direction attribute
Example
from:
to
My current implementation looks like this (simplified):
Repo link
The problem is returning a nested rule with the property declaration doesn't work, so how can I inject this
in another rule outside the rule that has the
padding-inline-start: 50px
in it?The text was updated successfully, but these errors were encountered: