Skip to content

Commit

Permalink
Support for configuring FontAwesome class in calendar-module: (#2949)
Browse files Browse the repository at this point in the history
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=<some_uid>"
}
```
  • Loading branch information
MagMar94 authored Oct 16, 2022
1 parent 7bbf8c1 commit 835c893
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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;
},
Expand Down

0 comments on commit 835c893

Please sign in to comment.