You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: fix transform note and clean up iconMap section
The transform note overstated the limitation — transform works in
browser setups too, as long as it doesn't reference helpers defined
outside config. Updated it to explain the actual pitfall and the
config.myHelper() workaround. Also removed a duplicate paragraph
and an outdated code example.
Copy file name to clipboardExpand all lines: docs/Filtering-and-Sorting.md
+3-28Lines changed: 3 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,11 +90,11 @@ transform: (event) => {
90
90
};
91
91
```
92
92
93
-
> **Note:** MagicMirror² fetches the module config from the server as JSON, which means **JavaScript functions in the config are lost** at runtime. The `transform` function only works when the config is loaded directly (e.g., Electron mode with a local `config.js` evaluated in-process). For standard browser-based setups, use`iconMap`instead.
93
+
> **Note:**Since MagicMirror² v2.35, the config is delivered to the browser via JSON. In browser-based setups, callback functions can break when they depend on symbols outside the serialized config scope (for example, standalone helper functions declared outside `let config = {}`). Keep `transform` self-contained or reference helpers through `config.myHelper(event)`. For icon assignment by category, prefer`iconMap`because it is plain data and works in all setups.
94
94
95
95
# Icon Map
96
96
97
-
The `iconMap` view option assigns icons to events based on their categories. Unlike `transform`, it uses a plain object (string → string mapping) that survives JSON serialization.
97
+
The `iconMap` view option assigns icons to events based on their categories. Unlike `transform`, it is plain data (string → string mapping), survives JSON serialization, and works in all MagicMirror² setups.
98
98
99
99
```js
100
100
iconMap: {
@@ -106,33 +106,8 @@ iconMap: {
106
106
}
107
107
```
108
108
109
-
Icon names use the format `prefix:name` (e.g. `noto:hospital`, `mdi:home`). The old
110
-
`prefix-name` format (e.g. `noto-hospital`) is still accepted but will log a
111
-
deprecation warning in the browser console.
112
-
113
109
Icon names use the `prefix:name` format from [Iconify](https://icon-sets.iconify.design/) (e.g. `noto:hospital`, `mdi:home`). For backwards compatibility, the legacy `prefix-name` format (e.g. `noto-hospital`) is automatically converted.
114
110
115
-
For each event, the module checks `event.categories` (in order) against the keys of `iconMap`. The first match sets `event.icon`. If the event already has an icon set (e.g., by`transform`), `iconMap` does not override it.
111
+
For each event, the module checks `event.categories` (in order) against the keys of `iconMap`. The first match sets `event.icon`. If the event already has an icon set (for example from calendar config defaults or`transform`), `iconMap` does not override it.
116
112
117
113
For `categories` to be populated, the iCal event must include a `CATEGORIES` property. See [Event-Object.md](Event-Object.md) for the full event shape.
118
-
119
-
You can also use `categories` with `transform` to assign icons, which is the older approach:
120
-
121
-
```js
122
-
transform: (event) => {
123
-
consticonMap= {
124
-
Birthday:"fxemoji:birthdaycake",
125
-
Health:"noto:hospital",
126
-
Work:"noto:briefcase",
127
-
Vacation:"noto:beach-with-umbrella",
128
-
Family:"noto:family"
129
-
};
130
-
for (const [category, icon] ofObject.entries(iconMap)) {
0 commit comments