Skip to content
This repository has been archived by the owner on Feb 19, 2025. It is now read-only.

Commit

Permalink
improvement: support color_classes config
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Apr 8, 2024
1 parent 40a8f01 commit a1cc055
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tails

Tails is a small set of utilities around working with tailwind class lists in Elixir.
Tails is a small set of utilities around working with tailwind class lists in Elixir.

# Utilities

Expand Down Expand Up @@ -54,7 +54,22 @@ We use custom defined colors for two things:

If you *don't* do this, there are certain cases that we are currently unable to disambiguate. For example, if you have a custom font size utility, i.e `text-really-big` and a custom color utility, used like `text-really-red`, we can't tell which is which. We don't guarantee the behavior of that combination, but as of the writing of this paragraph, they will both override the font size.

I highly suggest that you configure your colors file statically if you want to use tails *or* help us figure out a way to make it unnecessary, because I can't think of one :)
I highly suggest that you configure your colors file statically, or configure your colors by hand as explained below if you want to use tails *or* help us figure out a way to make it unnecessary, because I can't think of one :)

## Configuring custom colors without a colors file

You can configure custom colors without a colors file by setting the following configuration:

```elixir
config :tails, :color_classes, ["primary", "secondary", ...]
```

or if using a custom tails module

```elixir
config :my_app, Tails,
color_classes: ["primary", "secondary", ...]
```

## Merging Custom Colors

Expand Down
4 changes: 3 additions & 1 deletion lib/custom.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ defmodule Tails.Custom do

if otp_app == :tails do
@colors_file Application.compile_env(otp_app, :colors_file)
@color_classes Application.compile_env(otp_app, :color_classes) || []
@no_merge_classes Application.compile_env(otp_app, :no_merge_classes) || []
@dark_themes dark_themes || Application.compile_env(otp_app, :dark_themes)
@themes themes || Application.compile_env(otp_app, :themes)
@custom_variants Application.compile_env(otp_app, :variants) || []
@fallback_to_colors Application.compile_env(otp_app, :fallback_to_colors) || false
else
@colors_file Application.compile_env(otp_app, __MODULE__)[:colors_file]
@color_classes Application.compile_env(otp_app, __MODULE__)[:color_classes] || []
@no_merge_classes Application.compile_env(otp_app, __MODULE__)[:no_merge_classes] || []
@dark_themes dark_themes || Application.compile_env(otp_app, __MODULE__)[:dark_themes]
@themes themes || Application.compile_env(otp_app, __MODULE__)[:themes]
Expand All @@ -57,7 +59,7 @@ defmodule Tails.Custom do
Tails.Colors.builtin_colors()
end)

@all_colors Tails.Colors.all_color_classes(@colors)
@all_colors Tails.Colors.all_color_classes(@colors) ++ @color_classes

@colors_by_size @all_colors |> Enum.group_by(&byte_size/1)

Expand Down

0 comments on commit a1cc055

Please sign in to comment.