Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ with the `hover` variant will remain while all previous ones are dropped.

Now we have a red button, as we intended!

#### Using Custom Colors

If you are defining custom colors in you tailwind.config.js file, you can extend the colors that Twix will recognize by adding the following to your config.exs file:
```elixir
config :twix, colors: ["my_first_custom_color", "my_second_custom_color", "etc"]
``
```

## Installation

This package can be installed by adding `twix` to your
Expand Down
13 changes: 13 additions & 0 deletions lib/twix/config_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ defmodule Twix.ConfigUtils do
pink: [{Twix.Validate, :is_integer?}, {Twix.Validate, :is_opacity?}],
rose: [{Twix.Validate, :is_integer?}, {Twix.Validate, :is_opacity?}]
}
|> extend(Application.get_env(:twix, :colors))
]
end

defp extend(color_map, nil), do: color_map

defp extend(color_map, config) do
config
|> Enum.reduce(color_map, fn color, acc ->
Map.put(acc, String.to_atom(color), [
{Twix.Validate, :is_integer?},
{Twix.Validate, :is_opacity?}
])
end)
end
end