1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5// Package ui provides lipgloss styles for terminal output.
6package ui
7
8import (
9 "time"
10
11 "github.com/charmbracelet/lipgloss"
12 "github.com/klauspost/lctime"
13)
14
15// Terminal output styles using ANSI colors for broad compatibility.
16var (
17 Success = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) // green
18 Warning = lipgloss.NewStyle().Foreground(lipgloss.Color("3")) // yellow
19 Error = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) // red
20 Bold = lipgloss.NewStyle().Bold(true)
21)
22
23// Heading styles with backgrounds for contrast on any theme.
24var (
25 // H1 is the primary heading style (top-level items).
26 H1 = lipgloss.NewStyle().
27 Bold(true).
28 Foreground(lipgloss.Color("0")).
29 Background(lipgloss.Color("4")).
30 Padding(0, 1)
31 // H2 is the secondary heading style (nested items).
32 H2 = lipgloss.NewStyle().
33 Bold(true).
34 Foreground(lipgloss.Color("0")).
35 Background(lipgloss.Color("6")).
36 Padding(0, 1)
37)
38
39// FormatDate formats a time.Time as a date string using the user's locale.
40// Locale is auto-detected from LC_TIME, LC_ALL, or LANG environment variables.
41func FormatDate(t time.Time) string {
42 return lctime.Strftime("%x", t)
43}