Skip to content

Commit 329b121

Browse files
authored
Merge pull request #2 from simpletut/v1.0.3
Clean up
2 parents fb51196 + e582c3d commit 329b121

File tree

8 files changed

+67
-24
lines changed

8 files changed

+67
-24
lines changed

README.md

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# reactjs-availability-calendar
22

33
[![NPM version][npm-image]][npm-url]
4-
[![Build][github-build]][github-build-url]
54
![npm-typescript]
65
[![License][github-license]][github-license-url]
76

@@ -28,7 +27,7 @@ Add `Calendar` to your component:
2827
```js
2928
import React from 'react'
3029
import ReactDOM from 'react-dom/client'
31-
import { Calendar } from 'reactjs-availability-calendar'
30+
import Calendar from 'reactjs-availability-calendar'
3231

3332
const bookings = [
3433
{
@@ -54,23 +53,62 @@ root.render(
5453

5554
```
5655

57-
Include default stylesheet in your html
56+
## Default CSS
5857

59-
Note: Please host the CSS in this file yourself
58+
Please copy and self host the default CSS linked below.
6059

61-
<a href="https://github.com/simpletut/reactjs-availability-calendar/blob/main/styles/main.min.css">Link to CSS</a>
60+
<a href="https://github.com/simpletut/reactjs-availability-calendar/blob/main/styles/main.min.css">Default CSS</a>
6261
<br />
63-
<a href="https://github.com/simpletut/reactjs-availability-calendar/blob/main/styles/main.min.css">Link to Minified CSS</a>
62+
<a href="https://github.com/simpletut/reactjs-availability-calendar/blob/main/styles/main.css">Minified Default CSS</a>
6463

6564
```
66-
<link rel="stylesheet" href="path/to/hosted/styles.css">
65+
<link href="path/to/your/styles.css" rel="stylesheet">
6766
6867
```
6968

69+
## Settings / Configurations:
70+
71+
### bookings
72+
73+
**Example:**
74+
```
75+
{
76+
from: '01-08-2022',
77+
to: '01-16-2022',
78+
middayCheckout: true,
79+
}
80+
```
81+
**Type:** Array of Bookings\
82+
**Default:** []\
83+
**Description:** Dates should be in US format (MM-DD-YYYY).
84+
85+
86+
### showNumberOfMonths
87+
88+
**Type:** Number\
89+
**Default:** 12\
90+
**Description:** Number of Months to show
91+
92+
### showCurrentYear
93+
94+
**Type:** Bool\
95+
**Default:** true\
96+
**Description:** Render active Calendar Year
97+
98+
### showControls
99+
100+
**Type:** Bool\
101+
**Default:** true\
102+
**Description:** Render navigation buttons to move forward and previous Calendar Years
103+
104+
### showKey
105+
106+
**Type:** Bool\
107+
**Default:** true\
108+
**Description:** Render Key for the different Calendar States
109+
70110
[npm-url]: https://www.npmjs.com/package/reactjs-availability-calendar
71111
[npm-image]: https://img.shields.io/npm/v/reactjs-availability-calendar
72-
[github-license]: https://img.shields.io/github/license/simpletut/reactjs-availability-calendar/blob/main/LICENSE
112+
[github-license]: https://img.shields.io/github/license/simpletut/reactjs-availability-calendar
73113
[github-license-url]: https://github.com/simpletut/reactjs-availability-calendar/blob/main/LICENSE
74-
[github-build]: https://github.com/main/reactjs-availability-calendar/actions/workflows/publish.yml/badge.svg
75-
[github-build-url]: https://github.com/simpletut/reactjs-availability-calendar/actions/workflows/publish.yml
76-
[npm-typescript]: https://img.shields.io/npm/types/reactjs-availability-calendar
114+
[npm-typescript]: https://img.shields.io/npm/types/reactjs-availability-calendar

example/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom/client'
3-
import { Calendar } from 'reactjs-availability-calendar'
3+
import Calendar from 'reactjs-availability-calendar'
44

55
const bookings = [
66
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactjs-availability-calendar",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "React Availability Calendar",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/esm/index.js",

src/components/Calendar/Year/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import { daysOfTheWeek, daysOfTheWeekOffset } from './../Utils'
66

77
dayjs.extend(isBetween)
88

9-
const Year: FC<IYear> = ({ calMonths, bookedDates, lateCheckouts, currentYear = dayjs().year() }): JSX.Element => {
9+
const Year: FC<IYear> = ({
10+
showNumberOfMonths,
11+
bookedDates,
12+
lateCheckouts,
13+
currentYear = dayjs().year(),
14+
}): JSX.Element => {
1015
return (
1116
<div className='year' data-testid='year'>
12-
{new Array(calMonths).fill('').map((_, pos) => {
17+
{new Array(showNumberOfMonths).fill('').map((_, pos) => {
1318
const arrOffset = 1
1419
const month = pos + arrOffset
1520
const date = `${currentYear}-${month}`
@@ -68,7 +73,7 @@ const Year: FC<IYear> = ({ calMonths, bookedDates, lateCheckouts, currentYear =
6873
}
6974

7075
Year.defaultProps = {
71-
calMonths: 12,
76+
showNumberOfMonths: 12,
7277
bookedDates: [],
7378
lateCheckouts: [],
7479
}

src/components/Calendar/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dayjs.extend(isBetween)
1111

1212
const Calendar: FC<ICalendarPropTypes> = ({
1313
bookings,
14-
calMonths,
14+
showNumberOfMonths,
1515
showKey,
1616
showCurrentYear,
1717
showControls,
@@ -50,7 +50,7 @@ const Calendar: FC<ICalendarPropTypes> = ({
5050
}, [bookings, currentYear])
5151

5252
const configYear: IYear = {
53-
calMonths,
53+
showNumberOfMonths,
5454
bookedDates,
5555
lateCheckouts,
5656
currentYear,
@@ -87,7 +87,7 @@ const Calendar: FC<ICalendarPropTypes> = ({
8787

8888
Calendar.defaultProps = {
8989
bookings: [],
90-
calMonths: 12,
90+
showNumberOfMonths: 12,
9191
showKey: true,
9292
showCurrentYear: true,
9393
showControls: true,

src/components/Calendar/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type ShowMonths = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
1010

1111
export interface ICalendarPropTypes {
1212
bookings?: BookingType[]
13-
calMonths?: ShowMonths
13+
showNumberOfMonths?: ShowMonths
1414
showKey?: boolean
1515
showCurrentYear?: boolean
1616
showControls?: boolean
@@ -70,7 +70,7 @@ export enum DayOffset {
7070
export type DaysOfWeekOffsetType = DayOffset[]
7171

7272
export interface IYear {
73-
calMonths?: ShowMonths
73+
showNumberOfMonths?: ShowMonths
7474
bookedDates: blockedDaysType
7575
lateCheckouts: blockedDaysType
7676
currentYear: number

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import Calendar from './components/Calendar'
22

3-
export { Calendar }
3+
export default Calendar

tests/common.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render } from '@testing-library/react'
33

44
import 'jest-canvas-mock'
55

6-
import { Calendar } from '../src'
6+
import Calendar from '../src'
77

88
const bookings = [
99
{
@@ -93,7 +93,7 @@ describe('Calendar', () => {
9393
})
9494

9595
it('Should Render 6 Months', () => {
96-
const { getAllByTestId } = render(<Calendar calMonths={6} bookings={bookings} />)
96+
const { getAllByTestId } = render(<Calendar showNumberOfMonths={6} bookings={bookings} />)
9797
const months = getAllByTestId('month')
9898

9999
expect(months).toHaveLength(6)

0 commit comments

Comments
 (0)