1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5package ui
6
7import "github.com/charmbracelet/lipgloss"
8
9// Style wraps lipgloss.Style to conditionally render based on output mode.
10type Style struct {
11 style lipgloss.Style
12}
13
14// Render applies the style to the given text, or returns plain text in plain mode.
15func (s Style) Render(strs ...string) string {
16 if IsPlain() {
17 result := ""
18 for _, str := range strs {
19 result += str
20 }
21
22 return result
23 }
24
25 return s.style.Render(strs...)
26}
27
28// Style returns the underlying lipgloss.Style for advanced use.
29func (s Style) Style() lipgloss.Style {
30 return s.style
31}
32
33// Terminal output styles using ANSI colors for broad compatibility.
34//
35//nolint:gochecknoglobals // intentional globals for styled output
36var (
37 Success = Style{lipgloss.NewStyle().Foreground(lipgloss.Color("2"))} // green
38 Warning = Style{lipgloss.NewStyle().Foreground(lipgloss.Color("3"))} // yellow
39 Error = Style{lipgloss.NewStyle().Foreground(lipgloss.Color("1"))} // red
40 Bold = Style{lipgloss.NewStyle().Bold(true)}
41)