Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option for Background Color and Font Colors for each calendar #155

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Custom Home Assistant card displaying a responsive overview of multiple days wit
| `hidePastEvents` | boolean | false | `false` \| `true` | Do not show past events | 1.3.0 |
| `hideDaysWithoutEvents` | boolean | false | `false` \| `true` | Do not show days without events, except for today | 1.4.0 |
| `filter` | string | optional | Any regular expression | Remove events that match the regular expression | 1.7.0 |
| `showLegend` | boolean | false | `false` \| `true` | Show event location in overview | 1.7.0 |

### Calendars

Expand All @@ -85,6 +86,9 @@ Custom Home Assistant card displaying a responsive overview of multiple days wit
| `entity` | string | **Required** | `calendar.my_calendar` | Entity ID | 1.0.0 |
| `name` | string | optional | Any text | Name of the calendar | 1.7.0 |
| `color` | string | optional | Any CSS color | Color used for events from the calendar | 1.0.0 |
| `background` | string | optional | Any CSS color | Background color used for events from the calendar | 1.8.0 |
| `primarytext` | string | optional | Any CSS color | Title color used for events from the calendar | 1.8.0 |
| `secondarytext` | string | optional | Any CSS color | Time color used for events from the calendar | 1.8.0 |

### Texts

Expand Down Expand Up @@ -158,9 +162,11 @@ calendars:
type: custom:week-planner-card
calendars:
- entity: calendar.my_calendar_1
color: '#e6c229'
color: rgba(230,194,41,0)
background: rgba(230,194,41,0.3)
- entity: calendar.my_calendar_2
color: '#1a8fe3'
color: rgba(26,143,227,1)
background: rgba(26,143,227,0.3)
weather:
entity: weather.my_weather_service
showTemperature: true
Expand Down
5 changes: 4 additions & 1 deletion src/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class WeekPlannerCard extends LitElement {
html`
${day.events.map((event) => {
return html`
<div class="event ${event.class}" data-entity="${event.calendar}" style="--border-color: ${event.color}" @click="${() => { this._handleEventClick(event) }}">
<div class="event ${event.class}" data-entity="${event.calendar}" style="--border-color: ${event.color}; --event-background-color: ${event.background}; --primary-text-color: ${event.primarytext}; --secondary-text-color: ${event.secondarytext}" @click="${() => { this._handleEventClick(event) }}">
<div class="time">
${event.fullDay ?
html`${this._language.fullDay}` :
Expand Down Expand Up @@ -563,6 +563,9 @@ export class WeekPlannerCard extends LitElement {
originalEnd: this._convertApiDate(event.end),
fullDay: fullDay,
color: calendar.color ?? 'inherit',
background: calendar.background ?? 'inherit',
primarytext: calendar.primarytext ?? 'inherit',
secondarytext: calendar.secondarytext ?? 'inherit',
calendar: calendar.entity,
calendarSorting: calendarSorting,
class: this._getEventClass(startDate, endDate, fullDay)
Expand Down
4 changes: 4 additions & 0 deletions src/card.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export default css`
margin: 0 0 3px 0;
}

.container .day .events .event .title {
color: var(--primary-text-color, ##212121);
}

.container .day .events .event .location {
margin: 3px 0 0 0;
--mdc-icon-size: var(--event-icon-size);
Expand Down