wip: much more minimal layout
This commit is contained in:
parent
d86a436563
commit
f6260c85e7
68
cairde.go
68
cairde.go
|
@ -93,33 +93,28 @@ func main() {
|
|||
}
|
||||
|
||||
var (
|
||||
backgroundStyle = lipgloss.NewStyle().
|
||||
Align(lipgloss.Center)
|
||||
|
||||
mainStyle = lipgloss.NewStyle().
|
||||
BorderStyle(lipgloss.NormalBorder())
|
||||
|
||||
titleStyle = lipgloss.NewStyle().
|
||||
Height(1).
|
||||
Align(lipgloss.Center).
|
||||
Bold(true)
|
||||
|
||||
viewportStyle = lipgloss.NewStyle().
|
||||
BorderStyle(lipgloss.NormalBorder()).
|
||||
MarginLeft(1)
|
||||
BorderLeft(false).
|
||||
BorderRight(false).
|
||||
BorderTop(false).
|
||||
BorderBottom(true)
|
||||
|
||||
profileNameButtonStyle = lipgloss.NewStyle().
|
||||
Height(1).
|
||||
BorderStyle(lipgloss.NormalBorder()).
|
||||
Padding(0, 1).
|
||||
Bold(true)
|
||||
Bold(true).
|
||||
Underline(true)
|
||||
|
||||
inputStyle = lipgloss.NewStyle().
|
||||
Height(1).
|
||||
PaddingLeft(1)
|
||||
|
||||
chatStyle = lipgloss.NewStyle().
|
||||
PaddingLeft(1)
|
||||
BorderStyle(lipgloss.NormalBorder()).
|
||||
BorderLeft(false).
|
||||
BorderRight(false).
|
||||
BorderTop(true).
|
||||
BorderBottom(false)
|
||||
)
|
||||
|
||||
type profile struct {
|
||||
|
@ -139,8 +134,6 @@ type model struct {
|
|||
width int
|
||||
height int
|
||||
|
||||
title string
|
||||
|
||||
viewport viewport.Model
|
||||
|
||||
profiles []profile
|
||||
|
@ -154,13 +147,14 @@ type model struct {
|
|||
|
||||
func newModel(username, homeDir string) model {
|
||||
input := textinput.New()
|
||||
input.Prompt = ""
|
||||
input.SetCursorMode(textinput.CursorStatic)
|
||||
input.Focus()
|
||||
|
||||
return model{
|
||||
username: username,
|
||||
userDir: path.Join(homeDir, "/.cairde/"),
|
||||
torState: initialising,
|
||||
title: fmt.Sprintf("cairde@v0.1.0"),
|
||||
input: input,
|
||||
statusMsgs: new([]string),
|
||||
}
|
||||
|
@ -253,7 +247,7 @@ func (m model) initApp() tea.Msg {
|
|||
func (m model) Init() tea.Cmd {
|
||||
return tea.Batch(
|
||||
textinput.Blink,
|
||||
m.initApp,
|
||||
// m.initApp,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -385,8 +379,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
m.width = msg.Width - 2
|
||||
m.height = msg.Height - 2
|
||||
m.viewport = viewport.New(
|
||||
m.width-4,
|
||||
m.height-8,
|
||||
m.width,
|
||||
m.height-4,
|
||||
)
|
||||
|
||||
case tea.KeyMsg:
|
||||
|
@ -508,9 +502,7 @@ func (m model) View() string {
|
|||
// TODO: adjust when more panes are available
|
||||
m.viewport.SetContent(strings.Join(*m.statusMsgs, "\n"))
|
||||
|
||||
statusButton := profileNameButtonStyle.
|
||||
MarginLeft(1).
|
||||
Render("status")
|
||||
statusButton := profileNameButtonStyle.Render("status")
|
||||
|
||||
var profileNames []string
|
||||
for _, profile := range m.profiles {
|
||||
|
@ -529,34 +521,18 @@ func (m model) View() string {
|
|||
lipgloss.JoinVertical(
|
||||
lipgloss.Top,
|
||||
|
||||
lipgloss.PlaceHorizontal(
|
||||
m.width,
|
||||
lipgloss.Center,
|
||||
titleStyle.
|
||||
Width(m.width).
|
||||
Render(
|
||||
backgroundStyle.
|
||||
Width(lipgloss.Width(m.title)+2).
|
||||
Render(m.title),
|
||||
),
|
||||
),
|
||||
|
||||
viewportStyle.
|
||||
Width(m.width-4).
|
||||
Render(
|
||||
chatStyle.Render(
|
||||
m.viewport.View(),
|
||||
),
|
||||
),
|
||||
Width(m.width).
|
||||
Render(m.viewport.View()),
|
||||
|
||||
lipgloss.JoinHorizontal(
|
||||
lipgloss.Left,
|
||||
buttonBar...,
|
||||
),
|
||||
|
||||
inputStyle.Render(
|
||||
m.input.View(),
|
||||
),
|
||||
inputStyle.
|
||||
Width(m.width).
|
||||
Render(m.input.View()),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue