-
Notifications
You must be signed in to change notification settings - Fork 298
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
Add Tailwind support for Figma variables #109
Add Tailwind support for Figma variables #109
Conversation
will this work: |
Hey! Thanks for jumping on to this. Looking at the docs, it appears I made a mistake with the opacity code! It was this line I refactored; did I misunderstand? Fixed now: Regarding a user using variables but not a custom tailwind file, you make a fair point. Saying that, our designer was actually quite surprised about the color being rounded in the first place. But of course, you need to make sure things don't break going forward. Perhaps a "Conversion" dropdown would be useful here:
Saying that, maybe that doesn't work, as we would only need to decide what happens with variable, rounding happens anyway, so perhaps it's a kind of blended mix of the three? Also, I don't know enough about the UI element of figma panels to know where this would go. I see there is the debug UI; I assume that is where it happens? FWIW, this was our designer's reaction to seeing custom tokens: |
I wish the user had only to choose between two options, but in that case seems fair. I don't know if I have a 3 option switch. Will probably be similar to swiftui scaffold x etc thing. I'll take a look |
I wonder if two checkboxes could do it?
Results would be:
Vs Dropdown:
Just trying to think through the problem... |
Yeah, could make sense... Most people would use the round color but not use variable. I think I like this. |
f5fc48f
to
7081b8e
Compare
OK, updates made. PreferencesI added two new preferences, and disambiguated the one for values / sizes: roundTailwindValues: boolean;
roundTailwindColors: boolean,
customTailwindColors: boolean, I also made the labels less ambiguous (and perhaps in a future update we could update the UI to UI3?) ColorsA couple of points to take into account:
If we can get this merged sooner rather than later, I'll merge these changes into #110 and #113 then things will be looking pretty rosy! |
I'm happy. I think just the label could be shorter. Maybe use a popover to explain more, maybe I don't know. What do you think? Do you like this? I think it is just consuming too much space. |
I wondered the same. Your custom UI is quite bulky compared to the built-in one: But then even that looks like a lot of text. Here's the checkboxes in case you want to play around:
Or, shorter (this is probably the quickest win):
I wonder if groups might help? Though I know it's only Tailwind which has the majority of the options right now.
Or, shorter:
?? |
Could be something like "optimize" and opens a pop-up where you can select what you want to optimize, I don't know.. |
what if we did something like an accordion/collapsible https://ui.shadcn.com/docs/components/collapsible where you have the "advanced features" there? Not sure we have enough, but could work... Optimize layout works like this: |
By "advanced features" you mean the rounding / variables options? Also, would need to work out how the UI would look with an accordian. How would that look? I think the checkboxes would need to be block not inline if that was the case. |
Yes. You would have a block section, that expands with inline things. But that's just an idea. I'm open for other ideas too. As long as the UI is easy, feel free to think on anything |
OK, I took a quick stab at shorter labels and Second option was longer labels but simpler checkboxes: Third option, simpler checkboxes and smaller labels with longer descriptions: My feelings about a dropdown are:
Of the above screenshots:
Also, probably lose all the backgrounds and borders (they just make it look busy for no reason): Anyway. Heading to bed now. Would love to move ahead on this tomorrow! |
I think I like the most the first. Which one did you like the most? |
I like the last one, but I think there are too many options before the user sees the code which is the main part. Thanks. Should I merge already? |
Yeah, I suppose the last 3 options are probably the ones which the user would be most interested in. I think better groups as outlined earlier would be the best solution to this, but think that should be a separate ticket, and as mentioned taking a look at implementing a UI3 theme. So for now, I think yeah, get this merged 🫡 |
Ok, perfect. Thanks! |
OK. On to the next PR! |
* Modify Tailwind color functions to support Figma variables * Refactor function to arrow function * Reorganise all config to separate file * Simplify Tailwind code * Clarify Tailwind color usage * Add Tailwind support for horizontal auto-layout hug (#111) Co-authored-by: Dave Stewart <dev@davestewart.co.uk> * Add Tailwind support for Figma variables (#109) * Modify Tailwind color functions to support Figma variables * Refactor function to arrow function * Fix fill opacity code * Add new Tailwind preferences * Prefer Tailwind color when color matches exactly * Update UI with shorter labels and tooltips --------- Co-authored-by: Dave Stewart <dev@davestewart.co.uk> --------- Co-authored-by: Dave Stewart <dev@davestewart.co.uk>
Note
Check the comment thread, as the final PR also introduced new settings to determine when variables were used, as well as #110 which improved how colors are derived
This PR modifies the Tailwind color functions to support Figma variables.
This allows users to use custom variables in their design systems, such as
neutral/700
orbuttons/active-border
which then output as classes such asbg-neutral-700
orborder-buttons-active-border
:The main update to the code is that rather than passing in a
color
andopacity
, you pass the entirefill
orcolor stop
and the function's code returns the color name as-is if it's a variable, or looks up the nearest value if not.Output looks like this:
Closes #107
Relates to #102