Project 4: Movie Watchlist: Adding a nav bar to the movie library (+127, -0)

main.css (+87, -0)

From: curriculum/section14/lectures/02_adding_a_nav_bar/start/movie_library/static/css/main.css

To: curriculum/section14/lectures/02_adding_a_nav_bar/end/movie_library/static/css/main.css

            
            index 8a8de4c..be82915 100644
--- a/curriculum/section14/lectures/02_adding_a_nav_bar/start/movie_library/static/css/main.css
+++ b/curriculum/section14/lectures/02_adding_a_nav_bar/end/movie_library/static/css/main.css
@@ -53,6 +53,93 @@ body {
   background-color: var(--background-color);
 }
 
+.header {
+  padding: 0 2rem;
+  border-bottom: var(--border);
+}
+
+.header__logo {
+  display: flex;
+  align-items: center;
+  height: 4rem;
+  color: inherit;
+  text-decoration: none;
+}
+
+.header__logo:hover {
+  color: var(--accent-colour);
+}
+
+.logo__icon {
+  width: 2.5rem;
+  height: 2.5rem;
+}
+
+.logo__name {
+  margin-left: 0.5rem;
+  text-transform: uppercase;
+  font-weight: 600;
+  font-size: 20px;
+}
+
+.nav-container {
+  display: flex;
+  justify-content: space-between;
+
+  /* limits the width of the navigation area to 1200px and centres it within the header */
+  max-width: 75rem;
+  margin: 0 auto;
+}
+
+.nav {
+  display: flex;
+}
+
+.nav__link {
+  /* Setting display: flex and align-items: center places the links inside the list items
+       vertically in the center of the list item */
+  display: flex;
+  align-items: center;
+  padding: 0 0.5rem;
+
+  /* Removes standard underlines from these links. Explicitly inherits text colour from the body */
+  text-decoration: none;
+  color: inherit;
+}
+
+/* Sets the background colour and text colour of our navigation items when the item has 
+   the .nav__link--active class, indicating the current page */
+.nav__link--active {
+  background: var(--accent-colour);
+  color: var(--text-light);
+}
+
+/* Adds 1 relative unit of padding (determined by font size) to the right margin of all .nav__item
+   elements as long as they are not the last element in their parent */
+.nav__link:not(:last-child) {
+  margin-right: 1rem;
+}
+
+/* Adds a bottom border and applies a negative margin to the element, to nudge it over the
+   existing header bar border */
+.nav__link:hover {
+  margin-bottom: -3px;
+  border-bottom: var(--border);
+}
+
+.nav__item {
+  font-weight: 600;
+  letter-spacing: 1px;
+  text-transform: uppercase;
+}
+
+/* Sets the size of the icon (light/dark theme toggle) to be the same as the font size
+    So that it takes up more or less the same amount of space as the links */
+.nav__icon {
+  width: 1em;
+  height: 1em;
+}
+
 /* Button styles that we'll share across our site */
 .button {
   /* In order to easily position our buttons, we're making them block level elements */
        

nav.html (+40, -0)

From: curriculum/section14/lectures/02_adding_a_nav_bar/end/movie_library/templates/macros/nav.html

To: curriculum/section14/lectures/02_adding_a_nav_bar/end/movie_library/templates/macros/nav.html

            
            new file mode 100644
index 0000000..5e86ce3
--- /dev/null
+++ b/curriculum/section14/lectures/02_adding_a_nav_bar/end/movie_library/templates/macros/nav.html
@@ -0,0 +1,40 @@
+{% macro header(email, theme) %}
+<header class="header">
+    <div class="nav-container">
+        <a href="{{ url_for('pages.index') }}" class="header__logo">
+            <svg xmlns="http://www.w3.org/2000/svg" class="logo__icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
+  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 20h16a1 1 0 001-1V5a1 1 0 00-1-1H4a1 1 0 00-1 1v14a1 1 0 001 1z" />
+</svg> <span class="logo__name">Watchlist</span>
+        </a>
+        <nav class="nav">
+            {%- if not email %}
+                <a
+                    href="#"
+                    class="nav__link"
+                >
+                    <span class="nav__item">Log in</span>
+                </a>
+                <a
+                    href="#"
+                    class="nav__link"
+                >
+                    <span class="nav__item">Register</span>
+                </a>
+            {% else %}
+                <a 
+                    href="{{ url_for('pages.index') }}"
+                    class="nav__link {{ 'nav__link--active' if request.path == url_for('pages.index') }}"
+                >
+                    <span class="nav__item">Movies</span>
+                </a>
+                <a
+                    href="#"
+                    class="nav__link"
+                >
+                    <span class="nav__item">Log out</span>
+                </a>
+            {% endif %}
+        </nav>
+    </div>
+</header>
+{% endmacro %}