Skip to content

Commit

Permalink
fix mobile list of brainstormings behind the hamburger icon (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek authored Feb 14, 2021
1 parent 9f61454 commit 0d7e8c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 0 additions & 4 deletions assets/css/_bootstrap_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@
padding: 0.5rem 0.5rem;
background-color: inherit;
}

.navbar {
padding: 0;
}
4 changes: 2 additions & 2 deletions lib/mindwendel/brainstormings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ defmodule Mindwendel.Brainstormings do
[%Brainstorming{}, ...]
"""
def list_brainstormings_for(user_id) do
def list_brainstormings_for(user_id, limit \\ 3) do
Repo.all(
from brainstorming in Brainstorming,
join: users in assoc(brainstorming, :users),
where: users.id == ^user_id,
order_by: [desc: brainstorming.inserted_at],
limit: 3
limit: ^limit
)
end

Expand Down
14 changes: 7 additions & 7 deletions lib/mindwendel_web/templates/layout/root.html.leex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</head>

<body class="bg-light">
<nav class="navbar sticky-top navbar-expand-lg navbar-light bg-white border-bottom mb-2" style="height:50px;">
<nav class="navbar sticky-top navbar-expand-lg navbar-light bg-white border-bottom mb-2">
<div class="container">
<%= link to: "/", class: "navbar-brand mb-0 h1" do %>
<img src="<%= Routes.static_path(@conn, "/images/mindwendel_logo_black.svg") %>" height="20px" />
Expand All @@ -23,23 +23,23 @@
data-bs-target="#navbarDropdownToggler"
aria-controls="navbarDropdownToggler"
aria-expanded="false"
aria-label="Toggle navigation" >
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarDropdownToggler">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<ul class="navbar-nav me-auto mb-2 mb-lg-0 bg-white">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/">New brainstorming</a>
</li>

<%= if assigns[:current_user] do %>
<li class="nav-item dropdown d-none d-lg-block">
<li class="nav-item dropdown d-none d-lg-block bg-white">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">
Your brainstormings
</a>
<ul class="dropdown-menu">
<%= for brainstorming <- @current_user.brainstormings do %>
<%= for brainstorming <- list_brainstormings_for(@current_user, 10) do %>
<a class="dropdown-item <%= if assigns[:brainstorming].id == brainstorming.id, do: "active", else: "" %>" href="<%= Routes.brainstorming_show_path(@conn, :show, brainstorming) %>">
<%= brainstorming.name %>
</a>
Expand All @@ -49,8 +49,8 @@

<%# The following tags are invisible on larger screens due to .d-lg-none %>
<%# We do this to avoid a second level dropdown menu when the navbar is collapsed %>
<div class="dropdown-divider d-lg-none"></div>
<%= for brainstorming <- @current_user.brainstormings |> Enum.sort_by(&(&1.inserted_at), {:desc, Time}) do %>
<li class="nav-item"><hr class="dropdown-divider"></li>
<%= for brainstorming <- list_brainstormings_for(@current_user, 10) do %>
<li class="nav-item d-lg-none">
<a class="nav-link <%= if assigns[:brainstorming].id == brainstorming.id, do: "active", else: "" %>" href="<%= Routes.brainstorming_show_path(@conn, :show, brainstorming) %>">
<%= brainstorming.name %>
Expand Down
5 changes: 5 additions & 0 deletions lib/mindwendel_web/views/layout_view.ex
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
defmodule MindwendelWeb.LayoutView do
use MindwendelWeb, :view
alias Mindwendel.Brainstormings

def list_brainstormings_for(user, limit \\ 3) do
Brainstormings.list_brainstormings_for(user.id, limit)
end
end

0 comments on commit 0d7e8c9

Please sign in to comment.