Code Monkey home page Code Monkey logo

mmm-multimonth's Introduction

NOTE: THIS MODULE IS TO BE HOSTED ONLY AT https://github.com/BKeyport/MMM-Multimonth - Any other hosting location is invalid.

If you fork and change any code, please let me know, if it's useful for the general public, I'd love to add it!

If you find this module useful, and would like to contribute to the project, I appreciate the thought. Instead of giving to me, please donate to L'Arche Tahoma Hope at https://www.larchetahomahope.org/donate/ - in honor of Nancy Tyson. (Dedicate my donation checkbox). Nancy means the world to me. You don't have to notify me you have done so.

THANK YOU for your consideration.

MagicMirror Module to display a calendar with multiple months (user configurable)

screenshot

This is a module for the MagicMirror² project.

This will create a mini-calendar with as many months as the user wants, assuming screen space is available. Screenshots are with config examples.

Installation

Clone this repository in your ~/MagicMirror/modules/ folder ( $ cd ~MagicMirror/modules/ ):

git clone https://github.com/BKeyport/MMM-Multimonth

Note: NPM INSTALL is no longer required. This module is proud to no longer use any external dependencies!

Using the module

To use this module, add it to the modules array in the config/config.js file - shown options are defaults:

{
  module: 'MMM-Multimonth',
    position: 'top_left', // can be any of the postions
    config: { // Optional - will default to 3 months, with one previous and one next, vertical orientation.
    }
},

Full config options:

Option Default Description
startMonth -1 Starting month relative to the current month
monthCount 3 How many months do you want to display?
monthsVertical false Display months on a vertical line
repeatWeekdaysVertical false Repeat the weekday names? (Vertical Calendar Only)
weekNumbers false Show the week numbers (How many weeks in the year)
weekNumbersISO false Use ISO calculation or US/CA calculation (ignored if WeekNumbers is false) True = ISO, False = US/Canada.
highlightWeekend false highlight the weekend (See Below)
headerType 'short' How do you want the days displayed? In US - 'short' = "Sun, Mon, Tue" In US - 'narrow' = "S, M, T"
otherMonths false Display the previous and next month dimmed in the month grid.
eventsOn true Turn on and off Event monitoring
calNames [] List of calendar names to trigger underline. Empty will do all of them.
bigCalendar false Enable alternate big calendar mode, See below
instanceID If you'd like to have changes per instance, use a string here and specify in CSS.
startWeek 0 Starting day of your week
weekend1 0 1st Day of your weekend
weekend2 6 2nd day of your weekend

for the last three items: 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday.

Remember the format for options:

option: value, Example: startMonth: -1,

Important: calNames is an array, please specify as such ["Main", "Sportsball", "Utility"] case is IMPORTANT.

instanceID: You can specify in custom.css different css for each instance. For example, if you add instanceID: "test", to your code, you can overide that instance with:

.MMM-Multimonth .month-header.test {
  background-color: blue;
  color: var(--color-header);
  font-size: var(--font-size-small);
  line-height: var(--font-size-small)+5;
  border-radius: var(--back-rounding);
}

To get events to feed to module, add the calendar module into your config.js.

Suggested settings at minimum:

		{
			module: "calendar",
			config: {
				broadcastPastEvents: true,
				calendars: [
					{
						url: <insert URL>,
						name: <name>,
					},
					//.... As many as you'd like .... 
				],
			}
		},

New Features:

Event Colors:

The module now can use the colors from the calendar module, default is the system color set (white)

Event Symbols:

The module now can use the symbols from the calendar module in big calendar mode.

Example (uses public calendar from the University of Washington):

{
	url: "https://gohuskies.com/calendar.ashx/calendar.ics",
	name: "Huskies",
	symbol: "paw",
	color: "#4B2E83",
},

Big Calendar Mode:

I wanted a big calendar for the current month, and the solutions out there didn't do what I wanted, so here we are.

Big calendar mode will change two things in code.

The Week Number (if used) will become part of the first day of the week's spot.

Events will be summarized into a count and a symbol, and display below each day of the month.

To keep the CSS slim, I do not format anything differently, and it will break the constraints of the mini mode. Don't use if you're inexperienced in CSS. You will have to design your display yourself. If you have any questions, ask in the magic mirror forums. Myself or any of the CSS wizards will be happy to help you.

Updating from prior to 08 Jun 2024:

CSS is changed - please check all customizations. Old Elements, values, etc. have been deleted.

The following CSS code is all you need in custom.css if all you're changing is the colors and/or background edge rounding:

(Key changes here: "current" has been changed to "today", "background-week, color-week have been removed as redundant")

/* Defaults are shown */
.MMM-Multimonth .settings {
  --background-header: rgb(0, 128, 0);               /* for the month and year line, use green background */ 
  --background-dow: var(--color-background);         /* For the days of the week, use global background */ 
  --background-dowBlank: rgba(255, 255, 255, 0);     /* For the blank square if you use Week numbers */  
  --background-weekno: #808080;                      /* for the week number, use a grey background */ 
  --background-event: var(--color-background);		 /* Background for events, used in big mode only */
    
  --background-dimmed: var(--color-background);      /* For dimmed (previous/next month in current grid), use the global background color */
  --background-weekday: var(--color-background);     /* For normal days, use global background */ 
  --background-weekend: cornflowerblue;              /* For the days defined as your weekend, change the background to cornflowerblue */
  --background-today: Yellow;                        /* for the current day, change the background to yellow */ 

  --color-header: var(--color-text-bright);         /* for the header lines, use the global bright text color */ 
  --color-dow: var(--color-text);                   /* for the days of the week header, use the global text color */
  --color-dowBlank: rgba(255, 255, 255, 0);			/* For the blank square if you use Week numbers */ 
  --color-weekno: var(--color-text);                /* for the week numbers, use the global bright text color */

  --color-dimmed: var(--color-text-dimmed);         /* For dimmed (previous/next month in current grid), use the global dimmed text color */
  --color-weekday: var(--color-text);               /* For normal days, use global normal text */ 
  --color-weekend: var(--color-background);         /* For the days defined as your weekend, change the text to the background color */
  --color-today: var(--color-background);           /* for the current day, change the text to the background color */ 

  --back-rounding: 8px;                             /* Set the radius of the background rounded edges. See documentation for border-radius elsewhere */ 
  --alignment: center;                              /* Adjust the text alignment */ 
  --fontsize: var(--font-size-xsmall);              /* Set font size */
  --smallEventMarker: 3px;  						/* Event Marker size in pixels */
}

Notes on the colors above: You can use any colors you'd like. https://www.w3schools.com/cssref/css_colors.php is a list of accepted color names, or if you wanna make your own, https://www.w3schools.com/cssref/css_colors_legal.php. The above list is intended to be a sample, so I use different ways of doing legal colors. the "var" statements refer back to the master color list in Magic Mirror. You'll find a full list in main.css.

Screenshot How to get
screenshot monthsVertical: true,
repeatWeekdaysVertical: false,
weekNumbers: false,
screenshot monthsVertical: true,
repeatWeekdaysVertical: true,
weekNumbers: false,
screenshot monthsVertical: true,
repeatWeekdaysVertical: false,
weekNumbers: true,
screenshot monthsVertical: true,
repeatWeekdaysVertical: true,
weekNumbers: true,
screenshot monthsVertical: false,
weekNumbers: false,
screenshot monthsVertical: false,
weekNumbers: true,

Many thanks to kirash for the inspiration with the monthly_calendar module, sdetweil and lavolp3 for the help in coding and CSS work. Without your help, this would just be a pipe dream.

Please, if you have any suggestions for improvement, let me know, I'm learning JS and CSS as I write this, and I dream of much bigger things.

Language Localization is controlled by the master language of MagicMirror.

Update:

Simply issue the following command in the MMM-Multimonth folder:

    git pull

then restart your mirror.

Versioning

0.1 - Initial Release

0.2 - Change code to improve functionality, allow for some localization - will not move start of week yet, but will change languages with system.

0.25 - Fix code with temporary bodge so to refresh every hour to assure day changes sometime between midnight and 1 am.

0.3 - Removed bodge in 0.25, replaced with a simple refresh at midnight, no animation, as I find it annoying.

0.9 - Start of week now moves per moment.js. Note: at this point, module is almost everything I wanted. If I don't get any bug reports that I can control, I'm going to bump it up to 1.0 and call it good.

0.95 - Fix start of week issue. Had a calculation backwards. - Suggestion was made to optionally add week numbers to the system, still working on that.

0.99 - Major rewrite by Volker Wegert (Danke sehr!) - Implements everything I want, and I even understand the wizard level code he wrote.

1.00 - Minor changes to code/css to standardize look.

1.10 - Added leading and trailing months when 1 month is selected per user request.

1.20 - Added weekend highlight, default is off.

1.21 - Added weekend highlight for current day, so user could specify a different look for current day on weekend.

1.50 - Minor fixes

1.90 - Minor fixes/Remove EOL - Begin work on moving to a life without moment.js - Goal, no dependencies.

7 Sep 2022 - changing to date based versioning.

1 Oct 2022 - Completely removed moment.js from project. Returned to Beta Status due to lack of internationalization and start of week adjustments

4 Oct 2022 - Internationalization and Start of Week added back in. -- Note: I'm aware of a bug where the week numbers are showing an extra week. I'm redesigning the layout.

5 Oct 2022 - Fix bug in week numbers, fix extra week error.

12 Oct 2022 - Fix bug causing last day of month to fall off calendar if it's the same day as start of week.

24 Oct 2022 - Add config option for previous/next month display rather than forcing based on use.

29 Oct 2022 - Start Implementing streamlined CSS, add feature to move weekend around, documentation improvements.

4 Nov 2022 - Correct US/CA Week number calculation, add ISO calculation.

11 Nov 2022 - Changes:

  • Temporary disabled US/CA week numbers, routine isn't consistent. I'm gonna rework it. Regardless of how it's set, you will use ISO week numbers.
  • Rewrote javascript to match new knowledge, saving several lines of code and making more CSS sense.
  • added classes for future features, prepped more things for major future planned feature.
  • Streamlined CSS classes some more.
  • Due to changes, css class "current_day_weekend" is no longer supported. It does nothing.

26 Nov 2022 - Changes:

  • Added support for events from default calendar module.
  • Changed the following css elements: day, dim, weekend, current, event, settings.
  • Added new varable "--color-event" - which sets the color of the underline marking event on that day.

28 Nov 2022 - Added config option "eventsOn" to control event monitoring.

17 May 2023 - Added calNames - a way to control which calendars do what. Please see above.

16 Jul 2023 - Adjusted CSS to follow master font sizing from MagicMirror. Does not affect custom.css if used for this module.

18 Oct 2023 - Added CSS class "instanceID" to allow for more complex CSS. Yes, I'm still working on the module - just been busy. Added fontsize variable to defaults.

1 Dec 2023 - Basic changes to system to allow for a new feature (currently undocumented, need to go back through code to document due to being lazy and not writing down changes)

5 May 2024 - Fixed US Weeknumbers, among other bug fixes.

9 May 2024 - Adjusted README.md for new 3rd party list compatibility, plus capturing other changes.

8 Jun 2024 - MAJOR CSS re-write. Some values have changed, Some have been eliminated, some new.

18 Jun 2024 - Adjusted JS and CSS to make things line up better, found lots of little CSS bugs. Fully enabled color event handling.

mmm-multimonth's People

Contributors

bkeyport avatar kristjanesperanto avatar vwegert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mmm-multimonth's Issues

horizontal mode

For my setup, I need to have the months arranged horizontally left-to-right instead of vertically.

Beginning is posponed

Hey it is a really nice module !

But everytime my three months look always like your screenshot.
September starts on thursday and so on...
this needs to be fixed. And then its perfect.
Keep it up

Give weekends a style

Hi,

I already mentioned in on the forum, but again: this is a great module, thank you very much!
Overall I am very happy and styling with some CSS is good to do.
However here is one featurerequest:
May it be possible that the weekends get some extra-style? E.g. make the font-weight lower or so. On the classic wallcalenders the weekends have most time a bit different style, too.
I haven't seen a css-class I could use for that, therefore I believe when the grid is generated the saturday and sunday-days would need to get an extra css-class.
If that's already possible now please give me a hint.

regards

Nico

Drop Moment

It appears that moment.js is a dead project, and there is better modules for use. I'm gonna switch.

.

.

.

.

Spinster Request - Different colors for underline.

I have two calendars, one is my events calendar and the other is my holiday calendar. I want to have different color indications on the multimonth for the same. For example, I want to show my holiday calendar events similar to saturday and sundays format. Please suggest.

ISO 8601 Week number

The ISO 8601 standard defines week numbers using a Monday-based week (i.e. the week begins on Monday). Under this definition, the first week of the year is determined to be the first week that contains a Wednesday.

This means, then the calculation of the week number has to base on January 4th.
So the code should look like

const weekNumber = (dateObject) => {
	var fourJan = new Date(dateObject.getFullYear(),0,4);
	var numberOfDays = Math.floor((dateObject - fourJan) / (24 * 60 * 60 * 1000));
	var result = Math.ceil(( date.getDay() + 1 + numberOfDays) / 7);
	return result;
}

monthsVertical not working

Hi,

Thanks for this mm plugin. But it seems that monthsVertical: false doesnt work and I still get the months on vertical. I'm using the config from examples but changing this option. My config:

{
  module: 'MMM-Multimonth',
  position: 'bottom_bar', // can be any of the postions
  config: { // Optional - will default to 3 months, with one previous and one next, vertical orientation. 
      startMonth: -1, // Define when you start from current month (negative is before current, zero is current, positive is in future) 
      monthCount: 3, //  How many months to display - If Month Count is 1, Calendar will show previous and next month dates in empty spots.  
      // See screenshots for examples of the following config items. 
      monthsVertical: false, // Whether to arrange the months vertically (true) or horizontally (false).
      repeatWeekdaysVertical: false, // Whether to repeat the week days in each month in vertical mode. Ignored in horizontal mode.
      weekNumbers: false, // Whether to display the week numbers in front of each week.
      highlightWeekend: false, // Highlight Saturday and Sunday
    }
},

weekNumbers: true makes "UNDEFINED" output

Hi!

First of all thanks for maintaining the module!

I just updated MM and the modules, put the new options in but only got UNDEFINED shown at the modules position.
First I looked in the developer tools to see if my CSS has hidden something, but there wasn't anything in the site-source besides the UNDEFINED.
So I disabled all options and tried to enable one by one. As soon as I enable the weeknumbers it turns from showing the calendar to UNDEFINED.
Below is the current working config.
If you could look into that at some point it would be nice.

                {
                        module: 'MMM-Multimonth',
                        position: 'top_bar',
                        config: {
                                startMonth: -1,
                                monthCount: 3,
                                monthsVertical: false,
                                highlightWeekend: true,
                                repeatWeekdaysVertical: true,
//                              weekNumbers: true,
                                startWeek: 1,
                                headerType: 'short'
                        }
                },

Thanks again for the module!

Request

Add Week numbers to left of calendar, as requested by TheGardener88

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.