Class: Bootstrap5Helper::Spinner
- Defined in:
- lib/bootstrap5_helper/spinner.rb
Overview
Builds a simple CSS spinner component.
Instance Method Summary collapse
-
#initialize(template, opts = {}, &block) ⇒ Spinner
constructor
Class constructor.
-
#to_s ⇒ String
String representation of the object.
Methods inherited from Component
#capture, #concat, #config, #content_tag, #parse_arguments, #parse_context_or_options, #parse_tag_or_options, #parse_text_or_options, #uuid
Constructor Details
#initialize(template, opts = {}, &block) ⇒ Spinner
Note:
The different support types are: ‘:border` and `:grow`
Class constructor
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bootstrap5_helper/spinner.rb', line 18 def initialize(template, opts = {}, &block) super(template) @type = opts.fetch(:type, :border) @size = opts.fetch(:size, nil) @id = opts.fetch(:id, uuid) @class = opts.fetch(:class, '') @data = opts.fetch(:data, {}) @content = block || proc { '' } end |
Instance Method Details
#to_s ⇒ String
String representation of the object.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bootstrap5_helper/spinner.rb', line 33 def to_s content_tag( :span, id: @id, class: component_classes, role: 'status', aria: { hidden: true }, data: @data ) do content_tag :span, 'Loading', class: 'visually-hidden' end end |