styles.go 4.3 KB

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