styles.go 4.3 KB

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