Change style package, new components, ...

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-08-18 20:10:32 +02:00
parent 499d61bddf
commit 21b574eb6f
56 changed files with 2741 additions and 363 deletions
+15 -74
View File
@@ -1,92 +1,33 @@
# Ilovetui
# I Love TUI
A minimal Go library that provides a shared [Base16](https://github.com/tinted-theming/home) color theme for terminal UIs built with [bubbletea](https://github.com/charmbracelet/bubbletea) and [lipgloss](https://github.com/charmbracelet/lipgloss).
A shared [Base16](https://github.com/tinted-theming/home) theme, a themed wrapper around every official component, and a small set of custom Bubble Tea components, in one Go module, so every TUI built with it shares one config file and looks consistent.
The idea is simple: instead of every TUI app managing its own colors, they all share one theme file so the user customizes once and every app looks consistent.
## How it works
On import, `ilovetui` automatically loads the user's theme from `~/.config/ilovetui/config.yaml` (respecting `$XDG_CONFIG_HOME`).
If no config exists, it falls back to the embedded default. The active theme is exposed as the package-level variable `S`.
```go
import "github.com/anotherhadi/ilovetui"
// Use colors directly
style := lipgloss.NewStyle().Foreground(ilovetui.S.Primary)
// Use pre-built panel styles
box := ilovetui.RenderWithTitle(ilovetui.S.PanelFocused, "Title", content, w, h)
```
No setup required — just import and use.
## Installation
## Install
```sh
go get github.com/anotherhadi/ilovetui
```
## Theme
## Packages
The theme follows the [Base16](https://github.com/tinted-theming/home) standard (16 colors). The library exposes both the raw palette and semantic aliases:
- [`style`](style/README.md): the theme itself. Colors, pre-built panel styles, config loading.
- [`bubbles`](bubbles/README.md): themed constructors for official `bubbles/v2` components (`help`, `textarea`, `textinput`, `viewport`, ...).
- [`tabs`](tabs/README.md), [`modal`](modal/README.md), [`drawer`](drawer/README.md), [`notification`](notification/README.md), [`helpbar`](helpbar/README.md): custom components not found in the official `bubbles` library, styled from the same theme.
| Alias | Base16 | Meaning |
| ------------ | ------ | --------------------------------------- |
| `Background` | Base00 | Background |
| `SubtleBg` | Base01 | Lighter Background / Status Bars |
| `Selection` | Base02 | Selection Background |
| `Subtle` | Base03 | Comments / Invisibles |
| `Muted` | Base04 | Dark Foreground / Status Bars |
| `Text` | Base05 | Default Foreground |
| `Primary` | Base0D | Functions / Methods / Headings / Accent |
| `Success` | Base0B | Strings / Success / Diff Inserted |
| `Warning` | Base09 | Integers / Constants / Booleans |
| `Error` | Base08 | Variables / Errors / Diff Deleted |
Each package has its own README and a runnable example under `examples/<package>`.
The default theme is `./default.yaml`. Copy it and edit to customize:
## Quick start
```sh
mkdir -p ~/.config/ilovetui
cp $(go env GOPATH)/pkg/mod/github.com/anotherhadi/ilovetui*/default.yaml ~/.config/ilovetui/config.yaml
```
Or let your app write it on first run:
On import, `style` automatically loads the user's theme from `~/.config/ilovetui/config.yaml` (embedded default as fallback), exposed as the package-level `S`:
```go
ilovetui.WriteDefaultConfig(ilovetui.DefaultConfigPath())
import "github.com/anotherhadi/ilovetui/style"
s := lipgloss.NewStyle().Foreground(style.S.Primary)
box := style.RenderWithTitle(style.S.PanelFocused, "Title", content, w, h)
```
## Pre-built styles
`S` ships with a few ready-to-use lipgloss styles:
| Field | Description |
| ---------------- | ---------------------------------------- |
| `S.Bold` | Bold text |
| `S.Faint` | Muted / dimmed text |
| `S.Panel` | Rounded border, unfocused (Subtle color) |
| `S.PanelFocused` | Rounded border, focused (Primary color) |
## Helpers
```go
// Inner usable height of a bordered panel with outer height h
inner := ilovetui.ContentHeight(h)
// Render a box with a title embedded in the top border
box := ilovetui.RenderWithTitle(ilovetui.S.PanelFocused, "Header", content, w, h)
```
## API
```go
ilovetui.Init() // Reload from default config path
ilovetui.InitFrom(path string) // Reload from a custom path
ilovetui.InitFromBytes(data []byte) // Parse raw YAML
ilovetui.DefaultConfigPath() string // ~/.config/ilovetui/config.yaml
ilovetui.WriteDefaultConfig(path) // Write default config if missing
```
No setup required. See [`style/README.md`](style/README.md) for config details.
## Projects using ilovetui