Class: Shadcn::Marker::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/marker/component.rb

Overview

Port of registry/new-york-v4/ui/marker.tsx

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary collapse

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

#call, #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.



32
33
34
35
# File 'app/components/shadcn/marker/component.rb', line 32

def initialize(variant: :default, **attributes)
  @variant = variant&.to_sym || :default
  super(**attributes)
end

Instance Attribute Details

#variantObject (readonly)

Returns the value of attribute variant.



30
31
32
# File 'app/components/shadcn/marker/component.rb', line 30

def variant
  @variant
end

Instance Method Details

#element_attributes(**defaults) ⇒ Object



41
42
43
# File 'app/components/shadcn/marker/component.rb', line 41

def element_attributes(**defaults)
  super(**{ "data-variant" => variant }.merge(defaults))
end

#style_variantsObject



37
38
39
# File 'app/components/shadcn/marker/component.rb', line 37

def style_variants
  { variant: }
end