Class: Shadcn::Alert::Component
- Inherits:
-
Shadcn::ApplicationViewComponent
- Object
- ViewComponent::Base
- Shadcn::ApplicationViewComponent
- Shadcn::Alert::Component
- Defined in:
- app/components/shadcn/alert/component.rb
Overview
Port of registry/new-york-v4/ui/alert.tsx
Constant Summary
Constants inherited from Shadcn::ApplicationViewComponent
Shadcn::ApplicationViewComponent::CONTENTS_STYLE, Shadcn::ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from Shadcn::ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(variant: :default, **attributes) ⇒ Component
constructor
A new instance of Component.
- #style_variants ⇒ Object
Methods inherited from Shadcn::ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name
Constructor Details
#initialize(variant: :default, **attributes) ⇒ Component
Returns a new instance of Component.
34 35 36 37 |
# File 'app/components/shadcn/alert/component.rb', line 34 def initialize(variant: :default, **attributes) @variant = variant&.to_sym || :default super(**attributes) end |
Instance Attribute Details
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
32 33 34 |
# File 'app/components/shadcn/alert/component.rb', line 32 def variant @variant end |
Instance Method Details
#call ⇒ Object
47 48 49 |
# File 'app/components/shadcn/alert/component.rb', line 47 def call render_element(body: safe_join([ title, description, content ].compact)) end |
#element_attributes(**defaults) ⇒ Object
43 44 45 |
# File 'app/components/shadcn/alert/component.rb', line 43 def element_attributes(**defaults) super(**{ role: "alert" }.merge(defaults)) end |
#style_variants ⇒ Object
39 40 41 |
# File 'app/components/shadcn/alert/component.rb', line 39 def style_variants { variant: } end |