huh.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package styles
  2. import (
  3. "github.com/charmbracelet/huh"
  4. "github.com/charmbracelet/lipgloss"
  5. "github.com/opencode-ai/opencode/internal/tui/theme"
  6. )
  7. // returns a huh.Theme configured with the current app theme colors
  8. func HuhTheme() *huh.Theme {
  9. t := huh.ThemeBase()
  10. currentTheme := theme.CurrentTheme()
  11. // Base theme elements
  12. bgColor := currentTheme.Background()
  13. bgSecondaryColor := currentTheme.BackgroundSecondary()
  14. textColor := currentTheme.Text()
  15. textMutedColor := currentTheme.TextMuted()
  16. primaryColor := currentTheme.Primary()
  17. secondaryColor := currentTheme.Secondary()
  18. // accentColor := currentTheme.Accent()
  19. errorColor := currentTheme.Error()
  20. successColor := currentTheme.Success()
  21. // warningColor := currentTheme.Warning()
  22. // infoColor := currentTheme.Info()
  23. borderColor := currentTheme.BorderNormal()
  24. borderFocusedColor := currentTheme.BorderFocused()
  25. // Focused styles
  26. t.Focused.Base = t.Focused.Base.
  27. BorderStyle(lipgloss.HiddenBorder()).
  28. Background(bgColor).
  29. BorderForeground(borderColor)
  30. t.Focused.Title = t.Focused.Title.
  31. Foreground(textColor).
  32. Background(bgColor)
  33. t.Focused.NoteTitle = t.Focused.NoteTitle.
  34. Foreground(textColor).
  35. Background(bgColor)
  36. t.Focused.Directory = t.Focused.Directory.
  37. Foreground(textColor).
  38. Background(bgColor)
  39. t.Focused.Description = t.Focused.Description.
  40. Foreground(textMutedColor).
  41. Background(bgColor)
  42. t.Focused.ErrorIndicator = t.Focused.ErrorIndicator.
  43. Foreground(errorColor).
  44. Background(bgColor)
  45. t.Focused.ErrorMessage = t.Focused.ErrorMessage.
  46. Foreground(errorColor).
  47. Background(bgColor)
  48. t.Focused.SelectSelector = t.Focused.SelectSelector.
  49. Foreground(primaryColor).
  50. Background(bgColor)
  51. t.Focused.NextIndicator = t.Focused.NextIndicator.
  52. Foreground(primaryColor).
  53. Background(bgColor)
  54. t.Focused.PrevIndicator = t.Focused.PrevIndicator.
  55. Foreground(primaryColor).
  56. Background(bgColor)
  57. t.Focused.Option = t.Focused.Option.
  58. Foreground(textColor).
  59. Background(bgColor)
  60. t.Focused.MultiSelectSelector = t.Focused.MultiSelectSelector.
  61. Foreground(primaryColor).
  62. Background(bgColor)
  63. t.Focused.SelectedOption = t.Focused.SelectedOption.
  64. Foreground(successColor).
  65. Background(bgColor)
  66. t.Focused.SelectedPrefix = t.Focused.SelectedPrefix.
  67. Foreground(successColor).
  68. Background(bgColor)
  69. t.Focused.UnselectedPrefix = t.Focused.UnselectedPrefix.
  70. Foreground(textColor).
  71. Background(bgColor)
  72. t.Focused.UnselectedOption = t.Focused.UnselectedOption.
  73. Foreground(textColor).
  74. Background(bgColor)
  75. t.Focused.FocusedButton = t.Focused.FocusedButton.
  76. Foreground(bgColor).
  77. Background(primaryColor).
  78. BorderForeground(borderFocusedColor)
  79. t.Focused.BlurredButton = t.Focused.BlurredButton.
  80. Foreground(textColor).
  81. Background(bgSecondaryColor).
  82. BorderForeground(borderColor)
  83. // Text input styles
  84. t.Focused.TextInput.Cursor = t.Focused.TextInput.Cursor.
  85. Foreground(secondaryColor).
  86. Background(bgColor)
  87. t.Focused.TextInput.Placeholder = t.Focused.TextInput.Placeholder.
  88. Foreground(textMutedColor).
  89. Background(bgColor)
  90. t.Focused.TextInput.Prompt = t.Focused.TextInput.Prompt.
  91. Foreground(primaryColor).
  92. Background(bgColor)
  93. t.Focused.TextInput.Text = t.Focused.TextInput.Text.
  94. Foreground(textColor).
  95. Background(bgColor)
  96. // Blur and focus states should be similar
  97. t.Blurred = t.Focused
  98. t.Blurred.Base = t.Blurred.Base.
  99. BorderStyle(lipgloss.HiddenBorder()).
  100. Background(bgColor)
  101. // Help styles
  102. t.Help.Ellipsis = t.Help.Ellipsis.
  103. Foreground(textMutedColor).
  104. Background(bgColor)
  105. t.Help.ShortKey = t.Help.ShortKey.
  106. Foreground(primaryColor).
  107. Background(bgColor)
  108. t.Help.ShortDesc = t.Help.ShortDesc.
  109. Foreground(textMutedColor).
  110. Background(bgColor)
  111. t.Help.ShortSeparator = t.Help.ShortSeparator.
  112. Foreground(textMutedColor).
  113. Background(bgColor)
  114. t.Help.FullKey = t.Help.FullKey.
  115. Foreground(primaryColor).
  116. Background(bgColor)
  117. t.Help.FullDesc = t.Help.FullDesc.
  118. Foreground(textMutedColor).
  119. Background(bgColor)
  120. t.Help.FullSeparator = t.Help.FullSeparator.
  121. Foreground(textMutedColor).
  122. Background(bgColor)
  123. return t
  124. }