Coder Social home page Coder Social logo

activenavbar's Introduction

Activenavbar Gem Version Gem Total Downloads

active navbar is used to set the active navbar link, a navbar link becomes active when you click on it.

Installation

The simplest way to install is to use Bundler.

Add this line to your application's Gemfile:

gem 'activenavbar', '~> 1.0.4'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activenavbar

Method

navbar_link(label, path, active_class)
  • label: the link label.
  • path: the link path or controller path.
  • active_class: the style sheet active class.

Usage

Assume we have home, food and beverage page, and have navbar for each page below:

%ul
  %li
    = link_to "Home", homes_path
  %li
    = link_to "Food", foods_path
  %li
    = link_to "Beverage", beverages_path

Assume we have style sheet for navbar below:

ul {
  list-style-type: none;
  overflow: hidden;
}

li {
  float: left;
}

.nav > li > a {
  border-right: 1px solid #A80000;
  padding: 5px;
  color: #000;
}

.nav .active > a,
.nav .active > a:focus {
  color: red;
}

Now we want a navbar link becomes active when we click on it:

%ul
  = navbar_link "Home", root_path, "active"
  = navbar_link '<span class="glyphicon glyphicon-heart"></span> Food', foods_path, "active"
  = navbar_link "Beverage", beverages_path, "active"

Well, Home link becomes active when we click on Home link.

HTML output:

<ul>
  <li class="active"><a href="/">Home</a></li>
  <li class=""><a href="/foods"><span class="glyphicon glyphicon-heart"></span>Food</a></li>
  <li class=""><a href="/beverages">Beverage</a></li>
</ul>

License

MIT License

Copyright (c) 2014 - Present, Bunlong VAN ( Maintainer )

activenavbar's People

Contributors

bunlong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sopheak-se

activenavbar's Issues

Can't use icon image instead text label

When I use text label as a link it work well, but when I use icon image instead text label it doesn't work. It seem like there is no icon image feature. Thank!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.