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: add comments sidebar #135

Merged
merged 18 commits into from
May 10, 2024
Merged

feat: add comments sidebar #135

merged 18 commits into from
May 10, 2024

Conversation

thomasguillot
Copy link
Contributor

@thomasguillot thomasguillot commented Apr 19, 2024

All Submissions:

Changes proposed in this Pull Request:

This PR moves the comments functionality to a hidden sidebar, which can be toggled by a button within the content. While far from perfect, this is a good starting point. Ideally, we would want the button to display only when comments are enabled - perhaps this can be achieved with some JS? cc @laurelfulford.

comments-demo

How to test the changes in this Pull Request:

  1. Switch to this branch
  2. Check a post
  3. Try to open the comments

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@thomasguillot thomasguillot marked this pull request as ready for review April 23, 2024 15:24
@thomasguillot thomasguillot requested a review from a team as a code owner April 23, 2024 15:24
@thomasguillot
Copy link
Contributor Author

Few more issues:

The pagination doesn't fully works: it doesn't re-open the overlay.

And then a similar issue when using a comment's permalink, e.g #comment-5

Copy link
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

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

I think this looks good overall! I added a couple code comments/notes but I think they could either be incorporated into this PR or another iteration.

I tested both comments and pingbacks, and noticed some visual differences:

image

I also tested with Disqus, which seems to mostly work, except the reCAPTCHA it uses gets cut off. Disqus is used by a dozen publishers at the moment, and IIRC is our primary third-party commenting system. I'm not sure we can do anything about this but perhaps there's a recommended Disqus setting, or a fallback for Disqus users, that we can have queued up (like a non-sidebar version):

image

Lastly, similar to the issues you noted about the comment link not working, it'd also be handy if that reopened the sidebar because that's used when comments are held in moderation.

I'm making this as approved since it works as something in progress to be built on, but let me know if you have any questions about any of my feedback, or if I can look at anything again!

* Comments Menu toggle and overlay JavaScript.
*/
const body = document.body,
headerContain = document.querySelector( '.comments-menu' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but I think it would be good to rename this variable - the header bit caught me off-guard! Maybe something to do with its location, to contrast against commentsContent?

const body = document.body,
headerContain = document.querySelector( '.comments-menu' ),
commentsToggle = document.querySelectorAll( '.comments-menu-toggle' ),
commentsContents = document.querySelector( '.comments-contents' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
commentsContents = document.querySelector( '.comments-contents' );
commentsContents = document.querySelector( '.comments-contents' ),
commentsExist = document.querySelector( '.wp-block-comments' );
if ( ! commentsExist ) {
headerContain.parentNode.removeChild( headerContain );
return;
}

This could probably use more testing/cases, but it looks like it would work in a pinch to remove the comment toggle button -- it checks whether the wp-block-comments CSS class exists, and if not, removes the button.

Another approach could be to add a CSS class to the body if comments are open and using that to show/hide things? My only concern with relying on something existing is if it doesn't work in all cases (though the above -- plus this setup in general -- does work with Disqus).

@thomasguillot
Copy link
Contributor Author

Thank you @laurelfulford. I will create an issue to make sure I don't forget about it 😅

@thomasguillot thomasguillot merged commit 5ffcd15 into trunk May 10, 2024
5 checks passed
@thomasguillot thomasguillot deleted the add/comments-sidebar branch May 10, 2024 10:03
matticbot pushed a commit that referenced this pull request May 20, 2024
# [1.8.0-alpha.1](v1.7.0...v1.8.0-alpha.1) (2024-05-20)

### Bug Fixes

* correct annoying search preview issue ([#147](#147)) ([7dde399](7dde399))

### Features

* add comments sidebar ([#135](#135)) ([5ffcd15](5ffcd15))
* add support for co-author plus blocks ([#139](#139)) ([14e2893](14e2893))
* update search templates ([#137](#137)) ([5e89534](5e89534))
@matticbot
Copy link

🎉 This PR is included in version 1.8.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request May 28, 2024
# [1.8.0](v1.7.0...v1.8.0) (2024-05-28)

### Bug Fixes

* correct annoying search preview issue ([#147](#147)) ([7dde399](7dde399))

### Features

* add comments sidebar ([#135](#135)) ([5ffcd15](5ffcd15))
* add support for co-author plus blocks ([#139](#139)) ([14e2893](14e2893))
* update search templates ([#137](#137)) ([5e89534](5e89534))
@matticbot
Copy link

🎉 This PR is included in version 1.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants