Class: ShadcnPhlexcomponents::AspectRatio
- Defined in:
- lib/shadcn_phlexcomponents/components/aspect_ratio.rb
Constant Summary
Constants inherited from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary collapse
-
#initialize(ratio: "1/1", **attributes) ⇒ AspectRatio
constructor
A new instance of AspectRatio.
- #view_template ⇒ Object
Methods inherited from Base
#before_template, #convert_collection_hash_to_struct, #default_attributes, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child
Constructor Details
#initialize(ratio: "1/1", **attributes) ⇒ AspectRatio
Returns a new instance of AspectRatio.
14 15 16 17 18 |
# File 'lib/shadcn_phlexcomponents/components/aspect_ratio.rb', line 14 def initialize(ratio: "1/1", **attributes) ratio_arr = ratio.split("/").map(&:to_f) @ratio = ratio_arr[0] / ratio_arr[1] super(**attributes) end |
Instance Method Details
#view_template ⇒ Object
20 21 22 23 24 |
# File 'lib/shadcn_phlexcomponents/components/aspect_ratio.rb', line 20 def view_template(&) AspectRatioContainer(ratio: @ratio) do div(**@attributes, &) end end |