Skip to content

Commit

Permalink
feat: adding thread notification
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonNotJson committed Oct 6, 2023
1 parent 55115e1 commit f1833a4
Show file tree
Hide file tree
Showing 15 changed files with 339 additions and 26 deletions.
12 changes: 7 additions & 5 deletions apps/feeds/components/FeedLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Grid from "@mui/material/Grid"
import Card from "@mui/material/Card"
import CardActionArea from "@mui/material/CardActionArea"
import CardContent from "@mui/material/CardContent"
import Image from 'next/image'
import Image from "next/image"
import React, { useEffect, useState } from "react"
import { FeedInfo } from "../constants/types"
import { Lang, LangMap } from "../constants/langs"
Expand Down Expand Up @@ -38,14 +38,14 @@ const FeedLink = ({ name, feed, locale }: Props) => {
}
}
}
console.log(coverImg);

setCover(coverImg)
}, [])

return (
<Grid item xs={12} md={6}>
<CardActionArea component="span">
<Link
<Link
href={
(process.env.APP_ENV === "production" ? "/feeds/" : "") +
locale +
Expand Down Expand Up @@ -113,8 +113,10 @@ const FeedLink = ({ name, feed, locale }: Props) => {
</p>
</CardContent>
</div>
<div className="w-1/2 h-48 relative">
{cover && <Image src={cover} alt="Feed Cover Image" layout="responsive" />}
<div className="relative h-48 w-1/2">
{cover && (
<Image src={cover} alt="Feed Cover Image" layout="responsive" />
)}
</div>
</Card>
</Link>
Expand Down
2 changes: 2 additions & 0 deletions apps/forum/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import FeedBackBox from "./FeedBackBox";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import { API } from "@aws-amplify/api";
import { getUserAttr, getIdToken, LoadingSpinner } from "wasedatime-ui";
import { storeDate } from "@app/utils/storeDate";

const App = () => {
return (
Expand Down Expand Up @@ -67,6 +68,7 @@ const InnerApp = () => {

useEffect(() => {
fetchNotification();
storeDate();
}, []);

return (
Expand Down
15 changes: 15 additions & 0 deletions apps/forum/src/utils/getDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const getCurrentDateInJST = () => {
const date = new Date();
const jstOffset = 9 * 60; // JST is UTC+9
const localOffset = date.getTimezoneOffset();
date.setMinutes(date.getMinutes() + localOffset + jstOffset);

const YYYY = date.getFullYear();
const MM = String(date.getMonth() + 1).padStart(2, "0"); // Months are 0-based
const DD = String(date.getDate()).padStart(2, "0");
const HH = String(date.getHours()).padStart(2, "0");
const mm = String(date.getMinutes()).padStart(2, "0");
const SS = String(date.getSeconds()).padStart(2, "0");

return `${YYYY}${MM}${DD}${HH}${mm}${SS}`;
};
14 changes: 14 additions & 0 deletions apps/forum/src/utils/storeDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getCurrentDateInJST } from "./getDate";

export const storeDate = () => {
const storedDateInJST = localStorage.getItem("lastCheckedDateJST");
const currentDateInJST = getCurrentDateInJST();

if (!storedDateInJST) {
// If there's no stored date, set the current date to local storage.
localStorage.setItem("lastCheckedDateJST", currentDateInJST);
} else if (storedDateInJST !== currentDateInJST) {
// If the stored date and the current date are different, update the stored date.
localStorage.setItem("lastCheckedDateJST", currentDateInJST);
}
};
1 change: 1 addition & 0 deletions apps/root/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"vite-plugin-pwa": "0.12.0"
},
"dependencies": {
"@aws-amplify/api": "4.0.42",
"@aws-amplify/auth": "4.5.6",
"@aws-amplify/core": "4.5.6",
"@emotion/react": "11.9.0",
Expand Down
83 changes: 83 additions & 0 deletions apps/root/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions apps/root/src/components/aboutUs/MeetOurTeam/MeetOurTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ const MeetOurTeam = () => {
const { t } = useTranslation()
const [activeCardName, setActiveCardName] = useState("")

useEffect(() => {
console.log(activeCardName)
}, [activeCardName])

return (
<Wrapper>
<Title className="mt-3.5 mb-2.5 text-3xl text-light-text1 dark:text-dark-text1 sm:my-5 sm:text-4xl 2xl:text-5xl">
Expand Down
32 changes: 22 additions & 10 deletions apps/root/src/components/block/IconTextGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface IconTextGroupProps {
iconPath?: string
expanded?: boolean
currentPath?: string
tooltip?: string
}

const NavItemBlock = styled.div<NavItemBlockProps>`
Expand Down Expand Up @@ -62,6 +63,7 @@ export const IconTextGroup = ({
iconPath,
expanded,
currentPath,
tooltip,
}: IconTextGroupProps) => {
const [isHover, setIsHover] = useState(false)
return (
Expand All @@ -72,17 +74,27 @@ export const IconTextGroup = ({
onMouseOver={() => setIsHover(true)}
onMouseOut={() => setIsHover(false)}
>
<div className="text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1">
{isHover && hoverIcon ? hoverIcon : icon}
<div className="relative inline-flex items-center">
{" "}
{/* This is the wrapper */}
<div className="text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1">
{isHover && hoverIcon ? hoverIcon : icon}
</div>
{text && (
<NavItemText
className="ml-2 text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1" // added ml-2 for spacing
expanded={expanded}
>
{text}
</NavItemText>
)}
{/* Tooltip rendering */}
{tooltip && expanded && (
<span className="absolute top-1/2 left-full z-10 ml-2 w-auto -translate-y-1/2 transform whitespace-nowrap rounded bg-light-main px-3 py-2 text-xl text-dark-text1 dark:bg-dark-main">
{tooltip}
</span>
)}
</div>
{text && (
<NavItemText
className="text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1"
expanded={expanded}
>
{text}
</NavItemText>
)}
</NavItemBlock>
)
}
17 changes: 12 additions & 5 deletions apps/root/src/components/frame/MobileNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ const MobileNav = ({ navItems, openSignInModal }: Props) => {
className="flex-1 text-center"
customOnClick={() => setCurrentPath(item.path)}
>
<div className="text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1">
{item.icon}
</div>
<div className="text-lg text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1">
{item.name}
<div className="relative">
<div className="text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1">
{item.icon}
</div>
<div className="text-lg text-light-text2 group-hover:text-light-main dark:text-dark-text2 dark:group-hover:text-dark-text1">
{item.name}
</div>
{item.tooltip && (
<span className="absolute top-0 left-1/2 z-10 -translate-x-1/2 -translate-y-full transform whitespace-nowrap rounded bg-light-main px-3 py-2 text-lg text-dark-text1 dark:bg-dark-main">
{item.tooltip}
</span>
)}
</div>
</LinkOutsideRouter>
))
Expand Down
Loading

0 comments on commit f1833a4

Please sign in to comment.