Skip to content

Commit 62a3133

Browse files
committed
chore(calendar-beta): PR changes part 1
1 parent 7132c71 commit 62a3133

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

packages/genesys-spark-components/src/components/beta/gux-calendar-beta/gux-calendar.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
forceUpdate,
55
h,
66
JSX,
7-
Listen,
87
Method,
98
Prop,
109
State
@@ -63,9 +62,12 @@ export class GuxCalendar {
6362
@State()
6463
private maxValue: Temporal.PlainDate | null;
6564

66-
@Listen('guxdayselected')
67-
onDaySelected(event: CustomEvent<string>) {
68-
const selectedDate = Temporal.PlainDate.from(event.detail);
65+
detectDayClick(event: MouseEvent) {
66+
if (!((event.target as HTMLElement).tagName === 'GUX-DAY-BETA')) {
67+
return;
68+
}
69+
const dayElement = event.target as HTMLGuxDayBetaElement;
70+
const selectedDate = Temporal.PlainDate.from(dayElement.day);
6971
this.selectDate(selectedDate);
7072
event.stopPropagation();
7173
}
@@ -311,7 +313,10 @@ export class GuxCalendar {
311313

312314
private renderContent(): JSX.Element {
313315
return (
314-
<div onKeyDown={e => void this.onKeyDown(e)}>
316+
<div
317+
onKeyDown={e => void this.onKeyDown(e)}
318+
onClick={e => void this.detectDayClick(e)}
319+
>
315320
<div class="gux-content">
316321
<div class="gux-week-days">
317322
{getWeekdays(this.locale, this.startDayOfWeek).map(

packages/genesys-spark-components/src/components/beta/gux-day/gux-day.tsx

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
import {
2-
Component,
3-
Element,
4-
Event,
5-
EventEmitter,
6-
h,
7-
JSX,
8-
Prop,
9-
State,
10-
Watch
11-
} from '@stencil/core';
1+
import { Component, Element, h, JSX, Prop, State, Watch } from '@stencil/core';
122
import { getDesiredLocale } from 'i18n';
133
import * as sparkIntl from '../../../genesys-spark-utils/intl';
144
import { Temporal } from '@js-temporal/polyfill';
@@ -41,9 +31,6 @@ export class GuxDay {
4131
this.readDateFromProp();
4232
}
4333

44-
@Event({ eventName: 'guxdayselected' })
45-
daySelected: EventEmitter<string>;
46-
4734
/* Formatter for displaying the numeric day of the month */
4835
dayFormatter: Intl.DateTimeFormat;
4936

@@ -61,7 +48,6 @@ export class GuxDay {
6148
async connectedCallback(): Promise<void> {
6249
this.readDateFromProp();
6350
const locale = getDesiredLocale(this.root);
64-
this.dayFormatter = sparkIntl.dateTimeFormat(locale, { day: 'numeric' });
6551
this.readerFormatter = sparkIntl.dateTimeFormat(locale, {
6652
year: 'numeric',
6753
month: 'long',
@@ -71,7 +57,7 @@ export class GuxDay {
7157

7258
render(): JSX.Element {
7359
return (
74-
<button onClick={() => this.daySelected.emit(this.day)} type="button">
60+
<button type="button">
7561
<slot>
7662
<span aria-hidden="true">{this.date.day}</span>
7763
<span class="gux-sr-only">

packages/genesys-spark-components/src/utils/date/temporal.ts

+5
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ export function formatPlainDate(
2525
formatDate.setFullYear(date.year);
2626
formatDate.setMonth(date.month - 1);
2727
formatDate.setDate(date.day);
28+
formatDate.setHours(12);
29+
formatDate.setMinutes(0);
30+
formatDate.setSeconds(0);
31+
formatDate.setMilliseconds(0);
32+
2833
return formatter.format(formatDate);
2934
}

0 commit comments

Comments
 (0)