Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): update the PR view diff changes summary #295

Merged
merged 5 commits into from Aug 12, 2023

Conversation

Sanix-Darker
Copy link
Contributor

@Sanix-Darker Sanix-Darker commented Jul 22, 2023

Summary

UI changes proposal on +/- with colors like the view we have on github.

  • update colors (green/red) for adds/deletions.
  • add a formater util function for killos /Millions changes diffs.
  • add a sync amount of spaces between adds and deletions.

How did you test this change?

On my Ubuntu Os 20.04 , tmux, under allacrity.

go run gh-dash.go --debug

Images/Videos

BEFORE

Screenshot from 2023-07-22 19-19-04

AFTER

Screenshot from 2023-07-22 19-09-07

NOTE

  • This should work for all Unix based system.
  • I didn't create an issue because i thought there were not too many things to do on this branch, I hope it's okay.

@Sanix-Darker Sanix-Darker changed the title feat: update the PR view diff changes summary feat(ui): update the PR view diff changes summary Jul 22, 2023
Copy link
Owner

@dlvhdr dlvhdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great thank you! <3

return pr.getTextStyle().Render(
components.KeepSameSpacesOnAddDeletions(
fmt.Sprintf(
"\033[32m+%s \033[31m-%s",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use lipgloss for this. Specifically lipgloss.NewStyle().Foreground(lipgloss.Color("1")) and then use lipgloss.JoinHorizontal()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @dlvhdr
i updated the method like this :

func (pr *PullRequest) renderLines() string {
	deletions := 0
	if pr.Data.Deletions > 0 {
		deletions = pr.Data.Deletions
	}

    greenStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("2"))
    redStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("1"))

    greenText := greenStyle.Render("+" + components.FormatNumber(pr.Data.Additions))
    redText := redStyle.Render("-" + components.FormatNumber(deletions))

    return pr.getTextStyle().Render(
        components.KeepSameSpacesOnAddDeletions(
            lipgloss.JoinHorizontal(lipgloss.Top, greenText, redText),
        ),
    )
}

but am having an output not "fine" for the redText :

Peek 2023-07-23 15-55

Any tips ? 🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not near a computer right now but look at the code, there are other instances where I applied the "selected" background again. When you create a style you lose the bg the cell previously had, so you need to reapply it.

@dlvhdr
Copy link
Owner

dlvhdr commented Aug 12, 2023

@Sanix-Darker I fixed the issue, also see the open issue on lipgloss for reference: charmbracelet/lipgloss#144

@dlvhdr dlvhdr merged commit c70295f into dlvhdr:main Aug 12, 2023
2 checks passed
@Sanix-Darker
Copy link
Contributor Author

looks amazing @dlvhdr , thank you so much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants