Skip to content

Commit 72cf08f

Browse files
committed
Renaming
1 parent 6ffe2c5 commit 72cf08f

File tree

4 files changed

+42
-153
lines changed

4 files changed

+42
-153
lines changed

docs/generated-data.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,34 @@
77
Each calendar month object has a `key` attribute ranging from 0 to 11 (January to December), a `name` attribute and a `data` attribute to generate each field in the calendar.
88

99
```typescript
10+
type ValueName = {
11+
value: number,
12+
name: 'january' | 'febuary' | 'march' | 'april' | 'may' | 'june' | 'july' | 'august' | 'september' | 'october' | 'november' | 'december'
13+
}
14+
1015
interface CalendarMonth {
11-
key: number,
12-
name: string, // january, febuary, march ...
13-
data: Record<number, Array<{
16+
date: {
17+
object: Date,
18+
currentDate: 31,
19+
currentDay: 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun',
20+
currentMonth: ValueName,
21+
prevMonth: ValueName,
22+
nextMonth: ValueName,
23+
currentYear: 2022,
24+
prevYear: number,
25+
nextYear: number
26+
},
27+
calendarValues: Record<number, Array<{
1428
type: string, //prev, next or current
1529
value: number,
1630
dateValue: string
1731
}>>
1832
}
1933
```
2034

21-
### `data`
35+
### `calendarValues`
2236

23-
The `data` attribute is an object with 6 keys ranging from 1-6. Each number indicates a row in the calendar. Each key (row) has an array of 7 data fields (columns) for the dates from Sunday to Saturday.
37+
The `calendarValues` attribute is an object with 6 keys ranging from 1-6. Each number indicates a row in the calendar. Each key (row) has an array of 7 data fields (columns) for the dates from Sunday to Saturday.
2438

2539
|Sun|Mon|Tue|Wed|Thu|Fri|Sat|
2640
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
@@ -54,5 +68,17 @@ The `dateValue` attribute is the date string with the format `YYYY-MM-DD`.
5468
The `getCalendarYear` function returns the calendar year as an object with keys ranging from 0 - 11 (Jan - Feburary). The value corresponds to the data for the calendar month.
5569

5670
```typescript
57-
type CalendarYear = Record<number, CalendarMonth>
71+
interface YearCalendarMonth {
72+
key: number,
73+
name: string, // january, febuary, march ...
74+
calendarValues: Record<number, Array<{
75+
type: string, //prev, next or current
76+
value: number,
77+
dateValue: string
78+
}>>
79+
}
80+
```
81+
82+
```typescript
83+
type CalendarYear = Record<number, YearCalendarMonth>
5884
```

examples/calendar.html

Lines changed: 0 additions & 139 deletions
This file was deleted.

src/year.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dateConsts from './constants/days'
77
* @typedef CalendarMonth
88
* @property {number} key
99
* @property {string} name
10-
* @property {CalendarValues} data
10+
* @property {CalendarValues} calendarValues
1111
*/
1212

1313
/**
@@ -136,7 +136,7 @@ export default class Year {
136136
months[i] = {
137137
key: i,
138138
name: dateConsts.months[i],
139-
data: this.generateCalendarValues(i)
139+
calendarValues: this.generateCalendarValues(i)
140140
};
141141
}
142142

src/year.spec.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ describe('year.js', () => {
2222
const result = y.getCalendarYear();
2323

2424
expect(Object.keys(result).length).toBe(12);
25-
expect(Array.isArray(result[0].data[1])).toBeTruthy();
26-
expect(result[0].data[1][0].dateValue).toBeTruthy();
27-
expect(!!result[0].data[1][0].type).toBeTruthy();
28-
expect(!!result[0].data[1][0].value).toBeTruthy();
25+
expect(result[0].key).toEqual(0);
26+
expect(result[0].name).toEqual('january');
27+
expect(Array.isArray(result[0].calendarValues[1])).toBeTruthy();
28+
expect(result[0].calendarValues[1][0].dateValue).toBeTruthy();
29+
expect(!!result[0].calendarValues[1][0].type).toBeTruthy();
30+
expect(!!result[0].calendarValues[1][0].value).toBeTruthy();
2931
})
3032

3133
it('should correct fetch dates from previous year', () => {
@@ -36,7 +38,7 @@ describe('year.js', () => {
3638
// get last month
3739
expect(result[0].name).toEqual('january');
3840
// fetch first cell in first row of month calendar
39-
expect(result[0].data[1][0].dateValue).toMatch(/2021-12-26/);
41+
expect(result[0].calendarValues[1][0].dateValue).toMatch(/2021-12-26/);
4042
})
4143

4244
it('should correct fetch dates from next year', () => {
@@ -47,6 +49,6 @@ describe('year.js', () => {
4749
// get last month
4850
expect(result[11].name).toEqual('december');
4951
// fetch last cell in last row of month calendar
50-
expect(result[11].data[6][6].dateValue).toMatch(/2023-1-7/);
52+
expect(result[11].calendarValues[6][6].dateValue).toMatch(/2023-1-7/);
5153
})
5254
});

0 commit comments

Comments
 (0)