Module: Polaris::ClassNameHelper

Included in:
Component
Defined in:
app/helpers/polaris/class_name_helper.rb

Instance Method Summary collapse

Instance Method Details

#class_names(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/polaris/class_name_helper.rb', line 5

def class_names(*args)
  classes = []

  args.each do |class_name|
    case class_name
    when String
      classes << class_name if class_name.present?
    when Hash
      class_name.each do |key, val|
        classes << key if val
      end
    when Array
      classes << class_names(*class_name).presence
    end
  end

  classes.compact.uniq.join(" ")
end