Class: PhlexKit::DialogContent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::DialogContent
- Defined in:
- app/components/phlex_kit/dialog/dialog_content.rb
Overview
The
Constant Summary collapse
- SIZES =
{ xs: "xs", sm: "sm", md: nil, lg: "lg", xl: "xl", full: "full" }.freeze
Instance Method Summary collapse
-
#initialize(size: :md, show_close_button: true, labelledby: nil, describedby: nil, **attrs) ⇒ DialogContent
constructor
A new instance of DialogContent.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(size: :md, show_close_button: true, labelledby: nil, describedby: nil, **attrs) ⇒ DialogContent
Returns a new instance of DialogContent.
11 12 13 14 15 16 17 |
# File 'app/components/phlex_kit/dialog/dialog_content.rb', line 11 def initialize(size: :md, show_close_button: true, labelledby: nil, describedby: nil, **attrs) @size = size.to_sym @show_close_button = @labelledby = labelledby @describedby = describedby @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/phlex_kit/dialog/dialog_content.rb', line 19 def view_template(&block) cls = [ "pk-dialog", fetch_option(SIZES, @size, :size) ].compact.join(" ") aria = {} aria[:labelledby] = @labelledby if @labelledby aria[:describedby] = @describedby if @describedby dialog(**mix({ class: cls, aria: aria, data: { phlex_kit__dialog_target: "dialog", action: "click->phlex-kit--dialog#backdropClick" } }, @attrs)) do yield if @show_close_button (type: "button", class: "pk-overlay-close", data: { action: "click->phlex-kit--dialog#dismiss" }) do render Icon.new(:x, size: 15) span(class: "pk-sr-only") { "Close" } end end end end |