Class: StimulusPlumbers::Components::Calendar

Inherits:
Plumber::Base show all
Defined in:
lib/stimulus_plumbers/components/calendar.rb,
lib/stimulus_plumbers/components/calendar/turbo.rb,
lib/stimulus_plumbers/components/calendar/turbo/days_of_week.rb,
lib/stimulus_plumbers/components/calendar/turbo/days_of_month.rb,
lib/stimulus_plumbers/components/calendar/turbo/months_of_year.rb,
lib/stimulus_plumbers/components/calendar/turbo/years_of_decade.rb

Defined Under Namespace

Classes: Turbo

Constant Summary collapse

MONTH_STIMULUS_CONTROLLER =
"calendar-month"
YEAR_STIMULUS_CONTROLLER =
"calendar-year"
DECADE_STIMULUS_CONTROLLER =
"calendar-decade"
OBSERVER_STIMULUS_CONTROLLER =
"calendar-observer"
STIMULUS_ACTION =
"click->#{OBSERVER_STIMULUS_CONTROLLER}#onSelect".freeze

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::Renderer

#set_slots, #slot_block_for, #slot_kwargs_for, #slot_renderable?

Methods included from Plumber::Options::Aria

#labelled_aria

Methods included from Plumber::Options::Html

#merge_html_options

Constructor Details

This class inherits a constructor from StimulusPlumbers::Plumber::Base

Instance Method Details

#decadeObject



43
44
45
# File 'lib/stimulus_plumbers/components/calendar.rb', line 43

def decade
  template.tag.div(**decade_options)
end

#monthObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/stimulus_plumbers/components/calendar.rb', line 28

def month
  template.(:div, **month_options) do
    template.safe_join(
      [
        template.tag.div(**dow_options),
        template.tag.div(**dom_options)
      ]
    )
  end
end

#render(**kwargs) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stimulus_plumbers/components/calendar.rb', line 12

def render(**kwargs)
  html_options = merge_html_options(
    theme.resolve(:calendar),
    kwargs,
    {
      data: {
        controller: "#{MONTH_STIMULUS_CONTROLLER} #{OBSERVER_STIMULUS_CONTROLLER}",
        action:     STIMULUS_ACTION
      }
    }
  )
  template.(:div, **html_options, role: "grid") do
    template.safe_join([month, year, decade])
  end
end

#yearObject



39
40
41
# File 'lib/stimulus_plumbers/components/calendar.rb', line 39

def year
  template.tag.div(**year_options)
end