Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.

Commit 9e4b50c

Browse files
committed
bugfix, date added
1 parent 8684c2c commit 9e4b50c

5 files changed

Lines changed: 59 additions & 23 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# atomic calendar card v0.7.1
1+
# atomic calendar card v0.7.2
22
Advanced calendar card for Home Assistant with Lovelace
33

44
Calendar card with advanced settings. It loads calendar events from Home Assistant - Google calendar component.
@@ -35,7 +35,7 @@ If you have any suggestions about design or functionality, please let me know, o
3535

3636
## 1. Installation
3737
1. You need to have the ![Google calendar](https://www.home-assistant.io/components/calendar.google/) component configured in Home Assistant.
38-
2. Download `atomic-calendar.js` file to `/www` directory in your Home Assistant - [latest release](https://github.com/atomic7777/atomic_calendar/releases/download/v0.7.1/atomic-calendar.js) - link not working (in development)
38+
2. Download `atomic-calendar.js` file to `/www` directory in your Home Assistant - [latest release](https://github.com/atomic7777/atomic_calendar/releases/download/v0.7.2/atomic-calendar.js) - link not working (in development)
3939
3. Add this reference to your `ui-lovelace.yaml` file:
4040
```yaml
4141
resources:
@@ -60,6 +60,9 @@ If you have any suggestions about design or functionality, please let me know, o
6060
| showLocation | boolean | optional | v0.3.0 | `true` Show location link (right side)
6161
| showMonth | boolean | optional | v0.3.0 | `false` Show month under day (left side)
6262
| showLoader | boolean | optional | v0.7.0 | `true` Show animation, when events are being loaded from Google Calendar.
63+
| showDate | boolean | optional | v0.7.2 | `false` Show the date on the right side of the title
64+
| dateFormat | string | optional | v0.7.2 | `LL` Custom date format - see https://devhints.io/moment for examples
65+
6366

6467
### Text colors and fonts
6568
| Name | Type | Since | Description |

app.js

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class AtomicCalendar extends LitElement {
5656
})()
5757
}
5858

59-
var t0 = performance.now();
6059
if (this.modeToggle == 1)
6160
this.updateEventsHTML(this.events);
6261
else
@@ -70,8 +69,18 @@ class AtomicCalendar extends LitElement {
7069
<div class="cal-titleContainer">
7170
<div class="cal-title" @click='${e => this.handleToggle(e)}'>
7271
${this.config.title}
73-
</div>
74-
${(this.showLoader && this.config.showLoader) ? html`<div style="padding-top: 16px;padding-right: 16px;"><div class="loader" ></div> </div>` : ''}
72+
</div>
73+
74+
75+
${(this.showLoader && this.config.showLoader) ? html`
76+
<div class="loader" ></div>` : ''}
77+
78+
79+
<div class="calDate">
80+
${(this.config.showDate) ? this.getDate() : null}
81+
82+
</div>
83+
7584
</div>
7685
<div style="padding-top: 4px;">
7786
@@ -103,6 +112,7 @@ class AtomicCalendar extends LitElement {
103112
}
104113
.cal-title {
105114
font-size: var(--paper-font-headline_-_font-size);
115+
106116
color: var(--primary-text-color);
107117
padding: 4px 8px 12px 0px;
108118
line-height: 40px;
@@ -113,8 +123,24 @@ class AtomicCalendar extends LitElement {
113123
display: flex;
114124
flex-direction: row;
115125
justify-content: space-between;
126+
vertical-align: middle;
127+
align-items: center;
128+
margin: 0 8px 0 8px;
116129
}
117130
131+
132+
133+
.calDate {
134+
font-size: var(--paper-font-headline_-_font-size);
135+
font-size: 1.3rem;
136+
font-weight: 400;
137+
color: var(--primary-text-color);
138+
padding: 4px 8px 12px 0px;
139+
line-height: 40px;
140+
cursor: default;
141+
float:right;
142+
opacity: .75;
143+
}
118144
119145
table{
120146
color:black;
@@ -255,7 +281,7 @@ class AtomicCalendar extends LitElement {
255281
256282
257283
table.cal{
258-
color: ${this.config.titleColor}
284+
color: ${this.config.titleColor}
259285
margin-left: 0px;
260286
margin-right: 0px;
261287
border-spacing: 10px 5px;
@@ -293,17 +319,6 @@ class AtomicCalendar extends LitElement {
293319
padding: 4px;
294320
}
295321
296-
.calTitleContainer {
297-
display: flex;
298-
vertical-align: middle;
299-
align-items: center;
300-
justify-content: space-between;
301-
margin: 0 8px 0 8px;
302-
}
303-
304-
.calTitle {
305-
306-
}
307322
308323
.calTableContainer {
309324
width: 100%;
@@ -318,6 +333,8 @@ class AtomicCalendar extends LitElement {
318333
margin-left: -1px;
319334
}
320335
336+
337+
321338
.loader {
322339
border: 4px solid #f3f3f3;
323340
border-top: 4px solid grey;
@@ -340,6 +357,11 @@ class AtomicCalendar extends LitElement {
340357
341358
`
342359
}
360+
361+
getDate() {
362+
const date=moment().format(this.config.dateFormat)
363+
return html`${date}`
364+
}
343365

344366
setConfig(config) {
345367
if (!config.entities) {
@@ -360,7 +382,8 @@ class AtomicCalendar extends LitElement {
360382
showMonth: false, // show month under day (left side)
361383
fullTextTime: true, // show advanced time messages, like: All day, until Friday 12
362384
showCurrentEventLine: false, // show a line between last and next event
363-
385+
showDate: false,
386+
dateFormat: 'LL',
364387

365388
// color and font settings
366389
dateColor: 'var(--primary-text-color)', // Date text color (left side)
@@ -543,7 +566,7 @@ class AtomicCalendar extends LitElement {
543566
isEventNext) ? html `<div class="eventBar"><ha-icon icon="mdi:circle" class="event-circle"></ha-icon><hr class="event"/></div>` : ``
544567

545568
//show current event progress bar
546-
const progressBar = ``
569+
var progressBar = ``
547570
if (di == 0 && this.config.showProgressBar && event.isEventRunning) {
548571
let eventDuration = event.endTime.diff(event.startTime, 'minutes');
549572
let eventProgress = moment().diff(event.startTime, 'minutes');
@@ -552,10 +575,9 @@ class AtomicCalendar extends LitElement {
552575

553576
}
554577

555-
const finishedEventsStyle = (event.isEventFinished && this.config.dimFinishedEvents) ? `opacity: ` + this.config.finishedEventOpacity + `; filter: ` + this.config.finishedEventFilter : ``
578+
var finishedEventsStyle = (event.isEventFinished && this.config.dimFinishedEvents) ? `opacity: ` + this.config.finishedEventOpacity + `; filter: ` + this.config.finishedEventFilter : ``
556579

557580
const lastEventStyle = i == arr.length - 1 ? 'padding-bottom: 8px;' : ''
558-
559581
return html `
560582
561583
<tr class="${dayWrap}">
@@ -582,7 +604,7 @@ class AtomicCalendar extends LitElement {
582604
})
583605

584606
return htmlEvents
585-
})
607+
})
586608
this.content = html `<table><tbody>${htmlDays}</tbody></table>`
587609
}
588610

atomic-calendar.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"rollup": "^1.2.2",
3030
"rollup-plugin-commonjs": "^9.2.0",
3131
"rollup-plugin-node-resolve": "^4.0.0",
32+
"rollup-plugin-sourcemaps": "^0.4.2",
3233
"rollup-plugin-terser": "^4.0.4",
3334
"webpack": "^4.29.5",
3435
"webpack-cli": "^3.2.3",

0 commit comments

Comments
 (0)