@progressive-development/pd-calendar 0.1.15 → 0.1.17

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "progressive development calendar web component",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.1.15",
6
+ "version": "0.1.17",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
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
  *
@@ -148,7 +158,7 @@ export class PdCalendar extends LitElement {
148
158
  align-items: center;
149
159
  justify-content: center;
150
160
  background-color: var(--pd-calendar-week-title-bg-col, var(--pd-default-dark-col));
151
- font-size: 1em;
161
+ font-size: var(--pd-calendar-title-font-size, 1em);
152
162
  font-weight: bold;
153
163
  color: var(--pd-calendar-week-title-font-col, var(--pd-default-bg-col));
154
164
  font-family: var(--pd-default-font-title-family);
@@ -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
  }
@@ -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,10 +121,11 @@ class PdCalendarCell extends LitElement {
116
121
  }
117
122
 
118
123
  .cell-number {
119
- font-size: 1em;
124
+ pointer-events: none;
125
+ font-size: var(--pd-calendar-number-font-size, 1em);
120
126
  font-weight: bold;
121
127
  color: var(--pd-calendar-cell-day-info-col, var(--pd-default-bg-col));
122
- font-family: var(--pd-default-font-title-col);
128
+ font-family: var(--pd-default-font-content-family);
123
129
  }
124
130
 
125
131
  .cell-number.top-left {
@@ -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
- <div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
214
+
215
+ <div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
195
216
  </div>`;
196
217
  }
197
218