Giter Site home page Giter Site logo

foberleitner / simple-navigation-bootstrap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pdf/simple-navigation-bootstrap

0.0 0.0 0.0 97 KB

simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap navigation and dropdowns.

Ruby 100.00%

simple-navigation-bootstrap's Introduction

Simple Navigation for Bootstrap

This gem adds a renderer for Simple Navigation to output markup compatible with Twitter Bootstrap.

Getting Started

For Rails >= 3, simply add this gem to your Gemfile:

gem 'simple-navigation-bootstrap'

and run

bundle install

Follow the configuration instructions on the Simple Navigation wiki for initial configuration.

To use the Bootstrap renderer, specify it in your view:

render_navigation :expand_all => true, :renderer => :bootstrap

And the minimal navigation config you need is:

SimpleNavigation::Configuration.run do |navigation|  
  navigation.items do |primary|
    primary.dom_class = 'nav'
  end
end

See below for a more complete example.

Additional Functionality

In addition to generating Bootstrap-comptible list markup, you may specify an :icon attribute on your navigation items, either as an array or string, containing Bootstrap icon classes, to add an icon to the item.

For items with sub-navigation, you may specify :split => true to enable a split dropdown. Split dropdowns allow using an url on the primary navigation item, as well as having a dropdown containing sub-navigation. If you plan on using this feature, in your application.css or equivalent you must require the bootstrap_navbar_split_dropdowns stylesheet after requiring Bootstrap.

For example:

/*
*= require bootstrap_and_overrides
*= require bootstrap_navbar_split_dropdowns
*/

Examples

To create a navigation menu, you might do something like this:

SimpleNavigation::Configuration.run do |navigation|  
  navigation.items do |primary|
    primary.item :music, 'Music', musics_path
    primary.item :dvds, 'Dvds', dvds_path, :split => true do |dvds|
      dvds.item :action, 'Action', dvds_action_path
      dvds.item :drama, 'Drama', dvds_drama_path
    end
    primary.item :books, 'Books', :icon => ['icon-book', 'icon-white'] do |books|
      books.item :fiction, 'Fiction', books_fiction_path
      books.item :history, 'History', books_history_path
    end
    primary.dom_class = 'nav'
  end
end

Caveats

Requires Bootstrap version >= 2.1.0

Further Reading

TODO

So far, only nav markup and dropdowns are supported, may also implement buttons and nav lists in the future. And tests, there are currently no tests.

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.