Styling with TailwindCSS

Changing menu styles depending on which page we're on

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

Modified files

templates/app/base.html
--- 
+++ 
@@ -11,15 +11,30 @@
   <script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
 </head>
 <body>
+  {% url 'create_article' as create_new_url %}
+  {% url 'home' as your_articles_url %}
+  {% url 'account_email' as change_email_url %}
   <nav class="px-10 py-4 border-b border-gray-300 shadow-md">
     <div class="flex justify-end items-center gap-6 max-w-7x mx-auto">
         {% if user.is_authenticated %}
-        <a class="button primary" href="{% url 'account_signup' %}">Create new</a>
-        <a class="hover:shadow-underline hover:shadow-gray-300" href="{% url 'home' %}">Articles</a>
-        <a class="hover:shadow-underline hover:shadow-gray-300" href="{% url 'account_email' %}">Change email</a>
+          <a
+            class="button primary"
+            href="{% spaceless %}{% if request.path != create_new_url %} {{ create_new_url }} {% else %} # {% endif %}{% endspaceless %}">
+            Create new
+          </a>
+          <a
+            class="hover:shadow-underline hover:shadow-gray-300 {% if request.path == your_articles_url %} font-semibold {% endif %}"
+            href="{{ your_articles_url }}">
+            Your articles
+          </a>
+          <a
+            class="hover:shadow-underline hover:shadow-gray-300 {% if request.path == change_email_url %} font-semibold {% endif %}"
+            href="{{ change_email_url }}">
+            Change email
+          </a>
           <form method="POST" action="{% url 'account_logout' %}">
             {% csrf_token %}
-            <button class="hover:shadow-underline hover:shadow-gray-300" type="submit">Log out</button>
+            <button class="hover:shadow-underline  hover:shadow-gray-300" type="submit">Log out</button>
           </form>
         {% else %}
           <a class="button secondary text-sm" href="{% url 'account_login' %}">Log in</a>