Add a checkbox to switch between diff variants
This commit is contained in:
parent
f8055c75b4
commit
8b24eb4da2
3 changed files with 65 additions and 27 deletions
|
@ -47,6 +47,9 @@ def index():
|
||||||
search = request.args.get("search", type=str, default="")
|
search = request.args.get("search", type=str, default="")
|
||||||
query = websearch_to_fts_query(search) if search else None
|
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 ())
|
db.execute(f"SELECT count(*) FROM diffs{'_fts(?)' if query else ''}", (query,) if query else ())
|
||||||
|
|
||||||
diff_count = db.fetchall()[0][0]
|
diff_count = db.fetchall()[0][0]
|
||||||
|
@ -77,6 +80,7 @@ def index():
|
||||||
pagination=pagination,
|
pagination=pagination,
|
||||||
diff_count = diff_count,
|
diff_count = diff_count,
|
||||||
search=search,
|
search=search,
|
||||||
|
compact_diffs=compact_diffs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ details[open] summary::before {
|
||||||
width: 1.25em;
|
width: 1.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input {
|
.text-input {
|
||||||
border-radius: var(--radius-s);
|
border-radius: var(--radius-s);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
|
@ -250,12 +250,25 @@ details[open] summary::before {
|
||||||
transition: border-color 120ms, box-shadow 120ms;
|
transition: border-color 120ms, box-shadow 120ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input:focus {
|
.text-input:focus {
|
||||||
border-color: var(--accent-color);
|
border-color: var(--accent-color);
|
||||||
box-shadow: 0 0 0 2px hsl(225 90% 40% / 50%);
|
box-shadow: 0 0 0 2px hsl(225 90% 40% / 50%);
|
||||||
outline: none;
|
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 {
|
.button {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -367,7 +380,7 @@ details[open] summary::before {
|
||||||
|
|
||||||
/* Index */
|
/* Index */
|
||||||
|
|
||||||
.filters {
|
.home-filters {
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -376,12 +389,20 @@ details[open] summary::before {
|
||||||
border-bottom: 1px solid var(--border-color);
|
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;
|
display: flex;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filters [name="search"] {
|
.home-filters [name="search"] {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 20rem;
|
max-width: 20rem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
{% block header_class %}header-extended{% endblock header_class %}
|
{% block header_class %}header-extended{% endblock header_class %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="filters">
|
<div class="home-filters">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<form method="get">
|
<form method="get">
|
||||||
<input
|
<input
|
||||||
class="input"
|
class="text-input"
|
||||||
type="text"
|
type="text"
|
||||||
id="search"
|
id="search"
|
||||||
name="search"
|
name="search"
|
||||||
|
@ -22,10 +22,19 @@
|
||||||
<svg class="inline-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748Z"></path></svg>
|
<svg class="inline-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748Z"></path></svg>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" name="compact_diffs" value="true"
|
||||||
|
hx-get="/"
|
||||||
|
hx-target="#diff-list"
|
||||||
|
hx-select="#diff-list"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
/>
|
||||||
|
<p>Compact diffs</p>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container home-diff-list">
|
<div class="container home-diff-list" id="diff-list">
|
||||||
{% for diff in diffs %}
|
{% for diff in diffs %}
|
||||||
<article class="card changeset-card">
|
<article class="card changeset-card">
|
||||||
<p class="changeset-card-actions">
|
<p class="changeset-card-actions">
|
||||||
|
@ -41,27 +50,31 @@
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="changeset-card-diff-s">
|
{% if compact_diffs %}
|
||||||
<div>
|
<div class="changeset-card-title">{{ diff.diff_html|safe }}</div>
|
||||||
<div class="text-caption">Before</div>
|
{% else %}
|
||||||
<div class="diff-before changeset-card-title">{{ diff.diff_html|safe }}</div>
|
<div class="changeset-card-diff-s">
|
||||||
|
<div>
|
||||||
|
<div class="text-caption">Before</div>
|
||||||
|
<div class="diff-before changeset-card-title">{{ diff.diff_html|safe }}</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="text-caption">After</div>
|
||||||
|
<div class="diff-after changeset-card-title">{{ diff.diff_html|safe }}</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<div class="text-caption">After</div>
|
|
||||||
<div class="diff-after changeset-card-title">{{ diff.diff_html|safe }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class="changeset-card-diff-m">
|
<table class="changeset-card-diff-m">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-caption table-head">Before</th>
|
<th class="text-caption table-head">Before</th>
|
||||||
<td class="diff-before changeset-card-title">{{ diff.diff_html|safe }}</td>
|
<td class="diff-before changeset-card-title">{{ diff.diff_html|safe }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-caption table-head">After</th>
|
<th class="text-caption table-head">After</th>
|
||||||
<td class="diff-after changeset-card-title">{{ diff.diff_html|safe }}</td>
|
<td class="diff-after changeset-card-title">{{ diff.diff_html|safe }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
{% endif %}
|
||||||
</article>
|
</article>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue