Class: Shadcn::AlertDialog::Content::Component
- Inherits:
-
Shadcn::ApplicationViewComponent
- Object
- ViewComponent::Base
- Shadcn::ApplicationViewComponent
- Shadcn::AlertDialog::Content::Component
- Defined in:
- app/components/shadcn/alert_dialog/content/component.rb
Overview
AlertDialogContent — role="alertdialog", no dismiss button.
Constant Summary
Constants inherited from Shadcn::ApplicationViewComponent
Shadcn::ApplicationViewComponent::CONTENTS_STYLE, Shadcn::ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from Shadcn::ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(size: :default, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from Shadcn::ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(size: :default, **attributes) ⇒ Component
Returns a new instance of Component.
27 28 29 30 |
# File 'app/components/shadcn/alert_dialog/content/component.rb', line 27 def initialize(size: :default, **attributes) @size = size&.to_sym || :default super(**attributes) end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
25 26 27 |
# File 'app/components/shadcn/alert_dialog/content/component.rb', line 25 def size @size end |
Instance Method Details
#call ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/components/shadcn/alert_dialog/content/component.rb', line 44 def call tag.div("data-slot": "alert-dialog-portal", style: CONTENTS_STYLE) do safe_join([ render(Overlay::Component.new), render_element(body: safe_join([ header, content, ].compact)) ]) end end |
#element_attributes(**defaults) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/shadcn/alert_dialog/content/component.rb', line 32 def element_attributes(**defaults) super(**{ role: "alertdialog", "aria-modal" => "true", tabindex: "-1", "data-size" => size, "data-state" => "closed", hidden: true, "data-shadcn--dialog-target" => "content" }.merge(defaults)) end |