Skip to content

Solfanto/activity_calendar

Repository files navigation

ActivityCalendar

Github-inspired activity calendar.

Screenshot

Usage

# In controller
@activity_calendar = ActivityCalendar::Calendar.new(
  resource: @user,
  start_at: 1.year.ago.beginning_of_week(:sunday),
  end_at: Time.now,
  colors: {
    "#cce395" => {
      condition: ->(resource, date) { resource.commits_count_for(date).between?(1, 99) },
      title: ->(resource, date) { "#{resource.commits_count_for(date)} commits" }
    },
    "#8dc679" => {
      condition: ->(resource, date) { resource.commits_count_for(date) >= 100 },
      title: ->(resource, date) { "#{resource.commits_count_for(date)} commits" }
    }
  },
  default_color: "#ebedf0",    # optional
  default_title: "no commit",  # optional
  tile_width: 10,              # optional
  tile_height: 10,             # optional
  tile_spacing: 2,             # optional
  tile_data: { toggle: "tooltip", placement: "top", html: "true" }, # optional, compatible with Bootstrap by default
  border_width: 1,              # optional
  border_radius: 2,            # optional
  date_format: "on %B %d, %Y"  # optional
)
# In view
<%= render_activity_calendar @activity_calendar, id: "activity-calendar" %>

Installation

Add this line to your application's Gemfile:

gem 'activity_calendar', github: 'Solfanto/activity_calendar'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activity_calendar --source=https://github.com/Solfanto/activity_calendar.git

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

About

Github-inspired activity calendar.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published