-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from UnsignedArduino/staging
Environment page update
- Loading branch information
Showing
16 changed files
with
258 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { formatDuration } from "@/scripts/Utils/DateAndTime/Format"; | ||
import React from "react"; | ||
|
||
export function StaticLowPrecisionTextCountup({ | ||
date, | ||
}: { | ||
date: Date; | ||
}): React.ReactNode { | ||
const [show, setShow] = React.useState(false); | ||
const timeSince = Date.now() - date.getTime(); | ||
|
||
React.useEffect(() => { | ||
setShow(true); | ||
}, []); | ||
|
||
return ( | ||
<>{show ? (timeSince > 0 ? formatDuration(timeSince) : null) : null}</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { formatDuration } from "@/scripts/Utils/DateAndTime/Format"; | ||
import React from "react"; | ||
|
||
export function TextCountdown({ | ||
date, | ||
updatePeriod, | ||
onEnd, | ||
}: { | ||
date: Date; | ||
updatePeriod?: number; | ||
onEnd?: () => void; | ||
}): React.ReactNode { | ||
const [timeLeft, setTimeLeft] = React.useState<number>( | ||
date.getTime() - Date.now(), | ||
); | ||
|
||
React.useEffect(() => { | ||
const interval = setInterval(() => { | ||
setTimeLeft(date.getTime() - Date.now()); | ||
if (timeLeft <= 0) { | ||
clearInterval(interval); | ||
if (onEnd) { | ||
onEnd(); | ||
} | ||
} | ||
}, updatePeriod ?? 100); | ||
|
||
return () => { | ||
clearInterval(interval); | ||
}; | ||
}, [date, onEnd, timeLeft, updatePeriod]); | ||
|
||
return <>{timeLeft > 0 ? formatDuration(timeLeft) : null}</>; | ||
} | ||
|
||
export function TextCountup({ | ||
date, | ||
updatePeriod, | ||
serverRender = true, | ||
}: { | ||
date: Date; | ||
updatePeriod?: number; | ||
serverRender?: boolean; | ||
}): React.ReactNode { | ||
const [show, setShow] = React.useState(serverRender); | ||
const [timeSince, setTimeSince] = React.useState<number>( | ||
Date.now() - date.getTime(), | ||
); | ||
|
||
React.useEffect(() => { | ||
const interval = setInterval(() => { | ||
setTimeSince(Date.now() - date.getTime()); | ||
}, updatePeriod ?? 100); | ||
|
||
return () => { | ||
clearInterval(interval); | ||
}; | ||
}, [date, updatePeriod]); | ||
|
||
React.useEffect(() => { | ||
setShow(true); | ||
}, []); | ||
|
||
return ( | ||
<>{show ? (timeSince > 0 ? formatDuration(timeSince) : null) : null}</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default, getEnvironment, getBranch } from "./appProps"; | ||
export { default } from "./appProps"; | ||
export type { AppProps } from "./appProps"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React from "react"; | ||
import Layout from "../components/Layout"; | ||
import getAppProps, { AppProps } from "../components/WithAppProps"; | ||
import { formatDateAndTimeAndSecond } from "@/scripts/Utils/DateAndTime/Format"; | ||
import { TextCountup } from "@/components/TextCountFromDate"; | ||
|
||
const pageName = "Environment"; | ||
|
||
interface AboutProps { | ||
envVars: string[][]; | ||
appProps: AppProps; | ||
} | ||
|
||
export function About({ envVars, appProps }: AboutProps): JSX.Element { | ||
return ( | ||
<Layout title={pageName} currentPage={pageName} appProps={appProps}> | ||
<h1>Environment</h1> | ||
<p> | ||
Build hash:{" "} | ||
<a | ||
href={`https://github.com/UnsignedArduino/Awesome-Arcade/commit/${appProps.buildHash}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<code>{appProps.buildHash}</code> | ||
</a> | ||
<br /> | ||
Build branch:{" "} | ||
<a | ||
href={`https://github.com/UnsignedArduino/Awesome-Arcade/tree/${appProps.buildBranch}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<code>{appProps.buildBranch}</code> | ||
</a> | ||
<br /> | ||
Build time: <code>{appProps.buildTime}</code> ( | ||
{formatDateAndTimeAndSecond(new Date(appProps.buildTime))} -{" "} | ||
<TextCountup date={new Date(appProps.buildTime)} serverRender={false} />{" "} | ||
ago) | ||
</p> | ||
<h2>Build variables</h2> | ||
<code> | ||
{envVars.map((value: string[]) => { | ||
return ( | ||
<React.Fragment key={value[0]}> | ||
{value[0]}: {value[1]} | ||
<br /> | ||
</React.Fragment> | ||
); | ||
})} | ||
</code> | ||
</Layout> | ||
); | ||
} | ||
|
||
export async function getStaticProps(): Promise<{ props: AboutProps }> { | ||
const vercelEnvs = [ | ||
"NODE_ENV", | ||
"VERCEL_ENV", | ||
"VERCEL_URL", | ||
"VERCEL_GIT_PROVIDER", | ||
"VERCEL_GIT_REPO_SLUG", | ||
"VERCEL_GIT_REPO_OWNER", | ||
"VERCEL_GIT_REPO_ID", | ||
"VERCEL_GIT_COMMIT_REF", | ||
"VERCEL_GIT_COMMIT_SHA", | ||
"VERCEL_GIT_COMMIT_MESSAGE", | ||
"VERCEL_GIT_COMMIT_AUTHOR_LOGIN", | ||
"VERCEL_GIT_COMMIT_AUTHOR_NAME", | ||
]; | ||
|
||
return { | ||
props: { | ||
envVars: vercelEnvs.map((envVar: string) => { | ||
return [ | ||
envVar, | ||
process.env[envVar] != undefined ? process.env[envVar] : "undefined", | ||
]; | ||
}) as string[][], | ||
appProps: await getAppProps(), | ||
}, | ||
}; | ||
} | ||
|
||
export default About; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.