From 1e3917ada03b680e1e045b8f6602e706bc1c6e08 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Sat, 3 Oct 2015 22:44:36 -0500 Subject: [PATCH] navigation active class --- README.md | 1 - app/assets/stylesheets/molecules/nav.scss | 18 ++++++++++++++++++ app/helpers/application_helper.rb | 8 ++++++++ app/views/children/_sub_nav.html.haml | 4 ++-- app/views/layouts/_navigation.html.haml | 12 ++++++------ app/views/pages/_sub_nav.html.haml | 4 ++-- app/views/parents/_sub_nav.html.haml | 5 ++--- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 91c46e2..73b3919 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ A simple api to send sms messages with [twillio](https://www.twilio.com/). ## TODO -* active class on main navs * sorcery or a lower oauth solution * application log * app version file - milestone 0.9.0 diff --git a/app/assets/stylesheets/molecules/nav.scss b/app/assets/stylesheets/molecules/nav.scss index 7e7f0cc..027aed0 100644 --- a/app/assets/stylesheets/molecules/nav.scss +++ b/app/assets/stylesheets/molecules/nav.scss @@ -13,6 +13,15 @@ a { color: $light; } + + &.active { + background-color: $taupe; + + a { + color: $dark; + cursor: default; + } + } } } @@ -27,5 +36,14 @@ background-color: $light; } } + + .active a { + color: $grey; + cursor: default; + + &:hover { + background-color: transparent; + } + } } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 01c0b6e..5a5845e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,4 +4,12 @@ module ApplicationHelper link_to 'page', page_person_path(person) end + + def active_controller(kontroller) + 'active' if params[:controller] == kontroller + end + + def active_action(action) + 'active' if params[:action] == action + end end diff --git a/app/views/children/_sub_nav.html.haml b/app/views/children/_sub_nav.html.haml index 215428e..9e26d54 100644 --- a/app/views/children/_sub_nav.html.haml +++ b/app/views/children/_sub_nav.html.haml @@ -1,4 +1,4 @@ %ul.sub-nav - %li= link_to 'List', list_children_path - %li= link_to 'New', new_child_path + %li{ class: active_action('index') }= link_to 'List', list_children_path + %li{ class: active_action('new') }= link_to 'New', new_child_path diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 264ef49..d85149f 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -1,7 +1,7 @@ %ul.nav - %li= link_to 'Home', root_path - %li= link_to 'Parents', list_parents_path - %li= link_to 'Children', list_children_path - %li= link_to 'Staff', list_staff_path - %li= link_to 'Users', list_users_path - %li= link_to 'Pages', list_pages_path + %li{ class: active_controller('docs') }= link_to 'Home', root_path + %li{ class: active_controller('parents') }= link_to 'Parents', list_parents_path + %li{ class: active_controller('children') }= link_to 'Children', list_children_path + %li{ class: active_controller('staff') }= link_to 'Staff', list_staff_path + %li{ class: active_controller('users') }= link_to 'Users', list_users_path + %li{ class: active_controller('pages') }= link_to 'Pages', list_pages_path diff --git a/app/views/pages/_sub_nav.html.haml b/app/views/pages/_sub_nav.html.haml index a75d903..4f5539e 100644 --- a/app/views/pages/_sub_nav.html.haml +++ b/app/views/pages/_sub_nav.html.haml @@ -1,4 +1,4 @@ %ul.sub-nav - %li= link_to 'View Past Pages', list_pages_path - %li= link_to 'Send Page', page_person_path + %li{ class: active_action('index') }= link_to 'View Past Pages', list_pages_path + %li{ class: active_action('page') }= link_to 'Send Page', page_person_path diff --git a/app/views/parents/_sub_nav.html.haml b/app/views/parents/_sub_nav.html.haml index caa8ec7..fe785a8 100644 --- a/app/views/parents/_sub_nav.html.haml +++ b/app/views/parents/_sub_nav.html.haml @@ -1,4 +1,3 @@ %ul.sub-nav - %li= link_to 'List', list_parents_path - %li= link_to 'New', new_parent_path - + %li{ class: active_action('index') }= link_to 'List', list_parents_path + %li{ class: active_action('new') }= link_to 'New', new_parent_path