From b55566c5c3da8582992d722306b83f61076a6f20 Mon Sep 17 00:00:00 2001 From: Dorian Lesbre <dorian.lesbre@gmail.com> Date: Mon, 28 Dec 2020 09:55:36 +0100 Subject: [PATCH] Display current page in nav menu --- home/static/css/style.css | 12 ++++++++++-- home/templates/base.html | 24 ++++++++++++++++++++---- home/urls.py | 2 +- home/views.py | 4 ++-- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/home/static/css/style.css b/home/static/css/style.css index 1683bfc..c13207a 100644 --- a/home/static/css/style.css +++ b/home/static/css/style.css @@ -1,6 +1,8 @@ :root { + --color-bg: #fefefe; --color_bg_1: #4c4c7c; --color_bg_2: #26263c; + --color_bg_3: #39395c; --color_sep: #eb811b; } @@ -49,6 +51,7 @@ nav { color: white; margin: 0; padding: 0 20px; + border-bottom: 6px solid var(--color_bg_1); } nav a { @@ -62,12 +65,16 @@ nav a { nav a:hover { transition-property: background-color; - background-color: var(--color_bg_1); + background-color: var(--color_bg_3); transition-duration: 0.5s; } +nav a.current { + background-color: var(--color_bg_1); +} + main { - background-color: white; + background-color: var(--color-bg); justify-content: center; text-align: justify; padding: 1px 30px; @@ -76,6 +83,7 @@ main { } main h2 { + color: var(--color_bg_2); padding-top: 20px; font-size: 1.5rem; font-weight: 300; diff --git a/home/templates/base.html b/home/templates/base.html index 7075047..5eb252e 100644 --- a/home/templates/base.html +++ b/home/templates/base.html @@ -25,10 +25,26 @@ </header> <nav> - <a href="/" class="internal">Inscriptions</a> - <a href="/" class="internal">Activités</a> - <a href="/" class="internal">FAQ</a> - <a href="/" class="internal">Bouton autre</a> + <a href="/" rel="text/html" + class={% if slug == "home" %}"current"{% else %}"internal"{% endif %}> + Acceuil + </a> + <a href="/inscription/" rel="text/html" + class={% if slug == "inscription" %}"current"{% else %}"internal"{% endif %}> + Inscriptions + </a> + <a href="/activites/" rel="text/html" + class={% if slug == "activites" %}"current"{% else %}"internal"{% endif %}> + Activités + </a> + <a href="/faq/" rel="text/html" + class={% if slug == "faq" %}"current"{% else %}"internal"{% endif %}> + FAQ + </a> + <a href="/undef/" rel="text/html" + class={% if slug == "undef" %}"current"{% else %}"internal"{% endif %}> + Bouton autre + </a> </nav> <main> diff --git a/home/urls.py b/home/urls.py index 355175e..ce62abf 100644 --- a/home/urls.py +++ b/home/urls.py @@ -2,5 +2,5 @@ from django.urls import path from . import views urlpatterns = [ - path('', views.home, name = 'home'), + path('', views.static_view, {"slug":"home"}, name = 'home'), ] \ No newline at end of file diff --git a/home/views.py b/home/views.py index 8e9bac2..4029562 100644 --- a/home/views.py +++ b/home/views.py @@ -1,4 +1,4 @@ from django.shortcuts import render -def home(request): - return render(request, 'home.html', {}) +def static_view(request, slug): + return render(request, slug+'.html', {'slug': slug}) -- GitLab