Class: Components::Accordion
- Inherits:
-
Base
- Object
- Base
- Components::Accordion
- Defined in:
- app/components/accordion.rb
Instance Method Summary collapse
-
#initialize(title:, open: false, id: SecureRandom.uuid) ⇒ Accordion
constructor
A new instance of Accordion.
- #view_template ⇒ Object
Constructor Details
#initialize(title:, open: false, id: SecureRandom.uuid) ⇒ Accordion
Returns a new instance of Accordion.
2 3 4 5 6 |
# File 'app/components/accordion.rb', line 2 def initialize(title:, open: false, id: SecureRandom.uuid) @title = title @open = open @id = id end |
Instance Method Details
#view_template ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/accordion.rb', line 8 def view_template div class: "accordion accordion-flush mb-2" do div class: "accordion-item" do h3 class: "accordion-header" do class: "accordion-button #{"collapsed" unless @open}", type: "button", data: {bs_toggle: "collapse", bs_target: "##{@id}"}, aria: {controls: @id} do @title end end end div id: @id, class: "accordion-collapse collapse #{"show" if @open}" do div class: "accordion-body" do yield end end end end |