Class: Shadcn::Bubble::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Bubble::Component
- Defined in:
- app/components/shadcn/bubble/component.rb
Overview
Port of registry/new-york-v4/ui/bubble.tsx
Every variant here styles the child rather than this element: they are
all *:data-[slot=bubble-content]:… selectors, so a Bubble with no
Content inside it renders no colour at all. That is upstream's arrangement,
not a simplification — the bubble owns the layout and the content owns the
surface.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #element_attributes(**defaults) ⇒ Object
-
#initialize(variant: :default, align: :start, **attributes) ⇒ Component
constructor
A new instance of Component.
- #style_variants ⇒ Object
Methods inherited from ApplicationViewComponent
#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name
Constructor Details
#initialize(variant: :default, align: :start, **attributes) ⇒ Component
Returns a new instance of Component.
75 76 77 78 79 |
# File 'app/components/shadcn/bubble/component.rb', line 75 def initialize(variant: :default, align: :start, **attributes) @variant = variant&.to_sym || :default @align = align&.to_sym || :start super(**attributes) end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
73 74 75 |
# File 'app/components/shadcn/bubble/component.rb', line 73 def align @align end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
73 74 75 |
# File 'app/components/shadcn/bubble/component.rb', line 73 def variant @variant end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
85 86 87 |
# File 'app/components/shadcn/bubble/component.rb', line 85 def element_attributes(**defaults) super(**{ "data-variant" => variant, "data-align" => align }.merge(defaults)) end |
#style_variants ⇒ Object
81 82 83 |
# File 'app/components/shadcn/bubble/component.rb', line 81 def style_variants { variant: } end |