Class: ShadcnPhlexcomponents::DatePickerContent

Inherits:
Base
  • Object
show all
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

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(side: :bottom, align: :start, stimulus_controller_name: nil, aria_id: nil, **attributes) ⇒ DatePickerContent

Returns a new instance of DatePickerContent.



160
161
162
163
164
165
166
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 160

def initialize(side: :bottom, align: :start, stimulus_controller_name: nil, aria_id: nil, **attributes)
  @side = side
  @align = align
  @stimulus_controller_name = stimulus_controller_name
  @aria_id = aria_id
  super(**attributes)
end

Instance Method Details

#class_variants(**args) ⇒ Object



168
169
170
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 168

def class_variants(**args)
  PopoverContent.new.class_variants(class: "w-fit #{args[:class]}")
end

#default_attributesObject



172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 172

def default_attributes
  {
    id: "#{@aria_id}-content",
    tabindex: -1,
    role: "dialog",
    data: {
      side: @side,
      align: @align,
      "#{@stimulus_controller_name}-target" => "content",
      action: "#{@stimulus_controller_name}:click:outside->#{@stimulus_controller_name}#clickOutside",
    },
  }
end

#view_templateObject



186
187
188
189
190
191
192
# File 'lib/shadcn_phlexcomponents/components/date_picker.rb', line 186

def view_template(&)
  DatePickerContentContainer(stimulus_controller_name: @stimulus_controller_name) do
    div(**@attributes) do
      div(data: { "#{@stimulus_controller_name}-target" => "calendar" })
    end
  end
end