Skip to content

[Feature Request] {{ Calendar - events: ad a specific CSS class according to expression or condition }} #3738

@SimoneMSR

Description

@SimoneMSR

Prerequisites

  • I am running the latest version of MagicMirror², and know that this feature is not available now.
  • I know my issue is not related to a third-party module.
  • I have searched for existing issues that already include this feature request, without success.

Describe the Feature Request

I would like to customize the calendar so to apply specific CSS to events, via config.js, or via a module method, or notification.

Describe the Use Case

Say that I can add the class "past" to all past events, I could hide past events in the original calendar widget, but still have them rendered in the CalendarExt3 (which uses broadcasts from calendar module)

Describe Preferred Solution

config.js

....calendars: [
    {
      name : "my_calendar"
      url: "...",
      cssClasses : {
        past : "e.startDate < new Date()"
      }
    }
}

using a module method:

MM.getModules().find(m=>m.name=="calendar").setStyleCallback(event=>{
  var classes = {}
  classes.past = event.startDate < new Date()
  return classes
})

using a module motification:

myModule.sendNotification("calendar_setStyleCallback", {callback : event=>{
  var classes = {}
  classes.past = event.startDate < new Date()
  return classes
}})

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Participation

  • I am willing to submit a pull request for this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions