defmodule HelixWeb.HelixComponents do use Phoenix.Component alias Phoenix.HTML alias ColourHash def render_event(assigns) do %{type: type, value: value, source_id: source_id, message_id: message_id, timestamp: timestamp} = assigns.event ~H""" <%= if type == :text do %>
colorize(source_id)}> <%= Phoenix.HTML.raw(value) %>
colorize(source_id)}>
<%= source_id %>
<%= DateTime.from_unix!(timestamp, :millisecond) |> Calendar.strftime("%I:%M:%S")%>
<% end %> """ # <%= if type == :host do %> #
#
# { #
#
#
# <%= Phoenix.HTML.raw(message) %> #
#
#
#
#
#
#
# <% end %> # <%= if type == :challenger do %> #
#
#
#
#
#
#
# <%= Phoenix.HTML.raw(message) %> #
#
#
# {user.username} #
#
# <% end %> # <%= if type == :observer do %> #
#
#
#
#
#
#
# <%= Phoenix.HTML.raw(message) %> #
#
#
# {user.username} #
#
# <% end %> end defp colorize(text) do ColourHash.hex(text, lightness: [0.5, 0.9], saturation: [0.4, 0.9]) end end