Class: StimulusPlumbers::Components::Calendar::Renderer

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/components/calendar/renderer.rb

Constant Summary collapse

STIMULUS_CONTROLLER =
"calendar-month"
OBSERVER_STIMULUS_CONTROLLER =
"calendar-month-observer"
STIMULUS_DATA =
{
  controller: "#{STIMULUS_CONTROLLER} #{OBSERVER_STIMULUS_CONTROLLER}",
  action:     "click->#{OBSERVER_STIMULUS_CONTROLLER}#select"
}.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::HtmlOptions

#merge_html_options, #merge_string_option, #normalize_part

Constructor Details

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

Instance Method Details

#month(**kwargs) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/stimulus_plumbers/components/calendar/renderer.rb', line 14

def month(**kwargs)
  html_options = merge_html_options(
    { classes: theme.resolve(:calendar).fetch(:classes, ""), data: STIMULUS_DATA },
    kwargs
  )

  template.(:div, role: "grid", **html_options) do
    template.safe_join(
      [
        template.tag.div(data: { "#{STIMULUS_CONTROLLER}-target" => "daysOfWeek" }),
        template.tag.div(
          role: "rowgroup",
          data: { "#{STIMULUS_CONTROLLER}-target" => "daysOfMonth" }
        )
      ]
    )
  end
end