styles

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package styles provides reusable lipgloss-based TUI components.

Package styles provides reusable lipgloss-based TUI components.

Index

Constants

View Source
const (
	IconGlobe     = "\uf0ac" //  browser/web
	IconVersion   = "\uf02b" //  tag
	IconGitBranch = "\ue725" //  git branch
	IconCalendar  = "\uf073" //  calendar
	IconCode      = "\uf121" //  code
	IconGithub    = "\uf09b" //  github
	IconHeart     = "\uf004" //  heart
	IconGo        = "\ue627" //  go gopher
	IconArrow     = "\uf061" //  arrow right

	// Doctor / diagnostics
	IconDoctor  = "\uf0f1" // stethoscope
	IconCheck   = "\uf00c" // check
	IconX       = "\uf00d" // x
	IconWarning = "\uf071" // warning
	IconInfo    = "\uf05a" // info
	IconWrench  = "\uf0ad" // wrench
	IconPackage = "\uf187" // archive/package
	IconVideo   = "\uf03d" // video camera

	// Purge / filesystem
	IconTrash    = "\uf1f8" // trash
	IconFolder   = "\uf07b" // folder
	IconConfig   = "\ue615" // config
	IconDatabase = "\uf1c0" // database
	IconFilter   = "\uf0b0" // filter
	IconDesktop  = "\uf108" // desktop
	IconImage    = "\uf1c5" // image file
	IconCache    = "\uf49e" // cache
	IconLogs     = "\uf0f6" // file-text

	// Checkboxes
	IconCheckboxEmpty   = "\uf096" // unchecked
	IconCheckboxChecked = "\uf046" // checked

	// UI
	IconCursor = "\uf054" // chevron-right
)

Nerd Font icons (requires a Nerd Font to display correctly)

Variables

This section is empty.

Functions

func DefaultDarkPalette

func DefaultDarkPalette() config.ColorPalette

DefaultDarkPalette returns hardcoded dark theme colors.

func HistoryTableColumns

func HistoryTableColumns() []table.Column

HistoryTableColumns returns columns for history list table.

func NewDefaultSpinner

func NewDefaultSpinner(theme *Theme) spinner.Model

NewDefaultSpinner creates the default themed spinner.

func NewHistoryList

func NewHistoryList(theme *Theme, items []HistoryItem, width, height int) list.Model

NewHistoryList creates a themed list for history items.

func NewSearchInput

func NewSearchInput(theme *Theme) textinput.Model

NewSearchInput creates a search-specific input.

func NewStyledHelp

func NewStyledHelp(theme *Theme) help.Model

NewStyledHelp creates a themed help model.

func NewStyledInput

func NewStyledInput(theme *Theme, placeholder string) textinput.Model

NewStyledInput creates a themed text input.

func NewStyledSpinner

func NewStyledSpinner(theme *Theme, spinnerType SpinnerType) spinner.Model

NewStyledSpinner creates a themed spinner.

func NewStyledTable

func NewStyledTable(theme *Theme, columns []table.Column, rows []table.Row, width, height int) table.Model

NewStyledTable creates a themed table model.

func NewURLInput

func NewURLInput(theme *Theme) textinput.Model

NewURLInput creates a URL input field.

func RelativeTime

func RelativeTime(tm time.Time) string

RelativeTime formats a time as a human-readable relative string.

func StatsTableColumns

func StatsTableColumns() []table.Column

StatsTableColumns returns columns for domain stats table.

func TimeCategoryLabel

func TimeCategoryLabel(cat TimeCategory) string

TimeCategoryLabel returns the display label for a time category.

Types

type AboutRenderer

type AboutRenderer struct {
	// contains filtered or unexported fields
}

AboutRenderer renders build info in fastfetch style.

func NewAboutRenderer

func NewAboutRenderer(theme *Theme) *AboutRenderer

NewAboutRenderer creates a new about renderer with the given theme.

func (*AboutRenderer) Render

func (r *AboutRenderer) Render(info build.Info) string

Render renders build info with ASCII logo and styled info lines.

type CleanupKeyMap

type CleanupKeyMap struct {
	Up      key.Binding
	Down    key.Binding
	Confirm key.Binding
	Cancel  key.Binding
}

CleanupKeyMap defines keybindings for cleanup modal.

func DefaultCleanupKeyMap

func DefaultCleanupKeyMap() CleanupKeyMap

DefaultCleanupKeyMap returns default keybindings.

type CleanupModel

type CleanupModel struct {
	Ranges    []CleanupRangeInfo
	Selected  int
	Confirmed bool
	Canceled  bool
	// contains filtered or unexported fields
}

CleanupModel is a cleanup range selection modal.

func NewCleanup

func NewCleanup(theme *Theme) CleanupModel

NewCleanup creates a new cleanup modal.

func (CleanupModel) Done

func (m CleanupModel) Done() bool

Done returns true if the modal is complete.

func (CleanupModel) Init

func (m CleanupModel) Init() tea.Cmd

Init implements tea.Model.

func (CleanupModel) SelectedRange

func (m CleanupModel) SelectedRange() CleanupRange

SelectedRange returns the selected cleanup range.

func (CleanupModel) Update

func (m CleanupModel) Update(msg tea.Msg) (CleanupModel, tea.Cmd)

Update implements tea.Model.

func (CleanupModel) View

func (m CleanupModel) View() string

View implements tea.Model.

type CleanupRange

type CleanupRange int

CleanupRange represents a time range for history cleanup.

const (
	CleanupRangeLastHour CleanupRange = iota
	CleanupRangeLast24Hours
	CleanupRangeLast7Days
	CleanupRangeLast30Days
	CleanupRangeAll
)

func (CleanupRange) CutoffTime

func (r CleanupRange) CutoffTime() time.Time

CutoffTime returns the cutoff time for this range.

type CleanupRangeInfo

type CleanupRangeInfo struct {
	Range       CleanupRange
	Label       string
	Description string
}

CleanupRangeInfo holds display info for a cleanup range.

func AllCleanupRanges

func AllCleanupRanges() []CleanupRangeInfo

AllCleanupRanges returns all available cleanup ranges.

type CleanupResultMsg

type CleanupResultMsg struct {
	Confirmed bool
	Range     CleanupRange
}

CleanupResultMsg is sent when cleanup modal completes.

type ConfirmKeyMap

type ConfirmKeyMap struct {
	Yes     key.Binding
	No      key.Binding
	Left    key.Binding
	Right   key.Binding
	Confirm key.Binding
	Cancel  key.Binding
}

ConfirmKeyMap defines keybindings for the confirm dialog.

func DefaultConfirmKeyMap

func DefaultConfirmKeyMap() ConfirmKeyMap

DefaultConfirmKeyMap returns the default keybindings.

type ConfirmModel

type ConfirmModel struct {
	Message   string
	Yes       bool // Current selection
	Confirmed bool // User pressed enter
	Canceled  bool // User pressed escape
	// contains filtered or unexported fields
}

ConfirmModel is a yes/no confirmation dialog.

func NewConfirm

func NewConfirm(theme *Theme, message string) ConfirmModel

NewConfirm creates a new confirmation dialog.

func (ConfirmModel) Done

func (m ConfirmModel) Done() bool

Done returns true if the dialog is complete.

func (ConfirmModel) Init

func (m ConfirmModel) Init() tea.Cmd

Init implements tea.Model.

func (ConfirmModel) Result

func (m ConfirmModel) Result() bool

Result returns true if user confirmed "Yes".

func (ConfirmModel) Update

func (m ConfirmModel) Update(msg tea.Msg) (ConfirmModel, tea.Cmd)

Update implements tea.Model.

func (ConfirmModel) View

func (m ConfirmModel) View() string

View implements tea.Model.

type ConfirmResult

type ConfirmResult struct {
	Confirmed bool
	Yes       bool
}

ConfirmResult wraps the confirm dialog result for parent models.

type ConfirmResultMsg

type ConfirmResultMsg ConfirmResult

ConfirmResultMsg is sent when the confirm dialog completes.

type DmenuKeyMap

type DmenuKeyMap struct {
	Up     key.Binding
	Down   key.Binding
	Open   key.Binding
	Cancel key.Binding
}

DmenuKeyMap defines keybindings for dmenu browser.

func DefaultDmenuKeyMap

func DefaultDmenuKeyMap() DmenuKeyMap

DefaultDmenuKeyMap returns the default dmenu keybindings.

func (DmenuKeyMap) FullHelp

func (k DmenuKeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for expanded help.

func (DmenuKeyMap) ShortHelp

func (k DmenuKeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to show in compact help.

type DoctorMediaReport

type DoctorMediaReport struct {
	GStreamerAvailable bool
	HWAccelAvailable   bool
	AV1HWAvailable     bool

	HasVAPlugin      bool
	HasVAAPIPlugin   bool
	HasNVCodecPlugin bool

	AV1Decoders  []string
	H264Decoders []string
	H265Decoders []string
	VP9Decoders  []string

	VAAPIAvailable bool
	VAAPIDriver    string
	VAAPIVersion   string

	Warnings []string
}

type DoctorRenderer

type DoctorRenderer struct {
	// contains filtered or unexported fields
}

func NewDoctorRenderer

func NewDoctorRenderer(theme *Theme) *DoctorRenderer

func (*DoctorRenderer) Render

func (r *DoctorRenderer) Render(report DoctorReport) string

type DoctorReport

type DoctorReport struct {
	OverallOK bool
	Runtime   DoctorRuntimeReport
	Media     *DoctorMediaReport
}

type DoctorRuntimeCheck

type DoctorRuntimeCheck struct {
	Name            string
	PkgConfigName   string
	Installed       bool
	Version         string
	RequiredVersion string
	OK              bool
	Error           string
}

type DoctorRuntimeReport

type DoctorRuntimeReport struct {
	Prefix string
	OK     bool
	Checks []DoctorRuntimeCheck
}

type DomainStatsRow

type DomainStatsRow struct {
	Domain    string
	Visits    int
	Entries   int
	LastVisit string
}

DomainStatsRow converts domain stats to table row.

func (DomainStatsRow) ToRow

func (d DomainStatsRow) ToRow() table.Row

ToRow converts to table.Row.

type HistoryDelegate

type HistoryDelegate struct {
	Theme      *Theme
	ShowDomain bool
}

HistoryDelegate renders history items with theme styling.

func NewHistoryDelegate

func NewHistoryDelegate(theme *Theme) HistoryDelegate

NewHistoryDelegate creates a themed history list delegate.

func (HistoryDelegate) Height

func (d HistoryDelegate) Height() int

Height returns the height of each item.

func (HistoryDelegate) Render

func (d HistoryDelegate) Render(w io.Writer, m list.Model, index int, item list.Item)

Render renders a single list item.

func (HistoryDelegate) Spacing

func (d HistoryDelegate) Spacing() int

Spacing returns the spacing between items.

func (HistoryDelegate) Update

func (d HistoryDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd

Update handles item-level events.

type HistoryItem

type HistoryItem struct {
	ID          int64
	URL         string
	Title       string
	Domain      string
	VisitCount  int
	LastVisited time.Time
}

HistoryItem represents a history entry for the list.

func (HistoryItem) DescriptionValue

func (i HistoryItem) DescriptionValue() string

Description implements list.DefaultItem.

func (HistoryItem) FilterValue

func (i HistoryItem) FilterValue() string

FilterValue implements list.Item.

func (HistoryItem) TitleValue

func (i HistoryItem) TitleValue() string

Title implements list.DefaultItem.

type HistoryKeyMap

type HistoryKeyMap struct {
	Up           key.Binding
	Down         key.Binding
	Tab1         key.Binding
	Tab2         key.Binding
	Tab3         key.Binding
	Tab4         key.Binding
	NextTab      key.Binding
	PrevTab      key.Binding
	Search       key.Binding
	Open         key.Binding
	Delete       key.Binding
	DeleteDomain key.Binding
	Cleanup      key.Binding
	Filter       key.Binding
	Help         key.Binding
	Quit         key.Binding
}

HistoryKeyMap defines keybindings for history browser.

func DefaultHistoryKeyMap

func DefaultHistoryKeyMap() HistoryKeyMap

DefaultHistoryKeyMap returns the default history keybindings.

func (HistoryKeyMap) FullHelp

func (k HistoryKeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for expanded help.

func (HistoryKeyMap) ShortHelp

func (k HistoryKeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to show in compact help.

type KeyMap

type KeyMap interface {
	ShortHelp() []key.Binding
	FullHelp() [][]key.Binding
}

KeyMap defines keybindings that can be rendered as help.

type LoadingModel

type LoadingModel struct {
	Spinner spinner.Model
	Message string
	// contains filtered or unexported fields
}

LoadingModel wraps a spinner with a message.

func NewLoading

func NewLoading(theme *Theme, message string) LoadingModel

NewLoading creates a loading indicator with message.

func (LoadingModel) View

func (m LoadingModel) View() string

View renders the loading indicator.

type PurgeItem

type PurgeItem struct {
	entity.PurgeTarget
	Selected bool
}

PurgeItem wraps entity.PurgeTarget with selection state for the UI.

type PurgeKeyMap

type PurgeKeyMap struct {
	Up        key.Binding
	Down      key.Binding
	Toggle    key.Binding
	ToggleAll key.Binding
	Confirm   key.Binding
	Cancel    key.Binding
}

PurgeKeyMap defines keybindings for purge modal.

func DefaultPurgeKeyMap

func DefaultPurgeKeyMap() PurgeKeyMap

DefaultPurgeKeyMap returns default keybindings.

type PurgeModel

type PurgeModel struct {
	Items     []PurgeItem
	Cursor    int
	Confirmed bool
	Canceled  bool
	// contains filtered or unexported fields
}

PurgeModel is the multi-select purge modal.

func NewPurge

func NewPurge(theme *Theme, targets []entity.PurgeTarget) PurgeModel

NewPurge creates a new purge modal with the given targets.

func (PurgeModel) Done

func (m PurgeModel) Done() bool

Done returns true if the modal is complete.

func (PurgeModel) Init

func (m PurgeModel) Init() tea.Cmd

Init implements tea.Model.

func (PurgeModel) SelectedCount

func (m PurgeModel) SelectedCount() int

SelectedCount returns the number of selected, existing items.

func (PurgeModel) SelectedSize

func (m PurgeModel) SelectedSize() int64

SelectedSize returns the total size of selected, existing items.

func (PurgeModel) SelectedTypes

func (m PurgeModel) SelectedTypes() []entity.PurgeTargetType

SelectedTypes returns the selected target types.

func (PurgeModel) Update

func (m PurgeModel) Update(msg tea.Msg) (PurgeModel, tea.Cmd)

Update implements tea.Model.

func (PurgeModel) View

func (m PurgeModel) View() string

View implements tea.Model.

type SimpleDelegate

type SimpleDelegate struct {
	Theme *Theme
}

SimpleDelegate renders simple items.

func (SimpleDelegate) Height

func (d SimpleDelegate) Height() int

Height returns the height of each item.

func (SimpleDelegate) Render

func (d SimpleDelegate) Render(w io.Writer, m list.Model, index int, item list.Item)

Render renders a single list item.

func (SimpleDelegate) Spacing

func (d SimpleDelegate) Spacing() int

Spacing returns the spacing between items.

func (SimpleDelegate) Update

func (d SimpleDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd

Update handles item-level events.

type SimpleItem

type SimpleItem struct {
	TitleText string
	DescText  string
}

SimpleItem is a basic list item with title and description.

func (SimpleItem) FilterValue

func (i SimpleItem) FilterValue() string

FilterValue implements list.Item.

type SpinnerType

type SpinnerType int

SpinnerType defines available spinner styles.

const (
	SpinnerDots SpinnerType = iota
	SpinnerLine
	SpinnerMiniDot
	SpinnerJump
	SpinnerPulse
	SpinnerPoints
	SpinnerGlobe
	SpinnerMoon
	SpinnerMonkey
)

type TabsModel

type TabsModel struct {
	Tabs   []string
	Active int
	// contains filtered or unexported fields
}

TabsModel represents a horizontal tab bar.

func NewTabs

func NewTabs(theme *Theme, tabs ...string) TabsModel

NewTabs creates a new tab bar with the given labels.

func TimelineTabs

func TimelineTabs(theme *Theme) TabsModel

TimelineTabs creates tabs for history timeline view.

func (*TabsModel) Next

func (m *TabsModel) Next()

Next moves to the next tab.

func (*TabsModel) Prev

func (m *TabsModel) Prev()

Prev moves to the previous tab.

func (*TabsModel) SetActive

func (m *TabsModel) SetActive(index int)

SetActive sets the active tab index.

func (TabsModel) View

func (m TabsModel) View() string

View renders the tab bar.

func (TabsModel) ViewCompact

func (m TabsModel) ViewCompact() string

ViewCompact renders a compact tab bar without separators.

func (TabsModel) ViewWithCounts

func (m TabsModel) ViewWithCounts(counts []int) string

ViewWithCounts renders tabs with item counts.

type Theme

type Theme struct {
	// Base colors (from config.ColorPalette)
	Background     lipgloss.Color
	Surface        lipgloss.Color
	SurfaceVariant lipgloss.Color
	Text           lipgloss.Color
	Muted          lipgloss.Color
	Accent         lipgloss.Color
	Border         lipgloss.Color

	// Additional semantic colors
	Error   lipgloss.Color
	Warning lipgloss.Color
	Success lipgloss.Color

	// Pre-built styles
	Title        lipgloss.Style
	Subtitle     lipgloss.Style
	Normal       lipgloss.Style
	Subtle       lipgloss.Style
	Highlight    lipgloss.Style
	ErrorStyle   lipgloss.Style
	WarningStyle lipgloss.Style
	SuccessStyle lipgloss.Style

	// Component styles
	ActiveTab   lipgloss.Style
	InactiveTab lipgloss.Style
	TabBar      lipgloss.Style

	ListItem         lipgloss.Style
	ListItemSelected lipgloss.Style
	ListItemTitle    lipgloss.Style
	ListItemDesc     lipgloss.Style

	Badge      lipgloss.Style
	BadgeMuted lipgloss.Style

	Input        lipgloss.Style
	InputFocused lipgloss.Style

	HelpKey  lipgloss.Style
	HelpDesc lipgloss.Style

	Box       lipgloss.Style
	BoxHeader lipgloss.Style
}

Theme holds lipgloss colors and styles derived from config.

func NewTheme

func NewTheme(cfg *config.Config) *Theme

NewTheme creates a Theme from config, using dark palette only.

func NewThemeFromPalette

func NewThemeFromPalette(p config.ColorPalette) *Theme

NewThemeFromPalette creates a Theme from a ColorPalette.

func (*Theme) AccentBadge

func (t *Theme) AccentBadge(text string) string

AccentBadge renders a badge with accent color.

func (*Theme) DomainBadge

func (t *Theme) DomainBadge(domain string) string

DomainBadge renders a domain badge.

func (*Theme) InputBox

func (t *Theme) InputBox(input string, focused bool) string

InputBox wraps a text input in a styled box.

func (*Theme) MutedBadge

func (t *Theme) MutedBadge(text string) string

MutedBadge renders a badge with muted colors.

func (*Theme) Renderer

func (t *Theme) Renderer() *lipgloss.Renderer

Renderer returns a lipgloss renderer for the current output.

func (*Theme) StatusBadge

func (t *Theme) StatusBadge(text string, fg, bg lipgloss.Color) string

StatusBadge renders a status badge with custom colors.

func (*Theme) TimeBadge

func (t *Theme) TimeBadge(tm time.Time) string

TimeBadge renders a relative time badge.

func (*Theme) VisitBadge

func (t *Theme) VisitBadge(count int) string

VisitBadge renders a visit count badge.

type TimeCategory

type TimeCategory int

TimeCategory returns which timeline category a time belongs to.

const (
	TimeCategoryToday TimeCategory = iota
	TimeCategoryYesterday
	TimeCategoryThisWeek
	TimeCategoryOlder
)

func GetTimeCategory

func GetTimeCategory(tm time.Time) TimeCategory

GetTimeCategory returns the category for a given time.

Jump to

Keyboard shortcuts

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