|
7 | 7 | - [Override auto-generated shade values](#override-auto-generated-shade-values) |
8 | 8 | - [Customized palette keys](#customized-palette-keys) |
9 | 9 | - [Full configurations](#full-configurations) |
10 | | - - [Reference](#reference) |
| 10 | + - [About shades generating algorithm](#about-shades-generating-algorithm) |
| 11 | + - [Credits](#credits) |
11 | 12 |
|
12 | 13 | Adds multiple themes support for Tailwind CSS and Windi CSS. |
13 | 14 |
|
14 | | -You can just develop your app with one theme and it will work with multiple themes color palettes, all you need is just to specify your default (for shade `500`) color values for your theme pallette. We will generate all shades from `50` to `900` for you, following the built-in shade name convention of the [default color values](https://tailwindcss.com/docs/customizing-colors). |
| 15 | +You can just develop your app with one theme and it will work with multiple themes color palettes, all you need is just to specify your default color values for your theme pallette. We will generate all shades from `50` to `900` for you, following the built-in shade name convention of the [default color values](https://tailwindcss.com/docs/customizing-colors). |
15 | 16 |
|
16 | 17 | | Dracula (default theme) | Material | |
17 | 18 | | --------------------------- | ----------------------------- | |
@@ -242,7 +243,7 @@ As the [tailwindcss docs says](https://tailwindcss.com/docs/customizing-colors#g |
242 | 243 |
|
243 | 244 | > Bad news, color is complicated and despite trying dozens of different tools, we’ve yet to find one that does a good job generating these sorts of color palettes. We picked all of Tailwind’s default colors by hand, meticulously balancing them by eye and testing them in real designs to make sure we were happy with them. |
244 | 245 |
|
245 | | -You can specify all (or just a part of) the shades of a color if you want, this will overwrite the auto-generated shade value. It will be super useful if you find the auto-generated not satisfying. Below is an example configuration, you can explore more on the [`override-shades`](examples/override-shades) example: |
| 246 | +Although our shade generating algorithm is okay in most cases, you may still find the auto-generated shades not satisfying. You can specify all (or just a part of) the shades of a color if you want, this will overwrite the auto-generated shade value. Below is an example configuration, you can explore more on the [`override-shades`](examples/override-shades) example: |
246 | 247 |
|
247 | 248 | ```js |
248 | 249 | themeable({ |
@@ -301,39 +302,42 @@ themeable({ |
301 | 302 | This is the type definition of this plugin, you can dive into the source code to see more, all the type definitions are well documented for your convenience. If you have any questions, please fell free to open an issue. And new theme contribution is welcome! |
302 | 303 |
|
303 | 304 | ```ts |
304 | | -interface ThemeableOptions { |
305 | | - /** |
306 | | - * Support a list of theme definitions, the user should define the colors of the theme follow the contribute of Dracula theme. |
307 | | - * See https://draculatheme.com/contribute#color-palette |
308 | | - * @default [] |
309 | | - */ |
310 | | - themes?: Theme[]; |
311 | | - /** |
312 | | - * Prefix of the class to enable a theme, for example the container with class `${classPrefix}-dracula` will enable dracula theme in its children elements |
313 | | - * @default `themeable` |
314 | | - */ |
315 | | - classPrefix?: string; |
316 | | - /** The lighten step for auto generated shades smaller than the default `500` color |
317 | | - * For example, if you passed `#50FA7B` as the `green` theme key, and `shadeLightenStep` is 8, |
318 | | - * then we will use this color as the `DEFAULT` and shade `500` to generate all other shades of `green`, |
319 | | - * for shade smaller than `500`, we will add the lightness up `shadeLightenStep` in per 100 gap. |
320 | | - * Color `#50FA7B` converted to HSL is [135, 94, 64], so the shade `400` will be computed to [135, 94, 72] |
321 | | - * @default 8 |
322 | | - */ |
323 | | - shadeLightenStep?: number; |
324 | | - /** Similar with `shadeLightenStep` but for shades larger than `500` |
325 | | - * @default 11 |
326 | | - */ |
327 | | - shadeDarkenStep?: number; |
328 | | - /** When not specify any theme in HTML, the `defaultTheme` will be used |
329 | | - * @default `dracula` |
330 | | - */ |
331 | | - defaultTheme?: string; |
| 305 | +export interface ThemeableOptions { |
| 306 | + /** |
| 307 | + * Support a list of theme definitions, the user should define the colors of the theme follow the contribute of Dracula theme. |
| 308 | + * See https://draculatheme.com/contribute#color-palette |
| 309 | + * @default [] |
| 310 | + */ |
| 311 | + themes?: Theme[] |
| 312 | + /** |
| 313 | + * Prefix of the class to enable a theme, for example the container with class `${classPrefix}-dracula` will enable dracula theme in its children elements |
| 314 | + * @default `themeable` |
| 315 | + */ |
| 316 | + classPrefix?: string |
| 317 | + /** When not specify any theme in HTML, the `defaultTheme` will be used |
| 318 | + * @default `dracula` |
| 319 | + */ |
| 320 | + defaultTheme?: string |
| 321 | + /** |
| 322 | + * This will allow you the change the difference in saturation between each shade of color. By default we use 1.771968374684816 because these are the averages that steps change in tailwind's default colors. Thanks to https://tw-shade-gen.netlify.app/ |
| 323 | + */ |
| 324 | + saturationFactor?: number |
| 325 | + /** |
| 326 | + * This will allow you the change the difference in lightness between each shade of color. By default we use 7.3903743315508015 because these are the averages that steps change in tailwind's default colors. Thanks to https://tw-shade-gen.netlify.app/ |
| 327 | + */ |
| 328 | + lightFactor?: number |
332 | 329 | } |
333 | 330 | ``` |
334 | 331 |
|
335 | | -## Reference |
| 332 | +## About shades generating algorithm |
336 | 333 |
|
337 | | -1. https://github.com/dracula/tailwind |
338 | | -2. https://github.com/anheric/tailwindshades |
339 | | -3. [Theming Tailwind with CSS Variables](https://www.youtube.com/watch?v=MAtaT8BZEAo) |
| 334 | +The shades generating algorithm will find a best shade number (`50`-`900`) for your color, and then generate darker and lighter shades with fixed saturation and lightness step (`saturationFactor` and `lightFactor`). |
| 335 | +
|
| 336 | +## Credits |
| 337 | +
|
| 338 | +1. Idea of shades generation |
| 339 | + 1. https://github.com/dracula/tailwind |
| 340 | + 2. https://github.com/nickgraffis/tailwind-color-generator |
| 341 | + 3. https://github.com/anheric/tailwindshades |
| 342 | +2. Idea of theming |
| 343 | + 1. [Theming Tailwind with CSS Variables](https://www.youtube.com/watch?v=MAtaT8BZEAo) |
0 commit comments