@progressive-development/pd-calendar 0.1.14 → 0.1.15
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 +37 -43
- package/src/PdCalendarCell.js +12 -8
- package/stories/index.stories.js +36 -4
package/package.json
CHANGED
package/src/PdCalendar.js
CHANGED
|
@@ -55,6 +55,7 @@ export class PdCalendar extends LitElement {
|
|
|
55
55
|
static get properties() {
|
|
56
56
|
return {
|
|
57
57
|
refDate: { type: Object },
|
|
58
|
+
selectableDates: { type: Boolean},
|
|
58
59
|
hideWeekend: { type: Boolean, reflect: true },
|
|
59
60
|
prevMonthConstraint: { type: Number },
|
|
60
61
|
nextMonthConstraint: { type: Number },
|
|
@@ -115,13 +116,8 @@ export class PdCalendar extends LitElement {
|
|
|
115
116
|
.header-main {
|
|
116
117
|
display: flex;
|
|
117
118
|
align-items: center;
|
|
118
|
-
justify-content:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.header-icons {
|
|
122
|
-
position: absolute;
|
|
123
|
-
right: 0px;
|
|
124
|
-
top: 0px;
|
|
119
|
+
justify-content: space-between;
|
|
120
|
+
width: 100%;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
123
|
.content {
|
|
@@ -158,26 +154,15 @@ export class PdCalendar extends LitElement {
|
|
|
158
154
|
font-family: var(--pd-default-font-title-family);
|
|
159
155
|
}
|
|
160
156
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
align-items: center;
|
|
164
|
-
justify-content: center;
|
|
165
|
-
font-weight: bold;
|
|
166
|
-
font-size: 1.4em;
|
|
167
|
-
width: 120px;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
span.content-sub-title {
|
|
171
|
-
position: absolute;
|
|
172
|
-
right: 1px;
|
|
173
|
-
bottom: 0px;
|
|
174
|
-
font-size: 1.2em;
|
|
157
|
+
.content-title {
|
|
158
|
+
font-size: var(--pd-calendar-title-font-size, 1.2em);
|
|
175
159
|
font-weight: bold;
|
|
176
160
|
}
|
|
177
161
|
|
|
178
162
|
.arrow {
|
|
179
163
|
cursor: pointer;
|
|
180
|
-
--pd-icon-size: 1.
|
|
164
|
+
--pd-icon-size: var(--pd-calendar-title-icon-size, 1.2em);
|
|
165
|
+
--pd-icon-bg-col-hover: lightgrey;
|
|
181
166
|
}
|
|
182
167
|
`];
|
|
183
168
|
}
|
|
@@ -188,7 +173,8 @@ export class PdCalendar extends LitElement {
|
|
|
188
173
|
this.data = {};
|
|
189
174
|
this._viewType = VIEW_MONTH;
|
|
190
175
|
this.numberClass = "top-left";
|
|
191
|
-
this.hideWeekend =
|
|
176
|
+
this.hideWeekend = false;
|
|
177
|
+
this.selectableDates = false;
|
|
192
178
|
|
|
193
179
|
this._currentMonthNavNr = 0;
|
|
194
180
|
}
|
|
@@ -258,13 +244,15 @@ export class PdCalendar extends LitElement {
|
|
|
258
244
|
const special = this.data[key]
|
|
259
245
|
? this.data[key][0].special || false
|
|
260
246
|
: false;
|
|
247
|
+
|
|
248
|
+
|
|
261
249
|
itemTemplates.push(html`
|
|
262
250
|
<pd-calendar-cell
|
|
263
251
|
key="${key}"
|
|
264
252
|
dayNumber="${i}"
|
|
265
253
|
weekDayNumber="${tmpDate.getDay()}"
|
|
266
254
|
infoTxt="${infoTxt}"
|
|
267
|
-
?selectEnabled="${infoTxt !== undefined}"
|
|
255
|
+
?selectEnabled="${this.selectableDates || infoTxt !== undefined}"
|
|
268
256
|
?special="${special}"
|
|
269
257
|
numberClass="${this.numberClass}"
|
|
270
258
|
@select-date="${this._forwardEvent}"
|
|
@@ -276,25 +264,31 @@ export class PdCalendar extends LitElement {
|
|
|
276
264
|
return html`
|
|
277
265
|
<div class="layout-container">
|
|
278
266
|
<div class="header">
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
icon
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
267
|
+
|
|
268
|
+
<div class="header-main">
|
|
269
|
+
|
|
270
|
+
<div>
|
|
271
|
+
<pd-icon
|
|
272
|
+
@click="${this._previousMonth}"
|
|
273
|
+
class="arrow"
|
|
274
|
+
activeIcon
|
|
275
|
+
icon="previousArrow"
|
|
276
|
+
></pd-icon>
|
|
277
|
+
|
|
278
|
+
<pd-icon
|
|
279
|
+
@click="${this._nextMonth}"
|
|
280
|
+
class="arrow"
|
|
281
|
+
activeIcon
|
|
282
|
+
icon="nextArrow"
|
|
283
|
+
></pd-icon>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<div class="content-title">
|
|
287
|
+
${this._monthName} ${this._year}
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
</div>
|
|
291
|
+
|
|
298
292
|
</div>
|
|
299
293
|
|
|
300
294
|
<div class="content grid-container ${sizeVar}">
|
package/src/PdCalendarCell.js
CHANGED
|
@@ -83,7 +83,7 @@ class PdCalendarCell extends LitElement {
|
|
|
83
83
|
background-color: var(--my-info-cell-bg1-color);*/
|
|
84
84
|
background-color: var(--pd-calendar-cell-day-free-bg-col, var(--pd-default-col));
|
|
85
85
|
/*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
|
|
86
|
-
box-shadow: 1px 2px 2px;
|
|
86
|
+
box-shadow: var(--pd-calendar-cell-selectable-shadow, 1px 2px 2px);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
.special {
|
|
@@ -91,7 +91,7 @@ class PdCalendarCell extends LitElement {
|
|
|
91
91
|
background-color: var(--my-info-cell-bg1-color);*/
|
|
92
92
|
background-color: var(--pd-calendar-cell-day-special-bg-col, var(--pd-default-success-col));
|
|
93
93
|
/*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
|
|
94
|
-
box-shadow: 1px 2px 2px
|
|
94
|
+
box-shadow: var(--pd-calendar-cell-selectable-shadow, 1px 2px 2px);;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
.special:hover,
|
|
@@ -129,10 +129,10 @@ class PdCalendarCell extends LitElement {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/* Noch umstellen, passt nicht für alle größen (die anderen auf flex/center umgestellt) */
|
|
132
|
-
.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
.center {
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
justify-content: center;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
.free .cell-number, .special .cell-number {
|
|
@@ -168,7 +168,11 @@ class PdCalendarCell extends LitElement {
|
|
|
168
168
|
@keypress="${this._selectableCellClicked}"
|
|
169
169
|
@click="${this._selectableCellClicked}"
|
|
170
170
|
data-date="${this.key}"
|
|
171
|
-
class="cell cell-day ${this.special ? 'special' : 'free'}
|
|
171
|
+
class="cell cell-day ${this.numberClass} ${this.special ? 'special' : 'free'}
|
|
172
|
+
${this.weekDayNumber === 6 ||
|
|
173
|
+
this.weekDayNumber === 0
|
|
174
|
+
? 'we'
|
|
175
|
+
: ''}"
|
|
172
176
|
>
|
|
173
177
|
${this.infoTxt
|
|
174
178
|
? html` <div class="cell-info">${this.infoTxt}</div>`
|
|
@@ -179,7 +183,7 @@ class PdCalendarCell extends LitElement {
|
|
|
179
183
|
|
|
180
184
|
_renderEmptyCell() {
|
|
181
185
|
return html`<div
|
|
182
|
-
class="cell cell-day
|
|
186
|
+
class="cell cell-day ${this.numberClass} ${this.weekDayNumber === 6 ||
|
|
183
187
|
this.weekDayNumber === 0
|
|
184
188
|
? 'we'
|
|
185
189
|
: ''}"
|
package/stories/index.stories.js
CHANGED
|
@@ -9,22 +9,29 @@ export default {
|
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
function CalendarTemplate({ refDate, data, prevMonthConstraint, nextMonthConstraint, addSlot}) {
|
|
13
|
-
return html` <pd-calendar
|
|
12
|
+
function CalendarTemplate({ hideWeekend, refDate, data, prevMonthConstraint, nextMonthConstraint, addSlot}) {
|
|
13
|
+
return html` <pd-calendar
|
|
14
|
+
?hideWeekend="${hideWeekend}"
|
|
15
|
+
.refDate="${refDate}" .data="${data || {}}"
|
|
14
16
|
prevMonthConstraint="${prevMonthConstraint}" nextMonthConstraint="${nextMonthConstraint}">
|
|
15
17
|
${addSlot ? html`<p slot="calFooter">* excl. BTW</p>` : ''}
|
|
16
18
|
</pd-calendar> `;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
function CalendarSmallTemplate({ width, cellHeight, prevMonthConstraint, nextMonthConstraint}) {
|
|
21
|
+
function CalendarSmallTemplate({ hideWeekend, width, cellHeight, prevMonthConstraint, nextMonthConstraint}) {
|
|
20
22
|
return html`
|
|
21
23
|
<style>
|
|
22
24
|
.calendar-small {
|
|
23
25
|
--pd-calendar-width: ${width};
|
|
24
26
|
--pd-calendar-cell-height: ${cellHeight};
|
|
27
|
+
--pd-calendar-week-title-bg-col: white;
|
|
28
|
+
--pd-calendar-week-title-font-col: #0A3A48;
|
|
29
|
+
--pd-calendar-cell-selectable-shadow: 0;
|
|
30
|
+
--pd-calendar-cell-day-free-bg-col: white;
|
|
31
|
+
--pd-calendar-cell-day-info-free-col: #0A3A48;
|
|
25
32
|
}
|
|
26
33
|
</style>
|
|
27
|
-
<pd-calendar class="calendar-small" prevMonthConstraint="${prevMonthConstraint}"
|
|
34
|
+
<pd-calendar selectableDates ?hideWeekend="${hideWeekend}" class="calendar-small" prevMonthConstraint="${prevMonthConstraint}"
|
|
28
35
|
nextMonthConstraint="${nextMonthConstraint}" numberClass="center"
|
|
29
36
|
>
|
|
30
37
|
</pd-calendar>`;
|
|
@@ -62,6 +69,11 @@ const newDate6 = new Date(
|
|
|
62
69
|
now.getMonth(),
|
|
63
70
|
10
|
|
64
71
|
);
|
|
72
|
+
const newDate7 = new Date(
|
|
73
|
+
now.getFullYear(),
|
|
74
|
+
now.getMonth(),
|
|
75
|
+
11
|
|
76
|
+
);
|
|
65
77
|
|
|
66
78
|
export const Basic = CalendarTemplate.bind({});
|
|
67
79
|
Basic.args = {
|
|
@@ -71,6 +83,16 @@ Basic.args = {
|
|
|
71
83
|
|
|
72
84
|
export const BasicSmall = CalendarSmallTemplate.bind({});
|
|
73
85
|
BasicSmall.args = {
|
|
86
|
+
hideWeekend: false,
|
|
87
|
+
width: '220px',
|
|
88
|
+
cellHeight: '30px',
|
|
89
|
+
prevMonthConstraint: -1,
|
|
90
|
+
nextMonthConstraint: -1,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const BasicSmallWithoutWeekend = CalendarSmallTemplate.bind({});
|
|
94
|
+
BasicSmallWithoutWeekend.args = {
|
|
95
|
+
hideWeekend: true,
|
|
74
96
|
width: '220px',
|
|
75
97
|
cellHeight: '30px',
|
|
76
98
|
prevMonthConstraint: -1,
|
|
@@ -102,6 +124,7 @@ specialData[format(newDate3, 'YYYY-MM-DD')] = [{ info: '150 €', special: true}
|
|
|
102
124
|
specialData[format(newDate4, 'YYYY-MM-DD')] = [{ info: '180 €' }];
|
|
103
125
|
specialData[format(newDate5, 'YYYY-MM-DD')] = [{ info: '170 €' }];
|
|
104
126
|
specialData[format(newDate6, 'YYYY-MM-DD')] = [{ info: '150 €', special: true}];
|
|
127
|
+
specialData[format(newDate7, 'YYYY-MM-DD')] = [{ info: '150 €', special: true}];
|
|
105
128
|
WithSpecialDays.args = {
|
|
106
129
|
data: specialData,
|
|
107
130
|
prevMonthConstraint: 0,
|
|
@@ -109,6 +132,15 @@ WithSpecialDays.args = {
|
|
|
109
132
|
addSlot: true
|
|
110
133
|
};
|
|
111
134
|
|
|
135
|
+
export const WithSpecialDaysHideWeekend = CalendarTemplate.bind({});
|
|
136
|
+
WithSpecialDaysHideWeekend.args = {
|
|
137
|
+
hideWeekend: true,
|
|
138
|
+
data: specialData,
|
|
139
|
+
prevMonthConstraint: 0,
|
|
140
|
+
nextMonthConstraint: 3,
|
|
141
|
+
addSlot: true
|
|
142
|
+
};
|
|
143
|
+
|
|
112
144
|
const now2 = new Date();
|
|
113
145
|
now2.setMonth(now.getMonth() + 15);
|
|
114
146
|
export const WithSpecificDateAndConstraints = CalendarTemplate.bind({});
|