Current section
48 Versions
Jump to
Current section
48 Versions
Compare versions
11
files changed
+31
additions
-10
deletions
| @@ -1,5 +1,12 @@ | |
| 1 1 | # Changelog |
| 2 2 | |
| 3 | + ## 0.6.3 |
| 4 | + |
| 5 | + ### Changes |
| 6 | + |
| 7 | + - Class attrs now support class notation from [Surface](https://github.com/surface-ui/surface). Thanks @tunchamroeun! |
| 8 | + - Component `pagination`: added class entry for "current_page" which now can receive a custom class. |
| 9 | + |
| 3 10 | ## 0.6.2 |
| 4 11 | |
| 5 12 | ### Bug fixes |
| @@ -1,7 +1,7 @@ | |
| 1 1 | {<<"links">>, |
| 2 2 | [{<<"GitHub">>,<<"https://github.com/ArthurClemens/primer_live">>}]}. |
| 3 3 | {<<"name">>,<<"primer_live">>}. |
| 4 | - {<<"version">>,<<"0.6.2">>}. |
| 4 | + {<<"version">>,<<"0.6.3">>}. |
| 5 5 | {<<"description">>, |
| 6 6 | <<"An implementation of GitHub's Primer Design System for Phoenix LiveView.">>}. |
| 7 7 | {<<"app">>,<<"primer_live">>}. |
unknownlib/component.ex
File is too large to be displayed (100 KB limit).
| @@ -32,9 +32,12 @@ defmodule PrimerLive.Helpers.AttributeHelpers do | |
| 32 32 | ...> is_bar and "bar" |
| 33 33 | ...> ]) |
| 34 34 | "foo" |
| 35 | + |
| 36 | + iex> PrimerLive.Helpers.AttributeHelpers.classnames([nil, ["class1", "class2"], "class3"]) |
| 37 | + "class1 class2 class3" |
| 35 38 | """ |
| 36 39 | def classnames(input_classnames) do |
| 37 | - concat(input_classnames, " ") |
| 40 | + concat(input_classnames_normalize(input_classnames), " ") |
| 38 41 | end |
| 39 42 | |
| 40 43 | def inline_styles(input_styles) do |
| @@ -56,6 +59,17 @@ defmodule PrimerLive.Helpers.AttributeHelpers do | |
| 56 59 | end |
| 57 60 | end |
| 58 61 | |
| 62 | + # Make it works with HEEx and Surface |
| 63 | + # - [nil, "class1", "class2"] (HEEx | ~H\""" \""") |
| 64 | + # - [nil, ["class1", "class2"], "class3"] (.sface | ~F\""" \"""") |
| 65 | + defp input_classnames_normalize(input_classnames) do |
| 66 | + input_classnames |
| 67 | + |> Enum.map(&input_classnames_list_to_string/1) |
| 68 | + end |
| 69 | + |
| 70 | + defp input_classnames_list_to_string(class) when is_list(class), do: Enum.join(class, " ") |
| 71 | + defp input_classnames_list_to_string(class), do: class |
| 72 | + |
| 59 73 | @doc ~S""" |
| 60 74 | Concatenates 2 keyword lists of attributes. |
| 61 75 | - Ignores any nil or false entries |
| @@ -3,13 +3,13 @@ defmodule PrimerLive.Helpers.DeclarationHelpers do | |
| 3 3 | |
| 4 4 | defmacro class do |
| 5 5 | quote do |
| 6 | - attr(:class, :string, default: nil, doc: "Additional classname.") |
| 6 | + attr(:class, :any, default: nil, doc: "Additional classname.") |
| 7 7 | end |
| 8 8 | end |
| 9 9 | |
| 10 10 | defmacro slot_class do |
| 11 11 | quote do |
| 12 | - attr(:class, :string, doc: "Additional classname.") |
| 12 | + attr(:class, :any, doc: "Additional classname.") |
| 13 13 | end |
| 14 14 | end |
Loading more files…