ui-theme 0.1.0__tar.gz

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.
@@ -0,0 +1,63 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ workflow_dispatch:
8
+ inputs:
9
+ release_tag:
10
+ description: Existing release tag to publish
11
+ required: true
12
+ type: string
13
+
14
+ permissions:
15
+ contents: write
16
+ id-token: write # Required for trusted publishing
17
+
18
+ jobs:
19
+ build-and-publish:
20
+ name: Build and publish to PyPI
21
+ runs-on: ubuntu-latest
22
+ timeout-minutes: 20
23
+ environment:
24
+ name: pypi
25
+ url: https://pypi.org/p/ui-theme
26
+
27
+ steps:
28
+ - name: Checkout code
29
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
30
+ with:
31
+ fetch-depth: 0
32
+ ref: ${{ inputs.release_tag || github.ref }}
33
+
34
+ - name: Set up Python
35
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
36
+ with:
37
+ python-version: "3.12"
38
+
39
+ - name: Install build dependencies
40
+ run: |
41
+ python -m pip install --upgrade pip
42
+ python -m pip install build "twine>=7,<8" -e ".[dev]"
43
+
44
+ - name: Test release candidate
45
+ run: python -m pytest -q -o faulthandler_timeout=120
46
+
47
+ - name: Build package
48
+ run: python -m build
49
+
50
+ - name: Check distribution
51
+ run: python -m twine check dist/*
52
+
53
+ - name: Publish to PyPI
54
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
55
+
56
+ - name: Create GitHub Release
57
+ uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
58
+ with:
59
+ files: dist/*
60
+ tag_name: ${{ inputs.release_tag || github.ref_name }}
61
+ generate_release_notes: true
62
+ env:
63
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,4 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ dist/
4
+ .pytest_cache/
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.5
2
+ Name: ui-theme
3
+ Version: 0.1.0
4
+ Summary: Colour schemes, pywal, colour depth and animated effects for any UI backend
5
+ Author-email: Tristan Simas <tristan.simas@mail.mcgill.ca>
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: metaclass-registry>=0.2.1
9
+ Requires-Dist: terminaltexteffects==0.15.0
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest>=8; extra == 'dev'
@@ -0,0 +1,15 @@
1
+ # ui-theme
2
+
3
+ Colour meaning for any user interface, with no UI toolkit imported:
4
+
5
+ - `ui_theme.colour`: colour values (24-bit, a terminal's ANSI slots, the terminal default) and terminal palettes.
6
+ - `ui_theme.scheme`: semantic colours (`ThemeColour`) and colour schemes.
7
+ - `ui_theme.catalog`: the built-in schemes and default terminal palettes.
8
+ - `ui_theme.wal`: pywal's `colors.json`, decoded once into a palette and a scheme.
9
+ - `ui_theme.depth`: a terminal's colour depth (terminal backends only).
10
+ - `ui_theme.effects`: animated effects as functions of time over semantic colour.
11
+ - `ui_theme.splash`: TerminalTextEffects effects built in advance (run off the UI thread).
12
+ - `ui_theme.clock`: one animation clock for every running effect.
13
+ - `ui_theme.backend`: what a frontend implements (`Backend`, plus `TerminalBackend` for terminals).
14
+
15
+ A frontend writes one backend adapter. Toad's Textual adapter lives in Toad.
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ui-theme"
7
+ version = "0.1.0"
8
+ description = "Colour schemes, pywal, colour depth and animated effects for any UI backend"
9
+ authors = [{name = "Tristan Simas", email = "tristan.simas@mail.mcgill.ca"}]
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.12"
12
+ dependencies = [
13
+ "metaclass-registry>=0.2.1",
14
+ "terminaltexteffects==0.15.0",
15
+ ]
16
+
17
+ [project.optional-dependencies]
18
+ dev = ["pytest>=8"]
19
+
20
+ [tool.hatch.build.targets.wheel]
21
+ packages = ["src/ui_theme"]
22
+
23
+ [tool.pytest.ini_options]
24
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ """Colour schemes, pywal, colour depth and animated effects, for any UI backend.
2
+
3
+ Nothing here imports a UI toolkit. A frontend implements `ui_theme.backend`.
4
+ """
@@ -0,0 +1,81 @@
1
+ """What a frontend implements to draw ui_theme's schemes and effects.
2
+
3
+ Every backend maps a scheme to its own theme type, a theme colour to its own
4
+ colour type, and each kind of effect frame to its own paint. A backend that is
5
+ not a terminal sees only 24-bit colours (`ColourScheme.rgb` reads terminal
6
+ colours from the scheme's palette).
7
+
8
+ Terminals add a capability, `TerminalBackend`: they can emit the terminal's own
9
+ colours natively (so ANSI schemes follow the terminal's palette live), they map
10
+ a terminal palette to their palette type, and they have a colour depth.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from abc import ABC, abstractmethod
16
+ from typing import Any, Generic, TypeVar
17
+
18
+ from ui_theme.colour import AnsiColour, Colour, Rgb, TerminalPalette
19
+ from ui_theme.depth import ColourDepth
20
+ from ui_theme.effects import Band, Gradient, Mix, TextFrame
21
+ from ui_theme.scheme import ColourScheme, TextStyle, ThemeColour
22
+
23
+ ThemeT = TypeVar("ThemeT")
24
+ ColourT = TypeVar("ColourT")
25
+ PaintT = TypeVar("PaintT")
26
+ TargetT = TypeVar("TargetT")
27
+ PaletteT = TypeVar("PaletteT")
28
+
29
+
30
+ class Backend(ABC, Generic[ThemeT, ColourT, PaintT, TargetT]):
31
+ """A frontend's drawing of schemes and effects.
32
+
33
+ `TargetT` is what a paint is made for: a width in cells, a widget's
34
+ rectangle, a CSS selector.
35
+ """
36
+
37
+ @abstractmethod
38
+ def theme(self, scheme: ColourScheme) -> ThemeT:
39
+ """`scheme` as this frontend's theme."""
40
+
41
+ @abstractmethod
42
+ def colour(self, colour: type[ThemeColour]) -> ColourT:
43
+ """`colour` under the active scheme."""
44
+
45
+ @abstractmethod
46
+ def paint_gradient(self, frame: Gradient, target: TargetT) -> PaintT: ...
47
+
48
+ @abstractmethod
49
+ def paint_mix(self, frame: Mix, target: TargetT) -> PaintT: ...
50
+
51
+ @abstractmethod
52
+ def paint_band(self, frame: Band, target: TargetT) -> PaintT: ...
53
+
54
+ @abstractmethod
55
+ def paint_text(self, frame: TextFrame, target: TargetT) -> PaintT: ...
56
+
57
+
58
+ class TerminalBackend(Generic[PaletteT]):
59
+ """The terminal capability; a terminal frontend's backend mixes it in."""
60
+
61
+ depth: type[ColourDepth]
62
+
63
+ @abstractmethod
64
+ def palette(self, palette: TerminalPalette) -> PaletteT:
65
+ """`palette` as the palette this terminal maps ANSI colours to."""
66
+
67
+ @abstractmethod
68
+ def rgb(self, colour: Rgb) -> Any: ...
69
+
70
+ @abstractmethod
71
+ def ansi(self, colour: AnsiColour) -> Any: ...
72
+
73
+ @abstractmethod
74
+ def terminal_default(self) -> Any: ...
75
+
76
+ @abstractmethod
77
+ def text_style(self, style: TextStyle) -> Any: ...
78
+
79
+ @abstractmethod
80
+ def colour_variable(self, colour: Colour) -> str:
81
+ """Render a declared colour as this frontend's theme variable."""