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"

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

#decade(**kwargs) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/stimulus_plumbers/components/calendar.rb', line 37

def decade(**kwargs)
  html_options = merge_html_options(
    {
      hidden: true,
      role:   "grid",
      aria:   { label: I18n.t("stimulus_plumbers.calendar.decade_view") },
      data:   { controller: DECADE_STIMULUS_CONTROLLER }
    },
    kwargs
  )
  template.(:div, **html_options) do
    template.tag.div(data: { "#{DECADE_STIMULUS_CONTROLLER}-target": "grid" }, role: "rowgroup")
  end
end

#month(**kwargs) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stimulus_plumbers/components/calendar.rb', line 10

def month(**kwargs)
  html_options = merge_html_options(
    theme.resolve(:calendar),
    kwargs,
    { data: { controller: MONTH_STIMULUS_CONTROLLER } },
    { data: stimulus_theme_options }
  )
  template.(:div, **html_options, role: "grid") do
    template.safe_join([days_of_week, days_of_month])
  end
end

#year(**kwargs) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/stimulus_plumbers/components/calendar.rb', line 22

def year(**kwargs)
  html_options = merge_html_options(
    {
      hidden: true,
      role:   "grid",
      aria:   { label: I18n.t("stimulus_plumbers.calendar.year_view") },
      data:   { controller: YEAR_STIMULUS_CONTROLLER }
    },
    kwargs
  )
  template.(:div, **html_options) do
    template.tag.div(data: { "#{YEAR_STIMULUS_CONTROLLER}-target": "grid" }, role: "rowgroup")
  end
end