From 6c747fcb9c43bd04acdcbf077719b75e2fe123dd Mon Sep 17 00:00:00 2001 From: Dan Head Date: Fri, 21 Dec 2018 20:11:15 +0000 Subject: [PATCH] Rework navigation walker --- css/nav.css | 9 ++++++--- theme/classes/walker.navigation.php | 25 +++++++++++++++++++++++++ theme/functions.php | 19 ------------------- theme/partials/navigation.php | 13 +++++++------ 4 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 theme/classes/walker.navigation.php diff --git a/css/nav.css b/css/nav.css index 2f6b198..3a9d71d 100644 --- a/css/nav.css +++ b/css/nav.css @@ -118,18 +118,21 @@ top: -10000px; } +.nav__menu { + flex-grow: 1; +} + /** * nav List */ .nav__list { - flex-grow: 1; font-family: var(--heading-font-family); font-size: 1.5rem; } -.nav__list--sub-list { - margin: 0 0 0 var(--space-sm); +.nav__list .nav__list { + margin-left: var(--space-sm); } .nav__link, diff --git a/theme/classes/walker.navigation.php b/theme/classes/walker.navigation.php new file mode 100644 index 0000000..bf8ac92 --- /dev/null +++ b/theme/classes/walker.navigation.php @@ -0,0 +1,25 @@ +class Windycoys_Walker_Navigation extends Walker_Nav_Menu { + function start_lvl(&$output, $depth = 0) { + $output .= ''; + } + + function start_el(&$output, $item) { + $title = $item->title; + $url = $item->url; + if ($title && $url) { + $output .= ''; + } +} + diff --git a/theme/functions.php b/theme/functions.php index 45e5486..5a95a4a 100644 --- a/theme/functions.php +++ b/theme/functions.php @@ -29,25 +29,6 @@ class Windycoys_Walker_Comment extends Walker_Comment { } } -class Windycoys_Walker_Nav extends Walker_Nav_Menu { - function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { - $title = $item->post_title; - $uri = get_site_url() . '/' . $item->post_name; - - $output .= ''; - } -} - -function windycoys_nav() { - wp_nav_menu(array( - 'container' => 'ul', - 'menu_class' => 'nav__list nav__list--sub-list', - 'walker' => new Windycoys_Walker_Nav() - )); -} - function windycoys_the_tags() { $tags = get_the_tags(); if (!$tags) return false; diff --git a/theme/partials/navigation.php b/theme/partials/navigation.php index 1ded82c..8ac33d1 100644 --- a/theme/partials/navigation.php +++ b/theme/partials/navigation.php @@ -1,3 +1,4 @@ +