module Phlex::Helpers

def __append_token__(tokens, token)

def __append_token__(tokens, token)
ken
il then nil
tring then tokens << token
ymbol then tokens << token.name
rray then tokens.concat(token)
aise ArgumentError,
itional classes must be Symbols, Strings, or Arrays of Symbols or Strings."

def classes(*tokens, **conditional_tokens)

def classes(*tokens, **conditional_tokens)
= self.tokens(*tokens, **conditional_tokens)
ns.empty?
s: tokens }

def mix(*args)

def mix(*args)
ch_with_object({}) do |object, result|
.merge!(object) do |_key, old, new|
new
Hash
is_a?(Hash) ? mix(old, new) : new
Array
is_a?(Array) ? (old + new) : new
String
is_a?(String) ? "#{old} #{new}" : new
.transform_keys! do |key|
nd_with?("!") ? key.name.chop.to_sym : key

def tokens(*tokens, **conditional_tokens)

def tokens(*tokens, **conditional_tokens)
onal_tokens.each do |condition, token|
 = case condition
Symbol then send(condition)
Proc then condition.call
raise ArgumentError, "The class condition must be a Symbol or a Proc."
thy
token
 Hash then __append_token__(tokens, token[:then])
 __append_token__(tokens, token)
token
 Hash then __append_token__(tokens, token[:else])
join(" ")