-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c55452
commit 7d560bb
Showing
17 changed files
with
599 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './src/styles/global.css' | ||
import './src/styles/button.css' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
exports.onCreateBabelConfig = ({ actions }) => { | ||
actions.setBabelPlugin({ | ||
name: '@emotion/babel-plugin', | ||
options: { | ||
sourceMap: true, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: useCalendar | ||
route: /api-references/useCalendar | ||
menu: API References | ||
--- | ||
|
||
# useCalendar | ||
|
||
## Usage | ||
|
||
```ts | ||
function Component() { | ||
const { cursorDate, headers, body, navigation, view } = useCalendar() | ||
|
||
return ( | ||
<Something ... /> | ||
) | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
```ts | ||
export interface UseCalendarOptions { | ||
defaultDate?: Date | number | string | ||
defaultWeekStart?: WeekDayType | ||
defaultViewType?: CalendarViewType | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import useCalendar from '@veccu/react-calendar' | ||
import cx from 'classnames' | ||
import { format, getDate } from 'date-fns' | ||
import React from 'react' | ||
|
||
export default function Calendar() { | ||
const { calendar, headers, body, view, navigation } = useCalendar() | ||
|
||
return ( | ||
<> | ||
<table className="table-fixed border-collapse border border-gray-100 w-full rounded-sm"> | ||
<caption> | ||
<div className="flex flex-row justify-between items-center pb-4"> | ||
<div className="flex flex-row space space-x-2"> | ||
<button | ||
onClick={() => view.showMonthView()} | ||
className={cx('btn bg-blue-50', { | ||
'bg-blue-200': view.isMonthView, | ||
})} | ||
> | ||
M | ||
</button> | ||
<button | ||
onClick={() => view.showWeekView()} | ||
className={cx('btn bg-blue-50', { | ||
'bg-blue-200': view.isWeekView, | ||
})} | ||
> | ||
W | ||
</button> | ||
<button | ||
onClick={() => view.showDayView()} | ||
className={cx('btn bg-blue-50', { | ||
'bg-blue-200': view.isDayView, | ||
})} | ||
> | ||
D | ||
</button> | ||
</div> | ||
<div className="text-2xl font-black"> | ||
{format(calendar.cursorDate, 'yyyy.MM')} | ||
</div> | ||
<div className="flex flex-row space space-x-2"> | ||
<button | ||
onClick={() => navigation.toPrev()} | ||
className={cx('btn bg-blue-50')} | ||
> | ||
{'<'} | ||
</button> | ||
<button | ||
onClick={() => navigation.setToday()} | ||
className={cx('btn bg-blue-500 text-white')} | ||
> | ||
TODAY | ||
</button> | ||
<button | ||
onClick={() => navigation.toNext()} | ||
className={cx('btn bg-blue-50')} | ||
> | ||
{'>'} | ||
</button> | ||
</div> | ||
</div> | ||
</caption> | ||
<thead className="border-b-1"> | ||
<tr> | ||
{headers.weekDays.map(({ key, value }) => { | ||
return ( | ||
<th className="border border-gray-100 p-3" key={key}> | ||
{format(value, 'E')} | ||
</th> | ||
) | ||
})} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{body.value.map((week) => { | ||
const { key, value: days } = week | ||
|
||
return ( | ||
<tr key={key}> | ||
{days.map((day) => { | ||
const { key, value, isCurrentDate, isCurrentMonth } = day | ||
|
||
return ( | ||
<td | ||
key={key} | ||
className={cx( | ||
'border border-gray-100 p-6 text-center text-xl', | ||
{ | ||
'bg-blue-200 animate-pulse': isCurrentDate, | ||
'opacity-20': !isCurrentMonth, | ||
}, | ||
)} | ||
> | ||
{getDate(value)} | ||
</td> | ||
) | ||
})} | ||
</tr> | ||
) | ||
})} | ||
</tbody> | ||
</table> | ||
|
||
<button | ||
onClick={() => { | ||
window.location.href = '/getting-started/overview' | ||
}} | ||
className="block mt-20 mx-auto p-4 rounded bg-gradient-to-r from-indigo-400 via-purple-500 to-blue-500 text-white" | ||
> | ||
Go to <span className="italic font-bold">Getting Started</span> | ||
</button> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { css } from '@emotion/react' | ||
import React from 'react' | ||
|
||
export function Logo() { | ||
return ( | ||
<div | ||
css={css` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100%; | ||
`} | ||
> | ||
<img | ||
css={css` | ||
display: inline-block; | ||
margin-right: 8px; | ||
height: 36px; | ||
`} | ||
src="/icon/logo.png" | ||
alt="react-calendar Logo" | ||
/> | ||
<span | ||
css={css` | ||
font-weight: bolder; | ||
`} | ||
> | ||
React Calendar | ||
</span> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 16 additions & 3 deletions
19
docs/src/getting-started.mdx → docs/src/getting-started/quick-start.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.btn { | ||
@apply py-2 p-4; | ||
@apply rounded-md; | ||
} |
Oops, something went wrong.