making the enter/details key switch focus between issues and details; using the v key for switching between kanban and list view; making the footer stay at the buttom of the screen in kanban view
This commit is contained in:
@@ -24,13 +24,11 @@ type FullRow struct {
|
|||||||
RightDesc string
|
RightDesc string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type HelpBarConfig struct {
|
type HelpBarConfig struct {
|
||||||
ShortItems []ShortItem
|
ShortItems []ShortItem
|
||||||
FullRows []FullRow
|
FullRows []FullRow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type HelpBar struct {
|
type HelpBar struct {
|
||||||
view ViewKind
|
view ViewKind
|
||||||
config HelpBarConfig
|
config HelpBarConfig
|
||||||
@@ -38,7 +36,6 @@ type HelpBar struct {
|
|||||||
width int
|
width int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewHelpBar(view ViewKind) HelpBar {
|
func NewHelpBar(view ViewKind) HelpBar {
|
||||||
return HelpBar{view: view, config: helpBarConfig(view)}
|
return HelpBar{view: view, config: helpBarConfig(view)}
|
||||||
}
|
}
|
||||||
@@ -47,7 +44,6 @@ func (h *HelpBar) SetWidth(width int) {
|
|||||||
h.width = width
|
h.width = width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (h HelpBar) View() string {
|
func (h HelpBar) View() string {
|
||||||
if h.width == 0 {
|
if h.width == 0 {
|
||||||
return ""
|
return ""
|
||||||
@@ -111,7 +107,6 @@ func (h HelpBar) Height() int {
|
|||||||
return lipgloss.Height(h.View())
|
return lipgloss.Height(h.View())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (h HelpBar) IsExpanded() bool {
|
func (h HelpBar) IsExpanded() bool {
|
||||||
return h.showAll
|
return h.showAll
|
||||||
}
|
}
|
||||||
@@ -126,7 +121,7 @@ func helpBarConfig(view ViewKind) HelpBarConfig {
|
|||||||
return HelpBarConfig{
|
return HelpBarConfig{
|
||||||
ShortItems: []ShortItem{
|
ShortItems: []ShortItem{
|
||||||
{Key: "tab", Desc: "switch"},
|
{Key: "tab", Desc: "switch"},
|
||||||
{Key: "k", Desc: "kanban"},
|
{Key: "v", Desc: "kanban"},
|
||||||
{Key: "↑/k", Desc: "up"},
|
{Key: "↑/k", Desc: "up"},
|
||||||
{Key: "↓/j", Desc: "down"},
|
{Key: "↓/j", Desc: "down"},
|
||||||
{Key: "pgup/pgdn", Desc: "page"},
|
{Key: "pgup/pgdn", Desc: "page"},
|
||||||
@@ -144,14 +139,14 @@ func helpBarConfig(view ViewKind) HelpBarConfig {
|
|||||||
{LeftKey: "e", LeftDesc: "edit title", RightKey: "d", RightDesc: "edit description"},
|
{LeftKey: "e", LeftDesc: "edit title", RightKey: "d", RightDesc: "edit description"},
|
||||||
{LeftKey: "s", LeftDesc: "change status", RightKey: "p", RightDesc: "change priority"},
|
{LeftKey: "s", LeftDesc: "change status", RightKey: "p", RightDesc: "change priority"},
|
||||||
{LeftKey: "t", LeftDesc: "change type", RightKey: "x", RightDesc: "delete issue"},
|
{LeftKey: "t", LeftDesc: "change type", RightKey: "x", RightDesc: "delete issue"},
|
||||||
{LeftKey: "2", LeftDesc: "kanban", RightKey: "q", RightDesc: "quit"},
|
{LeftKey: "v", LeftDesc: "kanban", RightKey: "q", RightDesc: "quit"},
|
||||||
{LeftKey: "?", LeftDesc: "help", RightKey: "", RightDesc: ""},
|
{LeftKey: "?", LeftDesc: "help", RightKey: "", RightDesc: ""},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
case ViewKanban:
|
case ViewKanban:
|
||||||
return HelpBarConfig{
|
return HelpBarConfig{
|
||||||
ShortItems: []ShortItem{
|
ShortItems: []ShortItem{
|
||||||
{Key: "1", Desc: "issues"},
|
{Key: "v", Desc: "list view"},
|
||||||
{Key: "↑/k", Desc: "up"},
|
{Key: "↑/k", Desc: "up"},
|
||||||
{Key: "↓/j", Desc: "down"},
|
{Key: "↓/j", Desc: "down"},
|
||||||
{Key: "pgup/pgdn", Desc: "page"},
|
{Key: "pgup/pgdn", Desc: "page"},
|
||||||
@@ -164,7 +159,7 @@ func helpBarConfig(view ViewKind) HelpBarConfig {
|
|||||||
{Key: "?", Desc: "help"},
|
{Key: "?", Desc: "help"},
|
||||||
},
|
},
|
||||||
FullRows: []FullRow{
|
FullRows: []FullRow{
|
||||||
{LeftKey: "1", LeftDesc: "issues", RightKey: "↑/k", RightDesc: "up"},
|
{LeftKey: "v", LeftDesc: "list view", RightKey: "↑/k", RightDesc: "up"},
|
||||||
{LeftKey: "enter", LeftDesc: "view issue", RightKey: "↓/j", RightDesc: "down"},
|
{LeftKey: "enter", LeftDesc: "view issue", RightKey: "↓/j", RightDesc: "down"},
|
||||||
{LeftKey: "pgup", LeftDesc: "page up", RightKey: "pgdn", RightDesc: "page down"},
|
{LeftKey: "pgup", LeftDesc: "page up", RightKey: "pgdn", RightDesc: "page down"},
|
||||||
{LeftKey: "h/l", LeftDesc: "switch column", RightKey: "←/→", RightDesc: "move issue"},
|
{LeftKey: "h/l", LeftDesc: "switch column", RightKey: "←/→", RightDesc: "move issue"},
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
type DashboardKeyMap struct {
|
type DashboardKeyMap struct {
|
||||||
components.CommonKeyMap
|
components.CommonKeyMap
|
||||||
SwitchWindow key.Binding
|
SwitchWindow key.Binding
|
||||||
SwitchToKanbanBoard key.Binding
|
SwitchToKanbanBoard key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultDashboardKeyMap = DashboardKeyMap{
|
var defaultDashboardKeyMap = DashboardKeyMap{
|
||||||
@@ -20,8 +20,8 @@ var defaultDashboardKeyMap = DashboardKeyMap{
|
|||||||
key.WithHelp("tab", "switch window"),
|
key.WithHelp("tab", "switch window"),
|
||||||
),
|
),
|
||||||
SwitchToKanbanBoard: key.NewBinding(
|
SwitchToKanbanBoard: key.NewBinding(
|
||||||
key.WithKeys("k"),
|
key.WithKeys("v"),
|
||||||
key.WithHelp("k", "switch to kanban"),
|
key.WithHelp("v", "switch to kanban"),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ func (d *Model) handleKeyMsg(msg tea.KeyMsg) tea.Cmd {
|
|||||||
return func() tea.Msg { return msgs.SwitchToKanbanBoardMsg{} }
|
return func() tea.Msg { return msgs.SwitchToKanbanBoardMsg{} }
|
||||||
case d.IsFocusedOnList() && key.Matches(msg, d.keyMap.SelectIssue):
|
case d.IsFocusedOnList() && key.Matches(msg, d.keyMap.SelectIssue):
|
||||||
d.FocusDetail()
|
d.FocusDetail()
|
||||||
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.BackToList):
|
case d.IsFocusedOnDetail() && (key.Matches(msg, d.keyMap.BackToList) || key.Matches(msg, d.keyMap.SelectIssue)):
|
||||||
d.FocusList()
|
d.FocusList()
|
||||||
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.ScrollUp):
|
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.ScrollUp):
|
||||||
d.issueDetail.ScrollUp(1)
|
d.issueDetail.ScrollUp(1)
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ type KanbanKeyMap struct {
|
|||||||
var defaultKanbanKeyMap = KanbanKeyMap{
|
var defaultKanbanKeyMap = KanbanKeyMap{
|
||||||
CommonKeyMap: components.DefaultCommonKeyMap(),
|
CommonKeyMap: components.DefaultCommonKeyMap(),
|
||||||
SwitchToDashboard: key.NewBinding(
|
SwitchToDashboard: key.NewBinding(
|
||||||
key.WithKeys("1"),
|
key.WithKeys("v"),
|
||||||
key.WithHelp("1", "dashboard 1"),
|
key.WithHelp("v", "dashboard 1"),
|
||||||
),
|
),
|
||||||
MoveColumnLeft: key.NewBinding(
|
MoveColumnLeft: key.NewBinding(
|
||||||
key.WithKeys("h"),
|
key.WithKeys("h"),
|
||||||
@@ -68,7 +68,7 @@ func (d *Model) handleKeyMsg(msg tea.KeyMsg) tea.Cmd {
|
|||||||
cmd = d.moveIssue(-1)
|
cmd = d.moveIssue(-1)
|
||||||
case d.IsFocusedOnList() && key.Matches(msg, d.keyMap.SelectIssue):
|
case d.IsFocusedOnList() && key.Matches(msg, d.keyMap.SelectIssue):
|
||||||
d.FocusDetail()
|
d.FocusDetail()
|
||||||
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.BackToList):
|
case d.IsFocusedOnDetail() && (key.Matches(msg, d.keyMap.BackToList) || key.Matches(msg, d.keyMap.SelectIssue)):
|
||||||
d.FocusList()
|
d.FocusList()
|
||||||
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.ScrollUp):
|
case d.IsFocusedOnDetail() && key.Matches(msg, d.keyMap.ScrollUp):
|
||||||
d.issueDetail.ScrollUp(1)
|
d.issueDetail.ScrollUp(1)
|
||||||
|
|||||||
@@ -66,7 +66,15 @@ func (m *Model) View() string {
|
|||||||
board := lipgloss.JoinHorizontal(lipgloss.Left, todoCol, inProgCol, doneCol)
|
board := lipgloss.JoinHorizontal(lipgloss.Left, todoCol, inProgCol, doneCol)
|
||||||
content := lipgloss.JoinVertical(lipgloss.Left, board, m.issueDetail.View())
|
content := lipgloss.JoinVertical(lipgloss.Left, board, m.issueDetail.View())
|
||||||
|
|
||||||
|
// Add spacer to lock footer to bottom of screen when content is shorter than available space
|
||||||
|
// This is to avoid having the footer floating above the bottom of the screen
|
||||||
mainView := lipgloss.JoinVertical(lipgloss.Left, header, content, footer)
|
mainView := lipgloss.JoinVertical(lipgloss.Left, header, content, footer)
|
||||||
|
mainViewHeight := lipgloss.Height(mainView)
|
||||||
|
if mainViewHeight < m.height {
|
||||||
|
spacerHeight := m.height - mainViewHeight
|
||||||
|
spacer := lipgloss.NewStyle().Height(spacerHeight).Width(m.width).Render("")
|
||||||
|
mainView = lipgloss.JoinVertical(lipgloss.Left, header, content, spacer, footer)
|
||||||
|
}
|
||||||
|
|
||||||
return components.RenderModals(
|
return components.RenderModals(
|
||||||
m.width,
|
m.width,
|
||||||
|
|||||||
Reference in New Issue
Block a user