Skip to content

Commit

Permalink
Improved mobile navigation PoC
Browse files Browse the repository at this point in the history
  • Loading branch information
knomepasi committed Oct 7, 2024
1 parent c4aae7a commit 9efa041
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
svg:
for file in asset_sources/icons/*.svg; do scour $$file _includes/svg/`basename $$file` --strip-xml-prolog --enable-id-stripping --remove-metadata --enable-comment-stripping --enable-viewboxing --shorten-ids --shorten-ids-prefix=`basename $$file .svg`_; done
for file in asset_sources/includes/*.svg; do scour $$file _includes/svg/`basename $$file` --strip-xml-prolog --enable-id-stripping --remove-metadata --enable-comment-stripping --enable-viewboxing --shorten-ids --shorten-ids-prefix=`basename $$file .svg`_; done
local-test:
bundle exec jekyll serve
16 changes: 9 additions & 7 deletions _includes/layout/nav.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<nav id="nav">
{%- assign page_paths = site.nav_links | default: default_paths -%}
{%- for path in page_paths -%}
{%- assign my_page = site.pages | where: "path", path | first -%}
{%- if my_page.menu_title -%}
<a href="{{ my_page.url | relative_url }}">{{ my_page.menu_title | escape }}</a>
{%- endif -%}
{%- endfor -%}
<div class="menu">
{%- assign page_paths = site.nav_links | default: default_paths -%}
{%- for path in page_paths -%}
{%- assign my_page = site.pages | where: "path", path | first -%}
{%- if my_page.menu_title -%}
<a href="{{ my_page.url | relative_url }}">{{ my_page.menu_title | escape }}</a>
{%- endif -%}
{%- endfor -%}
</div>
</nav>
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
51 changes: 51 additions & 0 deletions asset_sources/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 48 additions & 9 deletions assets/css/xubuntu.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ header {
}
header .main {
position: relative;
z-index: 3;
z-index: 6;

display: grid;
grid-template-columns: 144px auto;
Expand Down Expand Up @@ -303,21 +303,60 @@ header {
}

header .main.compact {
display: block;
grid-template-columns: max-content auto;
}
header .main.compact #logo,
header .main.compact #logo img {
height: 30px;
}
header .main.compact nav {
margin-top: var(--pad);
align-content: start;
header .main.compact nav .menu {
display: none;
}
header .main.compact nav a {
display: inline-block;
margin: 0 var(--pad) calc(var(--pad) / 2) 0;
header .main.compact nav::before {
content: '';
display: block;
height: 30px;
width: 30px;
background-image: url(../images/menu.svg);
background-size: 22px;
background-repeat: no-repeat;
background-position: 50% 50%;
}

header .main.compact nav.open::before {
background-image: url(../images/menu_close.svg);
}
header .main.compact nav.open .menu {
display: block;
position: absolute;
top: calc(30px + var(--pad));
left: 0;
right: 0;
background-color: var(--color-bg);
width: auto;
z-index: 500;
border-radius: 0.5em;
}
header .main.compact nav.open .menu a {
display: block;
margin: 0;
padding: calc(var(--pad) / 2) var(--pad);
border-bottom: 1px solid hsl(0,0%,50%,0.2);
color: var(--color-link);
text-align: center;
font-weight: 500;
}
header .main.compact nav.open .menu a:first-child {
border-top-right-radius: 0.5em;
border-top-left-radius: 0.5em;
}
header .main.compact nav.open .menu a:last-child {
border-bottom: none;
border-bottom-right-radius: 0.5em;
border-bottom-left-radius: 0.5em;
}
header .main.compact nav.open .menu a:hover {
background-color: var(--color-bg-alternative);
}

/* Main */

Expand Down
51 changes: 51 additions & 0 deletions assets/images/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions assets/images/menu_close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 15 additions & 3 deletions assets/js/xubuntu.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
window.addEventListener( 'load', resize_header );
window.addEventListener( 'resize', resize_header );
window.addEventListener( 'load', init );

function init( ) {
window.addEventListener( 'resize', resize_header );
resize_header();

nav = document.getElementById( 'nav' );
nav.addEventListener( 'click', click_nav );
}

function resize_header( ) {
header = document.getElementById( 'header_main' );
logo = document.getElementById( 'logo' );
nav = document.getElementById( 'nav' );

header.classList.remove( 'compact' );
logo_width = 144;

if( ( nav.offsetWidth + logo.offsetWidth ) > header.offsetWidth ) {
if( ( nav.offsetWidth + logo_width ) > header.offsetWidth ) {
header.classList.add( 'compact' );
}
}

function click_nav( event ) {
this.classList.toggle( 'open' );
}

0 comments on commit 9efa041

Please sign in to comment.