Skip to content

Commit

Permalink
small improvements for better user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
canack committed Jun 26, 2024
1 parent 44e7f4a commit c86f842
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions internal/terminal/handler/ghtrigger/ghtrigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,20 +340,20 @@ func (m *ModelGithubTrigger) inputController(_ context.Context) {
}

func (m *ModelGithubTrigger) View() string {
baseStyle := lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240"))

termWidth := m.Viewport.Width
termHeight := m.Viewport.Height
baseStyle := lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder())
if m.triggerFocused {
baseStyle = baseStyle.BorderForeground(lipgloss.Color("240"))
} else {
baseStyle = baseStyle.BorderForeground(lipgloss.Color("130"))
}

var tableWidth int
for _, t := range tableColumnsTrigger {
tableWidth += t.Width
}

newTableColumns := tableColumnsTrigger
widthDiff := termWidth - tableWidth
widthDiff := m.Viewport.Width - tableWidth
if widthDiff > 0 {
keyWidth := &newTableColumns[2].Width
valueWidth := &newTableColumns[4].Width
Expand All @@ -363,7 +363,7 @@ func (m *ModelGithubTrigger) View() string {
*keyWidth = *valueWidth / 2
}
m.tableTrigger.SetColumns(newTableColumns)
m.tableTrigger.SetHeight(termHeight - 17)
m.tableTrigger.SetHeight(m.Viewport.Height - 17)
}

doc := strings.Builder{}
Expand Down
11 changes: 6 additions & 5 deletions internal/terminal/handler/ghworkflow/ghworkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ type ModelGithubWorkflow struct {
actualModelGithubTrigger *ghtrigger.ModelGithubTrigger
}

var baseStyle = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240"))

func SetupModelGithubWorkflow(viewport *viewport.Model, githubUseCase gu.UseCase, selectedRepository *hdltypes.SelectedRepository) *ModelGithubWorkflow {
var tableRowsTriggerableWorkflow []table.Row

Expand Down Expand Up @@ -120,6 +116,10 @@ func (m *ModelGithubWorkflow) Update(msg tea.Msg) (*ModelGithubWorkflow, tea.Cmd
}

func (m *ModelGithubWorkflow) View() string {
var style = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240"))

termWidth := m.Viewport.Width
termHeight := m.Viewport.Height

Expand All @@ -137,7 +137,8 @@ func (m *ModelGithubWorkflow) View() string {
}

doc := strings.Builder{}
doc.WriteString(baseStyle.Render(m.tableTriggerableWorkflow.View()))
doc.WriteString(style.Render(m.tableTriggerableWorkflow.View()))
doc.WriteString("\n\n\n")

return doc.String()
}
Expand Down
2 changes: 1 addition & 1 deletion internal/terminal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (m *model) View() string {
var width = lipgloss.Width(strings.Repeat("-", m.viewport.Width)) - 5
hdltypes.ScreenWidth = &width

dynamicWindowStyle := ts.WindowStyleCyan.Width(width).Height(m.viewport.Height - 22)
dynamicWindowStyle := lipgloss.NewStyle().Width(width).Height(m.viewport.Height - 22)
helpWindowStyle := ts.WindowStyleHelp.Width(width)

mainDoc.WriteString(m.modelHeader.View() + "\n")
Expand Down
4 changes: 2 additions & 2 deletions internal/terminal/handler/information/information.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func (m *ModelInfo) View() string {

infoDoc.WriteString(lipgloss.JoinVertical(lipgloss.Center, applicationName, applicationDescription, newVersionAvailableMsg))

docHeight := strings.Count(infoDoc.String(), "\n")
requiredNewlinesForPadding := m.Viewport.Height - docHeight - 13
docHeight := lipgloss.Height(infoDoc.String())
requiredNewlinesForPadding := m.Viewport.Height - docHeight - 12

infoDoc.WriteString(strings.Repeat("\n", max(0, requiredNewlinesForPadding)))

Expand Down
1 change: 0 additions & 1 deletion internal/terminal/style/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

var (
DocStyle = lipgloss.NewStyle().Padding(1, 2, 1, 2)
WindowStyleCyan = lipgloss.NewStyle().BorderForeground(lipgloss.Color("39"))
WindowStyleOrange = lipgloss.NewStyle().BorderForeground(lipgloss.Color("#ffaf00")).Border(lipgloss.RoundedBorder())
WindowStyleRed = lipgloss.NewStyle().BorderForeground(lipgloss.Color("9")).Border(lipgloss.RoundedBorder())
WindowStyleGreen = lipgloss.NewStyle().BorderForeground(lipgloss.Color("10")).Border(lipgloss.RoundedBorder())
Expand Down

0 comments on commit c86f842

Please sign in to comment.