@siegesailor/terminal-sigma 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { usePalette } from "../theme.js";
|
|
4
|
+
const percentOf = (metric) => Math.min(Math.max(Math.round(metric.value), 0), 100);
|
|
4
5
|
// A half-height bar: "▀" fills only the top of its row, so the bottom half
|
|
5
|
-
// spaces the items apart without a whole blank row.
|
|
6
|
+
// spaces the items apart without a whole blank row. Text centers in its row,
|
|
7
|
+
// so the percentage sits on the label's row instead of beside the bar.
|
|
6
8
|
function Bar({ metric, width }) {
|
|
7
9
|
const palette = usePalette();
|
|
8
|
-
const
|
|
9
|
-
const filled = Math.round((value / 100) * width);
|
|
10
|
+
const filled = Math.round((percentOf(metric) / 100) * width);
|
|
10
11
|
return (React.createElement(Text, null,
|
|
11
12
|
React.createElement(Text, { color: metric.color }, "▀".repeat(filled)),
|
|
12
|
-
React.createElement(Text, { color: palette.border }, "▀".repeat(width - filled))
|
|
13
|
-
React.createElement(Text, { dimColor: true }, ` ${String(value).padStart(3)}%`)));
|
|
13
|
+
React.createElement(Text, { color: palette.border }, "▀".repeat(width - filled))));
|
|
14
14
|
}
|
|
15
15
|
// Breathing room inside the border and between sections, unless the
|
|
16
16
|
// terminal is too short for it.
|
|
17
17
|
export default function TodayPanel({ title, sections, width, isCompact = false, }) {
|
|
18
18
|
const palette = usePalette();
|
|
19
19
|
const gap = isCompact ? 0 : 1;
|
|
20
|
-
// Border and padding take 6 columns
|
|
21
|
-
const barWidth = Math.max(width -
|
|
20
|
+
// Border and padding take 6 columns.
|
|
21
|
+
const barWidth = Math.max(width - 6, 4);
|
|
22
22
|
return (React.createElement(Box, { borderColor: palette.border, borderStyle: "round", flexDirection: "column", flexShrink: 0, paddingX: 2, paddingY: gap, width: width },
|
|
23
23
|
React.createElement(Text, { bold: true }, title),
|
|
24
24
|
sections.map((section, index) => (React.createElement(Box, { key: section.title ?? `section-${index}`, flexDirection: "column", marginTop: index === 0 ? gap : 1 },
|
|
@@ -27,7 +27,10 @@ export default function TodayPanel({ title, sections, width, isCompact = false,
|
|
|
27
27
|
React.createElement(Box, { gap: 1, justifyContent: "space-between" },
|
|
28
28
|
React.createElement(Box, { flexShrink: 0 },
|
|
29
29
|
React.createElement(Text, { color: metric.color }, metric.label)),
|
|
30
|
-
React.createElement(
|
|
30
|
+
React.createElement(Box, { flexGrow: 1, justifyContent: "flex-end" },
|
|
31
|
+
React.createElement(Text, { dimColor: true, wrap: "truncate-end" }, metric.detail)),
|
|
32
|
+
React.createElement(Box, { flexShrink: 0 },
|
|
33
|
+
React.createElement(Text, null, `${percentOf(metric)}%`))),
|
|
31
34
|
React.createElement(Bar, { metric: metric, width: barWidth })))),
|
|
32
35
|
section.advice ? (React.createElement(Text, { wrap: "truncate-end" },
|
|
33
36
|
React.createElement(Text, { color: section.advice.isDone ? palette.success : palette.accent }, "⏺ "),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"today-panel.js","sourceRoot":"","sources":["../../source/components/today-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsBzC,
|
|
1
|
+
{"version":3,"file":"today-panel.js","sourceRoot":"","sources":["../../source/components/today-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsBzC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE,CACpC,IAAI,CAAC,GAAG,CAAC,IAA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