1package header
2
3import (
4 "strings"
5
6 tea "github.com/charmbracelet/bubbletea"
7 "github.com/charmbracelet/soft-serve/ui/common"
8)
9
10type Header struct {
11 common common.Common
12 text string
13}
14
15func New(c common.Common, text string) *Header {
16 h := &Header{
17 common: c,
18 text: text,
19 }
20 return h
21}
22
23func (h *Header) SetSize(width, height int) {
24 h.common.Width = width
25 h.common.Height = height
26}
27
28func (h *Header) Init() tea.Cmd {
29 return nil
30}
31
32func (h *Header) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
33 return h, nil
34}
35
36func (h *Header) View() string {
37 s := h.common.Styles.Header.Copy().Width(h.common.Width)
38 return s.Render(strings.TrimSpace(h.text))
39}