Surn commited on
Commit
e63d029
·
1 Parent(s): b3b5b03

Add version info, scrollable sidebar, and radar fix

Browse files

Updated the README with changelog for version 0.2.3.
Made the sidebar scrollable in `ui.py` by adding CSS styles.
Adjusted radar ring alignment in `_render_radar` for better visuals.
Added `get_battlewords_version` to retrieve app version.
Enhanced `versions_html` to display Battlewords version in runtime info.

README.md CHANGED
@@ -105,6 +105,11 @@ docker run -p 8501:8501 battlewords
105
 
106
  ## Changelog
107
 
 
 
 
 
 
108
  - 0.2.2
109
  - Add Musical background and settings to toggle sound on/off.
110
 
 
105
 
106
  ## Changelog
107
 
108
+ - 0.2.3
109
+ - Update version information display
110
+ - adjust sonar grid alignment
111
+ - fix settings scroll issue
112
+
113
  - 0.2.2
114
  - Add Musical background and settings to toggle sound on/off.
115
 
battlewords/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "0.2.2"
2
  __all__ = ["models", "generator", "logic", "ui"]
 
1
+ __version__ = "0.2.3"
2
  __all__ = ["models", "generator", "logic", "ui"]
battlewords/ui.py CHANGED
@@ -298,6 +298,15 @@ def inject_styles() -> None:
298
  .bw-radio-circle.active.miss { background: linear-gradient(135deg, rgba(255,0,0,0.18), rgba(128,0,0,0.38)); }
299
  .bw-radio-circle.active.miss .dot { background:#ff4b4b; box-shadow: 0 0 10px rgba(255,75,75,0.85); }
300
  .bw-radio-caption { font-size: 0.8rem; color:#fff; opacity:0.85; letter-spacing:0.5px; }
 
 
 
 
 
 
 
 
 
301
  </style>
302
  """,
303
  unsafe_allow_html=True,
@@ -653,7 +662,7 @@ def _render_radar(puzzle: Puzzle, size: int, r_max: float = 0.85, max_frames: in
653
 
654
  rings: list[Circle] = []
655
  for x, y in zip(xs, ys):
656
- ring = Circle((x, y), radius=r_min, fill=False, edgecolor='#9ceffe', linewidth=ring_linewidth, alpha=1.0, zorder=3)
657
  ax.add_patch(ring)
658
  rings.append(ring)
659
 
 
298
  .bw-radio-circle.active.miss { background: linear-gradient(135deg, rgba(255,0,0,0.18), rgba(128,0,0,0.38)); }
299
  .bw-radio-circle.active.miss .dot { background:#ff4b4b; box-shadow: 0 0 10px rgba(255,75,75,0.85); }
300
  .bw-radio-caption { font-size: 0.8rem; color:#fff; opacity:0.85; letter-spacing:0.5px; }
301
+
302
+ /* Make the sidebar scrollable */
303
+ section[data-testid="stSidebar"] {
304
+ max-height: 100vh;
305
+ overflow-y: auto;
306
+ overflow-x: hidden;
307
+ scrollbar-width: thin;
308
+ scrollbar-color: transparent transparent;
309
+ }
310
  </style>
311
  """,
312
  unsafe_allow_html=True,
 
662
 
663
  rings: list[Circle] = []
664
  for x, y in zip(xs, ys):
665
+ ring = Circle((x - 0.5, y - 0.5), radius=r_min, fill=False, edgecolor='#9ceffe', linewidth=ring_linewidth, alpha=1.0, zorder=3)
666
  ax.add_patch(ring)
667
  rings.append(ring)
668
 
battlewords/version_info.py CHANGED
@@ -15,23 +15,35 @@ def commit_hash() -> str:
15
  return "<none>"
16
 
17
 
 
 
 
 
 
 
 
 
 
18
  def versions_html() -> str:
19
  """Return a small HTML snippet with runtime and app environment info.
20
 
21
- Includes: git commit, Python version, and Streamlit version.
22
  """
23
  python_version = ".".join(str(x) for x in sys.version_info[:3])
24
  full_python = sys.version.replace("\n", " ")
25
  commit = commit_hash()
26
  streamlit_version = getattr(st, "__version__", "not installed")
 
27
 
28
  html = f"""
29
  <div style="font-size: 0.85rem; color: #b7c3d0; margin-top: 1.5rem; padding-top: 0.5rem; border-top: 1px solid rgba(255,255,255,0.15);">
 
 
30
  <span>commit: <code>{commit}</code></span>
31
  &nbsp;|&nbsp;
32
  <span>python: <span title="{full_python}">{python_version}</span></span>
33
  &nbsp;|&nbsp;
34
- <span>streamlit: {streamlit_version}</span>
35
  </div>
36
  """
37
  return html
 
15
  return "<none>"
16
 
17
 
18
+ def get_battlewords_version() -> str:
19
+ """Read the __version__ variable from battlewords/__init__.py."""
20
+ try:
21
+ from battlewords import __version__
22
+ return __version__
23
+ except Exception:
24
+ return "<unknown>"
25
+
26
+
27
  def versions_html() -> str:
28
  """Return a small HTML snippet with runtime and app environment info.
29
 
30
+ Includes: git commit, Python version, Streamlit version, and Battlewords version.
31
  """
32
  python_version = ".".join(str(x) for x in sys.version_info[:3])
33
  full_python = sys.version.replace("\n", " ")
34
  commit = commit_hash()
35
  streamlit_version = getattr(st, "__version__", "not installed")
36
+ battlewords_version = get_battlewords_version()
37
 
38
  html = f"""
39
  <div style="font-size: 0.85rem; color: #b7c3d0; margin-top: 1.5rem; padding-top: 0.5rem; border-top: 1px solid rgba(255,255,255,0.15);">
40
+ <span>Battlewords v{battlewords_version}</span>
41
+ &nbsp;|&nbsp;
42
  <span>commit: <code>{commit}</code></span>
43
  &nbsp;|&nbsp;
44
  <span>python: <span title="{full_python}">{python_version}</span></span>
45
  &nbsp;|&nbsp;
46
+ <span>streamlit: {streamlit_version}</span>
47
  </div>
48
  """
49
  return html