summaryrefslogtreecommitdiff
path: root/lib/lsg_web/components/event_component.ex
blob: fa81d19960fe73abb7de1627c06e86befc6783c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
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
40
41
42
43
defmodule LSGWeb.EventComponent do
  use Phoenix.Component

  def content(assigns = %{event: %{type: :day_changed}}) do
    ~H"""
    Day changed:
    <span class="reason"><%= Date.to_string(@date) %></span>
    """
  end

  def content(assigns = %{event: %{type: :quit}}) do
    ~H"""
    <LSGWeb.Component.nick self={@self} nick={@user.nick} user_id={@user.id} account_id={@user.account} />
    has quit:
    <span class="reason"><%= @reason %></span>
    """
  end

  def content(assigns = %{event: %{type: :part}}) do
    ~H"""
    <LSGWeb.Component.nick self={@self} nick={@user.nick} user_id={@user.id} account_id={@user.account} />
    has left:
    <span class="reason"><%= @reason %></span>
    """
  end

  def content(assigns = %{event: %{type: :nick}}) do
    ~H"""
    <span class="old-nick"><%= @old_nick %></span>
    is now known as
    <LSGWeb.Component.nick self={@self} nick={@user.nick} user_id={@user.id} account_id={@user.account} />
    """
  end

  def content(assigns = %{event: %{type: :join}}) do
    ~H"""
    <LSGWeb.Component.nick self={@self} nick={@user.nick} user_id={@user.id} account_id={@user.account} />
    joined
    """
  end


end