Skip to content

Commit

Permalink
Push latest code with next birthday function
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenPG committed Mar 9, 2024
1 parent f558ba1 commit f70215a
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 18 deletions.
6 changes: 3 additions & 3 deletions asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.073c9b0a.css",
"main.js": "/static/js/main.bf458550.js",
"main.js": "/static/js/main.a353131e.js",
"static/js/787.e3145bef.chunk.js": "/static/js/787.e3145bef.chunk.js",
"index.html": "/index.html",
"main.073c9b0a.css.map": "/static/css/main.073c9b0a.css.map",
"main.bf458550.js.map": "/static/js/main.bf458550.js.map",
"main.a353131e.js.map": "/static/js/main.a353131e.js.map",
"787.e3145bef.chunk.js.map": "/static/js/787.e3145bef.chunk.js.map"
},
"entrypoints": [
"static/css/main.073c9b0a.css",
"static/js/main.bf458550.js"
"static/js/main.a353131e.js"
]
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="An answer to the question, how many cats do you have and how old are they?"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>How Old Are My Cats</title><script async src="https://www.googletagmanager.com/gtag/js?id=G-VRLRYJ97EF"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-VRLRYJ97EF")</script><script defer="defer" src="/static/js/main.bf458550.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="An answer to the question, how many cats do you have and how old are they?"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>How Old Are My Cats</title><script async src="https://www.googletagmanager.com/gtag/js?id=G-VRLRYJ97EF"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-VRLRYJ97EF")</script><script defer="defer" src="/static/js/main.a353131e.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
7 changes: 3 additions & 4 deletions new-cat-site/cat-site/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function App() {
* @param isoBirthdate incoming iso Birthdate
*/
function time_since(isoBirthdate: string): string {
console.log("Incoming " + isoBirthdate);
let currDate = new Date();
let birthDate = new Date(isoBirthdate);
let differenceInTimeMillis = currDate.getTime() - birthDate.getTime();
Expand All @@ -25,8 +24,6 @@ function App() {
let yearQuotient = Math.floor(differenceInTimeDays / 365);
let yearRemainder = differenceInTimeDays % 365;
let monthQuotient = Math.floor(yearRemainder / 30);
console.log("Years: " + yearQuotient);
console.log("Days: " + yearRemainder);
return yearQuotient + " Years " + monthQuotient + " Months old";
}

Expand All @@ -35,7 +32,9 @@ function App() {
<header className="App-header">
{/*// TODO - add a filter that will hide cards when you type in the filter*/}
<div style={{marginBottom: "3em"}}>
<TopBar/>
<TopBar
content={textContent.cards}
/>
</div>
<Grid container spacing={1}>
{
Expand Down
21 changes: 17 additions & 4 deletions new-cat-site/cat-site/src/app/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,41 @@ import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';

import textContent from "./contents.json";
import { nextBirthdayAsStr } from './birthday-calc';

export default function TopBar() {
export default function TopBar(props: any) {

const initialText = textContent["topBar"]["textBeginning"];

const styles = {
maxWidth: {
width: "100%"
},
strikethru: {
textDecoration: "line-through"
}
};

return (
<Box>
<AppBar style={{width: "100%"}}>
<AppBar style={styles.maxWidth}>
<Toolbar>
{/* Align text with center of screen */}
<Typography variant="h5" component="div">
{ initialText }
</Typography>
&nbsp;
<Typography variant="h5" component="div" style={{textDecoration: "line-through"}}>
<Typography variant="h5" component="div" style={styles.strikethru}>
{ textContent["topBar"]["textStruckThrough"] }
</Typography>
&nbsp;
<Typography variant="h5" component="div">
{ textContent["topBar"]["textEnd"]}
</Typography>
{/* // TODO put strike-thrus */}
&nbsp;
<Typography variant="h5" component="div">
- Next Birthday Is {nextBirthdayAsStr()}
</Typography>
</Toolbar>
</AppBar>
</Box>
Expand Down
31 changes: 31 additions & 0 deletions new-cat-site/cat-site/src/app/birthday-calc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import textContent from "./contents.json";

/**
* This takes in the entire props structure and manipulates incoming string data to generate
* a formatted output to be directly displayed.
* @returns the next birthday details as a string used for the banner of the page
*/
export function nextBirthdayAsStr(): string {
let soonestName: string = ""
let soonestDate: Date = new Date()
let soonestDays: number = 99999
textContent.cards.forEach(details => {
const date = new Date(details.birthdate);
const todaysDate = new Date();

date.setFullYear(2000);
todaysDate.setFullYear(2000);

let diff = date.getTime() - todaysDate.getTime()
var diffDays = Math.ceil(diff / (1000 * 3600 * 24));

// Number of diff days is in the future, and is less than current soonest days
if (diffDays > 0 && diffDays < soonestDays) {
soonestName = details.name
soonestDate = new Date(details.birthdate)
soonestDays = diffDays
}
})

return `${soonestName}`;
}
2 changes: 0 additions & 2 deletions new-cat-site/cat-site/src/app/catcard/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as React from 'react';
import Card from '@mui/joy/Card';
import CardContent from '@mui/joy/CardContent';
import Typography from '@mui/joy/Typography';
import Carousel from "react-material-ui-carousel";

export default function BasicCard(props: any) {

Expand Down
6 changes: 3 additions & 3 deletions static/js/main.bf458550.js → static/js/main.a353131e.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions static/js/main.a353131e.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion static/js/main.bf458550.js.map

This file was deleted.

0 comments on commit f70215a

Please sign in to comment.