Class: Playbook::PbDateRangeInline::DateRangeInline
- Inherits:
-
Object
- Object
- Playbook::PbDateRangeInline::DateRangeInline
show all
- Includes:
- ActionView::Context, ActionView::Helpers::TagHelper, Playbook::Props
- Defined in:
- app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb
Instance Method Summary
collapse
#dark_props, #generate_classname, #generate_classname_without_spacing, #initialize, #prop, #spacing_options, #spacing_props, #spacing_values
Instance Method Details
#classname ⇒ Object
24
25
26
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 24
def classname
generate_classname("pb_date_range_inline_kit", dark_class, align)
end
|
#dark_class ⇒ Object
64
65
66
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 64
def dark_class
dark ? "dark" : nil
end
|
#dates_in_current_year? ⇒ Boolean
41
42
43
44
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 41
def dates_in_current_year?
current_year = Time.current.year
start_date.year == current_year && end_date.year == current_year
end
|
#end_date_display ⇒ Object
56
57
58
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 56
def end_date_display
time_display(Playbook::PbKit::PbDateTime.new(end_date))
end
|
#icon_color ⇒ Object
37
38
39
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 37
def icon_color
size == "sm" ? "light" : nil
end
|
#start_date_display ⇒ Object
60
61
62
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 60
def start_date_display
time_display(Playbook::PbKit::PbDateTime.new(start_date))
end
|
#text_kit ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 28
def text_kit
case size
when "xs"
"caption"
when "sm"
"body"
end
end
|
#time_display(time) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'app/pb_kits/playbook/pb_date_range_inline/date_range_inline.rb', line 46
def time_display(time)
content_tag(:time, datetime: time.to_iso) do
if dates_in_current_year?
"#{time.to_month_downcase} #{time.to_day}"
else
"#{time.to_month_downcase} #{time.to_day}, #{time.to_year}"
end
end
end
|