Macro for tw prop #58
itsMapleLeaf
started this conversation in
Show and tell
Replies: 2 comments 5 replies
-
Update: I ironed out the remaining edge cases I mentioned: merging with existing className, and allowing separate use of I can't really think of much else to add here; the rest of the magic is handled by the |
Beta Was this translation helpful? Give feedback.
4 replies
-
Published the code and added a placeholder README 🔥 https://github.com/tw-in-js/twind.macro |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey! I put together a super barebones babel macro, which transforms
tw="..."
intoclassName={tw("... ")}
, and also adds the appropriate import. Here's the repo: https://github.com/itsMapleLeaf/twind.macroInstall from git:
npm i -D tw-in-js/twind.macro
(oryarn add
orpnpm i
)Add
babel-plugin-macros
https://github.com/kentcdodds/babel-plugin-macrosUse like so:
I recall seeing a macro listed on this project's roadmap somewhere, so I haven't published it to NPM or anything. This is just a head start more than anything, and still has some edge cases unaccounted for (duplicate imports, className and tw prop on the same element, etc.)
Beta Was this translation helpful? Give feedback.
All reactions