diff --git a/src/Contributors.jsx b/src/Contributors.jsx new file mode 100644 index 0000000..a375cf2 --- /dev/null +++ b/src/Contributors.jsx @@ -0,0 +1,75 @@ +import React, { useState } from "react" +import { createPortal } from "react-dom" +import clsx from "clsx" + +import cdownURL from "./cdown.svg" + +function CDown() { + return +} + +const contributors = [ + { + name: "Ethan", + avatar: "https://avatars2.githubusercontent.com/u/2985314?s=400", + url: "https://github.com/ethteck", + description:
+
, + }, + { + name: "stuckpixel", + avatar: "https://avatars3.githubusercontent.com/u/3634616?s=400", + url: "https://github.com/pixel-stuck", + description:
+
, + }, + { + name: "alex", + avatar: "https://avatars3.githubusercontent.com/u/9429556?s=400", + url: "https://github.com/nanaian", + description:
+
, + }, +] + +export default function Contributors({ captionPortal }) { + const [selected, setSelected] = useState(0) + const { name, description, url } = contributors[selected] + + return
+
+
+ {contributors.map((contributor, i) => { + let t = (Math.PI * 2) * ((i - selected) / contributors.length) + Math.PI/2 + + let x = 150 * Math.cos(t) + 200 + let y = 140 * Math.sin(t) + 200 + + return setSelected(i)} + src={contributor.avatar} + alt={contributor.name} + style={{ top: y + "px", left: x + "px", zIndex: y }} + /> + })} +
+ + +
+ +
+
+
+
+
+
+ + {captionPortal.current && createPortal(
+ {description} +
, captionPortal.current)} +
+} diff --git a/src/ProgressPane.jsx b/src/ProgressPane.jsx index 0cca4c5..8073003 100644 --- a/src/ProgressPane.jsx +++ b/src/ProgressPane.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useRef } from "react" +import React, { useState, useEffect } from "react" import { createPortal } from "react-dom" import { Area, XAxis, YAxis, AreaChart, CartesianGrid, Tooltip, ResponsiveContainer } from "recharts" import { scalePow } from "d3-scale" @@ -19,11 +19,16 @@ const csvVersions = { }, } -async function fetchData() { - const csv = await fetch("https://papermar.io/reports/progress.csv") +const colors = { + yellow: { stroke: "#e3ac34", fill: "#edc97e" }, + green: { stroke: "#40e334", fill: "#91eb7f" }, +} + +async function fetchData(version) { + const csv = await fetch(`https://papermar.io/reports/progress_${version}.csv`) .then(response => response.text()) - return csv + const rows = csv .split("\n") .filter(row => row.length) .map(row => { @@ -35,29 +40,29 @@ async function fetchData() { obj[key] = transform(data.shift()) } - obj.percentBytes = Math.round((obj.matchingBytes / obj.totalBytes) * 100) - return obj }) + + const latest = rows[rows.length - 1] + for (const row of rows) { + row.percentBytes = (row.matchingBytes / latest.totalBytes) * 100 + } + + return rows } -let cachedData = null - -export default function ProgressPane({ captionPortal, nonce }) { - const [data, setData] = useState(cachedData) +export default function ProgressPane({ captionPortal, nonce, color, version }) { + const [data, setData] = useState([]) useEffect(() => { - fetchData() + fetchData(version) .then(data => { - cachedData = data - setData(cachedData) + setData(data) }) - }, []) - - // TODO: cute spin animation when data loads + }, [version]) return
- {data && } + {data && } {!data && "Loading..."}
} @@ -73,9 +78,10 @@ const monthDates = [] } } -function DataView({ data, captionPortal, nonce }) { +function DataView({ data, captionPortal, nonce, color }) { const latest = data[data.length - 1] const oldest = data[0] + const { stroke, fill } = colors[color] const [selectedEntry, setSelectedEntry] = useState(latest) @@ -89,18 +95,9 @@ function DataView({ data, captionPortal, nonce }) { return } - const maxPercent = Math.ceil(latest.percentBytes / 25) * 25 + const maxPercent = latest ? Math.ceil(latest.percentBytes / 25) * 25 : 25 return <> - {/* - - - - - - -
Matched{Math.round((latest.matchingBytes / latest.totalBytes) * 10000) / 100}%
*/} -
@@ -115,8 +112,8 @@ function DataView({ data, captionPortal, nonce }) { type="linear" dataKey="percentBytes" unit="%" - stroke="#e3ac34" strokeWidth={2} - fill="#edc97e" + stroke={stroke} strokeWidth={2} + fill={fill} dot={true} isAnimationActive={false} /> @@ -127,7 +124,7 @@ function DataView({ data, captionPortal, nonce }) {
-