Class: RubyUI::Calendar

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/calendar/calendar.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Constructor Details

#initialize(selected_date: nil, input_id: nil, date_format: "yyyy-MM-dd", **attrs) ⇒ Calendar

Returns a new instance of Calendar.



5
6
7
8
9
10
# File 'lib/ruby_ui/calendar/calendar.rb', line 5

def initialize(selected_date: nil, input_id: nil, date_format: "yyyy-MM-dd", **attrs)
  @selected_date = selected_date
  @input_id = input_id
  @date_format = date_format
  super(**attrs)
end

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_ui/calendar/calendar.rb', line 12

def view_template
  div(**attrs) do
    RubyUI.CalendarHeader do
      RubyUI.CalendarTitle
      RubyUI.CalendarPrev
      RubyUI.CalendarNext
    end
    RubyUI.CalendarBody # Where the calendar is rendered (Weekdays and Days)
    RubyUI.CalendarWeekdays # Template for the weekdays
    RubyUI.CalendarDays # Template for the days
  end
end