From 8b83dd8c6d800bd24042a26f6b7f03593ac69b8e Mon Sep 17 00:00:00 2001 From: Kyle Gill Date: Fri, 29 Mar 2019 00:41:14 -0600 Subject: [PATCH] feat: day searching grid --- src/components/screens/Month/Month.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/screens/Month/Month.js b/src/components/screens/Month/Month.js index 73ccbe2..05d7fc7 100644 --- a/src/components/screens/Month/Month.js +++ b/src/components/screens/Month/Month.js @@ -1,7 +1,9 @@ import React, { Component } from "react"; +import { Link } from "react-router-dom"; import styled from "@emotion/styled"; import { isAfter, + isThisYear, format, addMonths, subMonths, @@ -42,9 +44,32 @@ class Month extends Component { } = this.props; const currentDay = new Date(year, month - 1); + // include all months unless it's this year + let dayIndexesToInclude = 31; + if (isThisYear(currentDay)) { + dayIndexesToInclude = new Date().getDate(); + } + let yearCards = []; for (let i = 0; i < getDaysInMonth(currentDay); i++) { - yearCards.push({i + 1}); + const isDisabled = dayIndexesToInclude <= i; + if (isDisabled) { + yearCards.push( + + {i + 1} + + ); + } else { + yearCards.push( + + {i + 1} + + ); + } } return (