Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # app/views/layouts/application.html.erb
- <!DOCTYPE html>
- <html>
- <head>
- <title>ChatHotwire</title>
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <%= csrf_meta_tags %>
- <%= csp_meta_tag %>
- <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
- <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
- <style>
- <%= ".message-author_#{current_user&.id}" %> {
- background-color: #007bff !important;
- padding: 10px;
- }
- </style>
- </head>
- <body>
- <div class="flex flex-col h-screen">
- <nav class="bg-gray-800">
- <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
- <div class="flex items-center justify-between h-16">
- <div class="flex items-center">
- <div class="flex-shrink-0">
- <a href="/">
- <img class="h-8 w-8" src="https://tailwindui.com/img/logos/workflow-mark-indigo-500.svg" alt="Workflow">
- </a>
- </div>
- <div class="hidden md:block">
- <div class="ml-10 flex items-baseline space-x-4">
- <% if current_user.present? %>
- <%= link_to "Sign out", destroy_user_session_path, data: { "turbo-method": :delete }, class: "text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium" %>
- <% else %>
- <%= link_to 'Sign in', new_user_session_path, class: 'text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium' %>
- <%= link_to 'Sign up', new_user_registration_path, class: 'text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium' %>
- <% end %>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="md:hidden" id="mobile-menu">
- <div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
- <% if current_user.present? %>
- <%= link_to "Sign out", destroy_user_session_path, data: { "turbo-method": :delete }, class: "text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium" %>
- <% else %>
- <%= link_to "Sign in", new_user_session_path, class: "text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium" %>
- <%= link_to "Sign up", new_user_registration_path, class: "text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium" %>
- <% end %>
- </div>
- </div>
- </nav>
- <header class="bg-white shadow">
- <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
- <h1 class="text-3xl font-bold text-gray-900">
- Chat
- </h1>
- </div>
- </header>
- <main>
- <div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
- <%= yield %>
- </div>
- </main>
- </div>
- </body>
- </html>
- # app/views/messages/_message.html.erb
- <div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg my-4 py-2 pl-1 author_<%= message.user.id %>">
- <div class="flex flex-row">
- <div class="basis-1/12"><%= l(message.created_at, format: :short) %></div>
- <div class="basis-3/12"><%= message.user.email %></div>
- <div class="basis-7/12"><%= message.body %></div>
- <div class="basis-1/12">
- <%= link_to like_message_path(message), data: { "turbo-method": :post } do %>
- <%= render partial: "messages/heart", locals: { user: user, message: message } %>
- <%= render partial: "messages/likes_count", locals: { message: message } %>
- <% end %>
- </div>
- </div>
- </div>
Add Comment
Please, Sign In to add comment