JNavith / tailwindcss-theme-variants

Media-query- or JavaScript-based theme variants with fallback for Tailwind CSS
https://tailwindcss-theme-variants.web.app/
MIT License
188 stars 5 forks source link

Condense the fallback case and regular case in `fallback` #1

Closed JNavith closed 3 years ago

JNavith commented 4 years ago

For example:

{
  themes: {
    light: { mediaQuery: prefersLight },
    dark: { mediaQuery: prefersDark },
  },
  fallback: true
}

Generates this:

bg-whatever {
  background-color: #whatever;
}

.light\:bg-whatever {
  background-color: #whatever;
}

/* This one isn't needed */
@media (prefers-color-scheme: light) {
  .light\:bg-whatever {
    background-color: #whatever;
  }
}

@media (prefers-color-scheme: dark) {
  .dark\:bg-whatever {
    background-color: #whatever;
  }
}

We can reclaim unnecessarily lost bytes by removing that unneeded case.

JNavith commented 3 years ago

API design idea: This should be provided by specifying fallback: "compact" or fallback: "condense"

JNavith commented 3 years ago

For 2.0, make this the default since CSS file size is a big concern with theming this complex. And rename the option to "uncompressed" to signify the change in default.

JNavith commented 3 years ago

Closed by 050b618694fd2b1523d7db33c60f658e61ce5176, 1d3f271eebc5b0d44b3f238c50d7221bc12962b9, and fe24b9d3cf4e679b8c642b3b739b8889def34b6c