Class: CalendarComponent

Inherits:
Component show all
Defined in:
app/components/calendar_component.rb

Overview

Calendar — Fomantic-UI date/time picker container.

Standalone usage (wraps any content — Input, Button, or nothing for inline):

Calendar(type: "date") { Input(icon: "calendar", icon_position: "left", placeholder: "Date") }
Calendar(type: "datetime") { Button { "Select date" } }
Calendar(type: "datetime")  # inline calendar (no input)

Inside a Form, date/time fields render the calendar automatically:

Form(url: "#") { DateField(:start_date) }

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/components/calendar_component.rb', line 22

def to_s
  data = { controller: "fui-calendar", fui_calendar_type_value: type }
  data[:fui_calendar_format_value]   = format   if format
  data[:fui_calendar_min_date_value] = min_date if min_date
  data[:fui_calendar_max_date_value] = max_date if max_date

  classes = class_names(
    "ui",
    size,
    ("inverted" if inverted),
    ("disabled" if disabled),
    "calendar"
  )

  tag.div(**merge_html_options(class: classes, data: data)) { @content }
end