Customize the color of the day

Issue #37 invalid
Former user created an issue

Is there a way, or could there be a way, to customize the color of the day? Instead of the standard 'blue'?

I understand that a day is only colored if it has events, and there can be multiple events per day... but similarly how we can pass in a 'badgeColor' for a day, could we pass in a 'dayColor' for the entire block?

Comments (5)

  1. Lukasz Kokoszkiewicz repo owner

    All colors can be setup using css stylesheets by targeting the specific classes in html.

  2. Former user Account Deleted reporter

    Yes I realize I could target

    .day.active a { background-color: something-other-than-blue; }
    

    And change the colors of all the days for the calendar.

    But what I'm referring to is the ability to color one day one color, and another day another. This could be easily done if I could simply pass in another class to the day, e.g. a 'dayColor' or 'dayClass'.

    Then I could set something up like this:

    .day.active a.day-success { background-color: green; }
    .day.active a.day-danger { background-color: red; }
    

    etc.

  3. Former user Account Deleted reporter

    I was able to accomplish exactly this by passing in a dayClass property when creating an even for a day. Then, in the Calendar.prototype.addOthers function, I added the following line:

    ...
    if (dayEvents.url) {
      day.find("a").attr("href", dayEvents.url);
    }
    // Added by brazilianldsjaguar
    if (dayEvents.dayClass) {
      day.find("a").addClass(dayEvents.dayClass);
    }
    ...
    

    And then, on initialization (or edit calls) for events, I can do something like this:

    $('.responsive-calendar').responsiveCalendar(
      {
        events: {
          '2015-06-14': { 'dayClass': 'day-success' }
        }
      }
    );
    
  4. Former user Account Deleted reporter

    Actually, I just realized this is already supported:

    events: { '2015-06-14': { 'class': 'day-success' } }
    

    Will add the 'day-success' class to the .day objects. My apologies for the confusion!

  5. Log in to comment