@@ -96,6 +96,9 @@ defmodule ExCSSModules do
9696 iex> class_name(%{"hello" => "world"}, "hello", "anything")
9797 "world"
9898
99+ iex> class_name(%{"hello" => "world"}, :hello, true)
100+ "world"
101+
99102 iex> class_name(%{"hello" => "world"}, "hello", false)
100103 nil
101104
@@ -111,8 +114,8 @@ defmodule ExCSSModules do
111114 Returns the class name or class names from the definition map, concatenated as
112115 one string separated by spaces.
113116
114- Second argument can be a string name of the key, a tuple with `{key, boolean}`
115- or a list of keys or tuples.
117+ Second argument can be a string or atom name of the key, a tuple with
118+ `{key, boolean}` or a list of keys or tuples.
116119
117120 ## Examples
118121
@@ -137,6 +140,9 @@ defmodule ExCSSModules do
137140 iex> class_name(%{"hello" => "world", "foo" => "bar"}, [{"hello", true}, {"foo", false}])
138141 "world"
139142
143+ iex> class_name(%{"hello" => "world", "foo" => "bar"}, [{:hello, true}, {:foo, false}])
144+ "world"
145+
140146 iex> class_name(%{"hello" => "world", "foo" => "bar"}, [{"hello", false}])
141147 nil
142148
@@ -153,6 +159,9 @@ defmodule ExCSSModules do
153159
154160 def class_name ( definition , { key , return_class? } ) , do: class_name ( definition , key , return_class? )
155161
162+ def class_name ( definition , key ) when is_atom ( key ) ,
163+ do: key |> Atom . to_string ( ) |> ( & class_name ( definition , & 1 ) ) . ( )
164+
156165 def class_name ( definition , key ) do
157166 definition
158167 |> stylesheet ( )
@@ -177,6 +186,9 @@ defmodule ExCSSModules do
177186 iex> class_selector(%{ "hello" => "world"}, "hello")
178187 ".world"
179188
189+ iex> class_selector(%{ "hello" => "world"}, :hello)
190+ ".world"
191+
180192 iex> class_selector(%{ "hello" => "world", "foo" => "bar"}, ["hello", "foo"])
181193 ".world.bar"
182194
0 commit comments