Add support pill

This commit is contained in:
Jake Howard 2023-08-29 21:57:04 +01:00
parent e93dde86a3
commit 0931217e74
Signed by: jake
GPG key ID: 57AFB45680EDD477
7 changed files with 43 additions and 3 deletions

View file

@ -0,0 +1,20 @@
$support-pill-size: 50px;
$support-pill-position: 1.5rem;
.tag.support-pill {
display: flex;
position: fixed;
right: $support-pill-position;
bottom: $support-pill-position;
align-items: center;
justify-content: center;
border-radius: math.div($support-pill-size, 2);
width: $support-pill-size;
height: $support-pill-size;
font-size: 100%;
z-index: $dropdown-content-z;
@include mobile {
display: none;
}
}

View file

@ -21,6 +21,7 @@
@import "password_required";
@import "commento";
@import "similar_content";
@import "support_pill";
html,
body {

View file

@ -17,7 +17,7 @@ class BlogPostPageTestCase(TestCase):
self.assertEqual(response.status_code, 200)
def test_queries(self) -> None:
with self.assertNumQueries(47):
with self.assertNumQueries(48):
self.client.get(self.page.url)

View file

@ -1,6 +1,6 @@
{% extends "wagtail_base.html" %}
{% load static sri %}
{% load static sri navbar_tags %}
{% block content %}
{% if page.body_html %}
@ -15,6 +15,10 @@
{% include "common/shareon.html" %}
{% include "common/comments.html" %}
{% if not request.user.is_authenticated %}
{% support_pill %}
{% endif %}
{% endif %}
{% endblock %}

View file

@ -0,0 +1,7 @@
{% load wagtailcore_tags %}
{% if support_page and page.id != support_page.id %}
<a href="{% pageurl support_page %}" class="tag is-primary support-pill" title="Support me">
<i class="fas fa-praying-hands"></i>
</a>
{% endif %}

View file

@ -22,3 +22,11 @@ def navbar(context: dict) -> dict:
"search_page_url": SingletonPageCache.get_url(SearchPage, request),
"guestbook_page": Page.objects.filter(slug="guestbook").first(),
}
@register.inclusion_tag("common/support-pill.html", takes_context=True)
def support_pill(context: dict) -> dict:
return {
"page": context["page"],
"support_page": Page.objects.filter(slug="support").first(),
}

View file

@ -35,7 +35,7 @@ class ContentPageTestCase(TestCase):
self.assertEqual(response.status_code, 200)
def test_queries(self) -> None:
with self.assertNumQueries(38):
with self.assertNumQueries(39):
self.client.get(self.page.url)