Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. /** @jsx jsx */
  2. import { useMonth } from "@datepicker-react/hooks";
  3. import { jsx } from "@emotion/core";
  4. import Day from "./Day";
  5.  
  6. function Month({ year, month, firstDayOfWeek }) {
  7. const { days, weekdayLabels, monthLabel } = useMonth({
  8. year,
  9. month,
  10. firstDayOfWeek
  11. });
  12.  
  13. return (
  14. <div>
  15. <div css={{ textAlign: "center", margin: "0 0 16px" }}>
  16. <strong>{monthLabel}</strong>
  17. </div>
  18. <div
  19. css={{
  20. display: "grid",
  21. gridTemplateColumns: "repeat(7, 1fr)",
  22. justifyContent: "center",
  23. marginBottom: "10px",
  24. fontSize: "10px"
  25. }}
  26. >
  27. {weekdayLabels.map(dayLabel => (
  28. <div css={{ textAlign: "center" }} key={dayLabel}>
  29. {dayLabel}
  30. </div>
  31. ))}
  32. </div>
  33. <div
  34. css={{
  35. display: "grid",
  36. gridTemplateColumns: "repeat(7, 1fr)",
  37. justifyContent: "center"
  38. }}
  39. >
  40. {days.map((day, index) => {
  41. if (typeof day === "object") {
  42. return (
  43. <Day
  44. date={day.date}
  45. key={day.date.toString()}
  46. dayLabel={day.dayLabel}
  47. />
  48. );
  49. }
  50.  
  51. return <div key={index} />;
  52. })}
  53. </div>
  54. </div>
  55. );
  56. }
  57.  
  58. export default Month;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement