Module: Koi::ModalHelper
- Defined in:
- app/helpers/koi/modal_helper.rb
Instance Method Summary collapse
- #koi_modal_footer(submit = "Save", discard = "Discard", form_id:, reverse: true) ⇒ Object
- #koi_modal_header(title:) ⇒ Object
- #koi_modal_tag(frame_id = "modal", frame: {}, dialog: {}, **attributes, &block) ⇒ Object
Instance Method Details
#koi_modal_footer(submit = "Save", discard = "Discard", form_id:, reverse: true) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/helpers/koi/modal_helper.rb', line 34 def (submit = "Save", discard = "Discard", form_id:, reverse: true) tag.(class: "actions", data: { reverse: ("" if reverse) }) do concat(tag.(submit, form: form_id, class: "button", data: { close_dialog: "" })) if discard.present? concat(tag.(discard, form: form_id, formmethod: "dialog", class: "button", data: { ghost_button: "" })) end end end |
#koi_modal_header(title:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/koi/modal_helper.rb', line 17 def koi_modal_header(title:, **) tag.header(class: "repel", data: "nowrap") do concat(tag.h2(title)) concat(tag.( class: "button", data: { action: "modal#dismiss", button_padding: "tight", "text-button": "", }, ) do tag.icon(" ".html_safe, aria: { hidden: true }, class: "icon", data: { icon: "close" }) + tag.span("Close", class: "visually-hidden") end) end end |
#koi_modal_tag(frame_id = "modal", frame: {}, dialog: {}, **attributes, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/koi/modal_helper.rb', line 5 def koi_modal_tag(frame_id = "modal", frame: {}, dialog: {}, **attributes, &block) if block turbo_frame_tag(frame_id, **_koi_modal_frame_attributes(frame)) do tag.dialog(**_koi_modal_dialog_attributes(dialog)) do tag.article(**_koi_modal_article_attributes(attributes), &block) end end else turbo_frame_tag(frame_id, **_koi_modal_frame_attributes(frame)) end end |