@asd20/ui 3.2.994 → 3.2.995

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
@@ -5,7 +5,7 @@
5
5
  "*.scss",
6
6
  "*.vue"
7
7
  ],
8
- "version": "3.2.994",
8
+ "version": "3.2.995",
9
9
  "private": false,
10
10
  "license": "MIT",
11
11
  "repository": {
@@ -11,7 +11,7 @@
11
11
  </div>
12
12
  </div>
13
13
  <!-- Days -->
14
- <ol class="asd20-calendar__days">
14
+ <!-- <ol class="asd20-calendar__days">
15
15
  <li
16
16
  class="asd20-calendar__day"
17
17
  v-for="(day, index) in days"
@@ -49,7 +49,49 @@
49
49
  />
50
50
  </div>
51
51
  </li>
52
+ </ol> -->
53
+
54
+ <ol class="asd20-calendar__days">
55
+ <template v-for="(week, weekIdx) in weekRows">
56
+ <li
57
+ v-for="(day, dayIdx) in week"
58
+ :key="weekIdx + '-' + dayIdx"
59
+ class="asd20-calendar__day"
60
+ :class="{
61
+ selected: day === selectedDay,
62
+ today: day.today,
63
+ outside: day.outsideOfCurrentMonth,
64
+ empty: day.events.length === 0,
65
+ }"
66
+ @click="onClickDay($event, day)"
67
+ >
68
+ <div class="asd20-calendar__date">
69
+ <span class="month">{{ day.month }}</span>
70
+ <span class="day">{{ day.number }}</span>
71
+ <span class="year">{{ day.year }}</span>
72
+ </div>
73
+ <div
74
+ class="asd20-calendar__events"
75
+ v-if="!annualView || !day.outsideOfCurrentMonth"
76
+ >
77
+ <Asd20CalendarEventButton
78
+ v-for="(event, index) in day.events"
79
+ :key="index"
80
+ :event="event"
81
+ :class="
82
+ day.events.length === 2
83
+ ? 'small-dot'
84
+ : day.events.length > 2
85
+ ? 'smaller-dot'
86
+ : ''
87
+ "
88
+ @click.native="onEventClick(event)"
89
+ />
90
+ </div>
91
+ </li>
92
+ </template>
52
93
  </ol>
94
+
53
95
  <asd20-viewport
54
96
  class="asd20-calendar__day-events"
55
97
  scrollable
@@ -90,6 +132,7 @@ export default {
90
132
  absolute: { type: Boolean, default: true },
91
133
  shortWeekdays: { type: Boolean, default: false },
92
134
  annualView: { type: Boolean, default: false },
135
+ hideWeekends: { type: Boolean, default: false },
93
136
  },
94
137
 
95
138
  data: () => ({
@@ -100,7 +143,7 @@ export default {
100
143
 
101
144
  watch: {
102
145
  days: {
103
- handler: function() {
146
+ handler: function () {
104
147
  this.selectedDay =
105
148
  this.days.find(day => {
106
149
  return day.today
@@ -116,17 +159,65 @@ export default {
116
159
  'asd20-calendar': true,
117
160
  'asd20-calendar--absolute': this.absolute,
118
161
  'asd20-calendar--annual': this.annualView,
162
+ 'asd20-calendar--five-day': this.hideWeekends,
119
163
  }
120
164
  },
121
165
  days() {
122
- return mapEventsToDays(
166
+ const allDays = mapEventsToDays(
123
167
  expandEvents(this.events, this.annualView),
124
168
  this.year,
125
- this.month,
169
+ this.month
126
170
  )
171
+ if (!this.hideWeekends) return allDays
172
+ return allDays.filter(day => {
173
+ // Note: day.date is usually a Date object in these helper patterns.
174
+ // But if it's not, you may need to use day.js, or construct new Date(day.year, day.month-1, day.number)
175
+ if (!day.date) {
176
+ try {
177
+ day.date = new Date(day.year, day.month - 1, day.number)
178
+ } catch {}
179
+ }
180
+ const jsDate =
181
+ day.date instanceof Date
182
+ ? day.date
183
+ : new Date(day.year, day.month - 1, day.number)
184
+ const dayOfWeek = jsDate.getDay()
185
+ return dayOfWeek !== 0 && dayOfWeek !== 6 // Exclude Sunday (0) and Saturday (6)
186
+ })
127
187
  },
128
188
  weekdayNames() {
129
- return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
189
+ const names = [
190
+ 'Sunday',
191
+ 'Monday',
192
+ 'Tuesday',
193
+ 'Wednesday',
194
+ 'Thursday',
195
+ 'Friday',
196
+ 'Saturday',
197
+ ]
198
+ return this.hideWeekends ? names.slice(1, 6) : names
199
+ },
200
+ weekRows() {
201
+ // Helper to chunk flat days array into weeks of 5 or 7 days
202
+ function chunk(arr, size) {
203
+ const result = []
204
+ for (let i = 0; i < arr.length; i += size) {
205
+ result.push(arr.slice(i, i + size))
206
+ }
207
+ return result
208
+ }
209
+
210
+ const colCount = this.hideWeekends ? 5 : 7
211
+ const weeks = chunk(this.days, colCount)
212
+
213
+ // Remove the last row if all days are outside the current month
214
+ while (
215
+ weeks.length &&
216
+ weeks[weeks.length - 1].every(day => day.outsideOfCurrentMonth)
217
+ ) {
218
+ weeks.pop()
219
+ }
220
+ return weeks
130
221
  },
131
222
  },
132
223
  methods: {
@@ -295,6 +386,8 @@ $accent: var(--color__accent);
295
386
  &--annual {
296
387
  .asd20-calendar__weekdays {
297
388
  padding: 0;
389
+ background: var(--color__primary);
390
+ color: #ffffff;
298
391
  }
299
392
  .asd20-calendar__days {
300
393
  position: relative;
@@ -320,7 +413,7 @@ $accent: var(--color__accent);
320
413
  width: calc(100% / 7);
321
414
  flex-grow: 1;
322
415
  display: flex;
323
- flex-direction:column;
416
+ flex-direction: column;
324
417
  align-items: flex-start;
325
418
  background-color: var(--website-page__alternate-background-t70);
326
419
  min-height: 2.5rem;
@@ -339,16 +432,20 @@ $accent: var(--color__accent);
339
432
  }
340
433
 
341
434
  .asd20-calendar__date {
342
- position: static;
435
+ position: absolute;
436
+ top: 50%;
437
+ left: 50%;
438
+ transform: translate(-50%, -50%);
343
439
  font-size: 0.875rem;
344
- margin: 0 0 0.125rem 0.125rem;
440
+ margin: 0 auto;
441
+ z-index: 10;
345
442
 
346
443
  .day {
347
- display: inline;
444
+ display: block;
348
445
  width: auto;
349
446
  height: auto;
350
447
  padding: 0;
351
- font-size: 0.875rem;
448
+ font-size: 1.5rem;
352
449
  }
353
450
 
354
451
  .weekday,
@@ -361,15 +458,18 @@ $accent: var(--color__accent);
361
458
  .asd20-calendar__events {
362
459
  position: static;
363
460
  display: flex;
364
- flex-direction: column;
461
+ flex-direction: row;
365
462
  width: 100%;
366
463
  justify-content: stretch;
367
- max-height: 2rem;
464
+ max-height: 2.5rem;
368
465
  overflow: hidden;
466
+ align-items: center;
467
+ justify-content: center;
369
468
 
370
469
  &::v-deep .asd20-calendar-event-button {
371
470
  background: transparent;
372
471
  padding: 0;
472
+ margin-right: 0;
373
473
  // width: space(0.375);
374
474
  // height: space(0.375);
375
475
  width: max-content;
@@ -377,30 +477,21 @@ $accent: var(--color__accent);
377
477
  // margin-right: space(0.0625);
378
478
  .title::before {
379
479
  width: 4rem;
380
- height: 2rem;
480
+ height: 2.5rem;
381
481
  margin: 0;
382
482
  border-radius: 0;
383
-
384
483
  }
385
484
  .title span {
386
485
  display: none;
387
486
  }
388
487
  }
389
488
  &::v-deep .small-dot {
390
- width: 4rem;
391
- height: 50%;
392
- // .title::before {
393
- // width: 12px;
394
- // height: 30px;
395
- // }
489
+ width: 50%;
490
+ height: 2.5rem;
396
491
  }
397
492
  &::v-deep .smaller-dot {
398
- width: 4rem;
399
- height: 33%;
400
- // .title::before {
401
- // width: 12px;
402
- // height: 30px;
403
- // }
493
+ width: 33%;
494
+ height: 2.5rem;
404
495
  }
405
496
  }
406
497
  .outside {
@@ -409,7 +500,13 @@ $accent: var(--color__accent);
409
500
  }
410
501
  }
411
502
  }
412
-
503
+ &--five-day {
504
+ .asd20-calendar__days {
505
+ .asd20-calendar__day {
506
+ width: calc(100% / 5);
507
+ }
508
+ }
509
+ }
413
510
  }
414
511
 
415
512
  @media (max-width: 767px) {
@@ -452,7 +549,7 @@ $accent: var(--color__accent);
452
549
  // 0 1px 0 0 var(--color__tertiary), -1px 0 0 0 var(--color__tertiary);
453
550
 
454
551
  &::v-deep .asd20-calendar__date {
455
- width: 100%;
552
+ // width: 100%;
456
553
  }
457
554
  &::v-deep .asd20-calendar__date .weekday {
458
555
  box-sizing: border-box;
@@ -540,5 +637,4 @@ $accent: var(--color__accent);
540
637
  }
541
638
  }
542
639
  }
543
-
544
640
  </style>