Class: StimulusPlumbers::Components::Calendar::Turbo
- Inherits:
-
Plumber::Base
- Object
- Plumber::Base
- StimulusPlumbers::Components::Calendar::Turbo
- 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
- STIMULUS_CONTROLLER =
"calendar-observer"- STIMULUS_ACTION =
"click->#{STIMULUS_CONTROLLER}#onSelect".freeze
Instance Attribute Summary
Attributes inherited from Plumber::Base
Instance Method Summary collapse
- #decade(date: Date.today, today: Date.today, selected_date: nil, **kwargs) ⇒ Object
- #month(date: Date.today, today: Date.today, show_other_months: false, weekday_format: :short, **kwargs) ⇒ Object
- #year(date: Date.today, today: Date.today, selected_date: nil, month_format: :short, **kwargs) ⇒ Object
Methods inherited from Plumber::Base
Methods included from Plumber::Renderer
#set_slots, #slot_block_for, #slot_kwargs_for, #slot_renderable?
Methods included from Plumber::Options::Aria
Methods included from Plumber::Options::Html
Constructor Details
This class inherits a constructor from StimulusPlumbers::Plumber::Base
Instance Method Details
#decade(date: Date.today, today: Date.today, selected_date: nil, **kwargs) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/stimulus_plumbers/components/calendar/turbo.rb', line 52 def decade(date: Date.today, today: Date.today, selected_date: nil, **kwargs) = ( theme.resolve(:calendar_quarter_grid), kwargs, { role: "grid", aria: { label: "Decade view" } } ) template.content_tag(:div, **) do Turbo::YearsOfDecade.new(template, date: date, today: today, selected_date: selected_date).render end end |
#month(date: Date.today, today: Date.today, show_other_months: false, weekday_format: :short, **kwargs) ⇒ Object
10 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 |
# File 'lib/stimulus_plumbers/components/calendar/turbo.rb', line 10 def month( date: Date.today, today: Date.today, show_other_months: false, weekday_format: :short, **kwargs ) selectable = kwargs.delete(:selectable) { false } selected_date = kwargs.delete(:selected_date) { nil } = ( theme.resolve(:calendar), kwargs, { data: { controller: STIMULUS_CONTROLLER, action: STIMULUS_ACTION } } ) template.content_tag(:div, role: "grid", **) 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 ).render ] ) end end |
#year(date: Date.today, today: Date.today, selected_date: nil, month_format: :short, **kwargs) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/stimulus_plumbers/components/calendar/turbo.rb', line 41 def year(date: Date.today, today: Date.today, selected_date: nil, month_format: :short, **kwargs) = ( theme.resolve(:calendar_quarter_grid), kwargs, { role: "grid", aria: { label: "Year view" } } ) template.content_tag(:div, **) do Turbo::MonthsOfYear.new(template, date: date, today: today, selected_date: selected_date, format: month_format).render end end |