mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
Setup navbar
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
@import "https://uchu.style/color.css";
|
||||
|
||||
.avatar {
|
||||
border-radius: 50%;
|
||||
}
|
||||
/* colors */
|
||||
:root {
|
||||
--primary-color: var(--uchu-red);
|
||||
--muted-color: var(--uchu-gray);
|
||||
}
|
||||
7
app/assets/stylesheets/nav.css
Normal file
7
app/assets/stylesheets/nav.css
Normal file
@@ -0,0 +1,7 @@
|
||||
.nav-item.active {
|
||||
color: var(--muted-color);
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
.avatar {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ class StaticPagesController < ApplicationController
|
||||
# get all unique project names
|
||||
@project_names = current_user.project_names
|
||||
@projects = current_user.projects
|
||||
@current_project = current_user.active_project
|
||||
@project_durations = @project_names.map do |project|
|
||||
{
|
||||
project: @projects.find { |p| p.project_key == project }&.label || project || "Unknown",
|
||||
duration: current_user.heartbeats.where(project: project).duration_formatted
|
||||
}
|
||||
end
|
||||
@current_project_duration = @project_durations.find { |p| p[:project] == @current_project }&.[](:duration)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,4 +74,14 @@ class User < ApplicationRecord
|
||||
def project_names
|
||||
heartbeats.select(:project).distinct.pluck(:project)
|
||||
end
|
||||
|
||||
def active_project
|
||||
heartbeats.order(time: :desc).first&.project
|
||||
end
|
||||
|
||||
def active_project_duration
|
||||
return nil unless active_project
|
||||
|
||||
Heartbeat.duration_formatted(heartbeats.where(project: active_project))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,22 +23,11 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<% flash.each do |name, msg| %>
|
||||
<div class="flash-message <%= name %>">
|
||||
<%= msg %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="header">
|
||||
<% if current_user %>
|
||||
<%= render "shared/user_mention", user: current_user %>
|
||||
<%= link_to "Sign Out", signout_path, method: :delete, data: { "turbo-method": :delete } %>
|
||||
<% else %>
|
||||
<%= link_to "Sign in with Slack", slack_auth_path %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= yield %>
|
||||
<%= render "shared/nav" %>
|
||||
|
||||
<main style="margin-left: 250px; padding: 20px;">
|
||||
<%= yield %>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<div class="container">
|
||||
|
||||
32
app/views/shared/_nav.html.erb
Normal file
32
app/views/shared/_nav.html.erb
Normal file
@@ -0,0 +1,32 @@
|
||||
<aside>
|
||||
<% flash.each do |name, msg| %>
|
||||
<div class="flash-message <%= name %>">
|
||||
<%= msg %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if current_user %>
|
||||
<%= render "shared/user_mention", user: current_user %>
|
||||
<% if current_user.active_project %>
|
||||
<div class="project-info">
|
||||
<div>Currently working on: <%= current_user.active_project %></div>
|
||||
<div>Duration: <%= current_user.active_project_duration %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= link_to "Logout", signout_path, data: { turbo_method: :delete } %>
|
||||
<% else %>
|
||||
<%= link_to "Login", slack_auth_path %>
|
||||
<% end %>
|
||||
<ul>
|
||||
<li>
|
||||
<%= link_to root_path, class: "nav-item #{current_page?(root_path) ? 'active' : ''}" do %>
|
||||
Home
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to leaderboards_path, class: "nav-item #{current_page?(leaderboards_path) ? 'active' : ''}" do %>
|
||||
Leaderboards
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
Reference in New Issue
Block a user