Class: BulmaX::Icon

Inherits:
BaseComponent show all
Defined in:
lib/bulma_x/icon.rb

Constant Summary

Constants inherited from BaseComponent

BaseComponent::BLANK_VALUES, BaseComponent::BOOLEAN, BaseComponent::COLORS, BaseComponent::COLOR_MODIFIER, BaseComponent::COLOR_PALETTE, BaseComponent::MODIFIERS, BaseComponent::MODIFIERS_DECLINED, BaseComponent::MODIFIERS_PALETTE

Constants included from Shared::SpacingOptions

Shared::SpacingOptions::VALID_SPACING_KEYS, Shared::SpacingOptions::VALID_SPACING_VALUES

Instance Method Summary collapse

Methods inherited from BaseComponent

#after_template, #attributes, #base_attributes, #base_classes, #before_template, #classes, #compact_blank, #css, #initialize, #render_root

Methods included from Shared::AriaOptions

#aria_attributes, included

Methods included from Shared::GlobalOptions

#global_attributes, #global_classes, included

Methods included from Shared::DataOptions

#data_attributes, included

Methods included from Shared::FlexOptions

#flex_classes, included

Methods included from Shared::SpacingOptions

included, #spacing_classes

Methods included from Shared::TextOptions

included, #text_classes

Methods included from ComponentDsl

included

Constructor Details

This class inherits a constructor from BulmaX::BaseComponent

Instance Method Details

#iconObject

Raises:

  • (NotImplementedError)


39
40
41
42
# File 'lib/bulma_x/icon.rb', line 39

def icon
  raise NotImplementedError,
        'You must implement the icon method, using FontAwesome, Material Icons, or another icon library.'
end

#icon_alignment_classObject



60
61
62
63
64
# File 'lib/bulma_x/icon.rb', line 60

def icon_alignment_class
  return unless @icon_alignment == :right

  'is-flex-direction-row-reverse'
end

#icon_container_classesObject



44
45
46
47
48
49
# File 'lib/bulma_x/icon.rb', line 44

def icon_container_classes
  %w[
    icon-text
    is-align-items-center
  ]
end

#icon_templateObject



33
34
35
36
37
# File 'lib/bulma_x/icon.rb', line 33

def icon_template(&)
  render_root do
    icon
  end
end

#icon_text_templateObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bulma_x/icon.rb', line 21

def icon_text_template(&)
  slot(:icon_container) do
    if @icon_alignment == :right
      span(&)
      render_root { icon }
    else
      render_root { icon }
      span(&)
    end
  end
end

#root_classesObject



51
52
53
54
55
56
57
58
# File 'lib/bulma_x/icon.rb', line 51

def root_classes
  super +
    [
      'icon',
      @control_alignment && "is-#{@control_alignment}",
      @size && "is-#{@size}"
    ]
end

#view_templateObject



13
14
15
16
17
18
19
# File 'lib/bulma_x/icon.rb', line 13

def view_template(&)
  if block_given?
    icon_text_template(&)
  else
    icon_template(&)
  end
end