feat: card day grid
This commit is contained in:
@@ -18,6 +18,7 @@ const JournalHeading = styled.h2`
|
|||||||
margin-top: ${SIZES.medium};
|
margin-top: ${SIZES.medium};
|
||||||
`;
|
`;
|
||||||
const JournalEntryArea = styled.textarea`
|
const JournalEntryArea = styled.textarea`
|
||||||
|
font-family: sans-serif;
|
||||||
flex-grow: 0.8;
|
flex-grow: 0.8;
|
||||||
color: ${props => props.theme.colors.primary};
|
color: ${props => props.theme.colors.primary};
|
||||||
caret-color: ${props => props.theme.colors.secondary};
|
caret-color: ${props => props.theme.colors.secondary};
|
||||||
|
|||||||
@@ -1,8 +1,38 @@
|
|||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { subDays, format, isToday } from "date-fns";
|
import styled from "@emotion/styled";
|
||||||
|
import {
|
||||||
|
isAfter,
|
||||||
|
format,
|
||||||
|
addMonths,
|
||||||
|
subMonths,
|
||||||
|
getDaysInMonth,
|
||||||
|
startOfMonth
|
||||||
|
} from "date-fns";
|
||||||
|
|
||||||
import Seek from "../../Seek";
|
import Seek from "../../Seek";
|
||||||
|
|
||||||
|
const YearCardGrid = styled.div`
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
|
||||||
|
grid-gap: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
`;
|
||||||
|
const YearCard = styled.div`
|
||||||
|
color: ${props =>
|
||||||
|
props.disabled
|
||||||
|
? props.theme.colors.quarternary
|
||||||
|
: props.theme.colors.secondary};
|
||||||
|
border: 1px solid;
|
||||||
|
border-color: ${props => props.theme.colors.quarternary};
|
||||||
|
padding: 30px;
|
||||||
|
border-radius: 5px;
|
||||||
|
text-align: center;
|
||||||
|
user-select: none;
|
||||||
|
&:hover {
|
||||||
|
border-color: ${props => !props.disabled && props.theme.colors.tertiary};
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
class Month extends Component {
|
class Month extends Component {
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
@@ -11,15 +41,25 @@ class Month extends Component {
|
|||||||
}
|
}
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const currentDay = new Date(year, month - 1);
|
const currentDay = new Date(year, month - 1);
|
||||||
|
|
||||||
|
let yearCards = [];
|
||||||
|
for (let i = 0; i < getDaysInMonth(currentDay); i++) {
|
||||||
|
yearCards.push(<YearCard key={i}>{i + 1}</YearCard>);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
<Seek
|
<Seek
|
||||||
title={format(currentDay, "YYYY MMM")}
|
title={format(currentDay, "YYYY MMM")}
|
||||||
prev={format(subDays(currentDay, 1), "/YYYY/MM")}
|
prev={format(subMonths(currentDay, 1), "/YYYY/MM")}
|
||||||
next={"asdf"}
|
next={format(addMonths(currentDay, 1), "/YYYY/MM")}
|
||||||
disableNext={isToday(new Date())}
|
disableNext={isAfter(
|
||||||
|
currentDay,
|
||||||
|
startOfMonth(subMonths(new Date(), 1))
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
<YearCardGrid>{yearCards}</YearCardGrid>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user