MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-CalendarExt3

    Scheduled Pinned Locked Moved Utilities
    689 Posts 82 Posters 2.8m Views 86 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      chadjohn2
      last edited by

      First off, I’m a complete and utter noob with coding. I’m capable enough to get MagicMirror installed and start adding in some of the 3rd party modules. I’m now trying to get into the space of modifying CSS and such for a little added customization.

      I’m trying to something that I think should be simple but I cannot get it work for the life of me. I’ve searched the forum and this topic and found a couple pieces but I’m still struggling. Finally got frustrated enough to create an account and post.

      I’m trying to change the color of events based on the title of an event coming from a google calendar. The events are coming in fine, just not changing color.

      Based on what I have read, I need to use the eventTransformer function. I have put the following into the config.js file (including the full module for total information).

      { 
      module: "MMM-CalendarExt3",
      position: "bottom_bar",
      config: {
      			mode: "week",
      			weekIndex: "0",
      			weeksInView: "2",
      			firstDayOfWeek: "1",
      			maxEventLines: "8",
      			fontSize: "25px",
      			eventHeight: "16px"
      		},
      eventTransformer: function(event) {
      if (event.title.search('Daycare') > -1) {
      event.className = 'Daycare'
      				}
      			}	
      		}
      

      then in the custom.css file (Trying hot pink hex so it pops out):

      .CX3 .Daycare {
      background-color:#FF69B4;
      color:#FF69B4;
      }
      

      For all I know, that’s completely wrong so any help you can provide will be appreciated!

      W M 2 Replies Last reply Reply Quote 0
      • W Offline
        Wenike @chadjohn2
        last edited by

        @chadjohn2 Try removing the }, before your event transformer text (it closes that config section but you need the event transformer in that config section). Also, per the github, your code for the event transformer needs to be something like:

        eventTransformer: (ev) => {
          if (ev.title.search('Daycare') > -1) ev.color = '#FF69B4'
          return ev
        }
        
        S 1 Reply Last reply Reply Quote 0
        • S Do not disturb
          sdetweil @Wenike
          last edited by sdetweil

          @Wenike your transformer is only doing style change,
          he wants to change the class , so his transformer is ok

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • M Offline
            MMRIZE @chadjohn2
            last edited by MMRIZE

            @chadjohn2
            There were several issues on your code.

            1. You didn’t return event object in your eventTransformer function.
              30718079-3e22-498f-88af-f332f084c764-image.png

            2. CSS(Cascading Style Sheets) has a Speciality to determine the priority of the definitions by calculation.
              Your .CX3 .Daycare is lower than default .CX3 .event.fullday or .CX3 .event.multiday. So in case of your event is fullday/multiday thing, your color definition would be ignored.
              .CX3 .event.Daycare or .CX3 .event.Daycare.fullday, .CX3 .event.Daycare.multiday would work.

            1 Reply Last reply Reply Quote 0
            • D Offline
              DDE12
              last edited by

              How do I reference the specific instances of CExt3? Like on different carousel pages, where I would have a month mode on one page and a week mode on another. I have this config:

              module: "calendar",
              	    position: "top_left",
                          broadcastPastEvents: true,
                          maximumNumberOfDays: 300,            
                          config: {
                              instanceId: "FamilyCal",
                              fade: false,
                              colored: true,
                              displaySymbol: false,
              	        calendars: [
                                      {   
                                      name: "Holidays",
              		        url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics",
                                      color: "rgb(240,175,20)"
                                      },
                                      {   
                                      name: "Dad",
                                      url: "https://private.calendar.com",
                                      color: "rgb(60,250,60)"
                                      },
                                      {   
                                      name: "Mom",
                                      url: "https://private.calendar.com",
                                      color: "rgb(250,40,150)"
                                      },
                                      {  
                                      name: "Child",
                                      url: "https://private.calendar.com",
                                      color: "rgb(180,40,250)"
                                      }
              		]
              	}
              },
              {
                        module: "MMM-CalendarExt3",
                        position: "fullscreen_above",
                        title: "",
                        config: {
                              mode: "month",
                              instanceId: "FamilyMonth",
                              calendarSet: ['Holidays', 'Dad', 'Mom', 'Child'],
                              maxEventLines: 5,
                              firstDayOfWeek: 0,
                              minimalDaysOfNewYear: 1,
                              eventHeight: '18px',
                              useSymbol: false                
                          }
                      },*/
                      {
                          module: "MMM-CalendarExt3",
                          position: "fullscreen_above",
                          title: "",
                          config: {
                              mode: "week",
                              instanceId: "FamilyWeek",
                              weekIndex: -1,
                              weeksInView: 5,
                              calendarSet: ['Holidays', 'Dad', 'Mom', 'Child'],
                              maxEventLines: 5,
                              firstDayOfWeek: 0,
                              minimalDaysOfNewYear: 1,
                              eventHeight: '18px',
                              useSymbol: false                
                       }
               }
              
              S 1 Reply Last reply Reply Quote 0
              • S Do not disturb
                sdetweil @DDE12
                last edited by sdetweil

                @DDE12 for each module you can ADD classes strings , by using the classes:“…”
                property after the
                module:“… name”

                then in pages you can use that name instead of the module name

                I prefer to configure pages differently

                in pages its

                   modules: [
                        [  'page1'],
                        [  'page2' ]
                    ]
                

                then for the modules u want on page1

                you add

                  classes:'page1',
                

                and for modules on page2

                   classes:'page2'
                

                you can do the same for fixed, etc

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                D 1 Reply Last reply Reply Quote 0
                • D Offline
                  DDE12 @sdetweil
                  last edited by

                  @sdetweil
                  Thank you for looking at this. Is this the proper implementation for your suggestion?

                  modules:  [
                     ['MonthPage'],
                     ['WeeksPage']
                     {
                            module: "MMM-CalendarExt3",
                            position: "fullscreen_above",
                            classes: 'MonthPage',
                                  config: {
                                       mode: "month",
                                       instanceId: "FamilyMonth",
                                       calendarSet: ['Holidays', 'Dad', 'Mom', 'Child'],
                                  }
                      },
                      {
                            module: "MMM-CalendarExt3",
                            position: "fullscreen_above",
                            classes: 'WeeksPage' 
                                  config: {
                                       mode: "week",
                                       instanceId: "FamilyWeek",
                                      calendarSet: ['Holidays', 'Dad', 'Mom', 'Child'],
                                  }
                      },
                      {
                            module: "MMM-Carousel",
                                    config: {
                                          mode: 'slides',
                                          slides: {
                                                     "Slide 2": ['MonthPage'],
                                                     "Slide 3": ['WeeksPage']
                                           }
                                    }
                       },
                  ]
                  
                  S 1 Reply Last reply Reply Quote 0
                  • S Do not disturb
                    sdetweil @DDE12
                    last edited by

                    @DDE12 no, I was giving you the config for the MMM-Pages module.

                    I don’t use Carousel, so not sure there

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    D 1 Reply Last reply Reply Quote 0
                    • D Offline
                      DDE12 @sdetweil
                      last edited by

                      @sdetweil
                      Like so…?

                      modules:  [
                         {
                                module: "MMM-CalendarExt3",
                                position: "fullscreen_above",
                                classes: 'MonthPage',
                                      config: {
                                           mode: "month",
                                           instanceId: "FamilyMonth",
                                           calendarSet: ['Holidays', 'Dad', 'Mom', 'Child'],
                                      }
                          },
                          {
                                module: "MMM-CalendarExt3",
                                position: "fullscreen_above",
                                classes: 'WeeksPage' 
                                      config: {
                                           mode: "week",
                                           instanceId: "FamilyWeek",
                                          calendarSet: ['Holidays', 'Dad', 'Mom', 'Child'],
                                      }
                          },
                          {
                                  module: 'MMM-pages',
                                       config: {
                                                   modules: [
                                                                  ['MonthPage'],
                                                                  ['WeeksPage']
                                                     ],
                                        },
                           },
                        }
                      ]
                      
                      S 1 Reply Last reply Reply Quote 0
                      • S Do not disturb
                        sdetweil @DDE12
                        last edited by

                        @DDE12 yes

                        I would label the pages ( in pages config)

                        page1
                        page2

                        cause that is the order they are shown.

                        you can have as many modules on a page as u want and can fit of course.

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        D 1 Reply Last reply Reply Quote 0
                        • D Offline
                          DDE12 @sdetweil
                          last edited by

                          @sdetweil
                          Yeah, that would definitely be less confusing. Do I have the classes: “FamilyWeek” and classes: “FamilyMonth” in the right place in the CalenderExt3 config(s)?

                          S 1 Reply Last reply Reply Quote 0
                          • S Do not disturb
                            sdetweil @DDE12
                            last edited by

                            @DDE12 either can be used in css to select elements to style

                            Sam

                            How to add modules

                            learning how to use browser developers window for css changes

                            D 1 Reply Last reply Reply Quote 0
                            • D Offline
                              DDE12 @sdetweil
                              last edited by

                              @sdetweil
                              I’m completely lost now. I thought all of this went in config.js.

                              S 1 Reply Last reply Reply Quote 0
                              • S Do not disturb
                                sdetweil @DDE12
                                last edited by

                                @DDE12 all of THAT goes.in config.js

                                but if you want to change the color of the text for the second day of the week

                                in custom.css

                                . MMM-CalendarExt3  .weekday_1 {
                                      color:green;
                                }
                                

                                Sam

                                How to add modules

                                learning how to use browser developers window for css changes

                                1 Reply Last reply Reply Quote 0
                                • B Offline
                                  bicolorbore586
                                  last edited by

                                  @fedale @MMRIZE @chadjohn2 I am also trying (unsuccessfully) to have the Calendar event change color depending on which name is in the title.

                                  With the original magicmirror calendar, I’ve used
                                  customEvents: [ {keyword: “Ben”, color: “Brown”} ], which shows the event title and associated symbol in Brown.
                                  1290b0bd-b654-42fe-9b13-051ec662cdf2-image.png

                                  In EXT3, using eventTransformer, only the symbol shows in color

                                  I’ve tried to use
                                  eventTransformer: function(event) {
                                  if (event.title.search(“Ben”) > -1) {
                                  event.className = “Ben”;
                                  }
                                  }
                                  with customer.css
                                  .CX3 .Ben {
                                  color: brown;
                                  }

                                  However, this then shows a blank calendar
                                  e0bc6deb-9688-4354-a914-bbeae156c41e-image.png

                                  Have any of you been successful?
                                  Where am I going wrong?

                                  Thanks

                                  M 1 Reply Last reply Reply Quote 0
                                  • M Offline
                                    MMRIZE @bicolorbore586
                                    last edited by MMRIZE

                                    @bicolorbore586
                                    You have to return event object in eventTransformer function. When you omit ‘return’ statement in a function, implicitly it is same with ‘return null’

                                    B 1 Reply Last reply Reply Quote 0
                                    • B Offline
                                      bicolorbore586 @MMRIZE
                                      last edited by

                                      @MMRIZE have tried that, still doesn’t show anything.

                                      eventTransformer: function(event) {
                                      if (event.title.search(“Ben”) > -1) {
                                      event.className = “Ben”;
                                      return event
                                      }
                                      }

                                      mumblebajM 1 Reply Last reply Reply Quote 0
                                      • mumblebajM Offline
                                        mumblebaj Module Developer @bicolorbore586
                                        last edited by

                                        @bicolorbore586 If I am not mistaken, your return goes outside the IF statement

                                        Check out my modules at: https://github.com/mumblebaj?tab=repositories
                                        Check my blog-post: https://mumblebaj.xyz/
                                        Check my MM Container: https://hub.docker.com/repository/docker/mumblebaj/magicmirror/general

                                        BKeyportB B 2 Replies Last reply Reply Quote 0
                                        • BKeyportB Offline
                                          BKeyport Module Developer @mumblebaj
                                          last edited by BKeyport

                                          @mumblebaj

                                          Try this:

                                          eventTransformer: function(ev) {
                                            if (ev.title.search(“Ben”) > -1)  ev.className = “Ben”;
                                            return ev
                                          }
                                          

                                          directly off the README.md :

                                          eventTransformer: (ev) => {
                                            if (ev.title.search('John') > -1) ev.color = 'blue'
                                            return ev
                                          }
                                          

                                          The "E" in "Javascript" stands for "Easy"

                                          1 Reply Last reply Reply Quote 0
                                          • B Offline
                                            bicolorbore586 @mumblebaj
                                            last edited by

                                            @mumblebaj so that now means I can see the events again, but still not coloured how I want.

                                            1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 28
                                            • 29
                                            • 30
                                            • 31
                                            • 32
                                            • 33
                                            • 34
                                            • 35
                                            • 30 / 35
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy