diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/application/_chat.html.erb | 13 | ||||
-rw-r--r-- | app/views/chat_messages/_list.html.erb | 3 | ||||
-rw-r--r-- | app/views/chat_messages/_message.html.erb | 47 | ||||
-rw-r--r-- | app/views/layouts/application.html.erb | 1 |
4 files changed, 60 insertions, 4 deletions
diff --git a/app/views/application/_chat.html.erb b/app/views/application/_chat.html.erb index 868986b..8abe73c 100644 --- a/app/views/application/_chat.html.erb +++ b/app/views/application/_chat.html.erb @@ -1,8 +1,13 @@ -<div class="flex flex-col h-full text-sm"> - <div id="chat_output" class="overflow-auto flex-grow"> - Chat output will go here. +<div data-controller="chat" class="flex flex-col h-full text-sm"> + <div data-chat-target="output" id="chat_output" class="overflow-auto flex-grow"> </div> <div class="flex-none"> - Chat input will go here. + <%= form_with model: ChatMessage.new, html: { autocomplete: "off" }, local: false, + data: { action: "chat#send" }, class: "flex" do |f| %> + <%= f.collection_select :chat_room_id, ChatRoom.accessible_to(current_char.user), + :id, :short_name, class: "flex-none" %> + <%= f.text_field :body, size: "1", maxlength: 255, required: true, + data: { chat_target: "message" }, class: "flex-grow inline-flex" %> + <% end %> </div> </div> diff --git a/app/views/chat_messages/_list.html.erb b/app/views/chat_messages/_list.html.erb new file mode 100644 index 0000000..8b12fd2 --- /dev/null +++ b/app/views/chat_messages/_list.html.erb @@ -0,0 +1,3 @@ +<% @chat_messages.each do |chat_message| %> + <%= render "message", chat_message: chat_message %> +<% end %> diff --git a/app/views/chat_messages/_message.html.erb b/app/views/chat_messages/_message.html.erb new file mode 100644 index 0000000..e9663ec --- /dev/null +++ b/app/views/chat_messages/_message.html.erb @@ -0,0 +1,47 @@ +<% chat_room_text_class = case chat_message.chat_room.gid + when "cosmic" then "text-gray-400" + when "trade" then "text-blue-400" + when "help" then "text-pink-300" + when "system" then "text-red-500" + when "achievement" then "text-purple-400" + when "news" then "text-yellow-400" + else "text-gray-400" + end + + chat_room_prefix = case chat_message.chat_room.gid + when "cosmic" then "[C]" + when "trade" then "[T]" + when "help" then "[H]" + when "system" then "[S]" + when "achievement" then "[A]" + when "news" then "[N]" + else nil + end +%> +<p> + <span class="<%= chat_room_text_class %>"> + <span class="text-xs"><%= chat_message.created_at.strftime("%H:%M") %></span> + <%= chat_room_prefix %> + </span> + <% if chat_message.chat_room.gid == "system" %> + <span class="text-glow <%= chat_room_text_class %>"><%= chat_message.body %></span> + <% elsif chat_message.chat_room.gid == "news" %> + <span class="<%= chat_room_text_class %>"><%= chat_message.body %></span> + <% elsif chat_message.chat_room.gid == "achievement" %> + <%#= render "components/text/title", title: chat_message.target.current_title %> + <span class="<%= chat_room_text_class %>"> + <%# TODO: Sort out this subject/target stuff that I just half-blindly ported over from old Esoterra. %> + <%= chat_message.target&.name %> <%= chat_message.body %> + </span> + <% else %> + <% if chat_message.sender %> + <%#= render "components/text/title", title: chat_message.sender.current_title %> + <% end %> + <span class="<%= chat_room_text_class %>"> + <% if chat_message.sender %> + <span class="font-bold"><%= chat_message.sender.name %>:</span> + <% end %> + <%= chat_message.body %> + </span> + <% end %> +</p> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3fe6f28..7ae44a9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -30,6 +30,7 @@ data-turbolinks-permanent> <%= render "chat" %> </div> + </div> <% else %> <div id="game_info_box" class="game-container-box side-box col-span-12 sm:col-span-4" data-turbolinks-permanent> |