Uses details to show/hide content warning field

This commit is contained in:
Mouse Reeve 2022-03-10 09:03:24 -08:00
parent e2476d1ad3
commit a922b8fd04
3 changed files with 32 additions and 38 deletions

View file

@ -1,14 +1,23 @@
{% load i18n %} {% load i18n %}
<div <div class="field is-relative">
class="field{% if not reply_parent.content_warning and not draft.content_warning %} is-hidden{% endif %}" <details
id="spoilers_{{ uuid }}{{ local_uuid }}" {% if reply_parent.content_warning or draft.content_warning %}open{% endif %}
> >
<summary class="is-flex">
<span class="icon icon-warning is-size-5 mr-1" aria-hidden="true"></span>
<span>
{% trans "Include spoiler alert" %}
</span>
<span class="details-close icon icon-plus" aria-hidden="true"></span>
</summary>
<label <label
class="label" class="label"
for="id_content_warning_{{ uuid }}{{ local_uuid }}" for="id_content_warning_{{ uuid }}{{ local_uuid }}"
> >
{% trans "Content warning:" %} {% trans "Content warning:" %}
</label> </label>
<div class="control">
<input <input
type="text" type="text"
name="content_warning" name="content_warning"
@ -20,3 +29,5 @@
{% if not draft %}data-cache-draft="id_content_warning_{{ book.id }}_{{ type }}"{% endif %} {% if not draft %}data-cache-draft="id_content_warning_{{ book.id }}_{{ type }}"{% endif %}
> >
</div> </div>
</details>
</div>

View file

@ -1,17 +0,0 @@
{% load i18n %}
<div class="control">
<input
type="checkbox"
class="is-hidden"
name="sensitive"
id="id_show_spoilers_{{ uuid }}{{ local_uuid }}"
{% if draft.content_warning or status.content_warning %}checked{% endif %}
aria-hidden="true"
{% if not draft %}data-cache-draft="id_sensitive_{{ book.id }}_{{ type }}{{ reply_parent.id }}"{% endif %}
>
{% trans "Include spoiler alert" as button_text %}
{% firstof draft.content_warning status.content_warning as pressed %}
{% firstof local_uuid '' as local_uuid %}
{% include 'snippets/toggle/toggle_button.html' with text=button_text icon="warning is-size-4" controls_text="spoilers" controls_uid=uuid|add:local_uuid focus="id_content_warning" checkbox="id_show_spoilers" class="toggle-button" pressed=pressed %}
</div>

View file

@ -37,8 +37,6 @@ reply_parent: the Status object this post will be in reply to, if applicable
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% include "snippets/create_status/content_warning_field.html" %}
{# fields that go between the content warnings and the content field (ie, quote) #} {# fields that go between the content warnings and the content field (ie, quote) #}
{% block pre_content_additions %}{% endblock %} {% block pre_content_additions %}{% endblock %}
@ -55,6 +53,8 @@ reply_parent: the Status object this post will be in reply to, if applicable
{# additional fields that go after the content block (ie, progress) #} {# additional fields that go after the content block (ie, progress) #}
{% block post_content_additions %}{% endblock %} {% block post_content_additions %}{% endblock %}
{% include "snippets/create_status/content_warning_field.html" %}
{% block options_block %} {% block options_block %}
{# cw, post privacy, and submit button #} {# cw, post privacy, and submit button #}
{% include "snippets/create_status/post_options_block.html" %} {% include "snippets/create_status/post_options_block.html" %}