Browse Source

Switch +/- on comment collapse buttons with CSS

This was previously being done a bit manually in the JS and HTML, but
CSS can handle it like this, which simplifies some things (and also
takes the +/- out of the DOM, which is probably good in this case).
merge-requests/76/merge
Deimos 5 years ago
parent
commit
4f03a0fa5c
  1. 4
      tildes/scss/modules/_btn.scss
  2. 4
      tildes/scss/modules/_comment.scss
  3. 6
      tildes/static/js/behaviors/comment-collapse-button.js
  4. 2
      tildes/tildes/templates/macros/comments.jinja2

4
tildes/scss/modules/_btn.scss

@ -46,6 +46,10 @@
} }
} }
.btn-comment-collapse-label::after {
content: "";
}
.btn-comment-label { .btn-comment-label {
@include min-touch-size; @include min-touch-size;

4
tildes/scss/modules/_comment.scss

@ -192,6 +192,10 @@
font-size: 0.6rem; font-size: 0.6rem;
line-height: 0.8rem; line-height: 0.8rem;
} }
.btn-comment-collapse-label::after {
content: "+";
}
} }
.is-comment-collapsed:not(:target) { .is-comment-collapsed:not(:target) {

6
tildes/static/js/behaviors/comment-collapse-button.js

@ -14,12 +14,6 @@ $.onmount("[data-js-comment-collapse-button]", function() {
$comment.toggleClass("is-comment-collapsed"); $comment.toggleClass("is-comment-collapsed");
} }
if ($comment.hasClass("is-comment-collapsed")) {
$this.text("+");
} else {
$this.html("−");
}
$this.blur(); $this.blur();
}); });
}); });

2
tildes/tildes/templates/macros/comments.jinja2

@ -45,7 +45,7 @@
<div class="comment-itself"> <div class="comment-itself">
<header class="comment-header"> <header class="comment-header">
<button class="btn btn-light btn-comment-collapse" data-js-comment-collapse-button> <button class="btn btn-light btn-comment-collapse" data-js-comment-collapse-button>
{{ "+" if comment.collapsed_state in ("full", "individual") else "−" }}
<span class="btn-comment-collapse-label"></span>
</button> </button>
{% if not is_individual_comment and comment.num_children > 0 %} {% if not is_individual_comment and comment.num_children > 0 %}

Loading…
Cancel
Save