diff --git a/components/Buttons/SignWithGitHub.tsx b/components/Buttons/SignWithGitHub.tsx index 07e045f..a85ed1a 100644 --- a/components/Buttons/SignWithGitHub.tsx +++ b/components/Buttons/SignWithGitHub.tsx @@ -1,16 +1,23 @@ import React from "react"; import styled from "styled-components"; import GitHubIcon from "@mui/icons-material/GitHub"; +import CircularProgress from "@mui/material/CircularProgress"; function SignWithGitHub(props) { - return ( - <> + if (props.withLoading) { + return ( + + + + ); + } else { + return ( Sign in with GitHub - - ); + ); + } } export default SignWithGitHub; diff --git a/components/Calendar/Calendar.tsx b/components/Calendar/Calendar.tsx index c4cc4dc..041621a 100644 --- a/components/Calendar/Calendar.tsx +++ b/components/Calendar/Calendar.tsx @@ -5,7 +5,7 @@ import { randomInt } from "crypto"; import { useRouter } from "next/router"; import { useSelector, useDispatch } from "react-redux"; import { SelectedDateInterface, updateDate } from "@redux/actions"; -import { Divider, Tooltip } from "@mui/material"; +import { Tooltip } from "@mui/material"; import { GitSt } from "@services/gitstory"; import CircularProgress from "@mui/material/CircularProgress"; import Link from "next/link"; @@ -33,6 +33,7 @@ export default function Calendar(props) { // init weekdays & Months const weekdaysArray = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]; const monthsArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; + // Get date object - Dates in month - First day of month let date = dayjs(props.date).locale("fr"); let daysInMonth = date.daysInMonth(); @@ -60,7 +61,6 @@ export default function Calendar(props) { isScanOn ? null : setIsLoading(false); } - // async function scanMonth(month, year) { setIsScanOn(true); setIsLoading(true); @@ -75,11 +75,6 @@ export default function Calendar(props) { fillCalendar(); }, [isLoading]); - // 📣 Interaction - //-------------------------------- - - // 📣 Rendering - //-------------------------------- function renderCalendar() { if (isLoading) { return ( @@ -157,14 +152,9 @@ export default function Calendar(props) { } } - // 📣 Final Rendering - //-------------------------------- return
{renderCalendar()}
; } -// 📣 Styling -//-------------------------------- - const MonthBox = styled.div` display: flex; justify-content: center; diff --git a/components/Calendar/YearCalendar.tsx b/components/Calendar/YearCalendar.tsx index 39fe25b..04536e2 100644 --- a/components/Calendar/YearCalendar.tsx +++ b/components/Calendar/YearCalendar.tsx @@ -5,12 +5,8 @@ import { randomInt } from "crypto"; import FancyRender from "@components/Loading/FancyRender"; export default function YearCalendar({ withRelativeTop = false, year }) { - // 📣 Filling & Init the YearCalendar - //-------------------------------- - let year_dates = []; - // Fill a Year of Month dates function createYearDates(year) { for (let i = 0; i < 12; i++) { year_dates.push(`${year}-${i + 1}-1`); @@ -19,8 +15,6 @@ export default function YearCalendar({ withRelativeTop = false, year }) { createYearDates(year); - // 📣 Final Rendering - //-------------------------------- return ( @@ -32,8 +26,6 @@ export default function YearCalendar({ withRelativeTop = false, year }) { ); } -// 📣 Styling -//-------------------------------- const YearCalendarBox = styled.div` top: -150px; position: relative; diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index 13d44d1..e9c12d2 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -8,9 +8,10 @@ import LogoutIcon from "@mui/icons-material/Logout"; import { GitSt } from "@services/gitstory"; import Dialog from "@components/Dialog/Dialog"; import SignWithGitHub from "@components/Buttons/SignWithGitHub"; +import { getExampleRepo } from "@services/example_repos"; export default function Header({ withLeftPart = true, withPaddings = false, ...props }) { - const { data: session } = useSession(); + const { data: session, status } = useSession(); const [headerSearchValue, setHeaderSearchValue] = useState([]); const [apiUsageCounter, setApiUsageCounter] = useState(0); @@ -31,7 +32,6 @@ export default function Header({ withLeftPart = true, withPaddings = false, ...p const visitor_limitation = 60; const signed_user_limitation = 5000; let api_limitation = session ? signed_user_limitation : visitor_limitation; - //alert("API usage: " + api_usage_counter + "/" + api_limitation); if (apiUsageCounter > api_limitation) { setOpenApiPopup(true); } else { @@ -53,7 +53,6 @@ export default function Header({ withLeftPart = true, withPaddings = false, ...p router.push("/"); }; - // Execute functions saveGitHubSessionToCookie(); if (props.disable_api_usage_check) { //setOpenApiPopup(true); @@ -62,32 +61,35 @@ export default function Header({ withLeftPart = true, withPaddings = false, ...p } const ProfileBox = () => { + if (status === "loading") { + return signIn()}>; + } if (session) { + return ( + + {session.user.name} + Profile photo + signOut()}> + + + + ); + } else { return ( <> - - {session.user.name} - - signOut()}> - - - + signIn()}> ); } - return ( - <> - signIn()}> - - ); }; return ( + - {props.title} | Gitstory + {props.title} | GitStory {/* SEO */} @@ -120,11 +122,11 @@ export default function Header({ withLeftPart = true, withPaddings = false, ...p - + GitStory logo diff --git a/components/Loading/Loading.tsx b/components/Loading/Loading.tsx index db1f389..26d1f81 100644 --- a/components/Loading/Loading.tsx +++ b/components/Loading/Loading.tsx @@ -3,9 +3,11 @@ import styled from "styled-components"; import CircularProgress from "@mui/material/CircularProgress"; function Loading() { - return - - ; + return ( + + + + ); } const LoadingBox = styled.div` @@ -17,7 +19,7 @@ const LoadingBox = styled.div` overflow: clip; font-size: 14px; box-shadow: 0 9px 11px 2px rgb(3 8 19 / 20%); -margin-top: 30px; + margin-top: 30px; position: relative; padding: 120px; display: flex; diff --git a/next.config.js b/next.config.js index 2249ddb..8900cdf 100644 --- a/next.config.js +++ b/next.config.js @@ -3,6 +3,10 @@ module.exports = { // ssr and displayName are configured by default styledComponents: true, }, + i18n: { + locales: ["en"], + defaultLocale: "en", + }, env: { // This is the default value, but we want to be explicit GITHUB_SECRET: process.env.GITHUB_SECRET, diff --git a/package-lock.json b/package-lock.json index eda3448..a62aaa2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gitstory", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "gitstory", - "version": "0.1.0", + "version": "1.0.0", "dependencies": { "@emotion/react": "^11.9.0", "@emotion/styled": "^11.8.1", diff --git a/pages/calendar/[[...slug]].tsx b/pages/calendar/[[...slug]].tsx index 008438c..680c925 100644 --- a/pages/calendar/[[...slug]].tsx +++ b/pages/calendar/[[...slug]].tsx @@ -74,7 +74,7 @@ export default function Repo() { return ( <> -
+
{slug[1]}/{slug[2]} diff --git a/pages/commits/[[...slug]].tsx b/pages/commits/[[...slug]].tsx index 474a23d..dc2beb3 100644 --- a/pages/commits/[[...slug]].tsx +++ b/pages/commits/[[...slug]].tsx @@ -64,7 +64,6 @@ export default function Repo() { useEffect(() => { if (router.isReady) { - // Get Date if (slug[3] === "date") { let date = new Date(parseInt(slug[4]), parseInt(slug[5]) - 1, parseInt(slug[6])); updateReduxDate(); @@ -135,10 +134,9 @@ export default function Repo() { - {console.log(commit)} - + @@ -234,7 +232,6 @@ const SubRepoInfo = styled.div` } `; -// Commit Box Design const CommitBox = styled.li` list-style: none; margin: 10px; @@ -260,7 +257,7 @@ const CommitRightGlobal = styled.div` margin-left: 20px; } - svg{ + svg { background-color: #10131b8f; padding: 5px; border-radius: 3px; diff --git a/pages/index.tsx b/pages/index.tsx index 8d2cf99..c22a844 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,13 +1,21 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import styled from "styled-components"; import { useRouter } from "next/router"; import KeyboardReturnIcon from "@mui/icons-material/KeyboardReturn"; import Footer from "@components/Footer/Footer"; import Header from "@components/Header/Header"; +import { getExampleRepo } from "@services/example_repos"; export default function Home() { - const [searchValue, setSearchValue] = useState([]); const router = useRouter(); + const exampleRepo = getExampleRepo(); + + const [searchValue, setSearchValue] = useState([]); + const [exampleRepoValue, setExampleRepoValue] = useState("swve/gitstory"); + + function changeRepoValue() { + setExampleRepoValue(exampleRepo); + } const handleSearchTextChange = (e) => { let value = e.target.value; @@ -27,18 +35,30 @@ export default function Home() { } }; + useEffect(() => { + changeRepoValue(); + } + , []); + + return ( -
+
{" "} - Beta + GitStory logo Beta Internet's git time machine - + Press Enter/Return to search diff --git a/redux/store/index.ts b/redux/store/index.ts index 704e94e..5b66fbb 100644 --- a/redux/store/index.ts +++ b/redux/store/index.ts @@ -1,4 +1,3 @@ -import { createStore } from "redux"; import { dateUpdate } from "@redux/reducers/dateupdate"; import { configureStore } from "@reduxjs/toolkit"; diff --git a/services/example_repos.ts b/services/example_repos.ts new file mode 100644 index 0000000..3351d49 --- /dev/null +++ b/services/example_repos.ts @@ -0,0 +1,22 @@ +const repos = [ + "tryghost/ghost", + "vercel/next.js", + "facebook/react", + "tiangolo/fastapi", + "tiangolo/typer", + "mongodb/mongo", + "swve/framestack", + "swve/gitstory", + "framer/motion", + "torvalds/linux", + "apple/swift", + "chromium/chromium", + "mozilla/firefox", + "twbs/bootstrap", + "facebook/react-native", + "python/cpython", +]; + +export function getExampleRepo() { + return repos[Math.floor(Math.random() * repos.length)]; +}