theme

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 3 Imported by: 0

README

theme

import "github.com/lucasassuncao/yedit/theme"

Package theme provides the palette, base lipgloss styles, and shared layout primitives used across yedit-built TUIs.

Index

Variables

Palette — narrow on purpose. Clients can extend it with their own colours; add to this list only when at least two yedit components need it.

var (
    Accent       = colorVal("63")  // blue — active borders, primary highlight
    AccentBright = colorVal("212") // pink — titles, selection
    Muted        = colorVal("240") // grey — inactive borders, status hints
    Dim          = colorVal("245") // light grey — secondary text
    Success      = colorVal("82")  // green — existing/added items, success alerts
    Danger       = colorVal("196") // red — error alerts
)

Common item styles. Each TUI is free to compose its own variants on top.

var (
    SelectedItem  = lipgloss.NewStyle().Bold(true).Foreground(AccentBright)
    ExistingItem  = lipgloss.NewStyle().Foreground(Success)
    AvailableItem = lipgloss.NewStyle().Foreground(Dim)
    StatusBar     = lipgloss.NewStyle().Foreground(Muted).PaddingLeft(1)
)

func CenterBox

func CenterBox(box string, term Size) string

CenterBox positions box at the centre of the given terminal Size by adding padding. Used by floating overlay/alert/picker views.

func RenderHeader

func RenderHeader(title, subtitle, right string, width int) string

RenderHeader returns a single-line header. title is rendered bold on the left, subtitle (if non-empty) follows after a separator, right (if non-empty) is right-aligned for context such as filenames.

func RenderTitledPanel

func RenderTitledPanel(title string, size Size, active bool, content string) string

RenderTitledPanel renders a rounded-border panel with the title embedded in the top edge: ╭─ Title ──────╮. size holds the OUTER dimensions (including the border rows/cols).

func RenderTwoColumnView

func RenderTwoColumnView(layout TwoColumnLayout) string

RenderTwoColumnView assembles the standard two-panel screen: header, panels side by side, a feedback line, and a hint line.

func TwoColumnWidths

func TwoColumnWidths(totalWidth int) (listW, rightW int)

TwoColumnWidths computes left and right column widths for the standard two-panel layout: left is totalWidth/3, clamped to [30, 60]; right gets the remainder minus 4 chars for the two border pairs.

type Size

Size holds a width/height pair. Used wherever a terminal or panel dimension is passed as a unit (alert, picker, RenderTitledPanel, CenterBox).

type Size struct{ W, H int }

type TwoColumnLayout

TwoColumnLayout carries the five sections of the standard two-panel screen.

type TwoColumnLayout struct {
    Header   string
    Left     string
    Right    string
    Feedback string // pass "" when there is nothing to report
    Hint     string
}

Generated by gomarkdoc

Documentation

Overview

Package theme provides the palette, base lipgloss styles, and shared layout primitives used across yedit-built TUIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	Accent       = colorVal("63")  // blue — active borders, primary highlight
	AccentBright = colorVal("212") // pink — titles, selection
	Muted        = colorVal("240") // grey — inactive borders, status hints
	Dim          = colorVal("245") // light grey — secondary text
	Success      = colorVal("82")  // green — existing/added items, success alerts
	Danger       = colorVal("196") // red — error alerts
)

Palette — narrow on purpose. Clients can extend it with their own colours; add to this list only when at least two yedit components need it.

View Source
var (
	SelectedItem  = lipgloss.NewStyle().Bold(true).Foreground(AccentBright)
	ExistingItem  = lipgloss.NewStyle().Foreground(Success)
	AvailableItem = lipgloss.NewStyle().Foreground(Dim)
	StatusBar     = lipgloss.NewStyle().Foreground(Muted).PaddingLeft(1)
)

Common item styles. Each TUI is free to compose its own variants on top.

Functions

func CenterBox

func CenterBox(box string, term Size) string

CenterBox positions box at the centre of the given terminal Size by adding padding. Used by floating overlay/alert/picker views.

func RenderHeader

func RenderHeader(title, subtitle, right string, width int) string

RenderHeader returns a single-line header. title is rendered bold on the left, subtitle (if non-empty) follows after a separator, right (if non-empty) is right-aligned for context such as filenames.

func RenderTitledPanel

func RenderTitledPanel(title string, size Size, active bool, content string) string

RenderTitledPanel renders a rounded-border panel with the title embedded in the top edge: ╭─ Title ──────╮. size holds the OUTER dimensions (including the border rows/cols).

func RenderTwoColumnView

func RenderTwoColumnView(layout TwoColumnLayout) string

RenderTwoColumnView assembles the standard two-panel screen: header, panels side by side, a feedback line, and a hint line.

func TwoColumnWidths

func TwoColumnWidths(totalWidth int) (listW, rightW int)

TwoColumnWidths computes left and right column widths for the standard two-panel layout: left is totalWidth/3, clamped to [30, 60]; right gets the remainder minus 4 chars for the two border pairs.

Types

type Size added in v0.2.0

type Size struct{ W, H int }

Size holds a width/height pair. Used wherever a terminal or panel dimension is passed as a unit (alert, picker, RenderTitledPanel, CenterBox).

type TwoColumnLayout added in v0.2.0

type TwoColumnLayout struct {
	Header   string
	Left     string
	Right    string
	Feedback string // pass "" when there is nothing to report
	Hint     string
}

TwoColumnLayout carries the five sections of the standard two-panel screen.

Jump to

Keyboard shortcuts

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