Skip to content

Commit d7b5c1f

Browse files
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.
1 parent 5839bda commit d7b5c1f

1 file changed

Lines changed: 3 additions & 28 deletions

File tree

docs/Filtering-and-Sorting.md

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ transform: (event) => {
9090
};
9191
```
9292

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.
9494
9595
# Icon Map
9696

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.
9898

9999
```js
100100
iconMap: {
@@ -106,33 +106,8 @@ iconMap: {
106106
}
107107
```
108108

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-
113109
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.
114110

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.
116112

117113
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-
const iconMap = {
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] of Object.entries(iconMap)) {
131-
if (event.categories.includes(category)) {
132-
event.icon = icon;
133-
break;
134-
}
135-
}
136-
return event;
137-
};
138-
```

0 commit comments

Comments
 (0)