Class: Events::EventComponent

Inherits:
CommonComponent show all
Defined in:
app/components/events/event_component.rb

Overview

this class render an event component for an events list

Instance Method Summary collapse

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.

Parameters:

  • opts (Hash)

    to generate content



10
11
12
13
# File 'app/components/events/event_component.rb', line 10

def initialize(event:, url: :event_path)
  @event = event
  @url = url
end

Instance Method Details

#dateObject



28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/events/event_component.rb', line 28

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

#descriptionObject



22
23
24
25
26
# File 'app/components/events/event_component.rb', line 22

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_contentString

Returns html_safe div.list-item-description.

Returns:

  • (String)

    html_safe div.list-item-description



16
17
18
19
20
# File 'app/components/events/event_component.rb', line 16

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