-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add scaffolding for future/experimental flags, with WIP new color palette as example #2132
Conversation
Just needs a Kidding of course. This is awesome, thanks Adam. Will test soon. 🙌 Edit: Meant to ask... thoughts on when this might make it into a real |
Well, I don't know if the implementation allows it easily, but if it is almost a freebie to do, I'd love that yolo flag. I often pull tailwind for throwaway interface prototypes and toy projects, and am not concerned about any kind of forward or backward compatibility in those case. Which would make those toy projects the perfect time to learn a new feature/test something new |
@adamwathan did you consider implementing telemetry? I noticed Next.js does this as a way to understand feature usage and I think it could be useful for Tailwind too. On build/run, it gets anonymous project data like config file content (1), project packages (2) and some system config (3).
Overall, it could help for easier decision making, content (docs, examples) for specific users (discovered in 2.), and more. Privacy and record uniqueness (you don't want to record data if it didn't change in the same project) are achieved using a one-way hash. I think this is pretty solid to implement it as opt-out (like Next does). |
I was interested in the visual differences between the old and the new color palette and made a quick thing, posting in case it's helpful to someone else :) Code Sandbox: https://codesandbox.io/s/tailwind-color-palette-comparison-f1igi |
I prefer the old blue 🙂 especially since I have a project entirely based on blue! Where do we comment on colours? |
@MarcelloTheArcane The new colors are underneath an experimental flag until version 2.0. So
until then, you have to opt in to them. You could also easily copy the old
blue values to your tailwind config file 👍
…On Thu, Aug 20, 2020, 12:43 AM Max Reynolds ***@***.***> wrote:
I prefer the old blue 🙂 especially since I have a project entirely based
on blue!
Where do we comment on colours?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2132 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEMPPOEMU5T42QTUMMFHW3SBTAZ7ANCNFSM4PV3ZCRQ>
.
|
I analyzed the new color palette to see if it conforms to the USWDS guidelines https://designsystem.digital.gov/design-tokens/color/overview/#color-and-accessibility. Conforming may be a non goal but I thought you all may be interested.
|
Nice, but did you base them all on a white background? Some of the lighter ones probably won't be used with that. |
Thanks! The bounds are based on the colors luminosity value and not contrast ratio so they are background independent. As an example: interface Color {
luminosity(): number;
}
function contrastRatio(foreground: Color, background: Color): number {
const fl = foreground.luminosity();
const bl = background.luminosity();
return (Math.max(fl, bl) + 0.05) / (Math.min(fl, bl) + 0.05);
} |
The relevant section of the guide is:
The guide also shows this table which I've translated to Tailwind shades:
|
What does the valid column mean? I don't really understand how color contrast can be measured without a color to contrast it against. |
@adamwathan The valid column is whether the luminance for that color falls within the bounds that the USWDS recommends for that shade. As I said, matching those bounds can definitely be a non goal but I thought it would be interesting to share the data. Since luminance is used to calculate contrast ratio, you can use the bounds to set the minimum range between two shades. |
Sorry I still think I'm missing something, do they recommend a luminance for any color named "100" or "200" for example somewhere? |
They do have a recommendation. As per the table, a color with a shade of 100 (eg blue-100) should have a luminance between Sorry for the confusing communication! Happy to answer any questions you may have 😄 |
Also maybe this table helps which shows the minimum contrast ratio between two shades. You can see that the minimum ratio maintains the magic number properties listed above. Eg, that a difference of >400 is at least 3:1, a difference of >500 is at least 4.5:1 and a difference of at least >700 is 7:1.
|
Gotcha, cool! Yeah I don't think fitting into their specific luminance ranges is a goal for us. We will provide documentation on picking WCAG color contrast compliant combinations but it likely won't be identical to the design.gov stuff. Feels unnecessarily robotic to me, the important thing is that people pick combinations with sufficient contrast, not so much that there is a rigid system for doing so. |
Fair enough and thanks for reading! I think the biggest value is the ability to intuit the contrast ratio while coding and there are many ways to achieve that goal. |
Here is the minimum contrast between shades for the experimental palette
|
Hey @adamwathan , USWDS follows their own guidelines, so not striving for their luminance bounds is totally fine. Still, the "magic number" concept they're using is a really valuable tool in accessible design. I have written a11y-contrast to calculate those values for any palette. Here are the results:
The numbers in the v2 proposal are smaller, which is great. This means, there are far more valid color combinations in version 2. Basically every combination with a magic number of Just in case you're interested in getting a Expand
This means there are up to 30 colors that need an adjustment to get the "magic number" down to I have written about this topic in my latest blog post, where I've also checked some other popular color palettes. |
@darekkay I really appreciate you calculating the magic numbers for Tailwind! (And referencing me in your blog post 😄 ) |
This PR introduces some scaffolding for some new feature flagging ideas inspired by how it's handled in Next.js.
It introduces two potential top level keys to the Tailwind config:
future
, for enabling features that are stable and will be the default in v2.0, but introduce breaking changes and therefore can't be added in a minor version. An example of this is the new color palette we are working on, or the idea to add default line heights to each font size.experimental
, for features that we hope will make it in to Tailwind at some point but are still a work in progress and not considered stable. These may change at any time in any release, and can also introduce breaking changes.Here's what a config might look like (features are just examples):
The goal of this is to make it easy for us to do both Tailwind 1.x and Tailwind 2.0 development on a single branch, and also get new features out to early adopters to test out easily without having two separate release streams.
This PR also adds some console logging during the build process to indicate a few things:
future
feature is enabled, the console informs you that you have opted-in to a stable breaking change.experimental
feature is enabled, the console warns you that you are using experimental features that could break at any time.future
feature is available but not enabled, Tailwind warns you that your build contains deprecated functionality and encourages you to opt-in to the new breaking changes now to simplify upgrading down the road.I hope this will make the upgrade process to 2.0 really smooth, at least for people who acknowledge the console warnings. In a perfect world, upgrading from the last 1.x release to 2.0 will involve the end-user literally doing nothing, because 2.0 will just make the opt-in future features the default and remove the deprecation warnings.
This PR also adds our WIP version of the new color palette (taken from Tailwind UI) as an example of an
experimental
feature. We will be refining this a lot in the next month or so but it's included now for anyone who wants to start playing with it and providing feedback.