Class: ShadcnPhlexcomponents::ProgressIndicator

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: nil, **attributes) ⇒ ProgressIndicator

Returns a new instance of ProgressIndicator.



51
52
53
54
# File 'lib/shadcn_phlexcomponents/components/progress.rb', line 51

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

Instance Method Details

#default_attributes ⇒ Object



56
57
58
59
60
61
62
# File 'lib/shadcn_phlexcomponents/components/progress.rb', line 56

def default_attributes
  value = @value || 0
  {
    style: "transform: translateX(-#{100 - value}%)",
    data: { progress_target: "indicator" },
  }
end

#view_template ⇒ Object



64
65
66
# File 'lib/shadcn_phlexcomponents/components/progress.rb', line 64

def view_template
  div(**@attributes)
end