Skip to content

Commit

Permalink
fixed height & width
Browse files Browse the repository at this point in the history
  • Loading branch information
somnek committed Jan 13, 2024
1 parent 611e3e0 commit e8b287a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions style.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const (
minHeightPerView = 8 // 6 item
maxHeightPerView = 12 // 10 item
fixedWidth = 80
fixedBodyLWidth = 36 // exclude padding
fixedBodyRWidth = 44 // exclude padding
)

var (
Expand All @@ -42,11 +44,11 @@ var (
}

bodyLStyle = lipgloss.NewStyle().
Padding(1, 2, 0, 4).
Padding(1, 0, 0, 4).
Border(lipgloss.RoundedBorder(), true, false, false, true).
BorderForeground(black)
bodyRStyle = lipgloss.NewStyle().
Padding(1, 4, 0, 2).
Padding(1, 4, 0, 0).
PaddingLeft(4).
Border(lipgloss.RoundedBorder(), true, true, false, false).
Foreground(black).
Expand Down
10 changes: 5 additions & 5 deletions view.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func buildContainerDescShort(c container) string {
if err != nil {
log.Fatal(err)
}
desc := fmt.Sprintf("ID : %v\n", runewidth.Truncate(container.ID, 20, "..."))
desc := fmt.Sprintf("ID : %v\n", runewidth.Truncate(container.ID, fixedBodyRWidth-6, "..."))
desc += fmt.Sprintf("Image : %s\n", container.Config.Image)
desc += fmt.Sprintf("Cmd : %s\n", strings.Join(container.Config.Cmd, " "))
desc += fmt.Sprintf("State : %s\n", container.State.String())
Expand All @@ -40,7 +40,7 @@ func buildContainerDescFull(c container) string {
if err != nil {
log.Fatal(err)
}
desc := fmt.Sprintf("ID: %s\n", container.ID)
desc := fmt.Sprintf("ID : %v\n", runewidth.Truncate(container.ID, fixedBodyRWidth-8, "..."))
desc += fmt.Sprintf("Image: %s\n", container.Config.Image)
desc += fmt.Sprintf("Cmd: %s\n", strings.Join(container.Config.Cmd, " "))
desc += fmt.Sprintf("Created: %s\n", container.Created)
Expand Down Expand Up @@ -139,9 +139,6 @@ func (m model) View() string {
bodyL = buildImageView(m)
}

// body R
// bodyR = bodyRStyle.Render(buildLogView(m))

// title
title := strings.Repeat(" ", 36) + "🐳 Docker"
titleStyle.MarginLeft((m.width - (fixedWidth + lipgloss.Width(title)/2)) / 2)
Expand All @@ -162,3 +159,6 @@ func padBodyHeight(s *string, itemCount int) {
*s += strings.Repeat("\n", minHeightPerView-itemCount)
}
}

// body R
// bodyR = bodyRStyle.Render(buildLogView(m))

0 comments on commit e8b287a

Please sign in to comment.