Giter VIP home page Giter VIP logo

bootstrap_calendar_rails's Introduction

Calendar helper for Twitter Bootstrap and Rails

This gem provide simple and easy way to create calendar with Twitter Bootstrap and Rails.

Installation

First of all you should include twitter bootstrap in your app. You can do it manually, or use twitter-bootstrap-rails gem.

Installing the Less stylesheets

To use Less stylesheets, you'll need the less-rails gem, and one of Javascript runtimes supported by CommonJS.

Include these lines in the Gemfile to install the gems from RubyGems.org:

gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "bootstrap_calendar_rails"

Then run bundle install from the command line:

bundle install

Then run the bootstrap generator to add Calendar includes into your assets:

rails generate calendar:install less

Installing the CSS stylesheets

If you don't need to customize the stylesheets using Less, the only gem you need is the bootstrap_calendar_rails gem:

gem "bootstrap_calendar_rails"

After running bundle install, run the generator:

rails generate calendar:install static

Usage

Basic usage

You should use something like this in the view

bootstrap_calendar Date.today {} do |date|
    date.day.to_s
end

it show you calendar for the current month.

Advanced usage

You can specify another start week day. Use start_day key for this:

bootstrap_calendar Date.today { start_day: :wednesday } do |date|
    date.day.to_s
end

You can extend day classes. Use extra_day_classes key and lambda for this:

options = { extra_day_classes: lambda { |classes, date|
  classes << 'cal-day-daylight' if true  
  }
}
bootstrap_calendar Date.today, options do |date|
  date.day.to_s
end

Example application

An example application is available at sharpyfox/bootstrap_calendar_rails_example. You can view it running on heroku here. Contributions welcome.

Screenshot

Inspiration

This gem are highly inspired by:

davidray and davidray / twitter-bootstrap-calendar Basically this gem is an adoptation davidray / twitter-bootstrap-calendar for my flavour

Serhioromano and Serhioromano / bootstrap-calendar I stole all css markup from him

Thanks guys!

Contribution

If you'd like to add features (or bug fixes) to improve the gem, you can fork the GitHub repo and make pull requests. Your code contributions are welcome!

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.