Skip to content

Commit 8c7327f

Browse files
authored
refactor: manual calendar config init objects (#790)
1 parent 9537a74 commit 8c7327f

3 files changed

Lines changed: 26 additions & 32 deletions

File tree

samples/scheduling/calendar/disabled-dates/src/index.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom/client';
33
import './index.css';
4-
import { IgrCalendar, IgrCalendarModule, DateRangeDescriptor, DateRangeType } from 'igniteui-react';
4+
import { IgrCalendar, DateRangeDescriptor, DateRangeType } from 'igniteui-react';
55
import 'igniteui-webcomponents/themes/light/bootstrap.css';
66

7-
IgrCalendarModule.register();
8-
97
export default class CalendarDisabledDates extends React.Component<any, any> {
108

11-
//public disabledDates: DateRangeDescriptor[];
12-
139
constructor(props: any) {
14-
super(props);
10+
super(props);
1511

1612
const today = new Date();
1713
const range = [
1814
new Date(today.getFullYear(), today.getMonth(), 3),
1915
new Date(today.getFullYear(), today.getMonth(), 8)
2016
];
2117

22-
const desc: DateRangeDescriptor = new DateRangeDescriptor();
23-
desc.dateRange = range;
24-
desc.rangeType = DateRangeType.Specific;
25-
26-
const dates: DateRangeDescriptor[] = [desc];
18+
const desc: DateRangeDescriptor = {
19+
dateRange: range,
20+
type: DateRangeType.Specific,
21+
}
22+
const disabledDates = [desc];
2723

28-
this.state = { disabledDates: dates};
24+
this.state = { disabledDates };
2925
}
3026

3127
public render(): JSX.Element {
3228
return (
3329
<div className="container sample">
34-
<IgrCalendar disabledDates={this.state.disabledDates} style={{width: '400px'}}/>
30+
<IgrCalendar disabledDates={this.state.disabledDates} style={{width: '400px'}}/>
3531
</div>
3632
);
3733
}

samples/scheduling/calendar/formatting/src/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ IgrRadioModule.register();
1111
export default class CalendarFormatting extends React.Component<any, any> {
1212

1313
constructor(props: any) {
14-
super(props);
14+
super(props);
1515
this.onRadioChange = this.onRadioChange.bind(this);
1616

17-
const formatOptions: IgrCalendarFormatOptions = new IgrCalendarFormatOptions();
18-
formatOptions.month = 'short';
19-
formatOptions.weekday = 'short';
17+
const formatOptions: IgrCalendarFormatOptions = {
18+
month: 'short',
19+
weekday: 'short',
20+
}
2021

21-
this.state = { calendarLocale: "en", calendarFormat: formatOptions };
22+
this.state = { calendarLocale: "en", calendarFormat: formatOptions };
2223
}
2324

2425
public render(): JSX.Element {
@@ -45,7 +46,7 @@ export default class CalendarFormatting extends React.Component<any, any> {
4546
<IgrCalendar weekStart='monday' formatOptions={this.state.calendarFormat}
4647
locale={this.state.calendarLocale}
4748
value={new Date()}
48-
style={{width: '400px'}}/>
49+
style={{width: '400px'}}/>
4950
</div>
5051
);
5152
}

samples/scheduling/calendar/special-dates/src/index.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom/client';
33
import './index.css';
4-
import { IgrCalendar, IgrCalendarModule, DateRangeDescriptor, DateRangeType } from 'igniteui-react';
4+
import { IgrCalendar, DateRangeDescriptor, DateRangeType } from 'igniteui-react';
55
import 'igniteui-webcomponents/themes/light/bootstrap.css';
66

7-
IgrCalendarModule.register();
8-
97
export default class CalendarSpecialDates extends React.Component<any, any> {
108

119
constructor(props: any) {
12-
super(props);
10+
super(props);
1311

1412
const today = new Date();
15-
1613
const range = [
1714
new Date(today.getFullYear(), today.getMonth(), 3),
1815
new Date(today.getFullYear(), today.getMonth(), 8)
19-
];
16+
];
2017

21-
const desc: DateRangeDescriptor = new DateRangeDescriptor();
22-
desc.dateRange = range;
23-
desc.rangeType = DateRangeType.Between;
24-
25-
const dates: DateRangeDescriptor[] = [desc];
18+
const desc: DateRangeDescriptor = {
19+
dateRange: range,
20+
type: DateRangeType.Between,
21+
}
22+
const specialDates = [desc];
2623

27-
this.state = { specialDates: dates};
24+
this.state = { specialDates };
2825
}
2926

3027
public render(): JSX.Element {
3128
return (
3229
<div className="container sample">
33-
<IgrCalendar specialDates={this.state.specialDates} style={{width: '400px'}}/>
30+
<IgrCalendar specialDates={this.state.specialDates} style={{width: '400px'}}/>
3431
</div>
3532
);
3633
}

0 commit comments

Comments
 (0)