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