From 6b16004d7af8e546e14a8b92a64f13195e4803a1 Mon Sep 17 00:00:00 2001 From: Ayush Date: Fri, 11 Apr 2025 17:28:32 +0530 Subject: [PATCH] feat+doc: init base app, change doc site styling Signed-off-by: Ayush --- docs/installation.md | 18 +++++++++++++ mkdocs.yml | 15 ++++++++--- poetry.lock | 10 ++++---- pyproject.toml | 51 ++++++++++++++++++++++++++++++++----- src/gitx/__init__.py | 5 ++++ src/gitx/app.py | 42 ++++++++++++++++++++++++++++++ src/gitx/css/app.tcss | 39 ++++++++++++++++++++++++++++ src/gitx/css/welcome.tcss | 0 src/gitx/main.py | 6 +++++ src/gitx/screens/welcome.py | 25 ++++++++++++++++++ 10 files changed, 196 insertions(+), 15 deletions(-) create mode 100644 src/gitx/css/app.tcss create mode 100644 src/gitx/css/welcome.tcss create mode 100644 src/gitx/screens/welcome.py diff --git a/docs/installation.md b/docs/installation.md index 709d5b3..cce6257 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -65,6 +65,24 @@ Installation Guide for gitx > [!NOTE] > For further information about poetry and managing environments refer to the [poetry docs](https://python-poetry.org/docs/managing-environments/). +5. To install and run the `gitx` package, run the following commands: + + ```sh + # Install the package in development mode + poetry install + + # Run the app using the entry point + poetry run gitxtui # or simply `gitxtui` if already in poetry environment + ``` + +6. To build the package, run: + + ```sh + poetry build + + # This will create dist/gitxtui-.tar.gz and dist/gitxtui--none-any.whl + ``` + ## Running Tests Run the test suite using pytest: diff --git a/mkdocs.yml b/mkdocs.yml index 68b603a..ecfeec5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -18,10 +18,10 @@ theme: # Dark mode - media: "(prefers-color-scheme: dark)" scheme: slate - primary: indigo - accent: indigo + primary: black + accent: black toggle: - icon: material/brightness-4 + icon: material/brightness-5 name: Switch to light mode features: - navigation.instant @@ -32,10 +32,19 @@ theme: - navigation.footer - content.code.copy - toc.follow + - navigation.tabs + # - navigation.tabs.sticky + - navigation.sections + - navigation.path + - toc.integrate + # - navigation.expand extra_css: - stylesheets/extra.css +extra_javascript: + - javascripts/textual-theme.js + markdown_extensions: - pymdownx.highlight: anchor_linenums: true diff --git a/poetry.lock b/poetry.lock index 1958dfd..bbd5c2f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. [[package]] name = "autoflake" @@ -280,7 +280,7 @@ description = "Read metadata from Python packages" optional = false python-versions = ">=3.9" groups = ["dev"] -markers = "python_version < \"3.10\"" +markers = "python_version == \"3.9\"" files = [ {file = "importlib_metadata-8.6.1-py3-none-any.whl", hash = "sha256:02a89390c1e15fdfdc0d7c6b25cb3e62650d0494005c97d6f148bf5b9787525e"}, {file = "importlib_metadata-8.6.1.tar.gz", hash = "sha256:310b41d755445d74569f993ccfc22838295d9fe005425094fad953d7f15c8580"}, @@ -1130,7 +1130,7 @@ description = "Backport of pathlib-compatible object wrapper for zip files" optional = false python-versions = ">=3.9" groups = ["dev"] -markers = "python_version < \"3.10\"" +markers = "python_version == \"3.9\"" files = [ {file = "zipp-3.21.0-py3-none-any.whl", hash = "sha256:ac1bbe05fd2991f160ebce24ffbac5f6d11d83dc90891255885223d42b3cd931"}, {file = "zipp-3.21.0.tar.gz", hash = "sha256:2c9958f6430a2040341a52eb608ed6dd93ef4392e02ffe219417c1b28b5dd1f4"}, @@ -1146,5 +1146,5 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" -python-versions = ">=3.9, <4.0" -content-hash = "1fb8c62ed808673c01889f0381a0ed2ba06bd20147cc5b71c4259422a4869d60" +python-versions = ">=3.9,<4.0" +content-hash = "a617e372e37243cb4e003e8caa67ff88f9cd5bd7771e0b142d236570dfe3be97" diff --git a/pyproject.toml b/pyproject.toml index bcdc5eb..2f308fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,10 +11,51 @@ authors = [ license = { text = "LICENSE" } readme = "README.md" requires-python = ">=3.9, <4.0" -dependencies = ["textual (>=2.1.2,<3.0.0)"] +dependencies = ["textual>=2.1.2,<3.0.0"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Version Control :: Git", +] + +[project.scripts] +gitxtui = "gitx.main:main" + +[project.urls] +Homepage = "https://github.com/gitxtui/gitx" +Documentation = "https://gitxtui.github.io/gitx/" +Issues = "https://github.com/gitxtui/gitx/issues" + +[build-system] +requires = ["poetry-core>=2.0.0,<3.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry] +name = "gitxtui" +version = "0.1.0-a1" +description = "TUI based git helper" +authors = [ + "Ayush ", + "Ashmit Singh ", + "Anmol Puri ", + "Anmol Kakkar ", +] +readme = "README.md" +packages = [{ include = "gitx", from = "src" }] + +[tool.poetry.scripts] +gitxtui = "gitx.main:main" -# [tool.poetry] -# package-mode = false +[tool.poetry.dependencies] +python = ">=3.9,<4.0" +textual = ">=2.1.2,<3.0.0" [tool.poetry.group.dev.dependencies] pytest = "^8.3.5" @@ -27,7 +68,3 @@ mkdocs-material = "^9.6.9" materialx = "^1.39.3" pymdown-extensions = "^10.14.3" material = "^0.1" - -[build-system] -requires = ["poetry-core>=2.0.0,<3.0.0"] -build-backend = "poetry.core.masonry.api" diff --git a/src/gitx/__init__.py b/src/gitx/__init__.py index e69de29..2b287c4 100644 --- a/src/gitx/__init__.py +++ b/src/gitx/__init__.py @@ -0,0 +1,5 @@ +""" +gitx - A TUI Git helper built with Textual +""" + +__version__ = "0.1.0-a1" diff --git a/src/gitx/app.py b/src/gitx/app.py index e69de29..2e275f0 100644 --- a/src/gitx/app.py +++ b/src/gitx/app.py @@ -0,0 +1,42 @@ +from textual.app import App, ComposeResult +from textual.binding import Binding +from textual.containers import Container +from textual.widgets import Header, Footer, Static + + +class GitxApp(App): + """A TUI Git client built with Textual.""" + + CSS_PATH = "css/app.tcss" + + BINDINGS = [ + Binding(key="q", action="quit", description="Quit"), + Binding(key="t", action="toggle_dark", description="Toggle dark mode"), + ] + + def compose(self) -> ComposeResult: + """Compose the app layout using the welcome screen.""" + self.theme = "flexoki" # Default theme + yield Header(show_clock=True) + yield Container( + Static("Welcome to gitx!", classes="welcome-title"), + Static("A Terminal User Interface for Git", classes="welcome-text"), + Static("Press 't' to toggle theme or 'q' to quit", classes="welcome-text"), + classes="welcome" + ) + yield Footer() + + def action_toggle_dark(self) -> None: + """Toggle between light and dark theme.""" + self.theme = ( + "flexoki" if self.theme == "catppuccin-latte" else "catppuccin-latte" + ) + +def main() -> None: + """Run the app.""" + app = GitxApp() + app.run() + + +if __name__ == "__main__": + main() diff --git a/src/gitx/css/app.tcss b/src/gitx/css/app.tcss new file mode 100644 index 0000000..27b8f3c --- /dev/null +++ b/src/gitx/css/app.tcss @@ -0,0 +1,39 @@ +/* Base application styles */ +Screen { + background: $surface; + color: $text; + layout: vertical; +} + +Header { + dock: top; + height: 1; +} + +Footer { + dock: bottom; + height: 1; +} + +/* Common styles that apply to the whole app */ +.welcome { + width: 100%; + height: 100%; + align: center middle; + background: $surface; +} + +.welcome-title { + text-style: bold; + text-align: center; + margin-bottom: 1; + color: $accent; + width: 100%; + height: 1; +} + +.welcome-text { + text-align: center; + margin-bottom: 1; + width: 100%; +} \ No newline at end of file diff --git a/src/gitx/css/welcome.tcss b/src/gitx/css/welcome.tcss new file mode 100644 index 0000000..e69de29 diff --git a/src/gitx/main.py b/src/gitx/main.py index e69de29..ad0a7a9 100644 --- a/src/gitx/main.py +++ b/src/gitx/main.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +from gitx.app import main + +if __name__ == "__main__": + main() diff --git a/src/gitx/screens/welcome.py b/src/gitx/screens/welcome.py new file mode 100644 index 0000000..3a9780d --- /dev/null +++ b/src/gitx/screens/welcome.py @@ -0,0 +1,25 @@ +"""Welcome screen for gitx.""" + +from textual.app import ComposeResult +from textual.containers import Container +from textual.screen import Screen +from textual.widgets import Header, Footer, Static + + +class WelcomeScreen(Screen): + """Welcome screen displayed when the application starts.""" + + def compose(self) -> ComposeResult: + """Compose the welcome screen layout.""" + yield Header(show_clock=True) + yield Container(classes="welcome") + yield Footer() + + def on_mount(self) -> None: + """Called when the screen is mounted.""" + welcome_container = self.query_one(".welcome", Container) + welcome_container.mount( + Static("gitx", classes="welcome-title"), + Static("A Terminal User Interface for Git", classes="welcome-text"), + Static("Press 't' to toggle theme or 'q' to quit", classes="welcome-text"), + )