Module: NfgUi::Components::Traits::Button

Included in:
Elements::Button
Defined in:
lib/nfg_ui/components/traits/button.rb

Overview

Access to pre-designed Button traits

Constant Summary collapse

TRAITS =
%i[block
close
link
outlined
remote
submit].freeze

Instance Method Summary collapse

Instance Method Details

#block_traitObject



19
20
21
# File 'lib/nfg_ui/components/traits/button.rb', line 19

def block_trait
  options[:block] = true
end

#close_traitObject



23
24
25
26
27
28
29
30
# File 'lib/nfg_ui/components/traits/button.rb', line 23

def close_trait
  self.as = :button
  data[:dismiss] = options.delete(:dismiss)
  options[:theme] = nil
  @css_classes = 'close'
  @body = '×'.html_safe
  assistive_html_attributes.merge!(aria: { label: 'close' })
end


15
16
17
# File 'lib/nfg_ui/components/traits/button.rb', line 15

def link_trait
  options[:theme] = :link
end

#outlined_traitObject



41
42
43
# File 'lib/nfg_ui/components/traits/button.rb', line 41

def outlined_trait
  options[:outlined] = true
end

#remote_traitObject



32
33
34
# File 'lib/nfg_ui/components/traits/button.rb', line 32

def remote_trait
  options[:remote] = true
end

#submit_traitObject



36
37
38
39
# File 'lib/nfg_ui/components/traits/button.rb', line 36

def submit_trait
  self.as = :button
  options[:type] = 'submit'
end