~earboxer/browset

a4640ce383328c26698de01794538877b43f1c7f — Zach DeCook 1 year, 1 month ago d392500
toolbar: Make mobile-friendly
2 files changed, 21 insertions(+), 2 deletions(-)

M browset.css
M browset.py
M browset.css => browset.css +11 -0
@@ 6,6 6,17 @@
	height: 3;
	dock: top;
}
#toolbar.mobile {
	grid-size: 2 1;
	grid-columns: 4 1fr;
	grid-gutter: 0;
}
#toolbar.mobile Button {
	display: none;
}
#toolbar.mobile Button.mobile {
	display: block;
}
.header {
	content-align: center middle;
}

M browset.py => browset.py +10 -2
@@ 2,8 2,8 @@
from textual.app import App, ComposeResult
from textual.widgets import Input, Button, Static, Footer
from textual.containers import Container
from rich.markdown import Markdown
from textual.binding import Binding
from textual.events import Resize
from mime.gemtext import Gemtext
from mime.plaintext import Plaintext
from mime.highlightedcode import HighlightedCode,mimetolexer


@@ 33,7 33,7 @@ class Browset(App):
    def compose(self) -> ComposeResult:
        yield Footer()
        yield Container(
            Button("🔙", variant='primary', name='back'), # ⏪
            Button("🔙", variant='primary', name='back', classes='mobile'), # ⏪
            Button("🔝", name='../'), # ⏫
            Button("🔜", variant='primary', name='soon'), # ⏩
            Button("🔄", variant='primary', name='refresh'), # 🔁


@@ 59,6 59,14 @@ class Browset(App):
            url = GeminiProtocol.relativeURL(url, self.url)
        self._do_url(url)


    async def on_resize(self, event: Resize) -> None:
      toolbar = self.query_one("#toolbar")
      if event.size.width < 60:
        toolbar.add_class('mobile')
      else:
        toolbar.remove_class('mobile')

    def action_back(self):
      if len(self.history):
        self.fistory.append(self.url)