Class: BulmaX::Field

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

Defined Under Namespace

Classes: Control, FieldLabel, Label

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

#render_selfObject

rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bulma_x/field.rb', line 38

def render_self
  render_root do
    slot(:field_label) if slot?(:field_label)

    if @horizontal || slot?(:field)
      slot(:field_body) do
        slots(:field).each { render it }
      end
    else
      unless slot?(:field_label)
        slot(:label) if slot?(:label)

        slots(:control).each { render it }
      end
    end

    slot(:help) if slot?(:help)
  end
end

#root_classesObject

rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bulma_x/field.rb', line 60

def root_classes
  super +
    [
      'field',
      @has_addons && 'has-addons',
      @has_addons && @addons_alignment && "has-addons-#{@addons_alignment}",
      @grouped && 'is-grouped',
      @grouped && @group_alignment && "is-grouped-#{@group_alignment}",
      @grouped && @group_multiline && 'is-grouped-multiline',
      @expanded && 'is-expanded',
      @narrow && 'is-narrow',
      @horizontal && 'is-horizontal'
    ]
end

#view_templateObject



29
30
31
32
33
34
35
# File 'lib/bulma_x/field.rb', line 29

def view_template(&)
  if @disabled
    fieldset(disabled: true) { render_self(&) }
  else
    render_self(&)
  end
end