Class: Events::EventComponent
- Inherits:
-
CommonComponent
- Object
- ViewComponent::Base
- CommonComponent
- Events::EventComponent
- Defined in:
- app/components/events/event_component.rb
Overview
this class render an event component for an events list
Instance Method Summary collapse
- #date ⇒ Object
- #description ⇒ Object
-
#initialize(event:, url: :event_path) ⇒ EventComponent
constructor
A new instance of EventComponent.
-
#list_item_content ⇒ String
Html_safe div.list-item-description.
Methods inherited from CommonComponent
#icon, #icon_text, #level, #level_item, #pagy, #turbo_yield
Methods included from ApplicationHelper
#fas_icon, #icon, #icon_text, #l_date, #l_long, #l_time, #notifications, #notify, #notify_status, #t_enum
Constructor Details
#initialize(event:, url: :event_path) ⇒ EventComponent
Returns a new instance of EventComponent.
8 9 10 11 |
# File 'app/components/events/event_component.rb', line 8 def initialize(event:, url: :event_path) @event = event @url = url end |
Instance Method Details
#date ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/components/events/event_component.rb', line 26 def date if @event.stop_on? if @event.single == true l(@event.stop_on) else "#{ t '.from' } #{ l @event.start_on } #{ t '.to'} #{l @event.stop_on }" end else "-" end end |
#description ⇒ Object
20 21 22 23 24 |
# File 'app/components/events/event_component.rb', line 20 def description cal = tag.div(icon_text("fas fa-calendar-day", @event.happenings_count), class: "tag") cat = tag.div(icon_text("fas fa-list", @event.group.title), class: "tag") tag.div date + cal + cat, class: "list-item-description" end |
#list_item_content ⇒ String
Returns html_safe div.list-item-description.
14 15 16 17 18 |
# File 'app/components/events/event_component.rb', line 14 def list_item_content title = tag.div icon_text("fas fa-calendar", @event.title), class: "list-item-title" tag.div title + description, class: "list-item-content" end |