diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index e99513b0..870152d5 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -14,6 +14,11 @@ } /* --- TOGGLES --- */ +[aria-pressed=true] { + background-color: hsl(171, 100%, 41%); + color: white; +} + input.toggle-control { display: none; } diff --git a/bookwyrm/static/js/shared.js b/bookwyrm/static/js/shared.js index b2de5736..49859fbf 100644 --- a/bookwyrm/static/js/shared.js +++ b/bookwyrm/static/js/shared.js @@ -29,6 +29,10 @@ window.onload = function() { // update localstorage Array.from(document.getElementsByClassName('set-display')) .forEach(t => t.onclick = updateDisplay); + + // toggle display + Array.from(document.getElementsByClassName('toggle-button')) + .forEach(t => t.onclick = toggleDisplay); }; function updateDisplay(e) { @@ -51,11 +55,31 @@ function setDisplay(el) { } function toggleAction(e) { + var pressed = e.currentTarget.getAttribute('aria-pressed') == 'false'; + e.currentTarget.setAttribute('aria-pressed', pressed); + + var targetId = e.currentTarget.getAttribute('data-controls'); + if (targetId) { + var target = document.getElementById(targetId); + if (pressed) { + target.className = target.className.replace('hidden', ''); + } else { + target.className += ' hidden'; + } + + } + // set hover, if appropriate - var hover = e.target.getAttribute('data-hover-target'); + var hover = e.currentTarget.getAttribute('data-hover-target'); if (hover) { document.getElementById(hover).focus(); } + + // set checkbox, if appropriate + var checkbox = e.currentTarget.getAttribute('data-controls-checkbox'); + if (checkbox) { + document.getElementById(checkbox).checked = !!pressed; + } } diff --git a/bookwyrm/templates/snippets/content_warning_field.html b/bookwyrm/templates/snippets/content_warning_field.html index 91bc8ba4..79494378 100644 --- a/bookwyrm/templates/snippets/content_warning_field.html +++ b/bookwyrm/templates/snippets/content_warning_field.html @@ -1,20 +1,4 @@ -{% load bookwyrm_tags %} -{% with 0|uuid as uuid %} -
-
- - -
- -
- - -
+
+ +
-{% endwith %} diff --git a/bookwyrm/templates/snippets/create_status.html b/bookwyrm/templates/snippets/create_status.html index 26f63508..c843f926 100644 --- a/bookwyrm/templates/snippets/create_status.html +++ b/bookwyrm/templates/snippets/create_status.html @@ -29,15 +29,27 @@
- {% include 'snippets/create_status_form.html' with type='review' %} +
- {% include 'snippets/create_status_form.html' with type="comment" placeholder="Some thoughts on '"|add:book.title|add:"'" %} +
- {% include 'snippets/create_status_form.html' with type="quotation" placeholder="An excerpt from '"|add:book.title|add:"'" %} +
diff --git a/bookwyrm/templates/snippets/create_status_form.html b/bookwyrm/templates/snippets/create_status_form.html index c92b2f3d..37bd7962 100644 --- a/bookwyrm/templates/snippets/create_status_form.html +++ b/bookwyrm/templates/snippets/create_status_form.html @@ -1,7 +1,8 @@ -