Class: Shadcn::NativeSelect::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::NativeSelect::Component
- Defined in:
- app/components/shadcn/native_select/component.rb
Overview
Port of registry/new-york-v4/ui/native-select.tsx — a real
Constant Summary collapse
- WRAPPER_CLASSES =
"group/native-select relative w-fit has-[select:disabled]:opacity-50"- ICON_CLASSES =
"pointer-events-none absolute top-1/2 right-3.5 size-4 " \ "-translate-y-1/2 text-muted-foreground opacity-50 select-none"
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(size: :default, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(size: :default, **attributes) ⇒ Component
Returns a new instance of Component.
32 33 34 35 |
# File 'app/components/shadcn/native_select/component.rb', line 32 def initialize(size: :default, **attributes) @size = size&.to_sym || :default super(**attributes) end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
30 31 32 |
# File 'app/components/shadcn/native_select/component.rb', line 30 def size @size end |
Instance Method Details
#call ⇒ Object
41 42 43 44 45 |
# File 'app/components/shadcn/native_select/component.rb', line 41 def call tag.div(class: WRAPPER_CLASSES, "data-slot": "native-select-wrapper") do safe_join([ render_element(body: content), chevron ]) end end |
#element_attributes(**defaults) ⇒ Object
37 38 39 |
# File 'app/components/shadcn/native_select/component.rb', line 37 def element_attributes(**defaults) super(**{ "data-size" => size }.merge(defaults)) end |