README.md in simple_calendar-2.4.3 vs README.md in simple_calendar-3.0.0

- old
+ new

@@ -2,11 +2,11 @@ ### 📆 A calendar for your Ruby on Rails app. [![Build Status](https://github.com/excid3/simple_calendar/workflows/Tests/badge.svg)](https://github.com/excid3/simple_calendar/actions) [![Gem Version](https://badge.fury.io/rb/simple_calendar.svg)](https://badge.fury.io/rb/simple_calendar) -Simple Calendar is designed to do one thing really really well: render a calendar. +Simple Calendar is designed to do one thing really really well: render a calendar. It lets you render a calendar of any size. Maybe you want a day view, a 4 day agenda, a week view, a month view, or a 6 week calendar. You can do all of that with the new gem, just give it a range of dates to render. @@ -118,11 +118,11 @@ In a Rails 6 app, the configuration could look like the following: * Add `gem 'rails-i18n'` to your `Gemfile` and run `bundle`. * Define the available and default locale e.g. in `config/application.rb`: -```ruby +```ruby # config/application.rb config.i18n.available_locales = [:en, :de, :fr] config.i18n.default_locale = :en ``` * Define the following translation keys: @@ -132,11 +132,11 @@ simple_calendar: previous: "<<" next: ">>" week: Woche ``` - + See the [Rails I18n Guide](https://guides.rubyonrails.org/i18n.html) for further information. ## Rendering Events What's a calendar without events in it? There are two simple steps for creating @@ -339,17 +339,34 @@ the top! :) ### AJAX Calendars Rendering calendars that update with AJAX is pretty simple. You'll need -to wrap your calendar in a div, overwrite the `next_link` and `previous_link` options, and setup your -controller to respond to JS requests. The response can simply replace +to follow these steps. + +- Run `rails g simple_calendar:views` to generate the views. +- Add an ID to the calendar view's outer div. `<div id="calendar" class="simple-calendar">` +- Add `remote: true` option to the next & preview links like [this](https://github.com/excid3/simple_calendar-ajax-example/blob/ac8a1dc933d5933608421f8b53a5f5cf756b942f/app/views/simple_calendar/_month_calendar.html.erb#L3). +- Create `js.erb` file to respond to JS requests, render the new calendar, and replace the calendar on the page by ID like [this](https://github.com/excid3/simple_calendar-ajax-example/blob/master/app/views/events/index.js.erb). + +The response can simply replace the HTML of the div with the newly rendered calendar. Take a look at **[excid3/simple_calendar-ajax-example](https://github.com/excid3/simple_calendar-ajax-example)** to see how it is done. +If you are using [Hotwire](https://hotwired.dev/), just wrap in a Turbo Frame. +Like this: +```erb +<%= turbo_frame_tag 'calendar' do %> + <%= month_calendar do |date| %> + <%= date.day %> + <% end %> +<% end %> +``` + + ## Custom Calendars The three main calendars available should take care of most of your needs, but simple_calendar makes it easy to create completely custom calendars (like maybe you only want business weeks). @@ -404,16 +421,10 @@ expect_any_instance_of(SimpleCalendar::Calendar).to receive(:link_to).at_least(:once).and_return("") ``` With modifications as appropriate. -## TODO - -- Rspec tests for Calendar -- Rspec tests for MonthCalendar -- Rspec tests for WeekCalendar - ## Author Chris Oliver <chris@gorails.com> [https://gorails.com](https://gorails.com) @@ -421,9 +432,5 @@ [@excid3](https://twitter.com/excid3) ## License Simple Calendar is licensed under the [MIT License](LICENSE.txt). - -## Support - -Need help