From 835c893205a79eb8beb608df3d9ec7c9dca28149 Mon Sep 17 00:00:00 2001 From: Magnus <34011212+MagMar94@users.noreply.github.com> Date: Sun, 16 Oct 2022 21:48:57 +0200 Subject: [PATCH] Support for configuring FontAwesome class in calendar-module: (#2949) Some icons in FontAwesome, like the Facebook-logo, requires a different class than `fas fa-fw fa-`. Added support for specifying the `className`: ```js { symbol: "facebook-square", symbolClassName: "fab fa-", url: "https://www.facebook.com/events/ical/upcoming/?uid=" } ``` --- CHANGELOG.md | 1 + modules/default/calendar/calendar.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7628820d..3aae77d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Special thanks to: @rejas, @sdetweil - Correctly show apparent temperature in SMHI weather provider - Ensure updatenotification module isn't shown when local is _ahead_ of remote +- Possibility to change FontAwesome class in calendar, so icons like `fab fa-facebook-square` works. ## [2.21.0] - 2022-10-01 diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index b19dc62b..3694a216 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -14,6 +14,7 @@ Module.register("calendar", { limitDays: 0, // Limit the number of days shown, 0 = no limit displaySymbol: true, defaultSymbol: "calendar-alt", // Fontawesome Symbol see https://fontawesome.com/cheatsheet?from=io + defaultSymbolClassName: "fas fa-fw fa-", showLocation: false, displayRepeatingCountTitle: false, defaultRepeatingCountTitle: "", @@ -247,7 +248,7 @@ Module.register("calendar", { const symbols = this.symbolsForEvent(event); symbols.forEach((s, index) => { const symbol = document.createElement("span"); - symbol.className = "fas fa-fw fa-" + s; + symbol.className = s; if (index > 0) { symbol.style.paddingLeft = "5px"; } @@ -771,6 +772,11 @@ Module.register("calendar", { getCalendarPropertyAsArray: function (url, property, defaultValue) { let p = this.getCalendarProperty(url, property, defaultValue); + if (property === "symbol" || property === "recurringSymbol" || property === "fullDaySymbol") { + const className = this.getCalendarProperty(url, "symbolClassName", this.config.defaultSymbolClassName); + p = className + p; + } + if (!(p instanceof Array)) p = [p]; return p; },