@progressive-development/pd-calendar 0.5.4 → 0.6.1

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.
@@ -1,246 +0,0 @@
1
- import { LitElement, css, html } from "lit";
2
- import { parse } from "fecha";
3
- import { PDColorStyles, PDFontStyles } from "@progressive-development/pd-shared-styles";
4
- class PdCalendarCell extends LitElement {
5
- /**
6
- * @event select-date - fires when user clicks on a selectable cell.
7
- */
8
- static get properties() {
9
- return {
10
- /**
11
- * If enabled, cell could be selected (with visible hover element and pointer)
12
- * vy the user => results in fire cell-selected.
13
- */
14
- selectEnabled: { type: Boolean },
15
- /**
16
- * If enabled, highlight the current day
17
- */
18
- today: { type: Boolean },
19
- /**
20
- * If enabled, highlight the selected day
21
- */
22
- selected: { type: Boolean },
23
- /**
24
- * If enabled the cell gets an special class (e.g. green day).
25
- */
26
- special: { type: Boolean },
27
- /**
28
- * If set shows info text in the middle (hack) of the cell (e.g. price info).
29
- */
30
- infoTxt: { type: String },
31
- /**
32
- * CSS class for day number inside the cell, top-left and center available
33
- */
34
- numberClass: { type: String },
35
- /* key, weekDayNumber, dayNumber could merged to date
36
- on the other hand then there is the need to calculate them for each cell... */
37
- key: { type: String },
38
- weekDayNumber: { type: Number },
39
- dayNumber: { type: Number }
40
- };
41
- }
42
- static get styles() {
43
- return [
44
- PDColorStyles,
45
- PDFontStyles,
46
- css`
47
- :host {
48
- display: block;
49
-
50
- /* Defined by PdCalendar and also setted here
51
- --my-primary-font: var(--squi-primary-font, Oswald);*/
52
-
53
- /* not used in the moment, was created for gradient cells
54
- --my-info-cell-bg2-color: var(--squi-title-color, #084c61);
55
- --my-info-cell-bg1-hover: var(--squi-highlight-color, #ffc857);
56
- --my-info-cell-bg2-hover: var(--squi-highlight-color, #177e89);
57
- */
58
- }
59
-
60
- .cell {
61
- width: 100%;
62
- height: 100%;
63
- min-height: 30px;
64
- }
65
-
66
- .cell-empty {
67
- background-color: var(--pd-calendar-cell-empty-bg-col, var(--pd-default-bg));
68
- }
69
-
70
- .cell-day {
71
- position: relative;
72
- /*background-image: linear-gradient(to right, rgb(51, 101, 138) , rgb(38, 76, 104)); */
73
- /*box-shadow: 2px 2px 3px;*/
74
- background-color: var(--pd-calendar-cell-day-bg-col, var(--pd-default-light-col));
75
- /*border-radius: 2px 2px 2px 2px;*/
76
- }
77
-
78
- .cell-day.we {
79
- background-color: var(--pd-calendar-cell-day-we-bg-col, var(--pd-default-disabled-light-col));
80
- }
81
-
82
- .free {
83
- /*background-image: linear-gradient(to right, green, darkgreen);
84
- background-color: var(--my-info-cell-bg1-color);*/
85
- background-color: var(--pd-calendar-cell-day-free-bg-col, var(--pd-default-col));
86
- /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
87
- box-shadow: var(--pd-calendar-cell-selectable-shadow, 1px 2px 2px);
88
- }
89
-
90
- .special {
91
- /*background-image: linear-gradient(to right, green, darkgreen);
92
- background-color: var(--my-info-cell-bg1-color);*/
93
- background-color: var(--pd-calendar-cell-day-special-bg-col, var(--pd-default-success-col));
94
- /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
95
- box-shadow: var(--pd-calendar-cell-selectable-shadow, 1px 2px 2px);;
96
- }
97
-
98
- .special:hover,
99
- .free:hover {
100
- background-color: var(--pd-calendar-cell-day-bg-col-hover, var(--pd-default-hover-col));
101
- /*background-image: linear-gradient(to right, var(--my-info-cell-bg1-hover), var(--my-info-cell-bg2-hover));*/
102
- cursor: pointer;
103
- }
104
-
105
-
106
- .cell-info {
107
- display: flex;
108
- align-items: center;
109
- justify-content: center;
110
- height: 100%;
111
- color: var(--pd-calendar-cell-day-info-col, var(--pd-default-bg-col));
112
- font-family: var(--pd-default-font-title-family);
113
- font-weight: bold;
114
- font-size: var(--pd-calendar-info-font-size, 1.5em);
115
- text-shadow: 1px 1px var(--pd-default-dark-col);
116
- pointer-events: none;
117
- }
118
-
119
- .cell-number {
120
- pointer-events: none;
121
- font-size: var(--pd-calendar-number-font-size, 1em);
122
- font-weight: bold;
123
- color: var(--pd-calendar-cell-day-info-col, var(--pd-default-bg-col));
124
- font-family: var(--pd-default-font-content-family);
125
- }
126
-
127
- .cell-number.top-left {
128
- position: absolute;
129
- left: 3px;
130
- top: 2px;
131
- }
132
-
133
- /* Noch umstellen, passt nicht für alle größen (die anderen auf flex/center umgestellt) */
134
- .center {
135
- display: flex;
136
- align-items: center;
137
- justify-content: center;
138
- }
139
-
140
- .free .cell-number, .special .cell-number {
141
- color: var(--pd-calendar-cell-day-info-free-col, var(--pd-default-bg-col));
142
- }
143
-
144
- .number-ring {
145
- position: absolute;
146
- height: 28px;
147
- width: 28px;
148
- border-radius: 50%;
149
- display: inline-block;
150
- }
151
-
152
- .today {
153
- border: 2px solid blue;
154
- pointer-events: none;
155
- }
156
-
157
- .selected {
158
- border: 2px solid red;
159
- }
160
-
161
- /* ToDo: Dont work for calendars sized by custom properties. Needed to calculate from calendar size
162
- not from window size, this is a topic for container queries, which are not available right now... */
163
- @media (max-width: 800px) {
164
- .cell-info {
165
- font-size: 1.3em;
166
- }
167
- .cell-number {
168
- font-size: 0.8em;
169
- }
170
- }
171
- @media (max-width: 500px) {
172
- .cell-info {
173
- font-weight: normal;
174
- font-size: 1em;
175
- }
176
- }
177
- `
178
- ];
179
- }
180
- constructor() {
181
- super();
182
- this.numberClass = "top-left";
183
- }
184
- _renderSelectableCell() {
185
- return html` <div
186
- @keypress="${this._selectableCellClicked}"
187
- @click="${this._selectableCellClicked}"
188
- @mouseenter="${this._mouseEnter}"
189
- @mouseleave="${this._mouseLeave}"
190
- data-date="${this.key}"
191
- class="cell cell-day ${this.numberClass} ${this.special ? "special" : "free"}
192
- ${(this.weekDayNumber === 6 || this.weekDayNumber === 0) && !this.special ? "we" : ""}"
193
- >
194
- ${this.infoTxt ? html` <div class="cell-info">${this.infoTxt}</div>` : ""}
195
-
196
- ${this.today ? html`<div class="number-ring today"></div>` : ""}
197
-
198
- ${this.selected ? html`<div class="number-ring selected"></div>` : ""}
199
-
200
- <div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
201
- </div>`;
202
- }
203
- _renderEmptyCell() {
204
- return html`<div
205
- class="cell cell-day ${this.numberClass} ${(this.weekDayNumber === 6 || this.weekDayNumber === 0) && !this.special ? "we" : ""}"
206
- >
207
- ${this.infoTxt ? html`<div class="cell-info">${this.infoTxt}</div>` : ""}
208
-
209
- <div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
210
- </div>`;
211
- }
212
- render() {
213
- return this.selectEnabled ? this._renderSelectableCell() : this._renderEmptyCell();
214
- }
215
- _selectableCellClicked(e) {
216
- const dateKey = e.target.dataset.date;
217
- if (dateKey) {
218
- const userSelectedDate = parse(dateKey, "YYYY-MM-DD");
219
- this.dispatchEvent(
220
- new CustomEvent("select-date", {
221
- detail: {
222
- dateKey,
223
- date: userSelectedDate
224
- }
225
- })
226
- );
227
- }
228
- }
229
- _mouseEnter() {
230
- const userSelectedDate = parse(this.key, "YYYY-MM-DD");
231
- this.dispatchEvent(
232
- new CustomEvent("mouse-enter-date", {
233
- detail: {
234
- dateKey: this.key,
235
- date: userSelectedDate
236
- }
237
- })
238
- );
239
- }
240
- _mouseLeave() {
241
- this.dispatchEvent(
242
- new CustomEvent("mouse-leave-date")
243
- );
244
- }
245
- }
246
- window.customElements.define("pd-calendar-cell", PdCalendarCell);
@@ -1,108 +0,0 @@
1
- import { LitElement, css, html } from "lit";
2
- class PdYearPopup extends LitElement {
3
- /**
4
- * @event select-date - fires when user clicks on a selectable cell.
5
- */
6
- static get properties() {
7
- return {
8
- yearSelection: { type: Array },
9
- currentYear: { type: String }
10
- };
11
- }
12
- static get styles() {
13
- return [
14
- css`
15
- :host {
16
- position: absolute;
17
- z-index: 10;
18
- top: 25px;
19
- right: 0;
20
- }
21
-
22
- ul {
23
- list-style: none;
24
- max-height: 250px;
25
- overflow-y: auto;
26
-
27
- margin: 0;
28
- padding: 4px 0;
29
- width: 90px;
30
- background: var(--pd-default-light-col, #ffffff);
31
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
32
- border-radius: 8px;
33
- border: 1px solid var(--pd-default-border-col, #ddd);
34
-
35
- display: flex;
36
- flex-direction: column;
37
-
38
- scrollbar-width: thin;
39
- }
40
-
41
- ul::-webkit-scrollbar {
42
- width: 6px;
43
- }
44
-
45
- ul::-webkit-scrollbar-thumb {
46
- background-color: rgba(0, 0, 0, 0.2);
47
- border-radius: 3px;
48
- }
49
-
50
- li {
51
- text-align: center;
52
- padding: 8px 0;
53
- margin: 0 4px;
54
- font-size: 14px;
55
- border-radius: 4px;
56
- color: var(--pd-default-dark-col, #333);
57
- transition: background-color 0.2s ease, color 0.2s ease;
58
- }
59
-
60
- li.selectable:hover {
61
- background-color: var(--pd-default-hover-bg, #f0f0f0);
62
- color: var(--pd-default-hover-col, #000);
63
- cursor: pointer;
64
- }
65
-
66
- li.current {
67
- background-color: var(--pd-default-primary-col, #007acc);
68
- color: white;
69
- font-weight: bold;
70
- }
71
- `
72
- ];
73
- }
74
- constructor() {
75
- super();
76
- this.yearSelection = [];
77
- }
78
- render() {
79
- return html`
80
- <ul>
81
- ${this.yearSelection.map((year) => html`
82
- <li class="${this.currentYear === year ? "current" : "selectable"}" data-year="${year}" @click="${this._yearSelection}">${year}</li>
83
- `)}
84
- </ul>
85
- `;
86
- }
87
- _yearSelection(event) {
88
- if (event.target.dataset.year) {
89
- this.dispatchEvent(new CustomEvent(
90
- "change-year-selection",
91
- {
92
- detail: {
93
- year: event.target.dataset.year
94
- }
95
- }
96
- ));
97
- } else {
98
- this._closeSelection();
99
- }
100
- }
101
- _closeSelection() {
102
- this.dispatchEvent(new CustomEvent("abort-year-selection"));
103
- }
104
- }
105
- window.customElements.define("pd-year-popup", PdYearPopup);
106
- export {
107
- PdYearPopup
108
- };