Class: Shadcn::Alert::Component

Inherits:
Shadcn::ApplicationViewComponent show all
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

Attributes inherited from Shadcn::ApplicationViewComponent

#attributes

Instance Method Summary collapse

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

#variantObject (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

#callObject



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_variantsObject



39
40
41
# File 'app/components/shadcn/alert/component.rb', line 39

def style_variants
  { variant: }
end