Class: ShadcnPhlexcomponents::Progress

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/progress.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

#initialize(value: 0, **attributes) ⇒ Progress

Returns a new instance of Progress.



14
15
16
17
# File 'lib/shadcn_phlexcomponents/components/progress.rb', line 14

def initialize(value: 0, **attributes)
  @value = value
  super(**attributes)
end

Instance Method Details

#default_attributesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/shadcn_phlexcomponents/components/progress.rb', line 19

def default_attributes
  {
    role: "progressbar",
    aria: {
      valuemax: 100,
      valuemin: 0,
      valuenow: @value,
    },
    data: {
      controller: "progress",
      progress_percent_value: @value,
    },
  }
end

#view_templateObject



34
35
36
37
38
# File 'lib/shadcn_phlexcomponents/components/progress.rb', line 34

def view_template
  div(**@attributes) do
    ProgressIndicator(value: @value)
  end
end