styles.go 4.3 KB

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