From 8b24eb4da254161fd59287f1ce0a18de6b08d352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Ny=CC=81vlt?= Date: Thu, 17 Aug 2023 18:06:25 +0200 Subject: [PATCH] Add a checkbox to switch between diff variants --- view/app.py | 4 +++ view/static/main.css | 31 +++++++++++++++++---- view/templates/index.html | 57 ++++++++++++++++++++++++--------------- 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/view/app.py b/view/app.py index 8604279..b7468cb 100644 --- a/view/app.py +++ b/view/app.py @@ -47,6 +47,9 @@ def index(): search = request.args.get("search", type=str, default="") query = websearch_to_fts_query(search) if search else None + # View options + compact_diffs = request.args.get("compact_diffs") is not None + db.execute(f"SELECT count(*) FROM diffs{'_fts(?)' if query else ''}", (query,) if query else ()) diff_count = db.fetchall()[0][0] @@ -77,6 +80,7 @@ def index(): pagination=pagination, diff_count = diff_count, search=search, + compact_diffs=compact_diffs, ) diff --git a/view/static/main.css b/view/static/main.css index c7be301..fa8053d 100644 --- a/view/static/main.css +++ b/view/static/main.css @@ -242,7 +242,7 @@ details[open] summary::before { width: 1.25em; } -.input { +.text-input { border-radius: var(--radius-s); border: 1px solid var(--border-color); padding: 0.375rem 0.75rem; @@ -250,12 +250,25 @@ details[open] summary::before { transition: border-color 120ms, box-shadow 120ms; } -.input:focus { +.text-input:focus { border-color: var(--accent-color); box-shadow: 0 0 0 2px hsl(225 90% 40% / 50%); outline: none; } +.checkbox { + font-size: var(--font-size-s); + display: flex; + align-items: center; + color: var(--color-muted); + font-weight: 500; + cursor: pointer; +} + +.checkbox input { + margin-right: 0.5rem; +} + .button { display: inline-flex; align-items: center; @@ -367,7 +380,7 @@ details[open] summary::before { /* Index */ -.filters { +.home-filters { margin-bottom: 2rem; position: sticky; top: 0; @@ -376,12 +389,20 @@ details[open] summary::before { border-bottom: 1px solid var(--border-color); } -.filters form { +.home-filters .container { + display: flex; + align-items: center; + flex-wrap: nowrap; + flex-shrink: 0; + gap: 1.5rem; +} + +.home-filters form { display: flex; gap: 0.5rem; } -.filters [name="search"] { +.home-filters [name="search"] { width: 100%; max-width: 20rem; } diff --git a/view/templates/index.html b/view/templates/index.html index abd1dbe..fbae8f8 100644 --- a/view/templates/index.html +++ b/view/templates/index.html @@ -3,11 +3,11 @@ {% block header_class %}header-extended{% endblock header_class %} {% block body %} -
+
+
-
+
{% for diff in diffs %}

@@ -41,27 +50,31 @@

-
-
-
Before
-
{{ diff.diff_html|safe }}
+ {% if compact_diffs %} +
{{ diff.diff_html|safe }}
+ {% else %} +
+
+
Before
+
{{ diff.diff_html|safe }}
+
+
+
After
+
{{ diff.diff_html|safe }}
+
-
-
After
-
{{ diff.diff_html|safe }}
-
-
- - - - - - - - - -
Before{{ diff.diff_html|safe }}
After{{ diff.diff_html|safe }}
+ + + + + + + + + +
Before{{ diff.diff_html|safe }}
After{{ diff.diff_html|safe }}
+ {% endif %}
{% endfor %}