-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Calendar] Remove promise based loading in favor of
loading
prop (#…
…1829) * Remove `onMonthChange` promise-based api in favor of `loading` prop * Update server request example for new API * Implement fake api for server request example * Update tests * Make CalendarSkeleton component and use it in the examples for loading state
- Loading branch information
1 parent
9fa389f
commit c932737
Showing
18 changed files
with
416 additions
and
269 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 |
---|---|---|
|
@@ -36,3 +36,5 @@ coverage | |
# editors | ||
.vs | ||
.DS_Store | ||
|
||
.vercel |
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 @@ | ||
.vercel |
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,32 @@ | ||
import { getDaysInMonth, isValid } from 'date-fns'; | ||
import { NowRequest, NowResponse } from '@now/node'; | ||
|
||
function getRandomNumber(min: number, max: number) { | ||
return Math.round(Math.random() * (max - min) + min); | ||
} | ||
|
||
export default function(req: NowRequest, res: NowResponse) { | ||
const { month } = req.query; | ||
|
||
if (!month || typeof month !== 'string') { | ||
res.status(400); | ||
return res.json({ | ||
reason: 'month query param is required', | ||
}); | ||
} | ||
|
||
const date = new Date(month); | ||
if (!isValid(date)) { | ||
res.status(422); | ||
return res.json({ | ||
reason: 'cannot parse month value', | ||
}); | ||
} | ||
|
||
setTimeout(() => { | ||
const daysInMonth = getDaysInMonth(date); | ||
const daysToHighlight = [1, 2, 3].map(_ => getRandomNumber(1, daysInMonth)); | ||
|
||
res.json({ daysToHighlight }); | ||
}, 500); // fake some long work | ||
} |
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
Oops, something went wrong.
c932737
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: