styles.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package styles
  2. import (
  3. "github.com/charmbracelet/lipgloss"
  4. "github.com/sst/opencode/internal/tui/theme"
  5. )
  6. var (
  7. ImageBakcground = "#212121"
  8. )
  9. // Style generation functions that use the current theme
  10. // BaseStyle returns the base style with background and foreground colors
  11. func BaseStyle() lipgloss.Style {
  12. t := theme.CurrentTheme()
  13. return lipgloss.NewStyle().
  14. Background(t.Background()).
  15. Foreground(t.Text())
  16. }
  17. // Regular returns a basic unstyled lipgloss.Style
  18. func Regular() lipgloss.Style {
  19. return lipgloss.NewStyle()
  20. }
  21. func Muted() lipgloss.Style {
  22. return lipgloss.NewStyle().Foreground(theme.CurrentTheme().TextMuted())
  23. }
  24. // Bold returns a bold style
  25. func Bold() lipgloss.Style {
  26. return Regular().Bold(true)
  27. }
  28. // Padded returns a style with horizontal padding
  29. func Padded() lipgloss.Style {
  30. return Regular().Padding(0, 1)
  31. }
  32. // Border returns a style with a normal border
  33. func Border() lipgloss.Style {
  34. t := theme.CurrentTheme()
  35. return Regular().
  36. Border(lipgloss.NormalBorder()).
  37. BorderForeground(t.BorderNormal())
  38. }
  39. // ThickBorder returns a style with a thick border
  40. func ThickBorder() lipgloss.Style {
  41. t := theme.CurrentTheme()
  42. return Regular().
  43. Border(lipgloss.ThickBorder()).
  44. BorderForeground(t.BorderNormal())
  45. }
  46. // DoubleBorder returns a style with a double border
  47. func DoubleBorder() lipgloss.Style {
  48. t := theme.CurrentTheme()
  49. return Regular().
  50. Border(lipgloss.DoubleBorder()).
  51. BorderForeground(t.BorderNormal())
  52. }
  53. // FocusedBorder returns a style with a border using the focused border color
  54. func FocusedBorder() lipgloss.Style {
  55. t := theme.CurrentTheme()
  56. return Regular().
  57. Border(lipgloss.NormalBorder()).
  58. BorderForeground(t.BorderFocused())
  59. }
  60. // DimBorder returns a style with a border using the dim border color
  61. func DimBorder() lipgloss.Style {
  62. t := theme.CurrentTheme()
  63. return Regular().
  64. Border(lipgloss.NormalBorder()).
  65. BorderForeground(t.BorderDim())
  66. }
  67. // PrimaryColor returns the primary color from the current theme
  68. func PrimaryColor() lipgloss.AdaptiveColor {
  69. return theme.CurrentTheme().Primary()
  70. }
  71. // SecondaryColor returns the secondary color from the current theme
  72. func SecondaryColor() lipgloss.AdaptiveColor {
  73. return theme.CurrentTheme().Secondary()
  74. }
  75. // AccentColor returns the accent color from the current theme
  76. func AccentColor() lipgloss.AdaptiveColor {
  77. return theme.CurrentTheme().Accent()
  78. }
  79. // ErrorColor returns the error color from the current theme
  80. func ErrorColor() lipgloss.AdaptiveColor {
  81. return theme.CurrentTheme().Error()
  82. }
  83. // WarningColor returns the warning color from the current theme
  84. func WarningColor() lipgloss.AdaptiveColor {
  85. return theme.CurrentTheme().Warning()
  86. }
  87. // SuccessColor returns the success color from the current theme
  88. func SuccessColor() lipgloss.AdaptiveColor {
  89. return theme.CurrentTheme().Success()
  90. }
  91. // InfoColor returns the info color from the current theme
  92. func InfoColor() lipgloss.AdaptiveColor {
  93. return theme.CurrentTheme().Info()
  94. }
  95. // TextColor returns the text color from the current theme
  96. func TextColor() lipgloss.AdaptiveColor {
  97. return theme.CurrentTheme().Text()
  98. }
  99. // TextMutedColor returns the muted text color from the current theme
  100. func TextMutedColor() lipgloss.AdaptiveColor {
  101. return theme.CurrentTheme().TextMuted()
  102. }
  103. // TextEmphasizedColor returns the emphasized text color from the current theme
  104. func TextEmphasizedColor() lipgloss.AdaptiveColor {
  105. return theme.CurrentTheme().TextEmphasized()
  106. }
  107. // BackgroundColor returns the background color from the current theme
  108. func BackgroundColor() lipgloss.AdaptiveColor {
  109. return theme.CurrentTheme().Background()
  110. }
  111. // BackgroundSecondaryColor returns the secondary background color from the current theme
  112. func BackgroundSecondaryColor() lipgloss.AdaptiveColor {
  113. return theme.CurrentTheme().BackgroundSecondary()
  114. }
  115. // BackgroundDarkerColor returns the darker background color from the current theme
  116. func BackgroundDarkerColor() lipgloss.AdaptiveColor {
  117. return theme.CurrentTheme().BackgroundDarker()
  118. }
  119. // BorderNormalColor returns the normal border color from the current theme
  120. func BorderNormalColor() lipgloss.AdaptiveColor {
  121. return theme.CurrentTheme().BorderNormal()
  122. }
  123. // BorderFocusedColor returns the focused border color from the current theme
  124. func BorderFocusedColor() lipgloss.AdaptiveColor {
  125. return theme.CurrentTheme().BorderFocused()
  126. }
  127. // BorderDimColor returns the dim border color from the current theme
  128. func BorderDimColor() lipgloss.AdaptiveColor {
  129. return theme.CurrentTheme().BorderDim()
  130. }