Class: PhlexUI::Calendar

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

Defined Under Namespace

Classes: Body, Days, Header, Next, Prev, Title, Weekdays

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#before_template

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/phlex_ui/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/phlex_ui/calendar.rb', line 12

def view_template
  div(**attrs) do
    render PhlexUI::Calendar::Header.new do
      render PhlexUI::Calendar::Title.new
      render PhlexUI::Calendar::Prev.new
      render PhlexUI::Calendar::Next.new
    end
    render PhlexUI::Calendar::Body.new # Where the calendar is rendered (Weekdays and Days)
    render PhlexUI::Calendar::Weekdays.new # Template for the weekdays
    render PhlexUI::Calendar::Days.new # Template for the days
  end
end