@progressive-development/pd-calendar 0.0.10 → 0.0.12

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.0.10",
6
+ "version": "0.0.12",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
package/src/PdCalendar.js CHANGED
@@ -4,9 +4,11 @@
4
4
  */
5
5
 
6
6
  import { LitElement, html, css } from 'lit';
7
- import { format, parse } from 'fecha';
7
+ import { format } from 'fecha';
8
8
  import '@progressive-development/pd-icon/pd-icon.js';
9
9
 
10
+ import './PdCalendarCell.js';
11
+
10
12
  // todo: use existing shortnames for locale here
11
13
  const weekDays = ['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'];
12
14
 
@@ -33,28 +35,38 @@ export class PdCalendar extends LitElement {
33
35
  * @event select-date
34
36
  */
35
37
 
38
+ static get properties() {
39
+ return {
40
+ refDate: { type: Object },
41
+ prevMonthConstraint: { type: Number },
42
+ nextMonthConstraint: { type: Number },
43
+ data: { type: Object },
44
+
45
+ /**
46
+ * CSS class for day number inside the cell, top-left and center available
47
+ */
48
+ numberClass: { type: String },
49
+
50
+ _currentDate: { type: Object },
51
+ _viewType: { type: Number },
52
+ _latestDate: { type: Object },
53
+ _earliestDate: { type: Object },
54
+ };
55
+ }
56
+
36
57
  static get styles() {
37
58
  return css`
38
59
  :host {
39
60
 
40
61
  /* Define custom properties for calendar element */
41
62
  --my-title-color: var(--squi-title-color, #084c61);
42
- --my-day-title-bg-color: var(--squi-title-color, #084c61);
43
- --my-cell-bg-color: var(--squi-title-color, lightgrey);
44
- --my-cell-we-bg-color: var(--squi-title-color, darkgrey);
45
- --my-cell-day-color: var(--squi-title-color, #fefefe);
46
-
47
- --my-info-cell-bg1-color: var(--squi-title-color, #177e89);
48
- --my-info-cell-bg2-color: var(--squi-title-color, #084c61);
49
- --my-info-cell-day-color: var(--squi-title-color, #fefefe);
50
-
51
- --my-info-cell-bg1-hover: var(--squi-highlight-color, #ffc857);
52
- --my-info-cell-bg2-hover: var(--squi-highlight-color, #177e89);
53
-
54
- --my-info-txt-color: var(--squi-info-txt, #fefefe);
55
-
63
+ --my-day-title-bg-color: var(--squi-title-color, #084c61);
64
+
56
65
  --my-primary-font: var(--squi-primary-font, Oswald);
57
66
 
67
+ --my-width: var(--pd-calendar-width, 100%);
68
+ --my-cell-height: var(--pd-calendar-cell-height, 70px);
69
+
58
70
  display: block;
59
71
  /*padding: 8px;
60
72
  width: 100vw;
@@ -63,6 +75,8 @@ export class PdCalendar extends LitElement {
63
75
 
64
76
  /* Layout Grid for the Calendar Component => Not really needed at the moment, more a test */
65
77
  .layout-container {
78
+ width: var(--my-width);
79
+ min-width: 220px;
66
80
  height: 100%;
67
81
  display: grid;
68
82
  grid-template-columns: 1fr 1fr 1fr;
@@ -80,12 +94,18 @@ export class PdCalendar extends LitElement {
80
94
 
81
95
  font-family: var(--my-primary-font);
82
96
  color: var(--my-title-color);
97
+
98
+ display: flex;
99
+ justify-content: left;
83
100
  }
84
101
 
85
102
  .header-main {
103
+ display: flex;
104
+ /* Nun über display flex in header und justify-content gelöst
86
105
  position: absolute;
106
+ top: 50%;
87
107
  left: 30%;
88
- display: flex;
108
+ transform: translate(0, -50%);*/
89
109
  }
90
110
 
91
111
  .header-icons {
@@ -110,11 +130,11 @@ export class PdCalendar extends LitElement {
110
130
  }
111
131
 
112
132
  .grid-container.max {
113
- grid-template-rows: minmax(10px, 30px) repeat(6, minmax(70px, 1fr));
133
+ grid-template-rows: minmax(10px, 30px) repeat(6, minmax(var(--my-cell-height), 1fr));
114
134
  }
115
135
 
116
136
  .grid-container.normal {
117
- grid-template-rows: minmax(10px, 30px) repeat(5, minmax(70px, 1fr));
137
+ grid-template-rows: minmax(10px, 30px) repeat(5, minmax(var(--my-cell-height), 1fr));
118
138
  }
119
139
 
120
140
  .title-week-day {
@@ -127,49 +147,6 @@ export class PdCalendar extends LitElement {
127
147
  font-family: var(--my-primary-font);
128
148
  }
129
149
 
130
- .cell {
131
- text-align: center;
132
- }
133
-
134
- .cell-empty {
135
- background-color: #fdfbfb;
136
- }
137
-
138
- .cell-day {
139
- position: relative;
140
- /*background-image: linear-gradient(to right, rgb(51, 101, 138) , rgb(38, 76, 104)); */
141
- /*box-shadow: 2px 2px 3px;*/
142
- background-color: var(--my-cell-bg-color);
143
- /*border-radius: 2px 2px 2px 2px;*/
144
- }
145
-
146
- .cell-day.we {
147
- background-color: var(--my-cell-we-bg-color);
148
- }
149
-
150
- .free {
151
- /*background-image: linear-gradient(to right, green, darkgreen);
152
- background-color: var(--my-info-cell-bg1-color);*/
153
- background-color: var(--my-info-cell-bg1-color);
154
- /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
155
- box-shadow: 1px 2px 2px;
156
- }
157
-
158
- .special {
159
- /*background-image: linear-gradient(to right, green, darkgreen);
160
- background-color: var(--my-info-cell-bg1-color);*/
161
- background-color: var(--green, green); /*#1da692*/
162
- /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
163
- box-shadow: 1px 2px 2px;
164
- }
165
-
166
- .special:hover,
167
- .free:hover {
168
- background-color: rgb(247, 211, 8);
169
- /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-hover), var(--my-info-cell-bg2-hover));*/
170
- cursor: pointer;
171
- }
172
-
173
150
  span.content-title {
174
151
  font-weight: bold;
175
152
  font-size: 1.5em;
@@ -179,54 +156,12 @@ export class PdCalendar extends LitElement {
179
156
 
180
157
  span.content-sub-title {
181
158
  position: absolute;
182
- left: 0px;
159
+ right: 1px;
183
160
  bottom: 0px;
184
161
  font-size: 1.2em;
185
162
  font-weight: bold;
186
163
  }
187
164
 
188
- span.cell-info {
189
- position: absolute;
190
- left: 35%;
191
- top: 30%;
192
- color: var(--my-info-txt-color);
193
- font-family: var(--my-primary-font);
194
- font-weight: bold;
195
- font-size: 1.5em;
196
- text-shadow: 1px 1px black;
197
- pointer-events: none;
198
- }
199
-
200
- span.cell-number {
201
- position: absolute;
202
- left: 3px;
203
- top: 1px;
204
- font-size: 0.9em;
205
- color: var(--my-cell-day-color);
206
- font-family: var(--my-primary-font);
207
- }
208
-
209
- .free .cell-number {
210
- color: var(--my-info-cell-day-color);
211
- }
212
-
213
- @media (max-width: 800px) {
214
- span.cell-info {
215
- left: 30%;
216
- font-size: 1.3em;
217
- }
218
- span.cell-number {
219
- font-size: 0.7em;
220
- }
221
- }
222
- @media (max-width: 500px) {
223
- span.cell-info {
224
- left: 15%;
225
- font-weight: normal;
226
- font-size: 1em;
227
- }
228
- }
229
-
230
165
  .arrow {
231
166
  /* Hack */
232
167
  padding-top: 8px;
@@ -237,36 +172,23 @@ export class PdCalendar extends LitElement {
237
172
  `;
238
173
  }
239
174
 
240
- static get properties() {
241
- return {
242
- currentDate: { type: Object },
243
- prevMonthConstraint: { type: Number },
244
- nextMonthConstraint: { type: Number },
245
- data: { type: Object },
246
- _viewType: { type: Number },
247
- _latestDate: { type: Object },
248
- _earliestDate: { type: Object },
249
- };
250
- }
251
-
252
175
  constructor() {
253
176
  super();
254
177
 
255
178
  this.data = {};
256
179
  this._viewType = VIEW_MONTH;
257
-
258
- // initialize date values with current date
259
- const now = new Date();
260
- this._initFromDate(now);
180
+ this.numberClass = "top-left";
261
181
  }
262
182
 
263
- firstUpdated() {
183
+ connectedCallback() {
184
+ super.connectedCallback();
185
+
264
186
  // get latest possible date
265
- if (this.nextMonthConstraint >= 0) {
266
- const now = new Date();
187
+ const ref = this.refDate || new Date();
188
+ if (this.nextMonthConstraint >= 0) {
267
189
  const tmpDate = new Date(
268
- now.getFullYear(),
269
- now.getMonth() + 1,
190
+ ref.getFullYear(),
191
+ ref.getMonth() + 1,
270
192
  0
271
193
  );
272
194
  tmpDate.setMonth(tmpDate.getMonth() + (this.nextMonthConstraint - 1));
@@ -275,15 +197,17 @@ export class PdCalendar extends LitElement {
275
197
 
276
198
  // get earliest possible date
277
199
  if (this.prevMonthConstraint >= 0) {
278
- const now = new Date();
279
200
  const tmpDate = new Date(
280
- now.getFullYear(),
281
- now.getMonth() + 1,
201
+ ref.getFullYear(),
202
+ ref.getMonth() + 1,
282
203
  0
283
204
  );
284
205
  tmpDate.setMonth(tmpDate.getMonth() - (this.prevMonthConstraint));
285
206
  this._earliestDate = tmpDate;
286
207
  }
208
+
209
+ // initialize date values with current date
210
+ this._initFromDate(ref);
287
211
  }
288
212
 
289
213
  render() {
@@ -321,37 +245,24 @@ export class PdCalendar extends LitElement {
321
245
  ? 'max'
322
246
  : 'normal';
323
247
  for (let i = 1; i <= this._numberOfDays; i += 1) {
324
- const tmpDate = new Date(this._year, this.currentDate.getMonth(), i);
248
+ const tmpDate = new Date(this._year, this._currentDate.getMonth(), i);
325
249
  const key = format(tmpDate, 'YYYY-MM-DD');
326
250
  // TODO => Array / Unit Thema... hier fest auf 0 zugegriffen zunächst
327
- const infoTxt = this.data[key] ? this.data[key][0].info : '';
251
+ const infoTxt = this.data[key] ? this.data[key][0].info : undefined;
328
252
  const special = this.data[key]
329
253
  ? this.data[key][0].special || false
330
254
  : false;
331
- if (infoTxt) {
332
255
  itemTemplates.push(html`
333
- <div
334
- @keypress="${this._freeDateClicked}"
335
- @click="${this._freeDateClicked}"
336
- data-date="${key}"
337
- class="cell cell-day ${special ? 'special' : 'free'}"
338
- >
339
- <span class="cell-info">${infoTxt}*</span>
340
- <span class="cell-number">${i}</span>
341
- </div>
256
+ <pd-calendar-cell
257
+ key="${key}"
258
+ dayNumber="${i}"
259
+ weekDayNumber="${tmpDate.getDay()}"
260
+ infoTxt="${infoTxt}"
261
+ ?selectEnabled="${infoTxt !== undefined}"
262
+ ?special="${special}"
263
+ numberClass="${this.numberClass}"
264
+ ></pd-calendar-cell>
342
265
  `);
343
- } else {
344
- itemTemplates.push(html`
345
- <div
346
- class="cell cell-day ${tmpDate.getDay() === 6 ||
347
- tmpDate.getDay() === 0
348
- ? 'we'
349
- : ''}"
350
- >
351
- <span class="cell-number">${i}</span>
352
- </div>
353
- `);
354
- }
355
266
  }
356
267
 
357
268
  return html`
@@ -391,27 +302,11 @@ export class PdCalendar extends LitElement {
391
302
  `;
392
303
  }
393
304
 
394
- _freeDateClicked(e) {
395
- const dateKey = e.target.dataset.date;
396
- if (dateKey) {
397
- // convert back to date
398
- const userSelectedDate = parse(dateKey, 'YYYY-MM-DD');
399
- this.dispatchEvent(
400
- new CustomEvent('select-date', {
401
- detail: {
402
- dateKey,
403
- date: userSelectedDate,
404
- },
405
- })
406
- );
407
- }
408
- }
409
-
410
305
  _nextMonth() {
411
306
  if (this._checkNextMonthConstraint()) {
412
307
  const newDate = new Date(
413
- this.currentDate.getFullYear(),
414
- this.currentDate.getMonth(),
308
+ this._currentDate.getFullYear(),
309
+ this._currentDate.getMonth(),
415
310
  1
416
311
  );
417
312
  newDate.setMonth(newDate.getMonth() + 1);
@@ -429,8 +324,8 @@ export class PdCalendar extends LitElement {
429
324
  _previousMonth() {
430
325
  if (this._checkPrevMonthConstraint()) {
431
326
  const newDate = new Date(
432
- this.currentDate.getFullYear(),
433
- this.currentDate.getMonth(),
327
+ this._currentDate.getFullYear(),
328
+ this._currentDate.getMonth(),
434
329
  1
435
330
  );
436
331
  newDate.setMonth(newDate.getMonth() - 1);
@@ -446,13 +341,16 @@ export class PdCalendar extends LitElement {
446
341
  }
447
342
 
448
343
  _initFromDate(date) {
344
+
345
+ console.log("Init date with: ", date);
346
+
449
347
  this._monthName = date.toLocaleString('default', { month: 'long' });
450
348
  this._year = date.getFullYear();
451
349
  this._daysFromPreviousMonth = PdCalendar._getPreviousMonthDays(date);
452
350
  // last month day
453
351
  const newDate2 = new Date(date.getFullYear(), date.getMonth() + 1, 0);
454
352
  this._numberOfDays = newDate2.getDate();
455
- this.currentDate = date;
353
+ this._currentDate = date;
456
354
  }
457
355
 
458
356
  static _getPreviousMonthDays(date) {
@@ -473,14 +371,14 @@ export class PdCalendar extends LitElement {
473
371
 
474
372
  _checkNextMonthConstraint() {
475
373
  if (this._latestDate) {
476
- return this.currentDate < this._latestDate;
374
+ return this._currentDate < this._latestDate;
477
375
  }
478
376
  return true;
479
377
  }
480
378
 
481
379
  _checkPrevMonthConstraint() {
482
380
  if (this._earliestDate) {
483
- return this.currentDate > this._earliestDate;
381
+ return this._currentDate > this._earliestDate;
484
382
  }
485
383
  return true;
486
384
  }
@@ -0,0 +1,225 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { parse } from 'fecha';
3
+
4
+ class PdCalendarCell extends LitElement {
5
+ /**
6
+ * @event select-date - fires when user clicks on a selectable cell.
7
+ */
8
+
9
+ static get properties() {
10
+ return {
11
+ /**
12
+ * If enabled, cell could be selected (with visible hover element and pointer)
13
+ * vy the user => results in fire cell-selected.
14
+ */
15
+ selectEnabled: { type: Boolean },
16
+
17
+ /**
18
+ * If enabled the cell gets an special class (e.g. green day).
19
+ */
20
+ special: { type: Boolean },
21
+
22
+ /**
23
+ * If set shows info text in the middle (hack) of the cell (e.g. price info).
24
+ */
25
+ infoTxt: { type: String },
26
+
27
+ /**
28
+ * CSS class for day number inside the cell, top-left and center available
29
+ */
30
+ numberClass: { type: String },
31
+
32
+ /* key, weekDayNumber, dayNumber could merged to date
33
+ on the other hand then there is the need to calculate them for each cell... */
34
+ key: { type: String },
35
+ weekDayNumber: { type: Number },
36
+ dayNumber: { type: Number },
37
+ };
38
+ }
39
+
40
+ static get styles() {
41
+ return css`
42
+ :host {
43
+ display: block;
44
+
45
+
46
+ /* Define custom properties for calendar cell element */
47
+ --my-cell-bg-color: var(--squi-title-color, lightgrey);
48
+ --my-cell-we-bg-color: var(--squi-title-color, darkgrey);
49
+ --my-cell-day-color: var(--squi-title-color, #fefefe);
50
+
51
+ --my-info-cell-bg1-color: var(--squi-title-color, #177e89);
52
+ --my-info-cell-day-color: var(--squi-title-color, #fefefe);
53
+ --my-info-txt-color: var(--squi-info-txt, #fefefe);
54
+ /* Defined by PdCalendar and also setted here
55
+ --my-primary-font: var(--squi-primary-font, Oswald);*/
56
+
57
+ /* not used in the moment, was created for gradient cells
58
+ --my-info-cell-bg2-color: var(--squi-title-color, #084c61);
59
+ --my-info-cell-bg1-hover: var(--squi-highlight-color, #ffc857);
60
+ --my-info-cell-bg2-hover: var(--squi-highlight-color, #177e89);
61
+ */
62
+ }
63
+
64
+ .cell {
65
+ width: 100%;
66
+ height: 100%;
67
+ min-height: 30px;
68
+ }
69
+
70
+ .cell-empty {
71
+ background-color: #fdfbfb;
72
+ }
73
+
74
+ .cell-day {
75
+ position: relative;
76
+ /*background-image: linear-gradient(to right, rgb(51, 101, 138) , rgb(38, 76, 104)); */
77
+ /*box-shadow: 2px 2px 3px;*/
78
+ background-color: var(--my-cell-bg-color);
79
+ /*border-radius: 2px 2px 2px 2px;*/
80
+ }
81
+
82
+ .cell-day.we {
83
+ background-color: var(--my-cell-we-bg-color);
84
+ }
85
+
86
+ .free {
87
+ /*background-image: linear-gradient(to right, green, darkgreen);
88
+ background-color: var(--my-info-cell-bg1-color);*/
89
+ background-color: var(--my-info-cell-bg1-color);
90
+ /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
91
+ box-shadow: 1px 2px 2px;
92
+ }
93
+
94
+ .special {
95
+ /*background-image: linear-gradient(to right, green, darkgreen);
96
+ background-color: var(--my-info-cell-bg1-color);*/
97
+ background-color: var(--green, green); /*#1da692*/
98
+ /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
99
+ box-shadow: 1px 2px 2px;
100
+ }
101
+
102
+ .special:hover,
103
+ .free:hover {
104
+ background-color: rgb(247, 211, 8);
105
+ /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-hover), var(--my-info-cell-bg2-hover));*/
106
+ cursor: pointer;
107
+ }
108
+
109
+
110
+ .cell-info {
111
+
112
+ /* center position https://www.w3.org/Style/Examples/007/center.en.html*/
113
+ position: absolute;
114
+ top: 50%;
115
+ left: 35%;
116
+ transform: translate(0, -50%);
117
+
118
+ color: var(--my-info-txt-color);
119
+ font-family: var(--my-primary-font);
120
+ font-weight: bold;
121
+ font-size: 1.5em;
122
+ text-shadow: 1px 1px black;
123
+ pointer-events: none;
124
+ }
125
+
126
+ .cell-number {
127
+ position: absolute;
128
+ font-size: 0.9em;
129
+ color: var(--my-cell-day-color);
130
+ font-family: var(--my-primary-font);
131
+ }
132
+
133
+ .cell-number.top-left {
134
+ left: 3px;
135
+ top: 1px;
136
+ }
137
+
138
+ .cell-number.center {
139
+ top: 50%;
140
+ left: 30%;
141
+ transform: translate(0, -50%);
142
+ }
143
+
144
+ .free .cell-number {
145
+ color: var(--my-info-cell-day-color);
146
+ }
147
+
148
+ /* ToDo: Dont work for calendars sized by custom properties. Needed to calculate from calendar size
149
+ not from window size, this is a topic for container queries, which are not available right now... */
150
+ @media (max-width: 800px) {
151
+ .cell-info {
152
+ left: 30%;
153
+ font-size: 1.3em;
154
+ }
155
+ .cell-number {
156
+ font-size: 0.7em;
157
+ }
158
+ }
159
+ @media (max-width: 500px) {
160
+ .cell-info {
161
+ left: 15%;
162
+ font-weight: normal;
163
+ font-size: 1em;
164
+ }
165
+ }
166
+ `;
167
+ }
168
+
169
+ constructor() {
170
+ super();
171
+ this.numberClass = "top-left";
172
+ }
173
+
174
+ _renderSelectableCell() {
175
+ return html` <div
176
+ @keypress="${this._selectableCellClicked}"
177
+ @click="${this._selectableCellClicked}"
178
+ data-date="${this.key}"
179
+ class="cell cell-day ${this.special ? 'special' : 'free'}"
180
+ >
181
+ ${this.infoTxt
182
+ ? html` <div class="cell-info">${this.infoTxt}</div>`
183
+ : ''}
184
+ <div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
185
+ </div>`;
186
+ }
187
+
188
+ _renderEmptyCell() {
189
+ return html`<div
190
+ class="cell cell-day top-left ${this.weekDayNumber === 6 ||
191
+ this.weekDayNumber === 0
192
+ ? 'we'
193
+ : ''}"
194
+ >
195
+ ${this.infoTxt
196
+ ? html`<div class="cell-info">${this.infoTxt}</div>`
197
+ : ''}
198
+ <div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
199
+ </div>`;
200
+ }
201
+
202
+ render() {
203
+ return this.selectEnabled
204
+ ? this._renderSelectableCell()
205
+ : this._renderEmptyCell();
206
+ }
207
+
208
+ _selectableCellClicked(e) {
209
+ const dateKey = e.target.dataset.date;
210
+ if (dateKey) {
211
+ // convert back to date
212
+ const userSelectedDate = parse(dateKey, 'YYYY-MM-DD');
213
+ this.dispatchEvent(
214
+ new CustomEvent('select-date', {
215
+ detail: {
216
+ dateKey,
217
+ date: userSelectedDate,
218
+ },
219
+ })
220
+ );
221
+ }
222
+ }
223
+ }
224
+
225
+ window.customElements.define('pd-calendar-cell', PdCalendarCell);
@@ -0,0 +1,57 @@
1
+ import { html } from 'lit';
2
+ import '../src/PdCalendarCell.js';
3
+
4
+ export default {
5
+ title: 'PdCalendar/CalendarCell',
6
+ component: 'pd-calendar-cell',
7
+ argTypes: {
8
+ },
9
+ };
10
+
11
+ function CalendarCellTemplate({infoTxt}) {
12
+ return html`
13
+
14
+ <div style="max-width: 400px;">
15
+
16
+ <pd-calendar-cell
17
+ key="2021-11-13"
18
+ dayNumber="13"
19
+ weekDayNumber="5"
20
+ infoTxt="Selectable"
21
+ selectEnabled
22
+ ></pd-calendar-cell>
23
+
24
+ <pd-calendar-cell
25
+ key="2021-11-14"
26
+ dayNumber="14"
27
+ weekDayNumber="6"
28
+ infoTxt="${infoTxt}"
29
+ selectEnabled
30
+ special
31
+ ></pd-calendar-cell>
32
+
33
+ <pd-calendar-cell
34
+ key="2021-11-15"
35
+ dayNumber="15"
36
+ weekDayNumber="1"
37
+ infoTxt="Empty"
38
+ ></pd-calendar-cell>
39
+
40
+ <pd-calendar-cell
41
+ key="2021-11-20"
42
+ dayNumber="20"
43
+ weekDayNumber="6"
44
+ infoTxt="Weekend"
45
+ ></pd-calendar-cell>
46
+
47
+ </div>`;
48
+ }
49
+
50
+ export const Basic = CalendarCellTemplate.bind({});
51
+ Basic.args = {
52
+ key: '2021-11-18',
53
+ dayNumber: 18,
54
+ weekDayNumber: 3,
55
+ infoTxt: "Special",
56
+ special: true
57
+ };
@@ -9,13 +9,27 @@ export default {
9
9
  },
10
10
  };
11
11
 
12
- function CalendarTemplate({ data, prevMonthConstraint, nextMonthConstraint, addSlot}) {
13
- return html` <pd-calendar .data="${data || {}}"
12
+ function CalendarTemplate({ refDate, data, prevMonthConstraint, nextMonthConstraint, addSlot}) {
13
+ return html` <pd-calendar .refDate="${refDate}" .data="${data || {}}"
14
14
  prevMonthConstraint="${prevMonthConstraint}" nextMonthConstraint="${nextMonthConstraint}">
15
15
  ${addSlot ? html`<p slot="calFooter">* excl. BTW</p>` : ''}
16
16
  </pd-calendar> `;
17
17
  }
18
18
 
19
+ function CalendarSmallTemplate({ width, cellHeight, prevMonthConstraint, nextMonthConstraint}) {
20
+ return html`
21
+ <style>
22
+ .calendar-small {
23
+ --pd-calendar-width: ${width};
24
+ --pd-calendar-cell-height: ${cellHeight};
25
+ }
26
+ </style>
27
+ <pd-calendar class="calendar-small" prevMonthConstraint="${prevMonthConstraint}"
28
+ nextMonthConstraint="${nextMonthConstraint}" numberClass="center"
29
+ >
30
+ </pd-calendar>`;
31
+ }
32
+
19
33
  // generate some test data (needed to show data for current month)
20
34
  const now = new Date();
21
35
  const newDate1 = new Date(
@@ -55,6 +69,14 @@ Basic.args = {
55
69
  nextMonthConstraint: -1,
56
70
  };
57
71
 
72
+ export const BasicSmall = CalendarSmallTemplate.bind({});
73
+ BasicSmall.args = {
74
+ width: '220px',
75
+ cellHeight: '30px',
76
+ prevMonthConstraint: -1,
77
+ nextMonthConstraint: -1,
78
+ };
79
+
58
80
  export const WithInfoAndConstraints = CalendarTemplate.bind({});
59
81
  const data = {};
60
82
  data[format(newDate1, 'YYYY-MM-DD')] = [{ info: '180 €' }];
@@ -85,4 +107,13 @@ WithSpecialDays.args = {
85
107
  prevMonthConstraint: 0,
86
108
  nextMonthConstraint: 3,
87
109
  addSlot: true
110
+ };
111
+
112
+ const now2 = new Date();
113
+ now2.setMonth(now.getMonth() + 15);
114
+ export const WithSpecificDateAndConstraints = CalendarTemplate.bind({});
115
+ WithSpecificDateAndConstraints.args = {
116
+ refDate: now2,
117
+ prevMonthConstraint: 1,
118
+ nextMonthConstraint: 1,
88
119
  };