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.Width = width
28 h.common.Height = height
29}
30
31// Init implements tea.Model.
32func (h *Header) Init() tea.Cmd {
33 return nil
34}
35
36// Update implements tea.Model.
37func (h *Header) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
38 return h, nil
39}
40
41// View implements tea.Model.
42func (h *Header) View() string {
43 s := h.common.Styles.Header.Copy().Width(h.common.Width)
44 return s.Render(strings.TrimSpace(h.text))
45}