Merge pull request #529 from mouse-reeve/html-cleanup

Html cleanup
This commit is contained in:
Mouse Reeve 2021-01-18 10:25:31 -08:00 committed by GitHub
commit f825709599
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 696 additions and 662 deletions

View file

@ -14,20 +14,16 @@
} }
/* --- TOGGLES --- */ /* --- TOGGLES --- */
input.toggle-control { .toggle-button[aria-pressed=true], .toggle-button[aria-pressed=true]:hover {
background-color: hsl(171, 100%, 41%);
color: white;
}
.hide-active[aria-pressed=true], .hide-inactive[aria-pressed=false] {
display: none; display: none;
} }
.hidden { .hidden {
display: none; display: none !important;
}
input.toggle-control:checked ~ .toggle-content {
display: block;
}
input.toggle-control:checked ~ .modal.toggle-content {
display: flex;
} }
/* --- STARS --- */ /* --- STARS --- */

View file

@ -1,7 +1,7 @@
// set up javascript listeners // set up javascript listeners
window.onload = function() { window.onload = function() {
// let buttons set keyboard focus // buttons that display or hide content
Array.from(document.getElementsByClassName('toggle-control')) document.querySelectorAll('[data-controls]')
.forEach(t => t.onclick = toggleAction); .forEach(t => t.onclick = toggleAction);
// javascript interactions (boost/fav) // javascript interactions (boost/fav)
@ -13,8 +13,6 @@ window.onload = function() {
.forEach(t => t.onclick = selectAll); .forEach(t => t.onclick = selectAll);
// toggle between tabs // toggle between tabs
Array.from(document.getElementsByClassName('tab-change-nested'))
.forEach(t => t.onclick = tabChangeNested);
Array.from(document.getElementsByClassName('tab-change')) Array.from(document.getElementsByClassName('tab-change'))
.forEach(t => t.onclick = tabChange); .forEach(t => t.onclick = tabChange);
@ -29,9 +27,22 @@ window.onload = function() {
// update localstorage // update localstorage
Array.from(document.getElementsByClassName('set-display')) Array.from(document.getElementsByClassName('set-display'))
.forEach(t => t.onclick = updateDisplay); .forEach(t => t.onclick = updateDisplay);
// hidden submit button in a form
document.querySelectorAll('.hidden-form input')
.forEach(t => t.onchange = revealForm);
}; };
function revealForm(e) {
var hidden = e.currentTarget.closest('.hidden-form').getElementsByClassName('hidden')[0];
if (hidden) {
removeClass(hidden, 'hidden');
}
}
function updateDisplay(e) { function updateDisplay(e) {
// used in set reading goal
var key = e.target.getAttribute('data-id'); var key = e.target.getAttribute('data-id');
var value = e.target.getAttribute('data-value'); var value = e.target.getAttribute('data-value');
window.localStorage.setItem(key, value); window.localStorage.setItem(key, value);
@ -41,37 +52,52 @@ function updateDisplay(e) {
} }
function setDisplay(el) { function setDisplay(el) {
// used in set reading goal
var key = el.getAttribute('data-hide'); var key = el.getAttribute('data-hide');
var value = window.localStorage.getItem(key) var value = window.localStorage.getItem(key);
if (!value) { addRemoveClass(el, 'hidden', value);
el.className = el.className.replace('hidden', '');
} else if (value != null && !!value) {
el.className += ' hidden';
}
} }
function toggleAction(e) { function toggleAction(e) {
// set hover, if appropriate var el = e.currentTarget;
var hover = e.target.getAttribute('data-hover-target'); var pressed = el.getAttribute('aria-pressed') == 'false';
if (hover) {
document.getElementById(hover).focus(); var targetId = el.getAttribute('data-controls');
document.querySelectorAll('[data-controls="' + targetId + '"]')
.forEach(t => t.setAttribute('aria-pressed', (t.getAttribute('aria-pressed') == 'false')));
if (targetId) {
var target = document.getElementById(targetId);
addRemoveClass(target, 'hidden', !pressed);
addRemoveClass(target, 'is-active', pressed);
}
// show/hide container
var container = document.getElementById('hide-' + targetId);
if (!!container) {
addRemoveClass(container, 'hidden', pressed);
}
// set checkbox, if appropriate
var checkbox = el.getAttribute('data-controls-checkbox');
if (checkbox) {
document.getElementById(checkbox).checked = !!pressed;
}
// set focus, if appropriate
var focus = el.getAttribute('data-focus-target');
if (focus) {
document.getElementById(focus).focus();
} }
} }
function interact(e) { function interact(e) {
e.preventDefault(); e.preventDefault();
ajaxPost(e.target); ajaxPost(e.target);
var identifier = e.target.getAttribute('data-id'); var identifier = e.target.getAttribute('data-id');
var elements = document.getElementsByClassName(identifier); Array.from(document.getElementsByClassName(identifier))
for (var i = 0; i < elements.length; i++) { .forEach(t => addRemoveClass(t, 'hidden', t.className.indexOf('hidden') == -1));
if (elements[i].className.includes('hidden')) {
elements[i].className = elements[i].className.replace('hidden', '');
} else {
elements[i].className += ' hidden';
}
}
return true;
} }
function selectAll(e) { function selectAll(e) {
@ -79,32 +105,32 @@ function selectAll(e) {
.forEach(t => t.checked=true); .forEach(t => t.checked=true);
} }
function tabChangeNested(e) {
var target = e.target.closest('li')
var parentElement = target.parentElement.closest('li').parentElement;
handleTabChange(target, parentElement)
}
function tabChange(e) { function tabChange(e) {
var target = e.target.closest('li') var el = e.currentTarget;
var parentElement = target.parentElement; var parentElement = el.closest('[role="tablist"]');
handleTabChange(target, parentElement)
}
function handleTabChange(target, parentElement) {
parentElement.querySelectorAll('[aria-selected="true"]') parentElement.querySelectorAll('[aria-selected="true"]')
.forEach(t => t.setAttribute("aria-selected", false)); .forEach(t => t.setAttribute("aria-selected", false));
target.querySelector('[role="tab"]').setAttribute("aria-selected", true); el.setAttribute("aria-selected", true);
parentElement.querySelectorAll('li') parentElement.querySelectorAll('li')
.forEach(t => t.className=''); .forEach(t => removeClass(t, 'is-active'));
target.className = 'is-active'; addClass(el, 'is-active');
var tabId = el.getAttribute('data-tab');
Array.from(document.getElementsByClassName(el.getAttribute('data-category')))
.forEach(t => addRemoveClass(t, 'hidden', t.id != tabId));
} }
function toggleMenu(e) { function toggleMenu(e) {
var el = e.target.closest('.pulldown-menu'); var el = e.currentTarget;
el.setAttribute('aria-expanded', el.getAttribute('aria-expanded') == 'false'); var expanded = el.getAttribute('aria-expanded') == 'false';
el.setAttribute('aria-expanded', expanded);
var targetId = el.getAttribute('data-controls');
if (targetId) {
var target = document.getElementById(targetId);
addRemoveClass(target, 'is-active', expanded);
}
} }
function ajaxPost(form) { function ajaxPost(form) {
@ -113,3 +139,31 @@ function ajaxPost(form) {
body: new FormData(form) body: new FormData(form)
}); });
} }
function addRemoveClass(el, classname, bool) {
if (bool) {
addClass(el, classname);
} else {
removeClass(el, classname);
}
}
function addClass(el, classname) {
var classes = el.className.split(' ');
if (classes.indexOf(classname) > -1) {
return;
}
el.className = classes.concat(classname).join(' ');
}
function removeClass(el, className) {
var classes = [];
if (el.className) {
classes = el.className.split(' ');
}
const idx = classes.indexOf(className);
if (idx > -1) {
classes.splice(idx, 1);
}
el.className = classes.join(' ');
}

View file

@ -39,14 +39,28 @@
{% if request.user.is_authenticated and not book.cover %} {% if request.user.is_authenticated and not book.cover %}
<div class="box p-2"> <div class="box p-2">
<h3 class="title is-6 mb-1">Add cover</h3>
<form name="add-cover" method="POST" action="/upload-cover/{{ book.id }}" enctype="multipart/form-data"> <form name="add-cover" method="POST" action="/upload-cover/{{ book.id }}" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<div class="field"> <div class="field has-addons">
<label class="label" for="id_cover">Cover:</label> <div class="control">
<input type="file" name="cover" accept="image/*" class="" id="id_cover"> <div class="file is-small mb-1">
<label class="file-label">
<input class="file-input" type="file" name="cover" accept="image/*" enctype="multipart/form-data" id="id_cover" required>
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose file...
</span>
</span>
</label>
</div>
</div>
<div class="control">
<button class="button is-small is-primary" type="submit">Add</button>
</div> </div>
<div class="field">
<button class="button is-small" type="submit">Add cover</button>
</div> </div>
</form> </form>
</div> </div>
@ -94,17 +108,9 @@
{% include 'snippets/trimmed_text.html' with full=book|book_description %} {% include 'snippets/trimmed_text.html' with full=book|book_description %}
{% if request.user.is_authenticated and perms.bookwyrm.edit_book and not book|book_description %} {% if request.user.is_authenticated and perms.bookwyrm.edit_book and not book|book_description %}
<div> {% include 'snippets/toggle/open_button.html' with text="Add description" controls_text="add-description" controls_uid=book.id focus="id_description" hide_active=True id="hide-description" %}
<input class="toggle-control" type="radio" name="add-description" id="hide-description-{{ book.id }}" checked>
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with text="Add description" controls_text="add-description" controls_uid=book.id %}
</div>
</div>
<div> <div class="box hidden" id="add-description-{{ book.id }}">
<input class="toggle-control" type="radio" name="add-description" id="add-description-{{ book.id }}" data-hover-target="id_description">
<div class="toggle-content hidden">
<div class="box">
<form name="add-description" method="POST" action="/add-description/{{ book.id }}"> <form name="add-description" method="POST" action="/add-description/{{ book.id }}">
{% csrf_token %} {% csrf_token %}
<p class="fields is-grouped"> <p class="fields is-grouped">
@ -113,12 +119,10 @@
</p> </p>
<div class="field"> <div class="field">
<button class="button is-primary" type="submit">Save</button> <button class="button is-primary" type="submit">Save</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="hide-description" controls_uid=book.id %} {% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="add-description" controls_uid=book.id hide_inactive=True %}
</div> </div>
</form> </form>
</div> </div>
</div>
</div>
{% endif %} {% endif %}
@ -144,40 +148,38 @@
</div> </div>
{% if readthroughs.exists %} {% if readthroughs.exists %}
<div> <section class="block">
<h2 class="title is-5">Your reading activity</h2> <header class="columns">
{% for readthrough in readthroughs %} <h2 class="column title is-5 mb-1">Your reading activity</h2>
{% include 'snippets/readthrough.html' with readthrough=readthrough %} <div class="column is-narrow">
{% endfor %} {% include 'snippets/toggle/open_button.html' with text="Add read dates" icon="plus" class="is-small" controls_text="add-readthrough" %}
</div> </div>
{% endif %} </header>
<div class="block"> <section class="hidden box" id="add-readthrough">
<div>
<input type="radio" class="toggle-control" name="add-readthrough-form" id="hide-create-readthrough" checked>
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with text="Add read dates" controls_text="add-readthrough" %}
</div>
</div>
<div>
<input type="radio" class="toggle-control" id="add-readthrough" name="add-readthrough-form">
<div class="toggle-content hidden box">
<form name="add-readthrough" action="/create-readthrough" method="post"> <form name="add-readthrough" action="/create-readthrough" method="post">
{% include 'snippets/readthrough_form.html' with readthrough=None %} {% include 'snippets/readthrough_form.html' with readthrough=None %}
<div class="field is-grouped"> <div class="field is-grouped">
<div class="control">
<button class="button is-primary" type="submit">Create</button> <button class="button is-primary" type="submit">Create</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="hide-create-readthrough" %} </div>
<div class="control">
{% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="add-readthrough" %}
</div>
</div> </div>
</form> </form>
</div> </section>
</div> {% for readthrough in readthroughs %}
</div> {% include 'snippets/readthrough.html' with readthrough=readthrough %}
{% endfor %}
</section>
{% endif %}
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<div class="box"> <section class="box">
{% include 'snippets/create_status.html' with book=book hide_cover=True %} {% include 'snippets/create_status.html' with book=book hide_cover=True %}
</div> </section>
<div class="block"> <section class="block">
<form name="tag" action="/tag/" method="post"> <form name="tag" action="/tag/" method="post">
<label for="tags" class="is-3">Tags</label> <label for="tags" class="is-3">Tags</label>
{% csrf_token %} {% csrf_token %}
@ -185,7 +187,7 @@
<input id="tags" class="input" type="text" name="name"> <input id="tags" class="input" type="text" name="name">
<button class="button" type="submit">Add tag</button> <button class="button" type="submit">Add tag</button>
</form> </form>
</div> </section>
{% endif %} {% endif %}
<div class="block"> <div class="block">

View file

@ -9,7 +9,7 @@
<p>There are no books here right now! Try searching for a book to get started</p> <p>There are no books here right now! Try searching for a book to get started</p>
{% else %} {% else %}
<div class="tabs is-small"> <div class="tabs is-small">
<ul> <ul role="tablist">
{% for shelf in suggested_books %} {% for shelf in suggested_books %}
{% if shelf.books %} {% if shelf.books %}
{% with shelf_counter=forloop.counter %} {% with shelf_counter=forloop.counter %}
@ -17,17 +17,13 @@
<p> <p>
{{ shelf.name }} {{ shelf.name }}
</p> </p>
<div class="tabs is-small is-toggle" role="tablist"> <div class="tabs is-small is-toggle">
<ul> <ul>
{% for book in shelf.books %} {% for book in shelf.books %}
<li class="{% if shelf_counter == 1 and forloop.first %}is-active{% endif %}" data-id="tab-book-{{ book.id }}"> <li class="tab-change{% if shelf_counter == 1 and forloop.first %} is-active{% endif %}" data-tab="book-{{ book.id }}" data-tab="book-{{ book.id }}" role="tab" tabindex="0" aria-selected="{% if shelf_counter == 1 and forloop.first %}true{% else %}false{% endif %}" aria-controls="book-{{ book.id }}" data-category="suggested-tabs">
<label for="book-{{ book.id }}" class="tab-change-nested">
<div role="tab" tabindex="0" aria-selected="{% if shelf_counter == 1 and forloop.first %}true{% else %}false{% endif %}" aria-controls="book-{{ book.id }}-panel">
<a> <a>
{% include 'snippets/book_cover.html' with book=book size="medium" %} {% include 'snippets/book_cover.html' with book=book size="medium" %}
</a> </a>
</div>
</label>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -41,16 +37,13 @@
{% for shelf in suggested_books %} {% for shelf in suggested_books %}
{% with shelf_counter=forloop.counter %} {% with shelf_counter=forloop.counter %}
{% for book in shelf.books %} {% for book in shelf.books %}
<div> <div class="suggested-tabs card{% if shelf_counter != 1 or not forloop.first %} hidden{% endif %}" role="tabpanel" id="book-{{ book.id }}">
<input class="toggle-control" type="radio" name="recent-books" id="book-{{ book.id }}" {% if shelf_counter == 1 and forloop.first %}checked{% endif %}>
<div class="toggle-content hidden" role="tabpanel" id="book-{{ book.id }}-panel">
<div class="card">
<div class="card-header"> <div class="card-header">
<p class="card-header-title"> <p class="card-header-title">
<span>{% include 'snippets/book_titleby.html' with book=book %}</span> <span>{% include 'snippets/book_titleby.html' with book=book %}</span>
</p> </p>
<div class="card-header-icon is-hidden-tablet"> <div class="card-header-icon is-hidden-tablet">
{% include 'snippets/toggle/toggle_button.html' with label="close" controls_text="no-book" class="delete" %} {% include 'snippets/toggle/toggle_button.html' with label="close" controls_text="book" controls_uid=book.id class="delete" nonbutton=True pressed=True %}
</div> </div>
</div> </div>
<div class="card-content"> <div class="card-content">
@ -58,14 +51,9 @@
{% include 'snippets/create_status.html' with book=book %} {% include 'snippets/create_status.html' with book=book %}
</div> </div>
</div> </div>
</div>
</div>
{% endfor %} {% endfor %}
{% endwith %} {% endwith %}
{% endfor %} {% endfor %}
<div>
<input class="toggle-control" type="radio" name="recent-books" id="no-book">
</div>
{% endif %} {% endif %}
{% if goal %} {% if goal %}
@ -98,24 +86,7 @@
{% if not goal and tab == 'home' %} {% if not goal and tab == 'home' %}
{% now 'Y' as year %} {% now 'Y' as year %}
<section class="block hidden" aria-title="Announcements" data-hide="hide-{{ year }}-reading-goal"> <section class="block hidden" aria-title="Announcements" data-hide="hide-{{ year }}-reading-goal">
<article class="card"> {% include 'snippets/goal_card.html' with year=year %}
<header class="card-header">
<h3 class="card-header-title has-background-primary has-text-white">
<span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {{ year }} reading goal
</h3>
</header>
<section class="card-content content">
<p>Set a goal for how many books you'll finish reading in {{ year }}, and track your progress throughout the year.</p>
{% include 'snippets/goal_form.html' %}
</section>
<footer class="card-footer has-background-white-bis">
<div class="card-footer-item is-flex-direction-column">
<button class="button is-danger is-light is-block set-display" data-id="hide-{{ year }}-reading-goal" data-value="true">Dismiss message</button>
<p class="help">You can set or change your reading goal any time from your <a href="{{ request.user.local_path }}">profile page</a></p>
</div>
</footer>
</article>
<hr> <hr>
</section> </section>
{% endif %} {% endif %}

View file

@ -6,17 +6,10 @@
{% if user == request.user %} {% if user == request.user %}
<div class="block"> <div class="block">
{% if goal %} {% if goal %}
<input type="radio" class="toggle-control" name="edit-goal" id="hide-edit-goal" checked> {% include 'snippets/toggle/open_button.html' with text="Edit goal" controls_text="show-edit-goal" focus="edit-form-header" %}
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with text="Edit goal" controls_text="show-edit-goal" %}
</div>
{% endif %} {% endif %}
</div>
<div class="block">
<input type="radio" class="toggle-control" name="edit-goal" id="show-edit-goal" data-hover-target="edit-form-header">
<div class="toggle-content{% if goal %} hidden{% endif %}">
{% now 'Y' as year %} {% now 'Y' as year %}
<section class="card"> <section class="card {% if goal %}hidden{% endif %}" id="show-edit-goal">
<header class="card-header"> <header class="card-header">
<h2 class="card-header-title has-background-primary has-text-white" tabindex="0" id="edit-form-header"> <h2 class="card-header-title has-background-primary has-text-white" tabindex="0" id="edit-form-header">
<span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {{ year }} reading goal <span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {{ year }} reading goal
@ -29,7 +22,6 @@
</section> </section>
</section> </section>
</div> </div>
</div>
{% endif %} {% endif %}
{% if not goal and user != request.user %} {% if not goal and user != request.user %}

View file

@ -41,17 +41,16 @@
</div> </div>
</form> </form>
<label for="main-nav" role="button" class="navbar-burger pulldown-menu" aria-label="menu" aria-expanded="false" data-target="mainNav" tabindex="0"> <div role="button" tabindex="0" class="navbar-burger pulldown-menu" data-controls="main-nav" aria-expanded="false">
<div class="navbar-item mt-3"> <div class="navbar-item mt-3">
<div class="icon icon-dots-three-vertical" title="Main navigation menu"> <div class="icon icon-dots-three-vertical" title="Main navigation menu">
<span class="is-sr-only">Main navigation menu</span> <span class="is-sr-only">Main navigation menu</span>
</div> </div>
</div> </div>
</label> </div>
</div> </div>
<input class="toggle-control" type="checkbox" id="main-nav"> <div class="navbar-menu" id="main-nav">
<div id="mainNav" class="navbar-menu toggle-content">
<div class="navbar-start"> <div class="navbar-start">
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<a href="/user/{{ request.user.localname }}/shelves" class="navbar-item"> <a href="/user/{{ request.user.localname }}/shelves" class="navbar-item">

View file

@ -27,16 +27,11 @@
<p> <p>
Didn't find what you were looking for? Didn't find what you were looking for?
</p> </p>
{% include 'snippets/toggle/open_button.html' with text="Show results from other catalogues" small=True controls_text="more-results" %}
<input class="toggle-control" type="radio" name="more-results" id="fewer-results" checked>
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with text="Show results from other catalogues" small=True controls_text="more-results" %}
</div>
</div> </div>
{% endif %} {% endif %}
<input class="toggle-control" type="radio" name="more-results" id="more-results" {% if not local_results.results %}checked{% endif %}> <div class="{% if local_results.results %}hidden{% endif %}" id="more-results">
<div class="toggle-content hidden">
{% for result_set in book_results|slice:"1:" %} {% for result_set in book_results|slice:"1:" %}
{% if result_set.results %} {% if result_set.results %}
<section class="block"> <section class="block">
@ -61,8 +56,9 @@
</section> </section>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if local_results.results %} {% if local_results.results %}
{% include 'snippets/toggle/toggle_button.html' with text="Hide results from other catalogues" small=True controls_text="fewer-results" %} {% include 'snippets/toggle/close_button.html' with text="Hide results from other catalogues" small=True controls_text="more-results" %}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View file

@ -31,18 +31,12 @@
{% if is_self %} {% if is_self %}
<div class="column is-narrow"> <div class="column is-narrow">
<input type="radio" id="create-shelf-form-hide" name="create-shelf-form" class="toggle-control" checked> {% include 'snippets/toggle/open_button.html' with text="Create shelf" icon="plus" class="is-clickable" controls_text="create-shelf-form" %}
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with text="Create shelf" icon="plus" class="is-clickable" controls_text="create-shelf-form-show" %}
</div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
<div> <div class="hidden box mb-5" id="create-shelf-form">
<input type="radio" id="create-shelf-form-show" name="create-shelf-form" class="toggle-control">
<div class="toggle-content hidden">
<div class="box mb-5">
<h2 class="title is-4">Create new shelf</h2> <h2 class="title is-4">Create new shelf</h2>
<form name="create-shelf" action="/create-shelf/" method="post"> <form name="create-shelf" action="/create-shelf/" method="post">
{% csrf_token %} {% csrf_token %}
@ -58,11 +52,9 @@
</label> </label>
<div class="field is-grouped"> <div class="field is-grouped">
<button class="button is-primary" type="submit">Create shelf</button> <button class="button is-primary" type="submit">Create shelf</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="create-shelf-form-hide" %} {% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="create-shelf-form" %}
</div> </div>
</form> </form>
</div>
</div>
</div> </div>
<div class="block columns"> <div class="block columns">
@ -76,17 +68,12 @@
</div> </div>
{% if is_self %} {% if is_self %}
<div class="column is-narrow"> <div class="column is-narrow">
<input type="radio" id="edit-shelf-form-hide" name="edit-shelf-form" class="toggle-control" checked> {% include 'snippets/toggle/open_button.html' with text="Edit shelf" icon="pencil" class="is-clickable" controls_text="edit-shelf-form" %}
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with text="Edit shelf" icon="pencil" class="is-clickable" controls_text="edit-shelf-form-show" %}
</div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
<input type="radio" id="edit-shelf-form-show" name="edit-shelf-form" class="toggle-control"> <div class="hidden box mb-5" id="edit-shelf-form">
<div class="toggle-content hidden">
<div class="box mb-5">
<h2 class="title is-4">Edit shelf</h2> <h2 class="title is-4">Edit shelf</h2>
<form name="create-shelf" action="/edit-shelf/{{ shelf.id }}" method="post"> <form name="create-shelf" action="/edit-shelf/{{ shelf.id }}" method="post">
{% csrf_token %} {% csrf_token %}
@ -106,10 +93,9 @@
</label> </label>
<div class="field is-grouped"> <div class="field is-grouped">
<button class="button is-primary" type="submit">Update shelf</button> <button class="button is-primary" type="submit">Update shelf</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="edit-shelf-form-hide" %} {% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="edit-shelf-form" %}
</div> </div>
</form> </form>
</div>
</div> </div>
<div class="block"> <div class="block">

View file

@ -0,0 +1,19 @@
<article class="card">
<header class="card-header">
{% block card-header %}
{% endblock %}
</header>
<section class="card-content">
{% block card-content %}
{% endblock %}
</section>
<footer class="card-footer has-background-white-bis">
{% block card-footer %}
{% endblock %}
</footer>
{% block card-bonus %}
{% endblock %}
</article>

View file

@ -0,0 +1,13 @@
{% load bookwyrm_tags %}
{% with 0|uuid as uuid %}
<div class="dropdown control{% if right %} is-right{% endif %}" id="menu-{{ uuid }}">
<button type="button" class="button dropdown-trigger pulldown-menu {{ class }}" aria-expanded="false" class="pulldown-menu" aria-haspopup="true" aria-controls="menu-options-{{ uuid }}" data-controls="menu-{{ uuid }}">
{% block dropdown-trigger %}{% endblock %}
</button>
<div class="dropdown-menu">
<ul class="dropdown-content" role="menu" id="menu-options-{{ book.id }}">
{% block dropdown-list %}{% endblock %}
</ul>
</div>
</div>
{% endwith %}

View file

@ -0,0 +1,23 @@
<div class="modal hidden" id="{{ controls_text }}-{{ controls_uid }}">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head" tabindex="0" id="modal-title-{{ controls_text }}-{{ controls_uid }}">
<h2 class="modal-card-title">
{% block modal-title %}{% endblock %}
</h2>
{% include 'snippets/toggle/toggle_button.html' with label="close" class="delete" nonbutton=True %}
</header>
{% block modal-form-open %}{% endblock %}
{% block modal-body %}{% endblock %}
<footer class="modal-card-foot">
{% block modal-footer %}{% endblock %}
</footer>
{% block modal-form-close %}{% endblock %}
</div>
<label class="modal-close is-large" for="{{ controls_text }}-{{ readthrough.id }}" aria-label="close"></label>
{% include 'snippets/toggle/toggle_button.html' with label="close" class="modal-close is-large" nonbutton=True %}
</div>

View file

@ -1,20 +1,4 @@
{% load bookwyrm_tags %} <div class="control{% if not parent_status.content_warning %} hidden{% endif %}" id="spoilers-{{ uuid }}">
{% with 0|uuid as uuid %} <label class="is-sr-only" for="id_content_warning-{{ uuid }}">Spoiler alert:</label>
<div class="control"> <input type="text" name="content_warning" maxlength="255" class="input" id="id_content_warning-{{ uuid }}" placeholder="Spoilers ahead!"{% if parent_status.content_warning %} value="{{ parent_status.content_warning }}"{% endif %}>
<div>
<input type="radio" class="toggle-control" id="include-spoilers-{{ uuid }}" name="sensitive" value="true" {% if parent_status.content_warning %}checked{% endif %} data-hover-target="id_content_warning_{{ uuid }}">
<div class="toggle-content hidden">
<label class="is-sr-only" for="id_content_warning_{{ uuid }}">Spoilers/content warning:</label>
<input type="text" name="content_warning" maxlength="255" class="input" id="id_content_warning_{{ uuid }}" placeholder="Spoilers ahead!"{% if parent_status.content_warning %} value="{{ parent_status.content_warning }}"{% endif %}>
{% include 'snippets/toggle/toggle_button.html' with controls_text="hide-spoilers" controls_uid=uuid text="Remove spoilers/content warning" small=True %}
</div>
</div>
<div>
<input type="radio" class="toggle-control" name="sensitive" value="false" id="hide-spoilers-{{ uuid }}" {% if not parent_status.content_warning %}checked{% endif %}>
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with controls_text="include-spoilers" controls_uid=uuid text="Add spoilers/content warning" small=True %}
</div>
</div>
</div> </div>
{% endwith %}

View file

@ -3,41 +3,32 @@
<div class="tabs is-boxed"> <div class="tabs is-boxed">
<ul role="tablist"> <ul role="tablist">
<li class="is-active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}"> <li class="tab-change is-active" data-category="tab-option-{{ book.id }}" role="tab" aria-selected="true" tabindex="0" data-tab="review-{{ book.id }}">
<label for="review-{{ book.id }}">
<div class="tab-change" role="tab" aria-selected="true" tabindex="0">
<a>Review</a> <a>Review</a>
</div>
</label>
</li> </li>
<li data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}"> <li class="tab-change" data-category="tab-option-{{ book.id }}" role="tab" tabindex="0" data-tab="comment-{{ book.id}}">
<label for="comment-{{ book.id}}">
<div class="tab-change" role="tab" tabindex="0">
<a>Comment</a> <a>Comment</a>
</div>
</label>
</li> </li>
<li data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}"> <li class="tab-change" data-category="tab-option-{{ book.id }}" role="tab" tabindex="0" data-tab="quote-{{ book.id }}">
<label for="quote-{{ book.id }}">
<div class="tab-change" role="tab" tabindex="0">
<a>Quote</a> <a>Quote</a>
</div>
</label>
</li> </li>
</ul> </ul>
</div> </div>
<div> <div class="tab-option-{{ book.id }}" id="review-{{ book.id }}">
<input class="toggle-control" type="radio" name="status-tabs-{{ book.id }}" id="review-{{ book.id }}" checked> {% with 0|uuid as uuid %}
{% include 'snippets/create_status_form.html' with type='review' %} {% include 'snippets/create_status_form.html' with type='review' %}
{% endwith %}
</div> </div>
<div> <div class="hidden tab-option-{{ book.id }}" id="comment-{{ book.id }}">
<input class="toggle-control" type="radio" name="status-tabs-{{ book.id }}" id="comment-{{ book.id }}"> {% with 0|uuid as uuid %}
{% 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="comment" placeholder="Some thoughts on '"|add:book.title|add:"'" %}
{% endwith %}
</div> </div>
<div> <div class="hidden tab-option-{{ book.id }}" id="quote-{{ book.id }}">
<input class="toggle-control" type="radio" name="status-tabs-{{ book.id }}" id="quote-{{ book.id }}"> {% with 0|uuid as uuid %}
{% include 'snippets/create_status_form.html' with type="quotation" placeholder="An excerpt from '"|add:book.title|add:"'" %} {% include 'snippets/create_status_form.html' with type="quotation" placeholder="An excerpt from '"|add:book.title|add:"'" %}
{% endwith %}
</div> </div>

View file

@ -1,7 +1,8 @@
<form class="toggle-content hidden tab-option-{{ book.id }}" name="{{ type }}" action="/post/{{ type }}" method="post" id="tab-{{ type }}-{{ book.id }}"> <form class="is-flex-grow-1" name="{{ type }}" action="/post/{{ type }}" method="post" id="tab-{{ type }}-{{ book.id }}{{ reply_parent.id }}">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}"> <input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="user" value="{{ request.user.id }}"> <input type="hidden" name="user" value="{{ request.user.id }}">
<input type="hidden" name="reply_parent" value="{{ reply_parent.id }}">
{% if type == 'review' %} {% if type == 'review' %}
<div class="control"> <div class="control">
<label class="label" for="id_name_{{ book.id }}_{{ type }}">Title:</label> <label class="label" for="id_name_{{ book.id }}_{{ type }}">Title:</label>
@ -9,8 +10,9 @@
</div> </div>
{% endif %} {% endif %}
<div class="control"> <div class="control">
{% if not type == 'reply' %}
<label class="label" for="id_{% if type == 'quotation' %}quote{% else %}content{% endif %}_{{ book.id }}_{{ type }}">{{ type|title }}:</label> <label class="label" for="id_{% if type == 'quotation' %}quote{% else %}content{% endif %}_{{ book.id }}_{{ type }}">{{ type|title }}:</label>
{% include 'snippets/content_warning_field.html' %} {% endif %}
{% if type == 'review' %} {% if type == 'review' %}
<fieldset> <fieldset>
@ -31,18 +33,30 @@
{% if type == 'quotation' %} {% if type == 'quotation' %}
<textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea> <textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>
{% else %} {% else %}
<textarea name="content" class="textarea" id="id_content_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea> {% include 'snippets/content_warning_field.html' with parent_status=status %}
<textarea name="content" class="textarea" id="id_content_{{ type }}-{{ book.id }}{{reply_parent.id}}" placeholder="{{ placeholder }}" {% if type == 'reply' %} aria-label="Reply"{% endif %} required></textarea>
{% endif %} {% endif %}
</div> </div>
{% if type == 'quotation' %} {% if type == 'quotation' %}
<div class="control"> <div class="control">
<label class="label" for="id_content_{{ book.id }}_quote">Comment:</label> <label class="label" for="id_content_quote-{{ book.id }}">Comment:</label>
<textarea name="content" class="textarea is-small" id="id_content_{{ book.id }}_quote"></textarea> {% include 'snippets/content_warning_field.html' with parent_status=status %}
<textarea name="content" class="textarea is-small" id="id_content_quote-{{ book.id }}"></textarea>
</div> </div>
{% endif %} {% endif %}
<div class="control is-grouped"> <input type="checkbox" class="hidden" name="sensitive" id="id_show_spoilers-{{ uuid }}" {% if status.content_warning %}checked{% endif %} aria-hidden="true">
{# bottom bar #}
<div class="columns pt-1">
<div class="field has-addons column">
<div class="control">
{% include 'snippets/toggle/toggle_button.html' with text="Include spoiler alert" icon="warning is-size-4" controls_text="spoilers" controls_uid=uuid focus="id_content_warning" checkbox="id_show_spoilers" class="toggle-button" pressed=status.content_warning %}
</div>
<div class="control">
{% include 'snippets/privacy_select.html' %} {% include 'snippets/privacy_select.html' %}
<button class="button is-primary" type="submit">post {{ type }}</button> </div>
</div>
<div class="column is-narrow">
<button class="button is-link" type="submit">Post</button>
</div>
</div> </div>
</form> </form>

View file

@ -0,0 +1,13 @@
{% extends 'snippets/components/modal.html' %}
{% block modal-title %}Delete these read dates?{% endblock %}
{% block modal-footer %}
<form name="delete-readthrough-{{ readthrough.id }}" action="/delete-readthrough" method="POST">
{% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}">
<button class="button is-danger" type="submit">
Delete
</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="delete-readthrough" controls_uid=readthrough.id %}
</form>
{% endblock %}

View file

@ -1,16 +1,16 @@
{% load bookwyrm_tags %} {% extends 'snippets/components/modal.html' %}
<div>
<input class="toggle-control" type="checkbox" name="finish-reading-{{ uuid }}" id="finish-reading-{{ uuid }}"> {% block modal-title %}
<div class="modal toggle-content hidden"> Finish "<em>{{ book.title }}</em>"
<div class="modal-background"></div> {% endblock %}
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Finish "{{ book.title }}"</p> {% block modal-form-open %}
{% include 'snippets/toggle/toggle_button.html' with label="close" controls_text="finish-reading" controls_uid=uuid class="delete" %} <form name="finish-reading" action="/finish-reading/{{ book.id }}" method="post">
</header> {% endblock %}
{% active_read_through book user as readthrough %}
<form name="finish-reading" action="/finish-reading/{{ book.id }}" method="post"> {% block modal-body %}
<section class="modal-card-body"> <section class="modal-card-body">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}"> <input type="hidden" name="id" value="{{ readthrough.id }}">
<div class="field"> <div class="field">
@ -25,9 +25,11 @@
<input type="date" name="finish_date" class="input" id="id_finish_date-{{ uuid }}" value="{% now "Y-m-d" %}"> <input type="date" name="finish_date" class="input" id="id_finish_date-{{ uuid }}" value="{% now "Y-m-d" %}">
</label> </label>
</div> </div>
</section> </section>
<footer class="modal-card-foot"> {% endblock %}
<div class="columns">
{% block modal-footer %}
<div class="columns">
<div class="column field"> <div class="column field">
<label for="post_status-{{ uuid }}"> <label for="post_status-{{ uuid }}">
<input type="checkbox" name="post-status" class="checkbox" id="post_status-{{ uuid }}" checked> <input type="checkbox" name="post-status" class="checkbox" id="post_status-{{ uuid }}" checked>
@ -37,13 +39,8 @@
</div> </div>
<div class="column"> <div class="column">
<button type="submit" class="button is-success">Save</button> <button type="submit" class="button is-success">Save</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="finish-reading" controls_uid=uuid %} {% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="finish-reading" controls_uid=uuid %}
</div>
</div>
</footer>
</form>
</div>
<label class="modal-close is-large" for="finish-reading-{{ uuid }}" aria-label="close" role="button"></label>
</div> </div>
</div> </div>
{% endblock %}
{% block modal-form-close %}</form>{% endblock %}

View file

@ -0,0 +1,23 @@
{% extends 'snippets/components/card.html' %}
{% block card-header %}
<h3 class="card-header-title has-background-primary has-text-white">
<span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {{ year }} reading goal
</h3>
{% endblock %}
{% block card-content %}
<div class="content">
<p>Set a goal for how many books you'll finish reading in {{ year }}, and track your progress throughout the year.</p>
{% include 'snippets/goal_form.html' %}
</div>
{% endblock %}
{% block card-footer %}
<div class="card-footer-item is-flex-direction-column">
<button class="button is-danger is-light is-block set-display" data-id="hide-{{ year }}-reading-goal" data-value="true">Dismiss message</button>
<p class="help">You can set or change your reading goal any time from your <a href="{{ request.user.local_path }}">profile page</a></p>
</div>
{% endblock %}

View file

@ -28,7 +28,7 @@
<p> <p>
<button type="submit" class="button is-link">Set goal</button> <button type="submit" class="button is-link">Set goal</button>
{% if goal %} {% if goal %}
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="hide-edit-goal" %} {% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="show-edit-goal" %}
{% endif %} {% endif %}
</p> </p>
</form> </form>

View file

@ -1,5 +1,5 @@
{% load bookwyrm_tags %} {% load bookwyrm_tags %}
<div class="select"> <div class="select {{ class }}">
{% with 0|uuid as uuid %} {% with 0|uuid as uuid %}
{% if not no_label %} {% if not no_label %}
<label class="is-sr-only" for="privacy-{{ uuid }}">Post privacy</label> <label class="is-sr-only" for="privacy-{{ uuid }}">Post privacy</label>
@ -12,7 +12,7 @@
Unlisted Unlisted
</option> </option>
<option value="followers" {% if current == 'followers' %}selected{% endif %}> <option value="followers" {% if current == 'followers' %}selected{% endif %}>
Followers only Followers
</option> </option>
<option value="direct" {% if current == 'direct' %}selected{% endif %}> <option value="direct" {% if current == 'direct' %}selected{% endif %}>
Private Private

View file

@ -1,18 +1,33 @@
{% load bookwyrm_tags %} {% load bookwyrm_tags %}
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<span class="is-sr-only">Leave a rating</span> <span class="is-sr-only">Leave a rating</span>
<div class="field is-grouped stars rate-stars"> <div class="block">
{% for i in '12345'|make_list %} <form class="hidden-form" name="rate" action="/post/rating" method="POST">
<form name="rate" action="/rate/" method="POST">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="user" value="{{ request.user.id }}"> <input type="hidden" name="user" value="{{ request.user.id }}">
<input type="hidden" name="book" value="{{ book.id }}"> <input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="privacy" value="public"> <input type="hidden" name="privacy" value="public">
<input type="hidden" name="rating" value="{{ forloop.counter }}"> <input type="hidden" name="rating" value="{{ forloop.counter }}">
<button type="submit" class="icon icon-star-{% if book|rating:user < forloop.counter %}empty{% else %}full{% endif %}">
<div class="field is-grouped stars form-rate-stars mb-1">
<label class="is-sr-only" for="no-rating-{{ book.id }}">No rating</label>
<input class="is-sr-only" type="radio" name="rating" value="" id="no-rating-{{ book.id }}" checked>
{% for i in '12345'|make_list %}
<input class="is-sr-only" id="book{{book.id}}-star-{{ forloop.counter }}" type="radio" name="rating" value="{{ forloop.counter }}" {% if book|rating:user == forloop.counter %}checked{% endif %}>
<label class="icon icon-star-empty" for="book{{book.id}}-star-{{ forloop.counter }}">
<span class="is-sr-only">{{ forloop.counter }} star{{ forloop.counter | pluralize }}</span> <span class="is-sr-only">{{ forloop.counter }} star{{ forloop.counter | pluralize }}</span>
</button> </label>
</form>
{% endfor %} {% endfor %}
</div>
<div class="field has-addons hidden">
<div class="control">
{% include 'snippets/privacy_select.html' with class="is-small" %}
</div>
<div class="control">
<button class="button is-small is-primary" type="submit">Rate</button>
</div>
</div>
</form>
</div> </div>
{% endif %} {% endif %}

View file

@ -1,7 +1,6 @@
{% load humanize %} {% load humanize %}
<div class="content block"> <div class="content block">
<input class="toggle-control" type="radio" name="show-edit-readthrough-{{ readthrough.id }}" id="show-readthrough-{{ readthrough.id }}" checked> <div id="hide-edit-readthrough-{{ readthrough.id }}">
<div class="toggle-content hidden">
<dl class="mb-1"> <dl class="mb-1">
{% if readthrough.start_date %} {% if readthrough.start_date %}
<div class="is-flex"> <div class="is-flex">
@ -16,48 +15,25 @@
</div> </div>
{% endif %} {% endif %}
</dl> </dl>
<div class="field is-grouped"> <div class="field has-addons">
{% include 'snippets/toggle/toggle_button.html' with small=True text="Edit read dates" icon="pencil" controls_text="edit-readthrough" controls_uid=readthrough.id %} <div class="control">
{% include 'snippets/toggle/toggle_button.html' with small=True text="Delete these read dates" icon="x" controls_text="delete-readthrough" controls_uid=readthrough.id %} {% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Edit read dates" icon="pencil" controls_text="edit-readthrough" controls_uid=readthrough.id focus="edit-readthrough" %}
</div>
<div class="control">
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Delete these read dates" icon="x" controls_text="delete-readthrough" controls_uid=readthrough.id focus="modal-title-delete-readthrough" %}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="block"> <div class="box hidden" id="edit-readthrough-{{ readthrough.id }}" tabindex="0">
<input class="toggle-control" type="radio" name="show-edit-readthrough-{{ readthrough.id }}" id="edit-readthrough-{{ readthrough.id }}"> <h3 class="title is-5">Edit read dates</h3>
<div class="toggle-content hidden">
<div class="box">
<form name="edit-readthrough" action="/edit-readthrough" method="post"> <form name="edit-readthrough" action="/edit-readthrough" method="post">
{% include 'snippets/readthrough_form.html' with readthrough=readthrough %} {% include 'snippets/readthrough_form.html' with readthrough=readthrough %}
<div class="field is-grouped"> <div class="field is-grouped">
<button class="button is-primary" type="submit">Save</button> <button class="button is-primary" type="submit">Save</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="show-readthrough" controls_uid=readthrough.id %} {% include 'snippets/toggle/close_button.html' with text="Cancel" controls_text="edit-readthrough" controls_uid=readthrough.id %}
</div> </div>
</form> </form>
</div>
</div>
</div>
<div>
<input class="toggle-control" type="checkbox" name="delete-readthrough-{{ readthrough.id }}" id="delete-readthrough-{{ readthrough.id }}">
<div class="modal toggle-content hidden">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Delete this read-though?</p>
<label class="delete" for="delete-readthrough-{{ readthrough.id }}" aria-label="close"></label>
</header>
<footer class="modal-card-foot">
<form name="delete-readthrough-{{ readthrough.id }}" action="/delete-readthrough" method="POST">
{% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}">
<button class="button is-danger is-light" type="submit">
Delete
</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="delete-readthrough" controls_uid=readthrough.id %}
</form>
</footer>
</div>
<label class="modal-close is-large" for="delete-readthrough-{{ readthrough.id }}" aria-label="close"></label>
</div>
</div> </div>
{% include 'snippets/delete_readthrough_modal.html' with controls_text="delete-readthrough" controls_uid=readthrough.id %}

View file

@ -1,25 +0,0 @@
{% load bookwyrm_tags %}
<form class="is-flex-grow-1" name="reply" action="/post/reply" method="post">
<div class="columns is-align-items-flex-end">
{% csrf_token %}
<input type="hidden" name="reply_parent" value="{{ status.id }}">
<input type="hidden" name="user" value="{{ request.user.id }}">
<div class="column">
{% include 'snippets/content_warning_field.html' with parent_status=status %}
<label for="id_content_{{ status.id }}-{{ uuid }}" class="is-sr-only">Reply</label>
<div class="field">
<textarea class="textarea" name="content" placeholder="Leave a comment..." id="id_content_{{ status.id }}-{{ uuid }}" required="true"></textarea>
</div>
</div>
<div class="column is-narrow">
<div class="field">
{% include 'snippets/privacy_select.html' with current=status.privacy %}
</div>
<div class="field">
<button class="button is-primary" type="submit">
post reply
</button>
</div>
</div>
</div>
</form>

View file

@ -1,36 +1,29 @@
<div class="dropdown"> {% extends 'snippets/components/dropdown.html' %}
<div class="dropdown-trigger"> {% block dropdown-trigger %}
<label for="shelf-select-dropdown-{{ book.id }}-toggle" role="button" aria-expanded="false" class="pulldown-menu" tabindex="0" aria-haspopup="true" aria-controls="shelf-select-{{ book.id }}"> <span>Change shelf</span>
<div class="button"> <span class="icon icon-arrow-down" aria-hidden="true"></span>
<span>Change shelf</span> {% endblock %}
<span class="icon icon-arrow-down" aria-hidden="true"></span>
</div> {% block dropdown-list %}
</label> {% for shelf in request.user.shelf_set.all %}
</div> {% if shelf.identifier != current.identifier %}
<input type="checkbox" class="toggle-control" id="shelf-select-dropdown-{{ book.id }}-toggle"> <li role="menuitem">
<div class="dropdown-menu toggle-content hidden" id="shelf-select-{{ book.id }}" role="menu">
<ul class="dropdown-content">
{% for shelf in request.user.shelf_set.all %}
{% if shelf.identifier != current.identifier %}
<li role="menuitem">
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post"> <form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}"> <input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="shelf" value="{{ shelf.identifier }}"> <input type="hidden" name="shelf" value="{{ shelf.identifier }}">
<button class="button is-small" type="submit">{{ shelf.name }}</button> <button class="button is-fullwidth is-small" type="submit">{{ shelf.name }}</button>
</form> </form>
</li> </li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<hr class="navbar-divider"> <hr class="navbar-divider">
<li> <li>
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/unshelve/" method="post"> <form class="dropdown-item pt-0 pb-0" name="shelve" action="/unshelve/" method="post">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}"> <input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="shelf" value="{{ current.id }}"> <input type="hidden" name="shelf" value="{{ current.id }}">
<button class="button is-small is-danger is-light" type="submit">Unshelve</button> <button class="button is-fullwidth is-small is-danger is-light" type="submit">Unshelve</button>
</form> </form>
</li> </li>
</ul> {% endblock %}
</div>
</div>

View file

@ -3,7 +3,8 @@
{% with book.id|uuid as uuid %} {% with book.id|uuid as uuid %}
{% active_shelf book as active_shelf %} {% active_shelf book as active_shelf %}
<div class="field is-grouped"> <div class="field has-addons">
<div class="control">
{% if switch_mode and active_shelf.book != book %} {% if switch_mode and active_shelf.book != book %}
{% include 'snippets/switch_edition_button.html' with edition=book size='is-small' %} {% include 'snippets/switch_edition_button.html' with edition=book size='is-small' %}
{% else %} {% else %}
@ -13,9 +14,9 @@
<span>Read</span> <span class="icon icon-check"></span> <span>Read</span> <span class="icon icon-check"></span>
</button> </button>
{% elif active_shelf.shelf.identifier == 'reading' %} {% elif active_shelf.shelf.identifier == 'reading' %}
{% include 'snippets/toggle/toggle_button.html' with small=True text="I'm done!" controls_text="finish-reading" controls_uid=uuid %} {% include 'snippets/toggle/toggle_button.html' with class="is-small" text="I'm done!" controls_text="finish-reading" controls_uid=uuid focus="modal-title-finish-reading" %}
{% elif active_shelf.shelf.identifier == 'to-read' %} {% elif active_shelf.shelf.identifier == 'to-read' %}
{% include 'snippets/toggle/toggle_button.html' with small=True text="Start reading" controls_text="start-reading" controls_uid=uuid %} {% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Start reading" controls_text="start-reading" controls_uid=uuid focus="modal-title-start-reading" %}
{% else %} {% else %}
<form name="shelve" action="/shelve/" method="post"> <form name="shelve" action="/shelve/" method="post">
{% csrf_token %} {% csrf_token %}
@ -24,42 +25,15 @@
<button class="button is-small" type="submit">Want to read</button> <button class="button is-small" type="submit">Want to read</button>
</form> </form>
{% endif %} {% endif %}
<div class="dropdown">
<div class="dropdown-trigger">
<label for="shelf-select-dropdown-{{ uuid }}-toggle" role="button" aria-expanded="false" class="pulldown-menu" tabindex="0" aria-haspopup="true" aria-controls="shelf-select-{{ uuid }}">
<div class="button is-small">
<span class="icon icon-arrow-down"><span class="is-sr-only">More shelves</span></span>
</div>
</label>
</div>
<input type="checkbox" class="toggle-control" id="shelf-select-dropdown-{{ uuid }}-toggle">
<div class="dropdown-menu toggle-content hidden" id="shelf-select-{{ uuid }}" role="menu">
<ul class="dropdown-content">
{% for shelf in request.user.shelf_set.all %}
<li role="menuitem">
{% if active_shelf.shelf.identifier != 'reading' and shelf.identifier == 'reading' %}
<div class="dropdown-item pt-0 pb-0">
{% include 'snippets/toggle/toggle_button.html' with small=True text="Start reading" controls_text="start-reading" controls_uid=uuid %}
</div>
{% else %}
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
<button class="button is-small" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>
<span>{{ shelf.name }}</span>
{% if shelf in book.shelf_set.all %}<span class="icon icon-check"></span>{% endif %}
</button>
</form>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
</div> </div>
{% include 'snippets/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%}
{% endif %} {% endif %}
</div> </div>
{% include 'snippets/start_reading_modal.html' with book=active_shelf.book %}
{% include 'snippets/finish_reading_modal.html' with book=active_shelf.book %} {% include 'snippets/start_reading_modal.html' with book=active_shelf.book controls_text="start-reading" controls_uid=uuid %}
{% latest_read_through book request.user as readthrough %}
{% include 'snippets/finish_reading_modal.html' with book=active_shelf.book controls_text="finish-reading" controls_uid=uuid readthrough=readthrough %}
{% endwith %} {% endwith %}
{% endif %} {% endif %}

View file

@ -0,0 +1,28 @@
{% extends 'snippets/components/dropdown.html' %}
{% block dropdown-trigger %}
<span class="icon icon-arrow-down">
<span class="is-sr-only">More shelves</span>
</span>
{% endblock %}
{% block dropdown-list %}
{% for shelf in request.user.shelf_set.all %}
<li role="menuitem">
{% if active_shelf.shelf.identifier != 'reading' and shelf.identifier == 'reading' %}
<div class="dropdown-item pt-0 pb-0">
{% include 'snippets/toggle/toggle_button.html' with class="is-fullwidth is-small" text="Start reading" controls_text="start-reading" controls_uid=button_uuid focus="modal-title-start-reading" %}
</div>
{% else %}
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
<button class="button is-fullwidth is-small" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>
<span>{{ shelf.name }}</span>
{% if shelf in book.shelf_set.all %}<span class="icon icon-check"></span>{% endif %}
</button>
</form>
{% endif %}
</li>
{% endfor %}
{% endblock %}

View file

@ -1,14 +1,15 @@
<div> {% extends 'snippets/components/modal.html' %}
<input class="toggle-control" type="checkbox" name="start-reading-{{ uuid }}" id="start-reading-{{ uuid }}">
<div class="modal toggle-content hidden"> {% block modal-title %}
<div class="modal-background"></div> Start "<em>{{ book.title }}</em>"
<div class="modal-card"> {% endblock %}
<header class="modal-card-head">
<p class="modal-card-title">Start "{{ book.title }}"</p> {% block modal-form-open %}
{% include 'snippets/toggle/toggle_button.html' with label="close" controls_text="start-reading" controls_uid=uuid class="delete" %} <form name="start-reading" action="/start-reading/{{ book.id }}" method="post">
</header> {% endblock %}
<form name="start-reading" action="/start-reading/{{ book.id }}" method="post">
<section class="modal-card-body"> {% block modal-body %}
<section class="modal-card-body">
{% csrf_token %} {% csrf_token %}
<div class="field"> <div class="field">
<label class="label"> <label class="label">
@ -16,9 +17,11 @@
<input type="date" name="start_date" class="input" id="start_id_start_date-{{ uuid }}" value="{% now "Y-m-d" %}"> <input type="date" name="start_date" class="input" id="start_id_start_date-{{ uuid }}" value="{% now "Y-m-d" %}">
</label> </label>
</div> </div>
</section> </section>
<footer class="modal-card-foot"> {% endblock %}
<div class="columns">
{% block modal-footer %}
<div class="columns">
<div class="column field"> <div class="column field">
<label for="post_status_start-{{ uuid }}"> <label for="post_status_start-{{ uuid }}">
<input type="checkbox" name="post-status" class="checkbox" id="post_status_start-{{ uuid }}" checked> <input type="checkbox" name="post-status" class="checkbox" id="post_status_start-{{ uuid }}" checked>
@ -30,10 +33,6 @@
<button class="button is-success" type="submit">Save</button> <button class="button is-success" type="submit">Save</button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="start-reading" controls_uid=uuid %} {% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="start-reading" controls_uid=uuid %}
</div> </div>
</div>
</footer>
</form>
</div>
<label class="modal-close is-large" for="start-reading-{{ uuid }}" aria-label="close"></label>
</div>
</div> </div>
{% endblock %}
{% block modal-form-close %}</form>{% endblock %}

View file

@ -1,29 +1,34 @@
{% extends 'snippets/components/card.html' %}
{% load bookwyrm_tags %} {% load bookwyrm_tags %}
{% load humanize %} {% load humanize %}
{% if not status.deleted %} {% block card-header %}
<article class="card"> <h3 class="card-header-title has-background-white-ter is-block">
<header class="card-header">
<div class="card-header-title has-background-white-ter">
<div class="columns">
<div class="column is-narrow">
{% include 'snippets/status_header.html' with status=status %} {% include 'snippets/status_header.html' with status=status %}
</div> </h3>
</div> {% endblock %}
</div>
</header>
<section class="card-content">
{% block card-content %}
{% include 'snippets/status_content.html' with status=status %} {% include 'snippets/status_content.html' with status=status %}
</section> {% endblock %}
<footer>
<div class="card-footer has-background-white-bis"> {% block card-footer %}
<div class="card-footer-item"> <div class="card-footer-item">
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
{% include 'snippets/toggle/toggle_button.html' with controls_text="show-comment" controls_uid=status.id text="Reply" icon='comment' small=True %} <div class="field has-addons">
<div class="control">
{% include 'snippets/toggle/toggle_button.html' with controls_text="show-comment" controls_uid=status.id text="Reply" icon="comment" class="is-small" focus="id_content_reply" %}
</div>
<div class="control">
{% include 'snippets/boost_button.html' with status=status %} {% include 'snippets/boost_button.html' with status=status %}
</div>
<div class="control">
{% include 'snippets/fav_button.html' with status=status %} {% include 'snippets/fav_button.html' with status=status %}
</div>
</div>
{% else %} {% else %}
<a href="/login"> <a href="/login">
@ -40,62 +45,33 @@
</span> </span>
</a> </a>
{% endif %} {% endif %}
</div> </div>
<div class="card-footer-item"> <div class="card-footer-item">
{% include 'snippets/privacy-icons.html' with item=status %} {% include 'snippets/privacy-icons.html' with item=status %}
</div> </div>
<div class="card-footer-item"> <div class="card-footer-item">
<a href="{{ status.remote_id }}">{{ status.published_date | post_date }}</a> <a href="{{ status.remote_id }}">{{ status.published_date | post_date }}</a>
</div> </div>
{% if status.user == request.user %} {% if status.user == request.user %}
<div class="card-footer-item"> <div class="card-footer-item">
{% include 'snippets/toggle/toggle_button.html' with controls_text="more-info" controls_uid=status.id text="More options" icon="dots-three" small=True %} {% include 'snippets/status_options.html' with class="is-small" right=True %}
</div> </div>
{% endif %} {% endif %}
</div> {% endblock %}
{% if request.user.is_authenticated %}
{% with status.id|uuid as uuid %} {% block card-bonus %}
<input class="toggle-control" type="checkbox" name="show-comment-{{ status.id }}" id="show-comment-{{ status.id }}" data-hover-target="id_content_{{ status.id }}-{{ uuid }}"> {% if request.user.is_authenticated %}
<div class="toggle-content hidden"> {% with status.id|uuid as uuid %}
<section class="hidden" id="show-comment-{{ status.id }}">
<div class="card-footer"> <div class="card-footer">
<div class="card-footer-item"> <div class="card-footer-item">
{% include 'snippets/reply_form.html' with status=status %} {% include 'snippets/create_status_form.html' with reply_parent=status type="reply" %}
</div> </div>
</div> </div>
</div> </section>
{% endwith %} {% endwith %}
{% endif %}
{% if status.user == request.user %}
<div>
<input class="toggle-control" type="checkbox" name="more-info-{{ status.id }}" id="more-info-{{ status.id }}">
<div class="toggle-content hidden card-footer">
{% if status.user == request.user %}
<div class="card-footer-item">
<form name="delete-{{status.id}}" action="/delete-status/{{ status.id }}" method="post">
{% csrf_token %}
<button class="button is-danger is-light" type="submit">
Delete post
</button>
</form>
</div>
{% endif %}
</div>
</div>
{% endif %}
</footer>
</article>
{% else %}
<article class="card">
<header class="card-header">
<p>
{% include 'snippets/avatar.html' with user=status.user %}
{% include 'snippets/username.html' with user=status.user %}
deleted this status
</p>
</header>
</article>
{% endif %} {% endif %}
{% endblock %}

View file

@ -10,19 +10,15 @@
{% endif %} {% endif %}
{% if status.content_warning %} {% if status.content_warning %}
<div class="toggle-content"> <div>
<p>{{ status.content_warning }}</p> <p>{{ status.content_warning }}</p>
<input class="toggle-control" type="radio" name="toggle-status-cw-{{ status.id }}" id="hide-status-cw-{{ status.id }}" checked> {% include 'snippets/toggle/open_button.html' with text="show more" class="is-small" controls_text="show-status-cw" controls_uid=status.id %}
<div class="toggle-content hidden">
{% include 'snippets/toggle/toggle_button.html' with text="Show More" small=True controls_text="show-status-cw" controls_uid=status.id %}
</div> </div>
</div>
<input class="toggle-control" type="radio" name="toggle-status-cw-{{ status.id }}" id="show-status-cw-{{ status.id }}">
{% endif %} {% endif %}
<div{% if status.content_warning %} class="toggle-content hidden"{% endif %}>
<div{% if status.content_warning %} class="hidden" id="show-status-cw-{{ status.id }}"{% endif %}>
{% if status.content_warning %} {% if status.content_warning %}
{% include 'snippets/toggle/toggle_button.html' with text="Show Less" small=True controls_text="hide-status-cw" controls_uid=status.id %} {% include 'snippets/toggle/close_button.html' with text="show less" class="is-small" controls_text="show-status-cw" controls_uid=status.id %}
{% endif %} {% endif %}
{% if status.quote %} {% if status.quote %}

View file

@ -0,0 +1,18 @@
{% extends 'snippets/components/dropdown.html' %}
{% block dropdown-trigger %}
<span class="icon icon-dots-three">
<span class="is-sr-only">More options</span>
</span>
{% endblock %}
{% block dropdown-list %}
<li role="menuitem">
<form class="dropdown-item pt-0 pb-0" name="delete-{{status.id}}" action="/delete-status/{{ status.id }}" method="post">
{% csrf_token %}
<button class="button is-danger is-light is-fullwidth is-small" type="submit">
Delete post
</button>
</form>
</li>
{% endblock %}

View file

@ -0,0 +1 @@
{% include 'snippets/toggle/toggle_button.html' with button_type='hide-inactive' %}

View file

@ -0,0 +1 @@
{% include 'snippets/toggle/toggle_button.html' with button_type='hide-active' %}

View file

@ -1,4 +1,13 @@
<label class="{% if class %}{{ class }}{% else %}button{% endif %}{% if small %} is-small{% endif %}" for="{{ controls_text }}{% if controls_uid %}-{{ controls_uid }}{% endif %}" tabindex="0" role="button"{% if label %} aria-label="{{ label }}"{% endif %}> <button
type="button"
class="{% if not nonbutton %}button {% endif %}{{ class }}{% if button_type %} {{ button_type }}{% endif %}"
data-controls="{{ controls_text }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"
{% if focus %}data-focus-target="{{ focus }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"{% endif %}
{% if checkbox %}data-controls-checkbox="{{ checkbox }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"{% endif %}
{% if label %}aria-label="{{ label }}"{% endif %}
aria-pressed="{% if pressed %}true{% else %}false{% endif %}"
>
{% if icon %} {% if icon %}
<span class="icon icon-{{ icon }}" title="{{ text }}"> <span class="icon icon-{{ icon }}" title="{{ text }}">
<span class="is-sr-only">{{ text }}</span> <span class="is-sr-only">{{ text }}</span>
@ -6,4 +15,4 @@
{% else %} {% else %}
{{ text }} {{ text }}
{% endif %} {% endif %}
</label> </button>

View file

@ -4,16 +4,14 @@
{% with full|truncatewords_html:60 as trimmed %} {% with full|truncatewords_html:60 as trimmed %}
{% if trimmed != full %} {% if trimmed != full %}
<div> <div id="hide-full-{{ uuid }}">
<input type="radio" name="show-hide-{{ uuid }}" id="show-{{ uuid }}" class="toggle-control" checked> <blockquote class="content" id="trimmed-{{ uuid }}"><span dir="auto">{{ trimmed | to_markdown | safe }}</span>
<blockquote class="content toggle-content hidden"><span dir="auto">{{ trimmed | to_markdown | safe }}</span> {% include 'snippets/toggle/open_button.html' with text="show more" controls_text="full" controls_uid=uuid class="is-small" %}
{% include 'snippets/toggle/toggle_button.html' with text="show more" controls_text="hide" controls_uid=uuid class="has-text-link is-clickable" %}
</blockquote> </blockquote>
</div> </div>
<div> <div id="full-{{ uuid }}" class="hidden">
<input type="radio" name="show-hide-{{ uuid }}" id="hide-{{ uuid }}" class="toggle-control"> <blockquote class="content"><span dir="auto">{{ full | to_markdown | safe }}</span>
<blockquote class="content toggle-content hidden"><span dir="auto">{{ full | to_markdown | safe }}</span> {% include 'snippets/toggle/close_button.html' with text="show less" controls_text="full" controls_uid=uuid class="is-small" %}
{% include 'snippets/toggle/toggle_button.html' with text="show less" controls_text="show" controls_uid=uuid class="has-text-link is-clickable" %}
</blockquote> </blockquote>
</div> </div>
{% else %} {% else %}

View file

@ -21,12 +21,13 @@ from .helpers import is_api_request, is_bookworm_request, object_visible_to_user
# pylint: disable= no-self-use # pylint: disable= no-self-use
class Status(View): class Status(View):
''' the view for *posting* ''' ''' get posting '''
def get(self, request, username, status_id): def get(self, request, username, status_id):
''' display a particular status (and replies, etc) ''' ''' display a particular status (and replies, etc) '''
try: try:
user = get_user_from_username(username) user = get_user_from_username(username)
status = models.Status.objects.select_subclasses().get(id=status_id) status = models.Status.objects.select_subclasses().get(
id=status_id, deleted=False)
except ValueError: except ValueError:
return HttpResponseNotFound() return HttpResponseNotFound()
@ -51,10 +52,11 @@ class Status(View):
@method_decorator(login_required, name='dispatch') @method_decorator(login_required, name='dispatch')
class CreateStatus(View): class CreateStatus(View):
''' get posting ''' ''' the view for *posting* '''
def post(self, request, status_type): def post(self, request, status_type):
''' create status of whatever type ''' ''' create status of whatever type '''
status_type = status_type[0].upper() + status_type[1:] status_type = status_type[0].upper() + status_type[1:]
try: try:
form = getattr(forms, '%sForm' % status_type)(request.POST) form = getattr(forms, '%sForm' % status_type)(request.POST)
except AttributeError: except AttributeError: