Upgrades #54
@@ -240,7 +240,12 @@ const CalenderContextProvider = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const calenderContextValues = {
|
// * Attempting to fix an issue with static generation where the date does not appear to be updating after initial generation.
|
||||||
|
const [currDate, setCurrDate] = useState<Date>(new Date());
|
||||||
|
|
||||||
|
const calenderContextValues: CalenderContextState = {
|
||||||
|
currDate,
|
||||||
|
setCurrDate,
|
||||||
selectedDate,
|
selectedDate,
|
||||||
title: selectedDateInfo.title,
|
title: selectedDateInfo.title,
|
||||||
layout: selectedDateInfo.layout,
|
layout: selectedDateInfo.layout,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { createContext, useState, ReactNode } from "react";
|
import React, { createContext, useState, ReactNode } from "react";
|
||||||
import { format, getDate, isBefore, startOfDay } from "date-fns";
|
import { format, getDate, isSameDay } from "date-fns";
|
||||||
import stickersSeeder from "../data/stickerSeeder";
|
import stickersSeeder from "../data/stickerSeeder";
|
||||||
|
|
||||||
const StickersContext = createContext({} as StickersContextState);
|
const StickersContext = createContext({} as StickersContextState);
|
||||||
@@ -21,9 +21,9 @@ const StickersContextProvider = ({
|
|||||||
|
|
||||||
const edited = currDate.edited
|
const edited = currDate.edited
|
||||||
? true
|
? true
|
||||||
: isBefore(currDate.date, startOfDay(new Date()))
|
: isSameDay(currDate.date, new Date())
|
||||||
? true
|
? false
|
||||||
: false;
|
: true;
|
||||||
currDate.edited = edited;
|
currDate.edited = edited;
|
||||||
// Add manual here when necessary.
|
// Add manual here when necessary.
|
||||||
|
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -2,7 +2,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"name": "lucid-creations-media-potty-chart",
|
"name": "lucid-creations-media-potty-chart",
|
||||||
"homepage": "https://lucidcreations.media/introducing-code-name-potty-chart/",
|
"homepage": "https://lucidcreations.media/introducing-code-name-potty-chart/",
|
||||||
"version": "v0.0.9.8-alpha",
|
"version": "v0.0.9.9-alpha",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Lucid Creations Media",
|
"name": "Lucid Creations Media",
|
||||||
"url": "https://lucidcreations.media",
|
"url": "https://lucidcreations.media",
|
||||||
@@ -22,16 +22,16 @@
|
|||||||
"@iconify/react": "^3.2.1",
|
"@iconify/react": "^3.2.1",
|
||||||
"date-fns": "^2.28.0",
|
"date-fns": "^2.28.0",
|
||||||
"formik": "^2.2.9",
|
"formik": "^2.2.9",
|
||||||
"framer-motion": "^6.3.1",
|
"framer-motion": "^6.3.3",
|
||||||
"next": "12.1.5",
|
"next": "12.1.5",
|
||||||
"react": "<=17.0.2",
|
"react": "<=17.0.2",
|
||||||
"react-dom": "<=17.0.2",
|
"react-dom": "<=17.0.2",
|
||||||
"sharp": "^0.30.4"
|
"sharp": "^0.30.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "<=17.0.2",
|
"@types/node": "^17.0.30",
|
||||||
"@types/node": "^17.0.25",
|
"@types/react": "<18.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
||||||
"eslint": "^8.14.0",
|
"eslint": "^8.14.0",
|
||||||
"eslint-config-next": "^12.1.5",
|
"eslint-config-next": "^12.1.5",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
@@ -41,5 +41,8 @@
|
|||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"typescript": "<4.6.0"
|
"typescript": "<4.6.0"
|
||||||
},
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"@types/react": "^17.0.38"
|
||||||
|
},
|
||||||
"packageManager": "yarn@3.1.0"
|
"packageManager": "yarn@3.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
getMonth,
|
getMonth,
|
||||||
sub,
|
sub,
|
||||||
getDate,
|
getDate,
|
||||||
isSameDay,
|
|
||||||
isBefore,
|
isBefore,
|
||||||
endOfDay
|
endOfDay
|
||||||
} from "date-fns";
|
} from "date-fns";
|
||||||
@@ -21,6 +20,8 @@ interface DayProps {
|
|||||||
sticker: StickerVal;
|
sticker: StickerVal;
|
||||||
date: Date;
|
date: Date;
|
||||||
selectedDate: Date;
|
selectedDate: Date;
|
||||||
|
currDate: Date;
|
||||||
|
isToday: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +38,9 @@ const Day = ({
|
|||||||
overflowDirection,
|
overflowDirection,
|
||||||
sticker,
|
sticker,
|
||||||
date,
|
date,
|
||||||
selectedDate
|
selectedDate,
|
||||||
|
currDate,
|
||||||
|
isToday
|
||||||
}: DayProps): JSX.Element => {
|
}: DayProps): JSX.Element => {
|
||||||
const handleNav = (direction: "next" | "prev") => {
|
const handleNav = (direction: "next" | "prev") => {
|
||||||
if (direction === "next") {
|
if (direction === "next") {
|
||||||
@@ -90,9 +93,7 @@ const Day = ({
|
|||||||
w="100%"
|
w="100%"
|
||||||
h="100%"
|
h="100%"
|
||||||
_hover={{
|
_hover={{
|
||||||
cursor: isBefore(date, endOfDay(new Date()))
|
cursor: isBefore(date, endOfDay(currDate)) ? "pointer" : "default",
|
||||||
? "pointer"
|
|
||||||
: "default",
|
|
||||||
background: "gray.700",
|
background: "gray.700",
|
||||||
border: "1px solid #FFF",
|
border: "1px solid #FFF",
|
||||||
color: "whiteAlpha.900"
|
color: "whiteAlpha.900"
|
||||||
@@ -131,16 +132,14 @@ const Day = ({
|
|||||||
justifyContent="flex-start"
|
justifyContent="flex-start"
|
||||||
pt={2}
|
pt={2}
|
||||||
_hover={{
|
_hover={{
|
||||||
cursor: isBefore(date, endOfDay(new Date()))
|
cursor: isBefore(date, endOfDay(currDate)) ? "pointer" : "default",
|
||||||
? "pointer"
|
|
||||||
: "default",
|
|
||||||
background: "gray.700",
|
background: "gray.700",
|
||||||
border: "1px solid #FFF"
|
border: "1px solid #FFF"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
p={
|
p={
|
||||||
isSameDay(new Date(), date)
|
isToday
|
||||||
? getDate(date) > 10
|
? getDate(date) > 10
|
||||||
? "0px 6px 3px 6px"
|
? "0px 6px 3px 6px"
|
||||||
: "0px 9px 3px 9px"
|
: "0px 9px 3px 9px"
|
||||||
@@ -148,8 +147,8 @@ const Day = ({
|
|||||||
}
|
}
|
||||||
h="auto"
|
h="auto"
|
||||||
w="auto"
|
w="auto"
|
||||||
border={isSameDay(new Date(), date) ? "1px solid #0068ff" : "0px"}
|
border={isToday ? "1px solid #0068ff" : "0px"}
|
||||||
borderRadius={isSameDay(new Date(), date) ? "100px" : "0px"}
|
borderRadius={isToday ? "100px" : "0px"}
|
||||||
>
|
>
|
||||||
{`${getDate(date)}`}
|
{`${getDate(date)}`}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -162,7 +161,7 @@ const Day = ({
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<StickersContextProvider>
|
<StickersContextProvider>
|
||||||
{isBefore(date, endOfDay(new Date())) && (
|
{isBefore(date, endOfDay(currDate)) && (
|
||||||
<AddUpdateSticker
|
<AddUpdateSticker
|
||||||
date={date}
|
date={date}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
@@ -173,6 +172,7 @@ const Day = ({
|
|||||||
updateStep={setStep}
|
updateStep={setStep}
|
||||||
selectedSticker={selectedSticker}
|
selectedSticker={selectedSticker}
|
||||||
updateSelectedSticker={setSelectedSticker}
|
updateSelectedSticker={setSelectedSticker}
|
||||||
|
currDate={currDate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</StickersContextProvider>
|
</StickersContextProvider>
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import CalenderNav from "./CalenderNav";
|
|||||||
import Day from "./Day";
|
import Day from "./Day";
|
||||||
|
|
||||||
const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
|
const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
|
||||||
const { selectedDate, layout, updateDate } = useContext(CalenderContext);
|
const { selectedDate, layout, updateDate, currDate, setCurrDate } =
|
||||||
|
useContext(CalenderContext);
|
||||||
const { stickersMonth } = useContext(StickersContext);
|
const { stickersMonth } = useContext(StickersContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -22,6 +23,14 @@ const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
|
|||||||
}
|
}
|
||||||
}, [newDate, updateDate]);
|
}, [newDate, updateDate]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.info("Check to update date.");
|
||||||
|
if (!isSameDay(currDate, new Date())) {
|
||||||
|
console.info("Updated date.");
|
||||||
|
setCurrDate(new Date());
|
||||||
|
}
|
||||||
|
}, [currDate, setCurrDate]);
|
||||||
|
|
||||||
// Simulated user settings context
|
// Simulated user settings context
|
||||||
const userSettings = {
|
const userSettings = {
|
||||||
theme: "default",
|
theme: "default",
|
||||||
@@ -91,6 +100,8 @@ const Calender = (newDate?: UpdateCalendarProps): JSX.Element => {
|
|||||||
sticker={sticker}
|
sticker={sticker}
|
||||||
date={date}
|
date={date}
|
||||||
selectedDate={selectedDate}
|
selectedDate={selectedDate}
|
||||||
|
currDate={currDate}
|
||||||
|
isToday={isSameDay(currDate, date)}
|
||||||
key={
|
key={
|
||||||
id.length
|
id.length
|
||||||
? id
|
? id
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ interface AddStickerProps {
|
|||||||
updateStep: React.Dispatch<React.SetStateAction<number>>;
|
updateStep: React.Dispatch<React.SetStateAction<number>>;
|
||||||
selectedSticker: StickerVal;
|
selectedSticker: StickerVal;
|
||||||
updateSelectedSticker: React.Dispatch<React.SetStateAction<StickerVal>>;
|
updateSelectedSticker: React.Dispatch<React.SetStateAction<StickerVal>>;
|
||||||
|
currDate: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +53,8 @@ const AddUpdateSticker = ({
|
|||||||
step,
|
step,
|
||||||
updateStep,
|
updateStep,
|
||||||
selectedSticker,
|
selectedSticker,
|
||||||
updateSelectedSticker
|
updateSelectedSticker,
|
||||||
|
currDate
|
||||||
}: AddStickerProps): JSX.Element => {
|
}: AddStickerProps): JSX.Element => {
|
||||||
// TODO: Import the stickers array from the calender context.
|
// TODO: Import the stickers array from the calender context.
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ const AddUpdateSticker = ({
|
|||||||
// ! Update these states to say "add" and "edit" for easier reading.
|
// ! Update these states to say "add" and "edit" for easier reading.
|
||||||
|
|
||||||
const [modalVariant] = useState<"currDate" | "notCurrDate">(
|
const [modalVariant] = useState<"currDate" | "notCurrDate">(
|
||||||
isSameDay(date, new Date()) ? "currDate" : "notCurrDate"
|
isSameDay(date, currDate) ? "currDate" : "notCurrDate"
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
|||||||
@@ -7,18 +7,20 @@ import Head from "next/head";
|
|||||||
|
|
||||||
function LCMPottyChart({ Component, pageProps }: AppProps): JSX.Element {
|
function LCMPottyChart({ Component, pageProps }: AppProps): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<ChakraProvider theme={AppTheme}>
|
<React.StrictMode>
|
||||||
<Layout {...pageProps}>
|
<ChakraProvider theme={AppTheme}>
|
||||||
<Head>
|
<Layout {...pageProps}>
|
||||||
<title>{"LCM Potty Chart"}</title>
|
<Head>
|
||||||
<meta
|
<title>{"LCM Potty Chart"}</title>
|
||||||
name="viewport"
|
<meta
|
||||||
content="width=device-width, user-scalable=yes, initial-scale=1.0"
|
name="viewport"
|
||||||
/>
|
content="width=device-width, user-scalable=yes, initial-scale=1.0"
|
||||||
</Head>
|
/>
|
||||||
<Component {...pageProps} />
|
</Head>
|
||||||
</Layout>
|
<Component {...pageProps} />
|
||||||
</ChakraProvider>
|
</Layout>
|
||||||
|
</ChakraProvider>
|
||||||
|
</React.StrictMode>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import appLogo from "../../../public/images/logo.svg";
|
|||||||
|
|
||||||
const Header = (): JSX.Element => {
|
const Header = (): JSX.Element => {
|
||||||
const appName = "LCM Potty Chart";
|
const appName = "LCM Potty Chart";
|
||||||
const appVersion = "v0.0.9.8-alpha";
|
const appVersion = "v0.0.9.9-alpha";
|
||||||
|
|
||||||
// Add transparency while not at the top of the page.
|
// Add transparency while not at the top of the page.
|
||||||
const [transparentNavbar, setTransparentNavbar] = useState<boolean>(false);
|
const [transparentNavbar, setTransparentNavbar] = useState<boolean>(false);
|
||||||
|
|||||||
2
types/CalenderContext.d.ts
vendored
2
types/CalenderContext.d.ts
vendored
@@ -55,6 +55,8 @@ interface UpdateCalendarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CalenderContextState {
|
interface CalenderContextState {
|
||||||
|
currDate: Date;
|
||||||
|
setCurrDate: React.Dispatch<React.SetStateAction<Date>>;
|
||||||
selectedDate: Date;
|
selectedDate: Date;
|
||||||
title: string;
|
title: string;
|
||||||
layout: MonthLayout;
|
layout: MonthLayout;
|
||||||
|
|||||||
Reference in New Issue
Block a user