git-viewer 11.0.0 → 13.0.0

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/entry.bundled.js +215 -56
  2. package/package.json +1 -1
@@ -1615,6 +1615,7 @@ var AppStore = class extends TypedEventTarget {
1615
1615
  __publicField(this, "search", "");
1616
1616
  __publicField(this, "selectedCommit", null);
1617
1617
  __publicField(this, "fullscreenDiff", false);
1618
+ __publicField(this, "theme", "light");
1618
1619
  }
1619
1620
  setRefs(refs) {
1620
1621
  this.refs = refs;
@@ -1628,6 +1629,15 @@ var AppStore = class extends TypedEventTarget {
1628
1629
  this.search = search;
1629
1630
  this.dispatchEvent(new Event("filter"));
1630
1631
  }
1632
+ setTheme(theme) {
1633
+ this.theme = theme;
1634
+ try {
1635
+ localStorage.setItem(THEME_STORAGE_KEY, theme);
1636
+ } catch {
1637
+ }
1638
+ applyTheme(theme);
1639
+ this.dispatchEvent(new Event("theme"));
1640
+ }
1631
1641
  selectCommit(commit) {
1632
1642
  this.selectedCommit = commit;
1633
1643
  this.dispatchEvent(new Event("selectedCommit"));
@@ -1639,7 +1649,8 @@ var AppStore = class extends TypedEventTarget {
1639
1649
  });
1640
1650
  }
1641
1651
  };
1642
- var colors = {
1652
+ var THEME_STORAGE_KEY = "git-viewer-theme";
1653
+ var lightPalette = {
1643
1654
  bg: "#ffffff",
1644
1655
  bgLight: "#f6f8fa",
1645
1656
  bgLighter: "#eaeef2",
@@ -1649,9 +1660,30 @@ var colors = {
1649
1660
  accent: "#0969da",
1650
1661
  accentDim: "#ddf4ff",
1651
1662
  green: "#1a7f37",
1652
- red: "#cf222e"
1663
+ red: "#cf222e",
1664
+ diffAddBg: "#dafbe1",
1665
+ diffDelBg: "#ffebe9",
1666
+ diffAddText: "#116329",
1667
+ diffDelText: "#a40e26"
1653
1668
  };
1654
- var graphColors = [
1669
+ var darkPalette = {
1670
+ bg: "#0b0f14",
1671
+ bgLight: "#111821",
1672
+ bgLighter: "#1a2431",
1673
+ border: "#283241",
1674
+ text: "#e6edf3",
1675
+ textMuted: "#9aa7b4",
1676
+ accent: "#7aa2ff",
1677
+ accentDim: "#0b1b33",
1678
+ green: "#3fb950",
1679
+ red: "#ff7b72",
1680
+ diffAddBg: "#132a1f",
1681
+ diffDelBg: "#2a1619",
1682
+ diffAddText: "#7ee787",
1683
+ diffDelText: "#ffa198"
1684
+ };
1685
+ var colors = lightPalette;
1686
+ var graphColorsLight = [
1655
1687
  "#0969da",
1656
1688
  // blue
1657
1689
  "#8250df",
@@ -1669,30 +1701,71 @@ var graphColors = [
1669
1701
  "#0550ae"
1670
1702
  // dark blue
1671
1703
  ];
1704
+ var graphColorsDark = [
1705
+ "#7aa2ff",
1706
+ // blue
1707
+ "#b488ff",
1708
+ // purple
1709
+ "#ff8bd3",
1710
+ // pink
1711
+ "#ff7b72",
1712
+ // red
1713
+ "#f5b85b",
1714
+ // orange
1715
+ "#f2cc8f",
1716
+ // amber
1717
+ "#3fb950",
1718
+ // green
1719
+ "#5cc8ff"
1720
+ // cyan
1721
+ ];
1722
+ var graphColors = graphColorsLight;
1723
+ function loadTheme() {
1724
+ try {
1725
+ let stored = localStorage.getItem(THEME_STORAGE_KEY);
1726
+ if (stored === "light" || stored === "dark") return stored;
1727
+ } catch {
1728
+ }
1729
+ let media = window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
1730
+ return media && media.matches ? "dark" : "light";
1731
+ }
1732
+ function applyTheme(theme) {
1733
+ document.documentElement.dataset.theme = theme;
1734
+ document.documentElement.style.colorScheme = theme;
1735
+ document.body.style.backgroundColor = theme === "dark" ? darkPalette.bg : lightPalette.bg;
1736
+ }
1672
1737
  function App(handle) {
1673
1738
  let store = new AppStore();
1674
1739
  handle.context.set(store);
1740
+ store.setTheme(loadTheme());
1741
+ handle.on(store, {
1742
+ theme: () => handle.update()
1743
+ });
1675
1744
  handle.queueTask(async (signal) => {
1676
1745
  let refs = await fetchRefs(signal);
1677
1746
  store.setRefs(refs);
1678
1747
  });
1679
- return () => /* @__PURE__ */ jsx(
1680
- "div",
1681
- {
1682
- css: {
1683
- display: "flex",
1684
- height: "100vh",
1685
- background: colors.bg,
1686
- color: colors.text,
1687
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
1688
- fontSize: "13px"
1689
- },
1690
- children: [
1691
- /* @__PURE__ */ jsx(Sidebar, {}),
1692
- /* @__PURE__ */ jsx(MainPanel, {})
1693
- ]
1694
- }
1695
- );
1748
+ return () => {
1749
+ colors = store.theme === "dark" ? darkPalette : lightPalette;
1750
+ graphColors = store.theme === "dark" ? graphColorsDark : graphColorsLight;
1751
+ return /* @__PURE__ */ jsx(
1752
+ "div",
1753
+ {
1754
+ css: {
1755
+ display: "flex",
1756
+ height: "100vh",
1757
+ background: colors.bg,
1758
+ color: colors.text,
1759
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
1760
+ fontSize: "13px"
1761
+ },
1762
+ children: [
1763
+ /* @__PURE__ */ jsx(Sidebar, {}),
1764
+ /* @__PURE__ */ jsx(MainPanel, {})
1765
+ ]
1766
+ }
1767
+ );
1768
+ };
1696
1769
  }
1697
1770
  function Sidebar(handle) {
1698
1771
  let store = handle.context.get(App);
@@ -1729,7 +1802,8 @@ function Sidebar(handle) {
1729
1802
  RefSection,
1730
1803
  {
1731
1804
  title: remote.toUpperCase(),
1732
- nodes
1805
+ nodes,
1806
+ initialExpanded: false
1733
1807
  },
1734
1808
  remote
1735
1809
  ))
@@ -1739,36 +1813,43 @@ function Sidebar(handle) {
1739
1813
  );
1740
1814
  }
1741
1815
  function RefSection(handle) {
1742
- let expanded = true;
1743
- return ({ title, nodes }) => /* @__PURE__ */ jsx("div", { css: { marginBottom: "8px" }, children: [
1744
- /* @__PURE__ */ jsx(
1745
- "div",
1746
- {
1747
- css: {
1748
- padding: "4px 12px",
1749
- fontSize: "10px",
1750
- fontWeight: 600,
1751
- textTransform: "uppercase",
1752
- letterSpacing: "0.5px",
1753
- color: colors.textMuted,
1754
- cursor: "pointer",
1755
- "&:hover": { color: colors.text }
1756
- },
1757
- on: {
1758
- click: () => {
1759
- expanded = !expanded;
1760
- handle.update();
1761
- }
1762
- },
1763
- children: [
1764
- expanded ? "\u25BC" : "\u25B6",
1765
- " ",
1766
- title
1767
- ]
1768
- }
1769
- ),
1770
- expanded && /* @__PURE__ */ jsx("div", { css: { paddingLeft: "8px" }, children: nodes.map((node) => /* @__PURE__ */ jsx(RefNodeItem, { node, depth: 0 }, node.name)) })
1771
- ] });
1816
+ let expanded = null;
1817
+ return ({
1818
+ title,
1819
+ nodes,
1820
+ initialExpanded = true
1821
+ }) => {
1822
+ if (expanded === null) expanded = initialExpanded;
1823
+ return /* @__PURE__ */ jsx("div", { css: { marginBottom: "8px" }, children: [
1824
+ /* @__PURE__ */ jsx(
1825
+ "div",
1826
+ {
1827
+ css: {
1828
+ padding: "4px 12px",
1829
+ fontSize: "10px",
1830
+ fontWeight: 600,
1831
+ textTransform: "uppercase",
1832
+ letterSpacing: "0.5px",
1833
+ color: colors.textMuted,
1834
+ cursor: "pointer",
1835
+ "&:hover": { color: colors.text }
1836
+ },
1837
+ on: {
1838
+ click: () => {
1839
+ expanded = !expanded;
1840
+ handle.update();
1841
+ }
1842
+ },
1843
+ children: [
1844
+ expanded ? "\u25BC" : "\u25B6",
1845
+ " ",
1846
+ title
1847
+ ]
1848
+ }
1849
+ ),
1850
+ expanded && /* @__PURE__ */ jsx("div", { css: { paddingLeft: "8px" }, children: nodes.map((node) => /* @__PURE__ */ jsx(RefNodeItem, { node, depth: 0 }, node.name)) })
1851
+ ] });
1852
+ };
1772
1853
  }
1773
1854
  function RefNodeItem(handle) {
1774
1855
  let store = handle.context.get(App);
@@ -1907,6 +1988,7 @@ function CommitList(handle) {
1907
1988
  }
1908
1989
  ),
1909
1990
  /* @__PURE__ */ jsx("div", { css: { flex: 1 } }),
1991
+ /* @__PURE__ */ jsx(ThemeToggle, {}),
1910
1992
  /* @__PURE__ */ jsx(
1911
1993
  "input",
1912
1994
  {
@@ -1983,6 +2065,68 @@ function CommitList(handle) {
1983
2065
  }
1984
2066
  );
1985
2067
  }
2068
+ function ThemeToggle(handle) {
2069
+ let store = handle.context.get(App);
2070
+ handle.on(store, {
2071
+ theme: () => handle.update()
2072
+ });
2073
+ return () => {
2074
+ let isDark = store.theme === "dark";
2075
+ return /* @__PURE__ */ jsx(
2076
+ "button",
2077
+ {
2078
+ "aria-label": "Toggle theme",
2079
+ title: isDark ? "Switch to light mode" : "Switch to dark mode",
2080
+ css: {
2081
+ display: "inline-flex",
2082
+ alignItems: "center",
2083
+ gap: "6px",
2084
+ padding: "4px 10px",
2085
+ border: `1px solid ${colors.border}`,
2086
+ borderRadius: "999px",
2087
+ background: colors.bg,
2088
+ color: colors.text,
2089
+ fontSize: "12px",
2090
+ cursor: "pointer",
2091
+ "&:hover": {
2092
+ borderColor: colors.accent,
2093
+ background: colors.bgLighter
2094
+ }
2095
+ },
2096
+ on: { click: () => store.setTheme(isDark ? "light" : "dark") },
2097
+ children: [
2098
+ isDark ? /* @__PURE__ */ jsx(
2099
+ "svg",
2100
+ {
2101
+ width: "14",
2102
+ height: "14",
2103
+ viewBox: "0 0 24 24",
2104
+ fill: "none",
2105
+ stroke: "currentColor",
2106
+ "stroke-width": "2",
2107
+ children: /* @__PURE__ */ jsx("path", { d: "M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8Z" })
2108
+ }
2109
+ ) : /* @__PURE__ */ jsx(
2110
+ "svg",
2111
+ {
2112
+ width: "14",
2113
+ height: "14",
2114
+ viewBox: "0 0 24 24",
2115
+ fill: "none",
2116
+ stroke: "currentColor",
2117
+ "stroke-width": "2",
2118
+ children: [
2119
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "4" }),
2120
+ /* @__PURE__ */ jsx("path", { d: "M12 2v2m0 16v2m10-10h-2M4 12H2m15.5-7.5-1.5 1.5M8 16l-1.5 1.5M16 16l1.5 1.5M8 8 6.5 6.5" })
2121
+ ]
2122
+ }
2123
+ ),
2124
+ /* @__PURE__ */ jsx("span", { children: isDark ? "Dark" : "Light" })
2125
+ ]
2126
+ }
2127
+ );
2128
+ };
2129
+ }
1986
2130
  function FilterButton(handle) {
1987
2131
  let store = handle.context.get(App);
1988
2132
  handle.on(store, {
@@ -2347,6 +2491,7 @@ function DiffPanel(handle) {
2347
2491
  "section",
2348
2492
  {
2349
2493
  connect: (node) => diffContentRef = node,
2494
+ class: store.theme === "dark" ? "d2h-dark-color-scheme" : "",
2350
2495
  css: {
2351
2496
  "& .d2h-wrapper": { background: "transparent" },
2352
2497
  "& .d2h-file-header": {
@@ -2358,16 +2503,30 @@ function DiffPanel(handle) {
2358
2503
  zIndex: 1
2359
2504
  },
2360
2505
  "& .d2h-file-name": { color: colors.text },
2361
- "& .d2h-code-line": { padding: "0 8px" },
2506
+ "& .d2h-code-line": {
2507
+ padding: "0 8px",
2508
+ background: colors.bg
2509
+ },
2362
2510
  "& .d2h-code-line-ctn": { color: colors.text },
2363
- "& .d2h-ins": { background: "#dafbe1" },
2364
- "& .d2h-del": { background: "#ffebe9" },
2365
- "& .d2h-ins .d2h-code-line-ctn": { color: colors.green },
2366
- "& .d2h-del .d2h-code-line-ctn": { color: colors.red },
2511
+ "& .d2h-ins": { background: colors.diffAddBg },
2512
+ "& .d2h-del": { background: colors.diffDelBg },
2513
+ "& .d2h-ins .d2h-code-line-ctn": {
2514
+ color: colors.diffAddText
2515
+ },
2516
+ "& .d2h-del .d2h-code-line-ctn": {
2517
+ color: colors.diffDelText
2518
+ },
2367
2519
  "& .d2h-code-linenumber": {
2368
2520
  color: colors.textMuted,
2521
+ background: colors.bgLight,
2369
2522
  borderRight: `1px solid ${colors.border}`
2370
2523
  },
2524
+ "& .d2h-code-line-prefix": { color: colors.textMuted },
2525
+ "& .d2h-emptyplaceholder": { background: colors.bgLight },
2526
+ "& .d2h-info": {
2527
+ background: colors.bgLight,
2528
+ color: colors.textMuted
2529
+ },
2371
2530
  "& .d2h-file-diff": {
2372
2531
  borderBottom: `1px solid ${colors.border}`
2373
2532
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-viewer",
3
- "version": "11.0.0",
3
+ "version": "13.0.0",
4
4
  "description": "Visual git log viewer with branch graph and diff display",
5
5
  "repository": {
6
6
  "type": "git",