repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

pico / tui / common
Antonio Mika · 31 May 24

styles.go

  1package common
  2
  3import (
  4	"github.com/charmbracelet/lipgloss"
  5)
  6
  7var (
  8	Indigo       = lipgloss.AdaptiveColor{Light: "#5A56E0", Dark: "#7571F9"}
  9	SubtleIndigo = lipgloss.AdaptiveColor{Light: "#7D79F6", Dark: "#514DC1"}
 10	Cream        = lipgloss.AdaptiveColor{Light: "#FFFDF5", Dark: "#FFFDF5"}
 11	Fuschia      = lipgloss.AdaptiveColor{Light: "#EE6FF8", Dark: "#EE6FF8"}
 12	Green        = lipgloss.AdaptiveColor{Light: "#ABE5D1", Dark: "#04B575"}
 13	DarkRed      = lipgloss.AdaptiveColor{Light: "#EBE5EC", Dark: "#2B2A2A"}
 14	Red          = lipgloss.AdaptiveColor{Light: "#FF4672", Dark: "#ED567A"}
 15	FaintRed     = lipgloss.AdaptiveColor{Light: "#FF6F91", Dark: "#C74665"}
 16	Grey         = lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}
 17	GreyLight    = lipgloss.AdaptiveColor{Light: "#BDB0BE", Dark: "#827983"}
 18)
 19
 20type Styles struct {
 21	Cursor,
 22	Wrap,
 23	Paragraph,
 24	Code,
 25	Subtle,
 26	Error,
 27	Prompt,
 28	FocusedPrompt,
 29	Note,
 30	Delete,
 31	Label,
 32	ListKey,
 33	InactivePagination,
 34	SelectionMarker,
 35	SelectedMenuItem,
 36	Logo,
 37	BlurredButtonStyle,
 38	FocusedButtonStyle,
 39	HelpSection,
 40	HelpDivider,
 41	App,
 42	InputPlaceholder,
 43	RoundedBorder lipgloss.Style
 44	Renderer *lipgloss.Renderer
 45}
 46
 47func DefaultStyles(renderer *lipgloss.Renderer) Styles {
 48	s := Styles{
 49		Renderer: renderer,
 50	}
 51
 52	s.Cursor = renderer.NewStyle().Foreground(Fuschia)
 53	s.Wrap = renderer.NewStyle().Width(58)
 54	s.Paragraph = s.Wrap.Margin(1, 0, 0, 2)
 55	s.Logo = renderer.NewStyle().
 56		Foreground(Cream).
 57		Background(Indigo).
 58		Padding(0, 1)
 59	s.Code = renderer.NewStyle().
 60		Foreground(Red).
 61		Background(DarkRed).
 62		Padding(0, 1)
 63	s.Subtle = renderer.NewStyle().
 64		Foreground(Grey)
 65	s.Error = renderer.NewStyle().Foreground(Red)
 66	s.Prompt = renderer.NewStyle().MarginRight(1).SetString(">")
 67	s.FocusedPrompt = s.Prompt.Foreground(Fuschia)
 68	s.InputPlaceholder = renderer.NewStyle().Foreground(Grey)
 69	s.Note = renderer.NewStyle().Foreground(Green)
 70	s.Delete = s.Error
 71	s.Label = renderer.NewStyle().Foreground(Fuschia)
 72	s.ListKey = renderer.NewStyle().Foreground(Indigo)
 73	s.InactivePagination = renderer.NewStyle().
 74		Foreground(Grey)
 75	s.SelectionMarker = renderer.NewStyle().
 76		Foreground(Fuschia).
 77		PaddingRight(1).
 78		SetString("•")
 79	s.SelectedMenuItem = renderer.NewStyle().Foreground(Fuschia)
 80	s.BlurredButtonStyle = renderer.NewStyle().
 81		Foreground(Cream).
 82		Background(GreyLight).
 83		Padding(0, 3)
 84	s.FocusedButtonStyle = s.BlurredButtonStyle.
 85		Background(Fuschia)
 86	s.HelpDivider = renderer.NewStyle().
 87		Foreground(Grey).
 88		Padding(0, 1).
 89		SetString("•")
 90	s.HelpSection = renderer.NewStyle().
 91		Foreground(Grey)
 92	s.App = renderer.NewStyle().Margin(1, 0, 1, 2)
 93	s.RoundedBorder = renderer.
 94		NewStyle().
 95		Padding(0, 1).
 96		BorderForeground(Indigo).
 97		Border(lipgloss.RoundedBorder(), true, true)
 98
 99	return s
100}