Skip to content
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

chore: move component library from tailwind to sass #2140

Closed
wants to merge 0 commits into from

Conversation

cprussin
Copy link
Collaborator

This PR migrates the component library and insights hub to Sass with css modules instead of tailwind.

For context, the main motivation for this is that we've found major limitations with Tailwind's tooling for systematizing a well tokenized the design system. For instance:

  • It's very clunky to deal with light & dark mode in tailwind with a well-defined set of design tokens, because it's not straightforward to add tokenized color names that automatically adjust depending on the screen mode without having to add a dark: class every time a color shows up in code. It's possible to add custom color names in tailwind, but defining them such that they automatically change based on the mode involves clunky use of css variables and can be very hard to work with.
  • You can't do math in tailwind, so doing things like offsetting an element by the amount of padding between a ghost button text and the outside of the hit zone so the elements look flush is very obnoxious
  • Tailwind is producing quite inefficient code, including large duplicated class lists, slow css class resolution, etc. These things have real, measurable impact on the browser and there are cases where the performance problems can actually be limiting, e.g. in live-updating tables.
  • Complex tailwind components involve such long class lists that we're finding it hard to maintain and improve over time, these components are effectively write-only code.
  • There are many cases where there are clunky implementation decisions just to support tailwind

After a lot of conversations with @partyparrotgreg we decided that the best solution is to move to sass, but use the Tailwind base theme configuration for things like spacing, the color spectrum, etc. So, in this PR, I've introduce a file in component-library called theme.scss which defines base tokens, and all component code is implemented in terms of those tokens. We believe this is nearly the best of all solutions:

  • css modules ensures we don't have a global css scope and avoids precedence issues that are common in older css. In many ways it achieves all the benefits of css-in-js solutions
  • css modules are also supported for server components without shipping component code to the client. In contrast, nearly all css-in-js solutions (besides tailwind) require all components to be client components to have styling, resulting in drastically more code shipped to the browser.
  • writing css allows us to have native editor and developer tooling
  • tokenizing with tailiwnd's tokens gives us all the benefits of working with tailwind's scales

Copy link

vercel bot commented Nov 21, 2024

@cprussin is attempting to deploy a commit to the Pyth Network Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Nov 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 0:10am
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 0:10am
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 0:10am
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 0:10am
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 0:10am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant