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.

    Picture in BG on a cell related to someone'S birthday

    Scheduled Pinned Locked Moved Utilities
    8 Posts 3 Posters 417 Views 3 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.
    • S Offline
      sdetweil @Chuck_morisse
      last edited by

      @Chuck_morisse i do not know exactly, but if you use the developer window then you can discover this info

      see the second link in my signature below

      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 @Chuck_morisse
        last edited by

        @Chuck_morisse
        There could be many approaches to accomplish your goal, So I need more precise conditions.

        1. Does your birthday calendar only include birthdays? (Are your targeting birthdays distinguishable by a separate calendar or by a specific title format?) => I Have to know how to point the birthday event from another normal event.

        2. All the targeting birthdays would have the own picture? It is not so easy to apply the default picture when there is no proper image (To be honest, it would be also possible, but many additional coding skill be needed.)

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

          @Chuck_morisse
          I assumed;

          • All targeting birthday events placed in the Birthdays calendar. Only those events would be considered.
          • All birthday events would have profile image. (At least as many as possible)
          • The profile image has a format like johndoe.webp, located in /modules/MMM-CalendarExt3.
          /* In your config.js */
          {
          	module: "calendar",
          	header: "Birthdays",
          	position: "top_left",
          	config: {
          		calendars: [
          			{
          				name: "Birthdays",
          				url: "https://somewhere.com/birthday.ics"
          			}
          		]
          	}
          },
          {
          	module: "MMM-CalendarExt3",
          	position: "bottom_bar",
          	config: {
          		mode: "week",
          		preProcessor: (event) => {
          			if (event.calendarName === "Birthdays") {
          				event.skip = true
          			}
          			return event
          		},
          		manipulateDateCell: (cellDom, events) => {
          			const birthday = events.filter(event => event.calendarName === "Birthdays")?.[0] || null;
          			if (birthday) {
          				const filename = birthday.title.replace(/[^a-z0-9]/gi, '').toLowerCase() + ".webp"
          				cellDom.classList.add("birthday-event")
          				cellDom.style.setProperty("--birthday-event-image", `url("/modules/MMM-CalendarExt3/${filename}")`)
          			}
          		}
          	}
          },
          
          /* In your custom.css */
          .CX3 .cell.birthday-event {
            background-position: center;
            background-repeat: no-repeat;
            background-size: cover;
            background-image: var(--birthday-event-image, "");
          }
          

          cb2ef4f3-74f2-4afc-8ae4-ce54b2aaa434-image.png

          Not considered

          • It will take the first birthday when multiple birthdays are in the same day.
          • If will not check whether the real image exists or not. (In the example, John Smith has no profile image, but that event is skipped also.)
          C 1 Reply Last reply Reply Quote 0
          • C Offline
            Chuck_morisse @MMRIZE
            last edited by

            @MMRIZE ,

            WOAH! Thanks you sir, this is exactly what I meant, you assumed everything just right.
            I tried copying everything into my config (and also in the customcss) but when I run “npm run config:check” I get the following error:

            [ERROR] Your configuration file contains syntax errors : (
            [ERROR] Line 221 column 82: Parsing error: Unexpected token .

            Line 221 corresponds to :
            const birthday = events.filter(event => event.calendarName === “Birthdays”)?.[0] || null;

            any idea? I feel we’re just on the edge of making it work.

            *By the way I did change one thing, in case it makes a difference… I replaced the picture format from .webp to .png

            Thanks you for your help!

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

              @Chuck_morisse
              I think npm run config:check cannot validate optional chaining operator (?.). That is somewhat modern state-of-art feature of ECMA Javascript since 2020.
              I think you can ignore that error message, anyhow it will work.
              I’m not using npm run config:check for that reason.

              C S 2 Replies Last reply Reply Quote 0
              • C Offline
                Chuck_morisse @MMRIZE
                last edited by

                @MMRIZE

                Ahhh, I see!
                Everything works just fine!
                Thanks a lot for this, I really like the look of it!

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @MMRIZE
                  last edited by

                  @MMRIZE @Chuck_morisse
                  I opened issue 3552
                  https://github.com/MagicMirrorOrg/MagicMirror/issues/3552

                  to document the need for better checking in config:check
                  (as we are switching linter versions anyhow)

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • 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