Class: Shadcn::AlertDialog::Action::Component
- Inherits:
-
Shadcn::ApplicationViewComponent
- Object
- ViewComponent::Base
- Shadcn::ApplicationViewComponent
- Shadcn::AlertDialog::Action::Component
- Defined in:
- app/components/shadcn/alert_dialog/action/component.rb
Overview
AlertDialogAction — shadcn wraps it in <Button asChild>, so it carries
the button's classes while staying the dialog's action element.
Direct Known Subclasses
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.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from Shadcn::ApplicationViewComponent
Instance Method Summary collapse
- #css_classes(extra = nil) ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(variant: :default, size: :default, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from Shadcn::ApplicationViewComponent
#call, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(variant: :default, size: :default, **attributes) ⇒ Component
Returns a new instance of Component.
14 15 16 17 18 |
# File 'app/components/shadcn/alert_dialog/action/component.rb', line 14 def initialize(variant: :default, size: :default, **attributes) @variant = variant&.to_sym || :default @size = size&.to_sym || :default super(**attributes) end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
12 13 14 |
# File 'app/components/shadcn/alert_dialog/action/component.rb', line 12 def size @size end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
12 13 14 |
# File 'app/components/shadcn/alert_dialog/action/component.rb', line 12 def variant @variant end |
Instance Method Details
#css_classes(extra = nil) ⇒ Object
29 30 31 |
# File 'app/components/shadcn/alert_dialog/action/component.rb', line 29 def css_classes(extra = nil) Button::Component.variant_classes(variant:, size:, class: extra) end |
#element_attributes(**defaults) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/components/shadcn/alert_dialog/action/component.rb', line 20 def element_attributes(**defaults) super(**{ type: "button", "data-variant" => variant, "data-size" => size, "data-action" => "shadcn--dialog#close" }.merge(defaults)) end |