Class: Arara::FabComponent
- Inherits:
-
ActionView::Component::Base
- Object
- ActionView::Component::Base
- Arara::FabComponent
- Includes:
- BaseComponent
- Defined in:
- app/components/arara/fab_component.rb
Defined Under Namespace
Classes: InvalidVariant
Constant Summary collapse
- VALID_VARIANTS =
%w(default mini extended extended_no_icon)
Instance Attribute Summary collapse
-
#extended_label ⇒ Object
readonly
Returns the value of attribute extended_label.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#label_before ⇒ Object
readonly
Returns the value of attribute label_before.
Instance Method Summary collapse
- #default_data_controller ⇒ Object
- #default_html_class ⇒ Object
- #html_options ⇒ Object
-
#initialize(variant: "default", label:, extended_label: nil, label_before: false, **kw) ⇒ FabComponent
constructor
A new instance of FabComponent.
Methods included from BaseComponent
#default_html_tag, #html_class, #html_content, #html_data, #html_tag, included
Constructor Details
#initialize(variant: "default", label:, extended_label: nil, label_before: false, **kw) ⇒ FabComponent
Returns a new instance of FabComponent.
14 15 16 17 18 19 20 21 22 |
# File 'app/components/arara/fab_component.rb', line 14 def initialize(variant: "default", label:, extended_label: nil, label_before: false, **kw) raise InvalidVariant.new("`#{variant}' is not a valid variant") unless VALID_VARIANTS.include?(variant.to_s) super(tag: "button", variant: variant, **kw) @variant = variant @label = label @extended_label = extended_label @label_before = label_before end |
Instance Attribute Details
#extended_label ⇒ Object (readonly)
Returns the value of attribute extended_label.
8 9 10 |
# File 'app/components/arara/fab_component.rb', line 8 def extended_label @extended_label end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'app/components/arara/fab_component.rb', line 8 def label @label end |
#label_before ⇒ Object (readonly)
Returns the value of attribute label_before.
8 9 10 |
# File 'app/components/arara/fab_component.rb', line 8 def label_before @label_before end |
Instance Method Details
#default_data_controller ⇒ Object
38 39 40 |
# File 'app/components/arara/fab_component.rb', line 38 def default_data_controller "mdc-ripple" end |
#default_html_class ⇒ Object
24 25 26 27 28 29 |
# File 'app/components/arara/fab_component.rb', line 24 def default_html_class return "mdc-fab mdc-fab--mini" if user_variant == "mini" return "mdc-fab mdc-fab--extended" if user_variant == "extended" return "mdc-fab mdc-fab--extended" if user_variant == "extended_no_icon" "mdc-fab" end |
#html_options ⇒ Object
31 32 33 34 35 36 |
# File 'app/components/arara/fab_component.rb', line 31 def opts = super opts[:aria] = {} unless opts.has_key?(:aria) opts[:aria][:label] = label opts end |