Skip to content

Commit

Permalink
fix(sidebar): set height on comment box
Browse files Browse the repository at this point in the history
Signed-off-by: Dolev Hadar <dolevc2@gmail.com>
  • Loading branch information
dlvhdr committed Oct 8, 2022
1 parent 0960a57 commit 409a15f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions ui/components/commentbox/commentbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {

func (m Model) View() string {
return lipgloss.NewStyle().
Width(m.textArea.Width()).
BorderTop(true).
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(styles.DefaultTheme.SecondaryBorder).
Expand All @@ -77,7 +76,6 @@ func (m Model) View() string {
Render(m.commentHelp.ShortHelpView(commentKeys)),
),
)

}

func (m *Model) Value() string {
Expand All @@ -96,6 +94,10 @@ func (m *Model) SetWidth(width int) {
m.textArea.SetWidth(width)
}

func (m *Model) SetHeight(height int) {
m.textArea.SetHeight(height)
}

func (m *Model) Reset() {
m.textArea.Reset()
}
5 changes: 4 additions & 1 deletion ui/components/issuesidebar/issuesidebar.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ type Model struct {
}

func NewModel() Model {
commentBox := commentbox.NewModel()
commentBox.SetHeight(styles.CommentBoxHeight)

return Model{
issue: nil,
isCommenting: false,
commentBox: commentbox.NewModel(),
commentBox: commentBox,
}
}

Expand Down
5 changes: 3 additions & 2 deletions ui/components/prsidebar/prsidebar.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Model struct {

func NewModel() Model {
commentBox := commentbox.NewModel()
commentBox.SetHeight(styles.CommentBoxHeight)

return Model{
pr: nil,
Expand Down Expand Up @@ -204,7 +205,7 @@ func (m *Model) SetRow(data *data.PullRequestData) {

func (m *Model) SetWidth(width int) {
m.width = width
m.commentBox.SetWidth(width)
m.commentBox.SetWidth(m.width)
}

func (m *Model) GetIsCommenting() bool {
Expand All @@ -228,5 +229,5 @@ func (m *Model) SetIsCommenting(isCommenting bool) tea.Cmd {
}

func (m *Model) getIndentedContentWidth() int {
return m.width - 6
return m.width - 4
}
1 change: 1 addition & 0 deletions ui/styles/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var (
SearchHeight = 3
FooterHeight = 2
ExpandedHelpHeight = 11
CommentBoxHeight = 8
FooterStyle = lipgloss.NewStyle().
Height(FooterHeight - 1).
BorderTop(true).
Expand Down

0 comments on commit 409a15f

Please sign in to comment.