-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% extends "!header.html" %} | ||
|
||
{%- block header_main_nav %} | ||
{%- if main_nav_links|tobool -%} | ||
<nav class="flex items-center space-x-6 text-sm font-medium"> | ||
{%- for text, item in main_nav_links.items() %} | ||
{%- if item is string %} | ||
{# Single link #} | ||
{%- set _active = "text-foreground" if pagename in item else "text-foreground/60" -%} | ||
<a href="{{ item }}" class="py-2 transition-colors hover:text-foreground/80 {{ _active }}" | ||
rel="noopener nofollow">{{ text }}</a> | ||
{%- elif item is mapping %} | ||
{# Nested links with focus and hover accessibility #} | ||
<div x-data="{ open: false }" @focusin="open = true" @focusout="open = false" @mouseenter="open = true" | ||
@mouseleave="open = false" class="relative navigation-link"> | ||
<a href="#" class="py-2 transition-colors hover:text-foreground/80 focus:outline-none" tabindex="0" | ||
aria-haspopup="true" :aria-expanded="open.toString()"> | ||
{{ text }} | ||
<svg fill="currentColor" height="24px" stroke="none" viewBox="0 0 24 24" width="24px" | ||
xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path> | ||
</svg> | ||
</a> | ||
<div x-show="open" x-transition:enter="transition ease-out duration-200" | ||
x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" | ||
x-transition:leave="transition ease-in duration-150" x-transition:leave-start="opacity-100 scale-100" | ||
x-transition:leave-end="opacity-0 scale-95" | ||
class="absolute bg-background mt-2 z-10 transition navigation-dropdown"> | ||
{%- for subtext, suburl in item.items() %} | ||
{%- set _active = "text-foreground" if pagename in suburl else "text-foreground/60" -%} | ||
<a href="{{ pathto(suburl) }}" class="block px-4 py-2 text-sm transition-colors {{ _active }}" tabindex="0"> | ||
{{ subtext }} | ||
</a> | ||
{%- endfor %} | ||
</div> | ||
</div> | ||
{%- endif %} | ||
{%- endfor %} | ||
</nav> | ||
{%- endif %} | ||
{%- endblock header_main_nav %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters