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

Allow files to be collapsable #92

Closed
adamjimenez opened this issue Jul 22, 2016 · 10 comments · Fixed by #358
Closed

Allow files to be collapsable #92

adamjimenez opened this issue Jul 22, 2016 · 10 comments · Fixed by #358

Comments

@adamjimenez
Copy link

adamjimenez commented Jul 22, 2016

Allow files to be collapsible.

Ideally this could be just CSS to avoid Javascript usage.
We could then allow an option to choose if the files start open or collapsed.


If enabled then the diffs will start as collapsed when there is more than one file.
You would then be able to click the header to toggle the collapse state of the different files.

@rtfpessoa
Copy link
Owner

I am up for any contributions regarding this.
Seems like an interesting idea 👍
Feel free to throw some ideas here and maybe be a bit more specific about the details.

@adamjimenez
Copy link
Author

I'm thinking something along the lines of the github client e.g:

image

@rtfpessoa
Copy link
Owner

@adamjimenez it looks good.

Maybe we could have an HTML version without the file summary and where all the files are collapsed.

@adamjimenez
Copy link
Author

Yes, that would be good. And if there is only one file then default it to expanded.

@samiraguiar
Copy link
Contributor

samiraguiar commented Oct 20, 2016

For starters, it could be possible to collapse the body of the diffs by clicking on its headers. This should be easy and can be achieved with jQuery. I currently do this with the following code:

function makePanesCollapsible() {
    const fileWrappers = $('.d2h-file-wrapper');

    $.each(fileWrappers, (idx, element) => {
        const header = $(element).children('.d2h-file-header');
        const body = $(element).children('.d2h-files-diff');

        header.click(() => {
            body.slideToggle();
        })
    });
}

If this seems reasonable I can work on it.

@rtfpessoa
Copy link
Owner

@samiraguiar actually it should not be hard. It is even possible with CSS.

I guess the hardest part is making it look good and usable.

If you have some time, maybe doing something like GitHub has would be easy.

I am always open for new PRs 😄

@rtfpessoa rtfpessoa changed the title option to collapse diffs Allow files to be collapsable Oct 5, 2019
@alamothe
Copy link

If we do this, then files that are linguist-generated could be auto-collapsed, like in Github.

@rtfpessoa
Copy link
Owner

@alamothe can you extend a bit on what you mean? Sorry, I am not familiar with linguist-generated.

@alamothe
Copy link

alamothe commented May 25, 2020

This article explains it https://help.github.com/en/github/administering-a-repository/customizing-how-changed-files-appear-on-github

Basically, if you have .gitattributes file in the repo root, it can list the files which are autogenerated. Then those will be automatically collapsed in GitHub when doing code review.

@rtfpessoa
Copy link
Owner

rtfpessoa commented Jun 7, 2020

@alamothe I think I see what you meant.
This would not be directly possible since diff2html just gets the text of the diff.

It could probably be done in https://github.com/rtfpessoa/diff2html-cli since it can have access to the filesystem, but for diff2html it would have to be manually passed.

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

Successfully merging a pull request may close this issue.

4 participants