Initial Commit
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
(function () {
|
||||
const dataEl = document.getElementById("chart-data");
|
||||
const canvas = document.getElementById("temperatureChart");
|
||||
if (!dataEl || !canvas) return;
|
||||
|
||||
const series = JSON.parse(dataEl.textContent || "[]");
|
||||
const colors = ["#166b5b", "#cf5a24", "#355c9a", "#7a4e9f", "#9a6235"];
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
function resizeCanvas() {
|
||||
const ratio = window.devicePixelRatio || 1;
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
canvas.width = Math.max(320, Math.floor(rect.width * ratio));
|
||||
canvas.height = Math.floor(360 * ratio);
|
||||
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
||||
}
|
||||
|
||||
function draw() {
|
||||
resizeCanvas();
|
||||
const width = canvas.clientWidth;
|
||||
const height = 360;
|
||||
const pad = { top: 24, right: 24, bottom: 44, left: 54 };
|
||||
const plotW = width - pad.left - pad.right;
|
||||
const plotH = height - pad.top - pad.bottom;
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
const points = series.flatMap((item) =>
|
||||
item.points.map((point) => ({
|
||||
...point,
|
||||
date: new Date(point.time),
|
||||
}))
|
||||
);
|
||||
|
||||
if (!points.length) {
|
||||
ctx.fillStyle = "#64706b";
|
||||
ctx.font = "16px system-ui, sans-serif";
|
||||
ctx.fillText("Waiting for readings for today.", pad.left, pad.top + 40);
|
||||
return;
|
||||
}
|
||||
|
||||
const minTime = Math.min(...points.map((point) => point.date.getTime()));
|
||||
const maxTime = Math.max(...points.map((point) => point.date.getTime()));
|
||||
const temps = points.map((point) => Number(point.temperature));
|
||||
const minTemp = Math.floor(Math.min(...temps) - 1);
|
||||
const maxTemp = Math.ceil(Math.max(...temps) + 1);
|
||||
const timeSpan = Math.max(1, maxTime - minTime);
|
||||
const tempSpan = Math.max(1, maxTemp - minTemp);
|
||||
|
||||
function xFor(date) {
|
||||
return pad.left + ((date.getTime() - minTime) / timeSpan) * plotW;
|
||||
}
|
||||
|
||||
function yFor(temp) {
|
||||
return pad.top + plotH - ((temp - minTemp) / tempSpan) * plotH;
|
||||
}
|
||||
|
||||
ctx.strokeStyle = "#dfe5df";
|
||||
ctx.lineWidth = 1;
|
||||
ctx.fillStyle = "#64706b";
|
||||
ctx.font = "12px system-ui, sans-serif";
|
||||
|
||||
for (let i = 0; i <= 4; i += 1) {
|
||||
const y = pad.top + (plotH / 4) * i;
|
||||
const temp = maxTemp - (tempSpan / 4) * i;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pad.left, y);
|
||||
ctx.lineTo(width - pad.right, y);
|
||||
ctx.stroke();
|
||||
ctx.fillText(`${temp.toFixed(1)}C`, 8, y + 4);
|
||||
}
|
||||
|
||||
series.forEach((item, index) => {
|
||||
const color = colors[index % colors.length];
|
||||
const sorted = item.points
|
||||
.map((point) => ({ ...point, date: new Date(point.time) }))
|
||||
.sort((a, b) => a.date - b.date);
|
||||
|
||||
ctx.strokeStyle = color;
|
||||
ctx.lineWidth = 3;
|
||||
ctx.beginPath();
|
||||
sorted.forEach((point, pointIndex) => {
|
||||
const x = xFor(point.date);
|
||||
const y = yFor(Number(point.temperature));
|
||||
if (pointIndex === 0) ctx.moveTo(x, y);
|
||||
else ctx.lineTo(x, y);
|
||||
});
|
||||
ctx.stroke();
|
||||
|
||||
sorted.forEach((point) => {
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
ctx.arc(xFor(point.date), yFor(Number(point.temperature)), 3, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
});
|
||||
});
|
||||
|
||||
const legendY = height - 18;
|
||||
series.forEach((item, index) => {
|
||||
const x = pad.left + index * 150;
|
||||
ctx.fillStyle = colors[index % colors.length];
|
||||
ctx.fillRect(x, legendY - 9, 10, 10);
|
||||
ctx.fillStyle = "#1d2522";
|
||||
ctx.font = "12px system-ui, sans-serif";
|
||||
ctx.fillText(item.name, x + 16, legendY);
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("resize", draw);
|
||||
draw();
|
||||
})();
|
||||
@@ -0,0 +1,327 @@
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--bg: #f6f7f4;
|
||||
--panel: #ffffff;
|
||||
--ink: #1d2522;
|
||||
--muted: #64706b;
|
||||
--line: #dfe5df;
|
||||
--brand: #166b5b;
|
||||
--brand-strong: #0d4d41;
|
||||
--accent: #cf5a24;
|
||||
--shadow: 0 10px 30px rgba(22, 37, 32, 0.08);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 14px clamp(16px, 4vw, 44px);
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: rgba(246, 247, 244, 0.92);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.brand {
|
||||
font-weight: 800;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.nav a {
|
||||
border-radius: 999px;
|
||||
padding: 8px 12px;
|
||||
color: var(--muted);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav a[aria-current="page"] {
|
||||
background: var(--ink);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.page {
|
||||
width: min(1180px, calc(100vw - 32px));
|
||||
margin: 0 auto;
|
||||
padding: 28px 0 48px;
|
||||
}
|
||||
|
||||
.hero {
|
||||
display: flex;
|
||||
align-items: end;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 6px;
|
||||
color: var(--accent);
|
||||
font-size: 0.78rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 8px;
|
||||
font-size: clamp(2rem, 4vw, 3.4rem);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: 6px;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 42px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
padding: 0 16px;
|
||||
background: var(--brand);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background: var(--brand-strong);
|
||||
}
|
||||
|
||||
.button.secondary {
|
||||
border: 1px solid var(--line);
|
||||
background: #fff;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.metric-card,
|
||||
.panel,
|
||||
.empty-state {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
background: var(--panel);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.metric-card {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.card-heading {
|
||||
display: flex;
|
||||
align-items: start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.card-heading span {
|
||||
flex: 0 0 auto;
|
||||
border-radius: 999px;
|
||||
padding: 4px 8px;
|
||||
background: #edf3ef;
|
||||
color: var(--muted);
|
||||
font-size: 0.74rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.reading-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.reading-row strong {
|
||||
font-size: 2.1rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.reading-row span {
|
||||
color: var(--muted);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.mini-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mini-stats dt {
|
||||
color: var(--muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.mini-stats dd {
|
||||
margin: 2px 0 0;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.panel-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.chart-wrap {
|
||||
min-height: 360px;
|
||||
}
|
||||
|
||||
#temperatureChart {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-height: 360px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 28px;
|
||||
}
|
||||
|
||||
.empty {
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.report-form {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, auto));
|
||||
align-items: end;
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.report-form label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
color: var(--muted);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
input,
|
||||
select {
|
||||
min-height: 42px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 0 12px;
|
||||
background: #fff;
|
||||
color: var(--ink);
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
border-bottom: 1px solid var(--line);
|
||||
padding: 12px 10px;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
th {
|
||||
color: var(--muted);
|
||||
font-size: 0.78rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.cards {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.report-form {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 620px) {
|
||||
.topbar,
|
||||
.hero,
|
||||
.panel-heading {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nav {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav a {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cards,
|
||||
.report-form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.reading-row strong {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user