Class: ShadcnPhlexcomponents::DatePickerTrigger
- Defined in:
- lib/shadcn_phlexcomponents/components/date_picker.rb
Constant Summary
Constants inherited from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary collapse
- #class_variants(**args) ⇒ Object
- #default_attributes ⇒ Object
-
#initialize(select_only: true, placeholder: nil, stimulus_controller_name: nil, aria_id: nil, **attributes) ⇒ DatePickerTrigger
constructor
A new instance of DatePickerTrigger.
- #view_template ⇒ Object
Methods inherited from Base
#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child
Constructor Details
#initialize(select_only: true, placeholder: nil, stimulus_controller_name: nil, aria_id: nil, **attributes) ⇒ DatePickerTrigger
Returns a new instance of DatePickerTrigger.
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 107 def initialize( select_only: true, placeholder: nil, stimulus_controller_name: nil, aria_id: nil, **attributes ) @select_only = select_only @placeholder = placeholder @aria_id = aria_id @stimulus_controller_name = stimulus_controller_name super(**attributes) end |
Instance Method Details
#class_variants(**args) ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 121 def class_variants(**args) if @select_only Button.new.class_variants(variant: :outline, class: "justify-between w-full data-[placeholder]:data-[has-value=false]:text-muted-foreground #{args[:class]}") else Button.new.class_variants(variant: :ghost, size: :icon, class: "size-7 mr-1.5 disabled:!opacity-100 #{args[:class]}") end end |
#default_attributes ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 143 def default_attributes { aria: { haspopup: "dialog", expanded: false, controls: "#{@aria_id}-content", }, data: { placeholder: @placeholder, action: "click->#{@stimulus_controller_name}#toggle", "#{@stimulus_controller_name}-target" => "trigger", }, } end |
#view_template ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 129 def view_template if @select_only (type: :button, disabled: @disabled, **@attributes) do span(class: "pointer-events-none", data: { "#{@stimulus_controller_name}-target" => "triggerText" }) icon("calendar", class: "size-5") end else (type: :button, disabled: @disabled, **@attributes) do icon("calendar", class: "size-5") end end end |