@kud/gh-ink 0.8.0 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.js +97 -34
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1065,6 +1065,7 @@ var FRAME_COLOR = "gray";
1065
1065
  var FRAME_PAD_X = 1;
1066
1066
  var FRAME_CHROME_COLS = 2 + FRAME_PAD_X * 2;
1067
1067
  var COLS = (process.stdout.columns ?? 120) - FRAME_CHROME_COLS;
1068
+ var MODAL_CHROME_COLS = 2 + 1 * 2;
1068
1069
  var topLevelCount = (s) => s.items.filter(
1069
1070
  (i) => i.kind !== "repo-header" && i.kind !== "subgroup-header" && !i.indent
1070
1071
  ).length;
@@ -1541,12 +1542,55 @@ var TURN_LEGEND = [
1541
1542
  ["\u2190", "#FF8700", "They spoke last \xB7 your turn"],
1542
1543
  ["\u2192", "#888888", "You spoke last \xB7 waiting on them"]
1543
1544
  ];
1545
+ var CELL_GUTTER = 2;
1546
+ var COL_GAP = 3;
1547
+ var cellWidthOf = (col) => Math.max(0, ...col.rows.map((r) => r.cell.length)) + CELL_GUTTER;
1548
+ var widthOf = (col) => Math.max(
1549
+ col.title.length,
1550
+ ...col.rows.map((r) => cellWidthOf(col) + r.label.length)
1551
+ );
1552
+ var groupWidth = (group) => Math.max(0, ...group.map(widthOf));
1553
+ var layoutWidth = (groups) => groups.reduce((total, g) => total + groupWidth(g), 0) + COL_GAP * Math.max(0, groups.length - 1);
1554
+ var legendLayout = (cols, available) => {
1555
+ const across = cols.map((c) => [c]);
1556
+ if (layoutWidth(across) <= available) return across;
1557
+ const stacked = [cols.slice(0, -1), cols.slice(-1)];
1558
+ if (layoutWidth(stacked) <= available) return stacked;
1559
+ return [cols];
1560
+ };
1561
+ var LegendGroup = ({
1562
+ group,
1563
+ width,
1564
+ marginRight
1565
+ }) => /* @__PURE__ */ jsx(Box, { flexDirection: "column", width, marginRight, children: group.map((col, index) => {
1566
+ const cellWidth = cellWidthOf(col);
1567
+ return /* @__PURE__ */ jsxs(
1568
+ Box,
1569
+ {
1570
+ flexDirection: "column",
1571
+ marginTop: index === 0 ? 0 : 1,
1572
+ children: [
1573
+ /* @__PURE__ */ jsx(Text, { bold: true, dimColor: true, children: col.title }),
1574
+ col.rows.map((row) => /* @__PURE__ */ jsxs(Box, { children: [
1575
+ /* @__PURE__ */ jsx(Text, { color: row.color, bold: row.bold, children: row.cell.padEnd(cellWidth) }),
1576
+ /* @__PURE__ */ jsx(Text, { wrap: "truncate-end", children: row.label })
1577
+ ] }, col.title + row.cell + row.label))
1578
+ ]
1579
+ },
1580
+ col.title
1581
+ );
1582
+ }) });
1544
1583
  var HelpModal = ({
1545
1584
  workToggle,
1546
1585
  extensions,
1547
1586
  hasJira,
1548
1587
  tabHelp
1549
1588
  }) => {
1589
+ const { columns } = useWindowSize();
1590
+ const available = Math.max(
1591
+ 20,
1592
+ columns - FRAME_CHROME_COLS - MODAL_CHROME_COLS
1593
+ );
1550
1594
  const keys = [
1551
1595
  ["\u2191 \u2193", "navigate"],
1552
1596
  ["\u2190 \u2192 \xB7 tab", "switch tab"],
@@ -1568,6 +1612,49 @@ var HelpModal = ({
1568
1612
  ["?", "this help"],
1569
1613
  ["q", "quit"]
1570
1614
  ];
1615
+ const statusColumn = {
1616
+ title: "Status",
1617
+ rows: [
1618
+ ...healthLegend.map(([health, label]) => ({
1619
+ cell: healthDisplay[health].glyph,
1620
+ color: healthDisplay[health].color,
1621
+ bold: true,
1622
+ label
1623
+ })),
1624
+ ...TURN_LEGEND.map(([cell, color, label]) => ({
1625
+ cell,
1626
+ color,
1627
+ bold: true,
1628
+ label
1629
+ })),
1630
+ {
1631
+ cell: "\uF086",
1632
+ color: "#FF8700",
1633
+ bold: true,
1634
+ label: "Open-thread count"
1635
+ }
1636
+ ]
1637
+ };
1638
+ const cols = [
1639
+ statusColumn,
1640
+ ...tabHelp ? [
1641
+ {
1642
+ title: "Tabs",
1643
+ rows: tabHelp.map(([tab, meaning]) => ({
1644
+ cell: tab,
1645
+ color: "#FF8700",
1646
+ label: meaning
1647
+ }))
1648
+ }
1649
+ ] : [],
1650
+ {
1651
+ title: "Keys",
1652
+ rows: keys.map(([key, label]) => ({ cell: key, color: "cyan", label }))
1653
+ }
1654
+ ];
1655
+ const groups = legendLayout(cols, available);
1656
+ const widths = groups.map((g) => Math.min(groupWidth(g), available));
1657
+ const contentWidth = Math.min(available, layoutWidth(groups));
1571
1658
  return /* @__PURE__ */ jsxs(
1572
1659
  Box,
1573
1660
  {
@@ -1575,42 +1662,18 @@ var HelpModal = ({
1575
1662
  borderStyle: "round",
1576
1663
  borderColor: "cyan",
1577
1664
  paddingX: 1,
1665
+ width: contentWidth + MODAL_CHROME_COLS,
1578
1666
  children: [
1579
1667
  /* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "Legend" }),
1580
- /* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
1581
- /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginRight: 3, minWidth: 26, children: [
1582
- /* @__PURE__ */ jsx(Text, { bold: true, dimColor: true, children: "Status" }),
1583
- healthLegend.map(([health, label]) => {
1584
- const { glyph: icon, color } = healthDisplay[health];
1585
- return /* @__PURE__ */ jsxs(Box, { children: [
1586
- /* @__PURE__ */ jsx(Text, { color, bold: true, children: icon + " " }),
1587
- /* @__PURE__ */ jsx(Text, { children: " " + label })
1588
- ] }, health);
1589
- }),
1590
- TURN_LEGEND.map(([icon, color, label]) => /* @__PURE__ */ jsxs(Box, { children: [
1591
- /* @__PURE__ */ jsx(Text, { color, bold: true, children: icon + " " }),
1592
- /* @__PURE__ */ jsx(Text, { children: " " + label })
1593
- ] }, icon)),
1594
- /* @__PURE__ */ jsxs(Box, { children: [
1595
- /* @__PURE__ */ jsx(Text, { bold: true, color: "#FF8700", children: "\uF086 " }),
1596
- /* @__PURE__ */ jsx(Text, { children: " Open-thread count" })
1597
- ] })
1598
- ] }),
1599
- tabHelp ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginRight: 3, minWidth: 30, children: [
1600
- /* @__PURE__ */ jsx(Text, { bold: true, dimColor: true, children: "Tabs" }),
1601
- tabHelp.map(([tab, meaning]) => /* @__PURE__ */ jsxs(Box, { children: [
1602
- /* @__PURE__ */ jsx(Text, { color: "#FF8700", children: tab.padEnd(10) }),
1603
- /* @__PURE__ */ jsx(Text, { children: meaning })
1604
- ] }, tab))
1605
- ] }) : null,
1606
- /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
1607
- /* @__PURE__ */ jsx(Text, { bold: true, dimColor: true, children: "Keys" }),
1608
- keys.map(([k, label]) => /* @__PURE__ */ jsxs(Box, { children: [
1609
- /* @__PURE__ */ jsx(Text, { color: "cyan", children: k.padEnd(11) }),
1610
- /* @__PURE__ */ jsx(Text, { children: label })
1611
- ] }, k))
1612
- ] })
1613
- ] }),
1668
+ /* @__PURE__ */ jsx(Box, { marginTop: 1, width: contentWidth, children: groups.map((group, index) => /* @__PURE__ */ jsx(
1669
+ LegendGroup,
1670
+ {
1671
+ group,
1672
+ width: widths[index],
1673
+ marginRight: index === groups.length - 1 ? 0 : COL_GAP
1674
+ },
1675
+ group[0]?.title ?? index
1676
+ )) }),
1614
1677
  tabHelp ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Each item lands in the FIRST tab that claims it, so counts are residuals rather than totals." }) : null,
1615
1678
  /* @__PURE__ */ jsx(Text, { dimColor: true, children: "esc \xB7 ? close" })
1616
1679
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/gh-ink",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Ink components for rendering GitHub PR review comments and health — controlled, presentation-only, built on @kud/ink-ui and fed by @kud/gh.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",