Class: StimulusPlumbers::Components::Calendar::Turbo

Inherits:
Plumber::Base
  • Object
show all
Defined in:
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: DaysOfMonth, DaysOfWeek, MonthsOfYear, YearsOfDecade

Constant Summary collapse

MONTH_SELECTOR_CONTROLLER =
"calendar-month-selector"
YEAR_SELECTOR_CONTROLLER =
"calendar-year-selector"
DECADE_SELECTOR_CONTROLLER =
"calendar-decade-selector"

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(date: Date.today, today: Date.today, selected_date: nil, since: nil, till: nil, disabled_years: [], **kwargs) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/stimulus_plumbers/components/calendar/turbo.rb', line 79

def decade(
  date: Date.today,
  today: Date.today,
  selected_date: nil,
  since: nil,
  till: nil,
  disabled_years: [],
  **kwargs
)
  html_options = merge_html_options(
    theme.resolve(:calendar_quarter_grid),
    kwargs,
    {
      role: "grid",
      aria: { label: I18n.t("stimulus_plumbers.calendar.decade_view") },
      data: { controller: DECADE_SELECTOR_CONTROLLER }
    }
  )
  template.(:div, **html_options) do
    Turbo::YearsOfDecade.new(
      template,
      date:           date,
      today:          today,
      selected_date:  selected_date,
      since:          since,
      till:           till,
      disabled_years: disabled_years
    ).render
  end
end

#month(date: Date.today, today: Date.today, show_other_months: false, weekday_format: :short, selectable: false, selected_date: nil, since: nil, till: nil, **kwargs) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/stimulus_plumbers/components/calendar/turbo.rb', line 11

def month(
  date: Date.today,
  today: Date.today,
  show_other_months: false,
  weekday_format: :short,
  selectable: false,
  selected_date: nil,
  since: nil,
  till: nil,
  **kwargs
)
  html_options = merge_html_options(
    theme.resolve(:calendar),
    kwargs,
    { data: { controller: MONTH_SELECTOR_CONTROLLER } }
  )
  template.(:div, role: "grid", **html_options) do
    template.safe_join(
      [
        Turbo::DaysOfWeek.new(template, format: weekday_format).render,
        Turbo::DaysOfMonth.new(
          template,
          date:              date,
          today:             today,
          selectable:        selectable,
          selected_date:     selected_date,
          show_other_months: show_other_months,
          since:             since,
          till:              till
        ).render
      ]
    )
  end
end

#year(date: Date.today, today: Date.today, selected_date: nil, month_format: :short, since: nil, till: nil, disabled_months: [], **kwargs) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/stimulus_plumbers/components/calendar/turbo.rb', line 46

def year(
  date: Date.today,
  today: Date.today,
  selected_date: nil,
  month_format: :short,
  since: nil,
  till: nil,
  disabled_months: [],
  **kwargs
)
  html_options = merge_html_options(
    theme.resolve(:calendar_quarter_grid),
    kwargs,
    {
      role: "grid",
      aria: { label: I18n.t("stimulus_plumbers.calendar.year_view") },
      data: { controller: YEAR_SELECTOR_CONTROLLER }
    }
  )
  template.(:div, **html_options) do
    Turbo::MonthsOfYear.new(
      template,
      date:            date,
      today:           today,
      selected_date:   selected_date,
      format:          month_format,
      since:           since,
      till:            till,
      disabled_months: disabled_months
    ).render
  end
end