diff --git a/.gitmodules b/.gitmodules index 4a4e6f771c9f..1a87981abacd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "data"] - path = data - url = https://github.com/co2birthdate/dataops.git [submodule "dataops"] path = dataops url = https://github.com/co2birthdate/dataops.git diff --git a/README.md b/README.md index 7f5f42b8a2a7..25663cc3c8f6 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ ## About this project This is the respository where CO2Birthdate's website lives. -HTML, CSS, and JS powered documents, generated using Python. +The website lets you know the difference of atmospheric carbon dioxide (CO₂) measurement on date of your birth and nowadays. + +## Developer's notes Once you've forked/cloned/downloaded/etc the repository, install project dependencies with ``` @@ -19,3 +21,9 @@ npm run dev ``` which will get a localhost up and running for development. Navigate to localhost:3000 in your browser of choice to see it in action/develop in the browser. + +To preview the website as static resources +``` +npm export +npm start +``` diff --git a/assets/jss/styles.js b/assets/jss/styles.js index 910d729d7847..0451ea7228dc 100644 --- a/assets/jss/styles.js +++ b/assets/jss/styles.js @@ -20,6 +20,13 @@ const CssStyles = () => { minHeight: '100vh', }, + 'main > h1': { + textAlign: 'center', + [theme.breakpoints.up('sm')]: { + textAlign: 'left', + }, + }, + 'main > section': { paddingBottom: theme.spacing(3), textAlign: 'center', diff --git a/components/shield.js b/components/shield.js new file mode 100644 index 000000000000..b22adc5c9ee0 --- /dev/null +++ b/components/shield.js @@ -0,0 +1,52 @@ +const Shield = ({ birthvalue, currentvalue, percentchange }) => ( + + CO₂ birthdate: {birthvalue} ppm: today we are {percentchange}% higher + + + + + + + + + + + + + + + + + Born at {birthvalue} ppm CO₂ + + + + We are {percentchange}% higher + + + + Most recent: {currentvalue} ppm CO₂ + + + +) + +export default Shield diff --git a/lib/api.js b/lib/api.js index e0b7ae30ec7c..c5c144299720 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,8 +1,8 @@ import { parse, isEqual } from 'date-fns' import { DATE_FORMAT } from './constants' -import co2Data from '../data/co2.json' -import latestCo2Data from '../data/latest.json' +import co2Data from '../dataops/output_data/co2.json' +import latestCo2Data from '../dataops/output_data/latest.json' export const getCo2Dates = async () => co2Data diff --git a/package.json b/package.json index 6e9d00024017..d849a5dcad79 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,15 @@ "version": "1.0.0", "private": true, "license": "LICENSE", + "engines": { + "node": ">=14" + }, "scripts": { + "start": "serve -l 3000 out", "clean": "rimraf out/ .next/ node_modules/.cache", "build": "next build", "export": "next export && echo > out/.nojekyll", - "prestart": "run-s clean build export", - "start": "serve -l 3000 out", - "predeploy": "run-s prestart", + "preexport": "run-s clean build", "deploy": "git add out/ && git commit -m \"Deploy to gh-pages\" && git subtree push --prefix out origin gh-pages", "dev": "next", "test": "echo 'Error: no test specified'" diff --git a/pages/co2/[date].js b/pages/co2/[date].js index 15d21fa6809d..5e2fbe62cb9e 100644 --- a/pages/co2/[date].js +++ b/pages/co2/[date].js @@ -1,21 +1,109 @@ -import Head from 'next/head' +import Box from '@material-ui/core/Box' +import List from '@material-ui/core/List' +import ListItem from '@material-ui/core/ListItem' +import ListItemText from '@material-ui/core/ListItemText' +import Typography from '@material-ui/core/Typography' import { parse, format } from 'date-fns' import Layout from '../../layouts/layout' +import Shield from '../../components/shield' import { getCo2ByDate, getCo2Dates } from '../../lib/api' -import { DATE_FORMAT, DEFAULT_DATE } from '../../lib/constants' +import { DATE_FORMAT, DEFAULT_DATE, WEBSITE_URL } from '../../lib/constants' const CO2Page = ({ date, ppm, difference, latest }) => ( <> - - - - - -

Date:

-

On this date: {ppm} ppm CO2

-

Most recent measurement: {latest.ppm} ppm CO2 on

-

That's a change of {(difference > 0) && '+'}{difference}%

+ + +   + CO2 Birthdate! + + + + + + + + {ppm} + + + ppm CO2} + secondary={'on this date'} + /> + + + + + + {latest.ppm} + + + ppm CO2} + secondary={'most recent measurement'} + /> + + + + + {(difference > 0) && '+'} + + {difference} + + % + + + that's a change + + + + + + Get your shield! + + + Right click to copy URL + + + + + + + + + HTML + +