@progressive-development/pd-calendar 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/PdCalendar.js +15 -0
- package/src/PdCalendarCell.js +23 -2
package/package.json
CHANGED
package/src/PdCalendar.js
CHANGED
|
@@ -20,6 +20,16 @@ const VIEW_LIST = 1;
|
|
|
20
20
|
const VIEW_MONTH = 2;
|
|
21
21
|
const VIEW_WEEK = 3;
|
|
22
22
|
|
|
23
|
+
const isToday = (someDate) => {
|
|
24
|
+
if (!someDate) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const today = new Date()
|
|
28
|
+
return someDate.getDate() === today.getDate() &&
|
|
29
|
+
someDate.getMonth() === today.getMonth() &&
|
|
30
|
+
someDate.getFullYear() === today.getFullYear()
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
/**
|
|
24
34
|
* PdCalendar displays montly view with information (selectable day cell).
|
|
25
35
|
*
|
|
@@ -197,6 +207,10 @@ export class PdCalendar extends LitElement {
|
|
|
197
207
|
this._currentMonthNavNr += 1;
|
|
198
208
|
this._initFromDate(startDateNextMonth);
|
|
199
209
|
}
|
|
210
|
+
|
|
211
|
+
if (changedProperties.has("refDate") && this.refDate) {
|
|
212
|
+
this._initFromDate(this.refDate);
|
|
213
|
+
}
|
|
200
214
|
super.update(changedProperties);
|
|
201
215
|
}
|
|
202
216
|
|
|
@@ -256,6 +270,7 @@ export class PdCalendar extends LitElement {
|
|
|
256
270
|
?special="${special}"
|
|
257
271
|
numberClass="${this.numberClass}"
|
|
258
272
|
@select-date="${this._forwardEvent}"
|
|
273
|
+
?today="${this.selectableDates && isToday(tmpDate)}"
|
|
259
274
|
></pd-calendar-cell>
|
|
260
275
|
`);
|
|
261
276
|
}
|
package/src/PdCalendarCell.js
CHANGED
|
@@ -16,6 +16,11 @@ class PdCalendarCell extends LitElement {
|
|
|
16
16
|
*/
|
|
17
17
|
selectEnabled: { type: Boolean },
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* If enabled, highlight the current day
|
|
21
|
+
*/
|
|
22
|
+
today: { type: Boolean },
|
|
23
|
+
|
|
19
24
|
/**
|
|
20
25
|
* If enabled the cell gets an special class (e.g. green day).
|
|
21
26
|
*/
|
|
@@ -116,6 +121,7 @@ class PdCalendarCell extends LitElement {
|
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
.cell-number {
|
|
124
|
+
pointer-events: none;
|
|
119
125
|
font-size: 1em;
|
|
120
126
|
font-weight: bold;
|
|
121
127
|
color: var(--pd-calendar-cell-day-info-col, var(--pd-default-bg-col));
|
|
@@ -139,6 +145,15 @@ class PdCalendarCell extends LitElement {
|
|
|
139
145
|
color: var(--pd-calendar-cell-day-info-free-col, var(--pd-default-bg-col));
|
|
140
146
|
}
|
|
141
147
|
|
|
148
|
+
.today {
|
|
149
|
+
position: absolute;
|
|
150
|
+
height: 23px;
|
|
151
|
+
width: 23px;
|
|
152
|
+
border: 1px solid blue;
|
|
153
|
+
border-radius: 50%;
|
|
154
|
+
display: inline-block;
|
|
155
|
+
}
|
|
156
|
+
|
|
142
157
|
/* ToDo: Dont work for calendars sized by custom properties. Needed to calculate from calendar size
|
|
143
158
|
not from window size, this is a topic for container queries, which are not available right now... */
|
|
144
159
|
@media (max-width: 800px) {
|
|
@@ -173,10 +188,15 @@ class PdCalendarCell extends LitElement {
|
|
|
173
188
|
this.weekDayNumber === 0
|
|
174
189
|
? 'we'
|
|
175
190
|
: ''}"
|
|
176
|
-
>
|
|
191
|
+
>
|
|
177
192
|
${this.infoTxt
|
|
178
193
|
? html` <div class="cell-info">${this.infoTxt}</div>`
|
|
179
194
|
: ''}
|
|
195
|
+
|
|
196
|
+
${this.today
|
|
197
|
+
? html`<div class="today"></div>`
|
|
198
|
+
: ''}
|
|
199
|
+
|
|
180
200
|
<div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
|
|
181
201
|
</div>`;
|
|
182
202
|
}
|
|
@@ -191,7 +211,8 @@ class PdCalendarCell extends LitElement {
|
|
|
191
211
|
${this.infoTxt
|
|
192
212
|
? html`<div class="cell-info">${this.infoTxt}</div>`
|
|
193
213
|
: ''}
|
|
194
|
-
|
|
214
|
+
|
|
215
|
+
<div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
|
|
195
216
|
</div>`;
|
|
196
217
|
}
|
|
197
218
|
|