An ember-cli addon to display calendar month(s) using moment.js.
currentMonth: null,
currentYear: null,
init() {
this.set('currentMonth', moment().month());
this.set('currentYear', moment().year());
},
oneMonthClassFunction(date) {
let selectedDays = [1, 2, 3, 5, 8, 13, 21];
if (selectedDays.includes(date.date()) && moment().isSame(date, 'month')) {
return 'selected';
}
},
today: null,
threeMonthsFromNow: null,
init() {
this.set('today', moment().startOf('day'));
this.set('threeMonthsFromNow', moment().startOf('day').add(2, 'months'));
},
threeMonthClassFunction(date) {
// pass anything you will need anything into this function in 'context'
const { startDate, endDate } = this.get('context');
if (date.isSame(startDate, 'day')) {
return 'start-date';
}
if (date.isSame(endDate, 'day')) {
return 'end-date';
}
if (date.isBetween(startDate, endDate)) {
return 'selected';
}
}
In your application's directory:
ember install datetime-bling
New features and bugfixes are welcome! Feel free to open a pull request.
npm test
(Runsember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
Code and documentation © Copyright 2017 Ryan Rishi. Code released under the MIT License;