From 0931217e74d2e51169fa9b6bbbc83e1dcd78e96e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 29 Aug 2023 21:57:04 +0100 Subject: [PATCH] Add support pill --- static/src/scss/_support_pill.scss | 20 +++++++++++++++++++ static/src/scss/base.scss | 1 + website/blog/tests.py | 2 +- .../common/templates/common/content_page.html | 6 +++++- .../common/templates/common/support-pill.html | 7 +++++++ website/common/templatetags/navbar_tags.py | 8 ++++++++ website/common/tests/test_pages.py | 2 +- 7 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 static/src/scss/_support_pill.scss create mode 100644 website/common/templates/common/support-pill.html diff --git a/static/src/scss/_support_pill.scss b/static/src/scss/_support_pill.scss new file mode 100644 index 0000000..97f79cf --- /dev/null +++ b/static/src/scss/_support_pill.scss @@ -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; + } +} diff --git a/static/src/scss/base.scss b/static/src/scss/base.scss index b4dd01b..8a84baf 100644 --- a/static/src/scss/base.scss +++ b/static/src/scss/base.scss @@ -21,6 +21,7 @@ @import "password_required"; @import "commento"; @import "similar_content"; +@import "support_pill"; html, body { diff --git a/website/blog/tests.py b/website/blog/tests.py index bdd6b9e..4bacc0a 100644 --- a/website/blog/tests.py +++ b/website/blog/tests.py @@ -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) diff --git a/website/common/templates/common/content_page.html b/website/common/templates/common/content_page.html index e4be19d..ca8edb5 100644 --- a/website/common/templates/common/content_page.html +++ b/website/common/templates/common/content_page.html @@ -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 %} diff --git a/website/common/templates/common/support-pill.html b/website/common/templates/common/support-pill.html new file mode 100644 index 0000000..38f4aa3 --- /dev/null +++ b/website/common/templates/common/support-pill.html @@ -0,0 +1,7 @@ +{% load wagtailcore_tags %} + +{% if support_page and page.id != support_page.id %} + + + +{% endif %} diff --git a/website/common/templatetags/navbar_tags.py b/website/common/templatetags/navbar_tags.py index 025e5c8..ae143c1 100644 --- a/website/common/templatetags/navbar_tags.py +++ b/website/common/templatetags/navbar_tags.py @@ -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(), + } diff --git a/website/common/tests/test_pages.py b/website/common/tests/test_pages.py index 1470f67..9968746 100644 --- a/website/common/tests/test_pages.py +++ b/website/common/tests/test_pages.py @@ -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)