lisboa

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 6 Imported by: 0

README

Lisboa

Lisboa is a visual aesthetic and design language for text and tools for applying it, including a Go library

Documentation

Overview

Package lisboa provides a consistent theme system for Bubble Tea v2 TUI applications at Operator Foundation.

Lisboa implements the six-category universal semantic color system (surface, text, subtle, accent, warning, critical) defined in DESIGN.md, with three time-of-day theme variants (Dia, Tarde, Noite) defined in STYLE.md.

Quick Start

Create a theme from Bubble Tea's background color detection:

import (
    tea "charm.land/bubbletea/v2"
    "charm.land/lipgloss/v2"
    "codeberg.org/curiosa/lisboa"
)

type model struct {
    theme    lisboa.Theme
    help     help.Model
    textarea textarea.Model
}

func (m model) Init() tea.Cmd {
    return tea.RequestBackgroundColor
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    switch msg := msg.(type) {
    case tea.BackgroundColorMsg:
        m.theme = lisboa.NewTheme(lisboa.DiaNoite, msg.IsDark())
        m.help.Styles = m.theme.HelpStyles()
        m.textarea.Styles = m.theme.TextareaStyles()
    }
    return m, nil
}

func (m model) View() tea.View {
    title := m.theme.TitleStyle().Render(lisboa.AppTitle("EXEMPLO"))
    body := m.theme.BodyStyle().Render("Olá, mundo!")
    help := m.theme.SubtleStyle().Render("q: sair")

    content := lipgloss.JoinVertical(lipgloss.Left, title, body, help)

    v := tea.NewView(content)
    v.AltScreen = true
    v.BackgroundColor = m.theme.Surface
    v.ForegroundColor = m.theme.Text
    return v
}

Theme Pairs

Lisboa offers two pairing modes that map three variants onto the terminal's binary light/dark signal:

  • DiaNoite: Dia (light) ↔ Noite (dark). Works with automatic terminal background detection.
  • TardeNoite: Tarde (mid-dark) ↔ Noite (dark). Requires application-controlled switching since both backgrounds are dark.

Direct Variant Selection

For time-based switching or explicit configuration, bypass the pair mechanism:

theme := lisboa.NewThemeVariant(lisboa.Tarde)

Semantic Colors

All Theme fields are image/color.Color values organized into six categories. Use them directly with Lip Gloss v2 styles:

style := lipgloss.NewStyle().
    Foreground(theme.Accent).
    Background(theme.Surface)

Redundant Encoding

Per DESIGN.md, color must never be the sole carrier of semantic information. Lisboa provides icon constants and style pairs:

fmt.Sprintf("%s %s", lisboa.IconCritical,
    theme.StatusStyles().Critical.Render("Connection failed"))

Produces: ✗ Connection failed

Package lisboa provides a consistent theme system for Bubble Tea v2 TUI applications. It implements the six-category universal semantic color system defined in DESIGN.md with three time-of-day variants.

Usage with Bubble Tea v2:

func (m model) Init() tea.Cmd {
    return tea.RequestBackgroundColor
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    switch msg := msg.(type) {
    case tea.BackgroundColorMsg:
        m.theme = lisboa.NewTheme(lisboa.DiaNoite, msg.IsDark())
    }
    return m, nil
}

Index

Constants

View Source
const (
	IconInfo     = "ℹ"
	IconSuccess  = "✓"
	IconWarning  = "⚠"
	IconCritical = "✗"
)

Status icon constants for redundant encoding.

View Source
const (
	PointerSelected   = "▸ "
	PointerUnselected = "  "
)

Selection pointer constants.

Variables

This section is empty.

Functions

func AppTitle

func AppTitle(name string) string

AppTitle returns a decorated application title string.

╭─── APPNAME ───╮

func PaneHeader

func PaneHeader(title string) string

PaneHeader returns a box-drawing pane header string.

┌─ title ─

Types

type Pair

type Pair int

Pair represents a theme pair mapping two variants onto the terminal's binary light/dark background signal.

const (
	// DiaNoite selects Dia for light backgrounds, Noite for dark.
	// Works with automatic terminal background detection.
	DiaNoite Pair = iota

	// TardeNoite selects Tarde for the light branch, Noite for
	// dark. Both variants have dark backgrounds, so automatic
	// terminal detection cannot distinguish them. Switching must
	// be application-controlled (e.g. by system clock or config).
	TardeNoite
)

func (Pair) String

func (p Pair) String() string

String returns the name of the pair.

type StatusStyle

type StatusStyle struct {
	// Info renders informational messages: ℹ text
	Info lipgloss.Style
	// Success renders success messages: ✓ text
	Success lipgloss.Style
	// Warning renders warning messages: ⚠ text
	Warning lipgloss.Style
	// Critical renders error messages: ✗ text
	Critical lipgloss.Style
}

StatusStyle returns styles for status messages. Each pairs a semantic color with an icon to ensure redundant encoding per DESIGN.md.

type Theme

type Theme struct {

	// Surface family — background plane.
	Surface       color.Color
	SurfaceSunken color.Color
	SurfaceDeep   color.Color
	SurfaceRaised color.Color

	// Text family — primary readable content.
	Text          color.Color
	TextSecondary color.Color

	// Subtle family — de-emphasized content, metadata, borders.
	Subtle       color.Color
	SubtleFaint  color.Color
	SubtleBorder color.Color

	// Accent family — interactive and informational elements.
	// Core hue: blue (Oklch 220°–250°).
	Accent         color.Color
	AccentEmphasis color.Color
	AccentMuted    color.Color

	// Accent aesthetic variants. These extend into adjacent hue
	// territory (Oklch 180°–280°) and require cor validation to
	// confirm they satisfy the variant constraint under all
	// dichromacy projections.
	AccentPurple color.Color
	AccentCyan   color.Color
	AccentTeal   color.Color

	// Warning family — caution states requiring attention.
	// Core hue: yellow (Oklch 80°–100°).
	Warning     color.Color
	WarningMild color.Color

	// Critical family — danger states demanding immediate attention.
	// Core hue: red (Oklch 15°–35°).
	Critical       color.Color
	CriticalSevere color.Color
	// contains filtered or unexported fields
}

Theme holds resolved semantic colors for a specific variant. All color fields implement image/color.Color.

Colors are organized into six categories per DESIGN.md: surface, text, subtle (achromatic), and accent, warning, critical (chromatic).

func NewTheme

func NewTheme(p Pair, isDark bool) Theme

NewTheme creates a theme by selecting a variant from a pair.

For DiaNoite, isDark should come from tea.BackgroundColorMsg.IsDark(). For TardeNoite, isDark should come from application logic (system clock, user configuration, or explicit command) since both variants have dark backgrounds and terminal detection cannot distinguish them.

func NewThemeVariant

func NewThemeVariant(v Variant) Theme

NewThemeVariant creates a theme for a specific variant directly, bypassing the pair selection mechanism.

func (Theme) ActiveVariant

func (t Theme) ActiveVariant() Variant

ActiveVariant returns the resolved theme variant.

func (Theme) BodyStyle

func (t Theme) BodyStyle() lipgloss.Style

BodyStyle returns a style for primary body text.

func (Theme) FaintStyle

func (t Theme) FaintStyle() lipgloss.Style

FaintStyle returns a style for timestamps, metadata, and other tertiary content.

func (Theme) FocusedBorderStyle

func (t Theme) FocusedBorderStyle() lipgloss.Style

FocusedBorderStyle returns a border style for the focused pane.

func (Theme) HelpStyles

func (t Theme) HelpStyles() help.Styles

HelpStyles returns styles for the help bubble.

func (Theme) HostnameStyle

func (t Theme) HostnameStyle() lipgloss.Style

HostnameStyle returns a style for machine/host names.

func (Theme) IsDark

func (t Theme) IsDark() bool

IsDark reports whether the active variant has a dark background.

func (Theme) ListItemStyles

func (t Theme) ListItemStyles() list.DefaultItemStyles

ListItemStyles returns styles for list items in the list bubble.

func (Theme) ListStyles

func (t Theme) ListStyles() list.Styles

ListStyles returns styles for the list bubble.

func (Theme) LocalUserStyle

func (t Theme) LocalUserStyle() lipgloss.Style

LocalUserStyle returns a style for the local username. Should be paired with a "(local)" label prefix for redundant encoding.

func (Theme) PlaceholderStyle

func (t Theme) PlaceholderStyle() lipgloss.Style

PlaceholderStyle returns a style for input placeholder text.

func (Theme) PromptStyle

func (t Theme) PromptStyle() lipgloss.Style

PromptStyle returns a style for input prompts.

func (Theme) RemoteUserStyle

func (t Theme) RemoteUserStyle() lipgloss.Style

RemoteUserStyle returns a style for remote usernames. Distinguished from local by the absence of the "(local)" label prefix.

func (Theme) SecondaryStyle

func (t Theme) SecondaryStyle() lipgloss.Style

SecondaryStyle returns a style for secondary body text.

func (Theme) SelectedStyle

func (t Theme) SelectedStyle() lipgloss.Style

SelectedStyle returns a style for the currently selected list item. Pairs accent color with bold weight and a pointer glyph.

func (Theme) StatusStyles

func (t Theme) StatusStyles() StatusStyle

StatusStyles returns styles for status messages.

func (Theme) SubtleStyle

func (t Theme) SubtleStyle() lipgloss.Style

SubtleStyle returns a style for de-emphasized content such as help text and keybinding hints.

func (Theme) TextareaStyles

func (t Theme) TextareaStyles() textarea.Styles

TextareaStyles returns styles for the textarea bubble.

func (Theme) TextinputStyles

func (t Theme) TextinputStyles() textinput.Styles

TextinputStyles returns styles for the textinput bubble.

func (Theme) TitleStyle

func (t Theme) TitleStyle() lipgloss.Style

TitleStyle returns a style for the application title bar.

╭─── APPNAME ───╮

func (Theme) UnfocusedBorderStyle

func (t Theme) UnfocusedBorderStyle() lipgloss.Style

UnfocusedBorderStyle returns a border style for unfocused panes.

func (Theme) UnselectedStyle

func (t Theme) UnselectedStyle() lipgloss.Style

UnselectedStyle returns a style for unselected list items.

func (Theme) ViewportLineStyle

func (t Theme) ViewportLineStyle(line int) lipgloss.Style

ViewportLineStyle returns a function suitable for viewport's StyleLineFunc field. It applies no special per-line styling by default. Applications can wrap this to add line numbers or highlighting using theme colors.

type Variant

type Variant int

Variant represents a theme variant corresponding to a Portuguese time of day.

const (
	// Dia is the morning variant with a light background.
	// Sourced from Catppuccin Latte.
	Dia Variant = iota

	// Tarde is the afternoon variant with a mid-dark background.
	// Sourced from Catppuccin Frappé.
	Tarde

	// Noite is the night variant with a dark background.
	// Sourced from Catppuccin Mocha.
	Noite
)

func (Variant) String

func (v Variant) String() string

String returns the Portuguese name of the variant.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL