Skip to content

MagicMirror² module to display what page you're on.

License

Notifications You must be signed in to change notification settings

edward-shen/MMM-page-indicator

Repository files navigation

MMM-page-indicator

Screenshot

This MagicMirror² Module is designed to indicate what "page" you are looking at. This module is designed to be an indicator only. By itself, it only offers a basic way to change the page, by clicking on the circle indicative of the page you wish to change to.

Project Status

This module is in maintenance mode. It is a small but mature and does what it is supposed to do.

We will be keeping this module compatible with the latest version of MagicMirror², but we don't plan to add any new features or make any major changes to the codebase.

If you have any issues or bugs, please feel free to open an issue.

Installation

In your terminal, go to your MagicMirror's module directory and clone this repository:

cd ~/MagicMirror/modules
git clone https://github.com/edward-shen/MMM-page-indicator

Update

Just enter the module's directory, pull the update and install the dependencies:

cd ~/MagicMirror/modules/MMM-page-indicator
git pull

Configuration

To use this module, add it to the modules array in the config/config.js file:

    {
        module: 'MMM-page-indicator',
        position: 'bottom_bar',
        config: {
            pages: 3,
        }
    },

Configuration options

Option Description
pages Number of pages that you have.
Expected Value type: int.
activeBright Should the active circle be bright.
Expected Value type: boolean.
inactiveDimmed Should the inactive circles be dimmed?
Expected Value type: boolean.
inactiveHollow Should the inactive circles be hollow?
Expected Value type: boolean.
showPageNumberOnHover Should the page number be shown on hover?
Expected Value type: boolean.

Styling

With the CSS classes active-page and page-{i} you can easily style the page indicators. The active-page class is applied to the currently active page indicator, while the page-{i} class is applied to the page indicator of page number i. This allows you to change the color, icon and other properties of the indicators.

Without styling, the indicators will look like this:

screencast 1

Below are some styling examples. Just add them to your custom.css file to test them on your system. With CSS you can do a lot of things, so feel free to experiment with the styles.

Example: Changing the icon of a page indicator

You can assign a different icon per page indicator. This example sets the page 2 indicator to a orange star.

screencast 2

Click to see the CSS
.MMM-page-indicator .page-2::before {
    color: orange;
    content:"⭐";
}

Example: Animating the active page indicator

This example extends the one above and adds a pulsing effect to the active page indicator.

screencast 3

Click to see the CSS
.MMM-page-indicator .page-2::before {
    color: orange;
    content:"⭐";
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.MMM-page-indicator .active-page {
    animation: pulse 1.2s ease-in-out infinite;
}

Example: Adding description text to the page indicators

This is an advanced example which adds a description text to the page indicators and changes every indicator to a different icon.

screencast 4

Click to see the CSS
.MMM-page-indicator .indicator::before {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-emoji: text;
  line-height: 1.6;
  letter-spacing: 0.2rem;
  white-space: pre;
  padding: 0px 15px;
}

.MMM-page-indicator .page-0::before {
    content:"🏠 \A Home";
}

.MMM-page-indicator .page-1::before {
    content:"📅 \A Calendar";
}

.MMM-page-indicator .page-2::before {
    content:"⭐ \A News";
}

.MMM-page-indicator .page-3::before {
    content:"⛅ \A Weather";
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.MMM-page-indicator .active-page {
    color: orange;
    font-variant-emoji: text;
    animation: pulse 5s ease-in-out infinite;
}

Sending notifications to the module

This module responds to the notification PAGE_CHANGED. The payload should be an integer. Note that this has strict error checking, so "3" will not work, while 3 will. Also do note that to switch to page 1, you need to send 0 to the module. This uses a zero-based numbering system.

Let's say that you want to change the indicator to page 3. In your code, you would write:

this.sendNotification("PAGE_CHANGED", 2);

This would cause the module to change show that you are on page 3.

If you wish to change the number of pages, you need to send a MAX_PAGES_CHANGED notification with your payload as an integer.

this.sendNotification("MAX_PAGES_CHANGED", 4);

This would now show that there are now 4 pages to display.

You can also just send PAGE_INCREMENT or PAGE_DECREMENT without any payloads to have the module change the displayed page by one. If you are using MMM-pages with this module, sending an integer as a payload for a PAGE_INCREMENT or PAGE_DECREMENT notification will perform as described in the MMM-pages documentation. If you are not using MMM-pages, the indicator will ignore the payload and just change the displayed page by one.

FAQ

  • Help! My module is (above/below) another module in the same region but I want it to be somewhere else!

    The order of your config.js determines your module location. If you have two modules, both with position:bottom_bar, the one that is first listed will appear on top. The rest will appear in the same order you defined them in. If you want this module to be at the very bottom, define this module as the last module in your config.js file. If you want it to be on top in that region, make sure no other module is defined before it that has the same region.

  • Can I make a pull request?

    Please do! I'd love for this to be integrated in many modules!

  • I want more config options!

    Please make an issue. Thanks!

Developer commands

  • npm install - Install dependencies for development.
  • node --run lint - Run linting checks.
  • node --run lint:fix - Fix linting issues.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

All notable changes to this project will be documented in the CHANGELOG file.

About

MagicMirror² module to display what page you're on.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published