Skip to content

Commit 77cc9e4

Browse files
committed
5.7.0 - Add light/dark support
1 parent 18716c9 commit 77cc9e4

File tree

17 files changed

+75
-32
lines changed

17 files changed

+75
-32
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
7878
- run: |
7979
mk python-release owner=vkottler \
80-
repo=runtimepy version=5.6.4
80+
repo=runtimepy version=5.7.0
8181
if: |
8282
matrix.python-version == '3.12'
8383
&& matrix.system == 'ubuntu-latest'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
=====================================
33
generator=datazen
44
version=3.1.4
5-
hash=41c5a2511c80b2cbbaee668bb6a75bd2
5+
hash=aa59dcef7f11c767458b14ad97f9de59
66
=====================================
77
-->
88

9-
# runtimepy ([5.6.4](https://pypi.org/project/runtimepy/))
9+
# runtimepy ([5.7.0](https://pypi.org/project/runtimepy/))
1010

1111
[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
1212
![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)

local/variables/package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
major: 5
3-
minor: 6
4-
patch: 4
3+
minor: 7
4+
patch: 0
55
entry: runtimepy

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
44

55
[project]
66
name = "runtimepy"
7-
version = "5.6.4"
7+
version = "5.7.0"
88
description = "A framework for implementing Python services."
99
readme = "README.md"
1010
requires-python = ">=3.11"

runtimepy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.1.4
4-
# hash=beefe82269955725f177c01474f7cea1
4+
# hash=c51f4ac6cf134b3c3fa872a096e83489
55
# =====================================
66

77
"""
@@ -10,7 +10,7 @@
1010

1111
DESCRIPTION = "A framework for implementing Python services."
1212
PKG_NAME = "runtimepy"
13-
VERSION = "5.6.4"
13+
VERSION = "5.7.0"
1414

1515
# runtimepy-specific content.
1616
METRICS_NAME = "metrics"

runtimepy/data/css/bootstrap_extra.css

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,17 @@ textarea.text-logs {
7777
padding-bottom: 0 !important;
7878

7979
border-top: 0;
80-
background-color: var(--bs-secondary-bg-subtle);
8180
}
8281

8382
.vertical-divider {
8483
flex-basis: 0.75em;
8584
flex-grow: 0;
8685
flex-shrink: 0;
87-
background-color: var(--bs-secondary-bg-subtle);
8886
}
8987

9088
.vertical-divider:hover {
9189
cursor: col-resize;
92-
background-color: var(--bs-secondary-bg);
90+
background-color: var(--bs-highlight-bg) !important;
9391
}
9492

9593
button:hover {
@@ -99,3 +97,14 @@ button:hover {
9997
.channel-value-input {
10098
width: 6em;
10199
}
100+
101+
/*
102+
* Should probably build the bootstrap stuff from source and set custom Sass:
103+
* https://getbootstrap.com/docs/5.3/customize/sass/
104+
*/
105+
106+
:root {
107+
/* Prefer 'Arial' and 'Consolas' at the highest priority. */
108+
--bs-font-sans-serif: Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
109+
--bs-font-monospace: Consolas, "Liberation Mono", "Courier New", monospace;
110+
}

runtimepy/data/css/main.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ body > :first-child {
2828
width: 100vw;
2929
height: 100vh;
3030
opacity: 1.0;
31-
background-color: var(--bs-secondary-bg-subtle);
3231
}
3332

3433
.click-plot {

runtimepy/data/js/classes/WindowHashManager.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class WindowHashManager {
77
this.tabFilter = "";
88
this.tabsShown = true;
99
this.channelsShown = true;
10+
this.lightMode = false;
1011
this.plotChannels = {};
1112
this.filters = {};
1213
this.minTxPeriod = 0.0;
@@ -17,6 +18,15 @@ class WindowHashManager {
1718
this.update();
1819
}
1920

21+
lightDarkClick(event) {
22+
this.lightMode = !this.lightMode;
23+
24+
document.getElementById("runtimepy")
25+
.setAttribute("data-bs-theme", this.lightMode ? "light" : "dark");
26+
27+
this.update();
28+
}
29+
2030
channelClick(event) {
2131
this.channelsShown = !this.channelsShown;
2232

@@ -106,6 +116,12 @@ class WindowHashManager {
106116
channelsButton.addEventListener("click", this.channelClick.bind(this));
107117
}
108118

119+
/* Click handler for light/dark toggle. */
120+
let lightDarkButton = document.getElementById("theme-button");
121+
if (lightDarkButton) {
122+
lightDarkButton.addEventListener("click", this.lightDarkClick.bind(this));
123+
}
124+
109125
/* Click handlers for new window buttons. */
110126
for (const button of document.querySelectorAll(".window-button")) {
111127
button.onclick = () => {
@@ -150,13 +166,6 @@ class WindowHashManager {
150166
}
151167
}
152168

153-
if (split.includes("hide-tabs")) {
154-
tabButton.click();
155-
}
156-
if (split.includes("hide-channels")) {
157-
channelsButton.click();
158-
}
159-
160169
/* Check for tab filter. */
161170
for (let item of split) {
162171
if (item.includes("=")) {
@@ -171,6 +180,16 @@ class WindowHashManager {
171180
}
172181
}
173182
}
183+
184+
if (split.includes("hide-tabs")) {
185+
tabButton.click();
186+
}
187+
if (split.includes("hide-channels")) {
188+
channelsButton.click();
189+
}
190+
if (split.includes("light-mode")) {
191+
lightDarkButton.click();
192+
}
174193
}
175194
}
176195

@@ -199,6 +218,9 @@ class WindowHashManager {
199218
if (!this.channelsShown) {
200219
hash += ",hide-channels"
201220
}
221+
if (this.lightMode) {
222+
hash += ",light-mode";
223+
}
202224

203225
if (this.minTxPeriod != 0.0) {
204226
hash += `,min-tx-period-ms=${this.minTxPeriod}`;

runtimepy/net/server/app/bootstrap/elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def centered_markdown(
192192
div(
193193
text=stream.getvalue(),
194194
parent=horiz_container,
195-
class_str="text-light p-3 pb-0",
195+
class_str="text-body p-3 pb-0",
196196
)
197197

198198
div(parent=horiz_container)

runtimepy/net/server/app/bootstrap/tabs.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
# internal
1010
from runtimepy import PKG_NAME
11+
from runtimepy.net.server.app.bootstrap import icon_str
1112
from runtimepy.net.server.app.bootstrap.elements import (
1213
BOOTSTRAP_BUTTON,
14+
bootstrap_button,
1315
collapse_button,
1416
flex,
1517
toggle_button,
@@ -85,16 +87,23 @@ def __init__(self, name: str, parent: Element) -> None:
8587

8688
# Create application container.
8789
self.container = div(parent=parent, id=name)
88-
self.container.add_class("d-flex", "align-items-start")
90+
self.container.add_class("d-flex", "align-items-start", "bg-body")
8991

9092
# Dark theme.
9193
self.container["data-bs-theme"] = "dark"
92-
parent.add_class("bg-dark")
9394

9495
# Buttons.
9596
self.button_column = div(parent=self.container)
9697
self.button_column.add_class(
97-
"d-flex", "flex-column", "h-100", "bg-secondary-subtle"
98+
"d-flex", "flex-column", "h-100", "bg-dark-subtle"
99+
)
100+
101+
# Dark/light theme switch button.
102+
bootstrap_button(
103+
icon_str("lightbulb"),
104+
tooltip=" Toggle light/dark.",
105+
id="theme-button",
106+
parent=self.button_column,
98107
)
99108

100109
# Toggle tabs button.

runtimepy/net/server/app/env/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,8 @@ def channel_environments(app: AppInfo, tabs: TabbedContent) -> None:
155155
)
156156

157157
# Add splash screen element.
158-
div(id=f"{PKG_NAME}-splash", parent=tabs.container)
158+
div(
159+
id=f"{PKG_NAME}-splash",
160+
parent=tabs.container,
161+
class_str="bg-success-subtle bg-gradient",
162+
)

runtimepy/net/server/app/env/modal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232

3333
content = div(
3434
parent=div(
35-
parent=modal, class_str="modal-dialog text-light " + TEXT
35+
parent=modal, class_str="modal-dialog text-body " + TEXT
3636
),
3737
class_str="modal-content rounded-0",
3838
)

runtimepy/net/server/app/env/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def plot_settings(tabs: TabbedContent) -> None:
4343
div(
4444
text="0 ms ('high', run at native refresh rate)",
4545
parent=container,
46-
class_str="text-nowrap text-primary",
46+
class_str="text-nowrap text-body-emphasis",
4747
)
4848

4949
slider(
@@ -53,7 +53,7 @@ def plot_settings(tabs: TabbedContent) -> None:
5353
div(
5454
text="100 ms ('low', 10 Hz)",
5555
parent=container,
56-
class_str="text-nowrap text-primary",
56+
class_str="text-nowrap text-body-emphasis",
5757
)
5858

5959
div(tag="hr", parent=modal.body)

runtimepy/net/server/app/env/tab/html.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def compose(self, parent: Element) -> None:
238238
logs = div(
239239
tag="textarea",
240240
parent=div(parent=vert_container, class_str="form-floating"),
241-
class_str=f"form-control rounded-0 {TEXT} text-logs",
241+
class_str=(f"form-control rounded-0 {TEXT} text-logs"),
242242
id=self.get_id("logs"),
243243
title=f"Text logs for {self.name}.",
244244
)
@@ -258,7 +258,7 @@ def compose(self, parent: Element) -> None:
258258
div(
259259
id=self.get_id("divider"),
260260
parent=container,
261-
class_str="vertical-divider border-start",
261+
class_str="vertical-divider border-start bg-dark-subtle",
262262
)
263263

264264
self._compose_plot(container)

runtimepy/net/server/app/placeholder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DummyTab(Tab):
1919
def compose(self, parent: Element) -> None:
2020
"""Compose the tab's HTML elements."""
2121

22-
parent.add_class("text-light")
22+
parent.add_class("text-body")
2323

2424
for idx in range(10):
2525
div(parent=parent, text="Hello, world! " + str(idx))

runtimepy/net/server/app/sound.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SoundTab(Tab):
1717
def compose(self, parent: Element) -> None:
1818
"""Compose the tab's HTML elements."""
1919

20-
container = div(parent=parent, class_str="text-light")
20+
container = div(parent=parent, class_str="text-body")
2121

2222
div(text="Hello, world! 1", parent=container)
2323
div(text="Hello, world! 2", parent=container)

runtimepy/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
aiofiles
2-
vcorelib>=3.4.1
2+
vcorelib>=3.4.2
33
svgen>=0.6.8
44
websockets
55
psutil

0 commit comments

Comments
 (0)