Skip to content

Commit da0af8e

Browse files
committed
feat: make input styling more universal, retouch results.html filter nav
1 parent dd9ff4e commit da0af8e

5 files changed

Lines changed: 117 additions & 54 deletions

File tree

webtool/static/css/components/buttons.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ button.no-border {
118118
border-color: var(--red);
119119
}
120120

121-
a.button-like, .button-like button, button.button-like, .plain-page button:not(.self-styled), input[type=submit] {
121+
a.button-like, .button-like button, button.button-like, li.button-like, .plain-page button:not(.self-styled), input[type=submit] {
122122
padding: 8px;
123123
}
124124

webtool/static/css/components/dataset-overview.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,58 @@
99

1010
.result-list nav.tabs {
1111
margin: var(--spacing-regular) auto;
12+
}
13+
14+
/* The bar over the dataset list: the set being looked at on one row, the
15+
filters narrowing it down on the next, kept a little apart so they read as
16+
two separate decisions. */
17+
.dataset-filters form {
18+
display: flex;
19+
flex-direction: column;
20+
row-gap: var(--spacing-small);
21+
}
22+
23+
.dataset-filters ul {
24+
display: flex;
25+
flex-wrap: wrap;
26+
align-items: center;
27+
gap: var(--spacing-small);
28+
}
29+
30+
/* gaps do the spacing here, so the margin the metadata bar puts on its nav
31+
items would only double it */
32+
.dataset-metadata > nav.dataset-filters li {
33+
margin-right: 0;
34+
}
35+
36+
/* the set being looked at, called out against the ones that are not */
37+
.dataset-metadata .dataset-filters .button-like.current,
38+
.dataset-metadata .dataset-filters .button-like.current:hover {
39+
background: var(--bright);
40+
border-color: var(--bright);
41+
color: var(--semidark);
42+
}
43+
44+
/* the filter row sits on the dark bar, so its text needs what the buttons
45+
around it already get */
46+
.dataset-filters .dataset-filter-options {
47+
color: var(--bright);
48+
}
49+
50+
.dataset-filters .dataset-filter-options label {
51+
display: flex;
52+
align-items: center;
53+
column-gap: var(--spacing-tiny);
54+
white-space: nowrap;
55+
}
56+
57+
/* the search boxes take whatever the fixed-width controls leave */
58+
.dataset-filters .dataset-filter-options .search-box {
59+
flex: 1 1 10rem;
60+
min-width: 0;
61+
}
62+
63+
/* what submits the row closes it off */
64+
.dataset-filters .dataset-filter-submit {
65+
margin-left: auto;
1266
}

webtool/static/css/components/forms.css

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ form .notice {
7979
padding: var(--spacing-regular);
8080
}
8181

82-
/* Shared form definition for UserInput fields and annotation fields */
83-
:is(.form-element, .form-controls) input:not([type=checkbox]):not([type=hidden]),
84-
:is(.form-element, .form-controls) textarea,
85-
:is(.form-element, .form-controls) select {
82+
input:not([type=checkbox]):not([type=hidden]),
83+
textarea,
84+
select {
8685
width: 100%;
8786
box-sizing: border-box;
8887
font: inherit;
@@ -94,7 +93,7 @@ form .notice {
9493
padding: var(--spacing-small);
9594
}
9695

97-
:is(.form-element, .form-controls) select {
96+
select {
9897
-moz-appearance:none;
9998
-webkit-appearance:none;
10099
appearance:none;
@@ -105,24 +104,24 @@ form .notice {
105104
padding-right: calc(var(--spacing-small) + 16px);
106105
}
107106

108-
:is(.form-element, .form-controls) select:open {
107+
select:open {
109108
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="%23333333" stroke-width="2.5" stroke-linecap="butt" stroke-linejoin="miter" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" transform="matrix(1,0,0,-1,0,0)"><polyline points="2,5 8,11 14,5"></polyline></svg>');
110109
}
111110

112-
:is(.form-element, .form-controls) select:focus {
111+
select:focus {
113112
outline: none;
114113
border-bottom: var(--stroke-heavy) solid var(--fourcat-accent);
115114
}
116115

117-
:is(.form-element, .form-controls) input:not([type=checkbox]):focus,
118-
:is(.form-element, .form-controls) textarea:focus,
119-
:is(.form-element, .form-controls) select:focus {
116+
input:not([type=checkbox]):focus,
117+
textarea:focus,
118+
select:focus {
120119
outline: var(--stroke) solid var(--fourcat-accent);
121120
border-bottom: var(--stroke-heavy) solid var(--fourcat-accent);
122121
outline-offset: calc(-1 * var(--stroke-light));
123122
}
124123

125-
:is(.form-element, .form-controls) input[type=checkbox] {
124+
input[type=checkbox] {
126125
box-sizing: border-box;
127126
width: 1.2rem;
128127
height: 1.2rem;
@@ -136,36 +135,35 @@ form .notice {
136135
transition: outline 0.1s;
137136
}
138137

139-
:is(.form-element, .form-controls) input[type=checkbox]:checked {
138+
input[type=checkbox]:checked {
140139
background-color: var(--button-bg-regular);
141140
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="butt" stroke-linejoin="miter" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"><polyline points="2,7 7,12 14,3"></polyline></svg>');
142141
background-repeat: no-repeat;
143142
background-position: center;
144143
}
145144

146-
:is(.form-element, .form-controls) option,
147-
:is(.form-element, .form-controls) optgroup {
145+
option,
146+
optgroup {
148147
font-family: Chivo, sans-serif;
149148
font-size: var(--font-body);
150149
}
151150

152-
:is(.form-element, .form-controls) textarea {
151+
textarea {
153152
min-height: 8em;
154153
resize: vertical;
155154
}
156155

157-
:is(.form-element, .form-controls) input.invalid,
158-
:is(.form-element, .form-controls) input:user-invalid,
159-
:is(.form-element, .form-controls) input.invalid:not([type=checkbox]):not([type=hidden]),
160-
:is(.form-element, .form-controls) textarea.invalid,
161-
:is(.form-element, .form-controls) textarea:user-invalid {
156+
input.invalid,
157+
input:user-invalid,
158+
input.invalid:not([type=checkbox]):not([type=hidden]),
159+
textarea.invalid,
160+
textarea:user-invalid {
162161
background: var(--red-light);
163162
border-color: var(--red);
164163
color: var(--red);
165164
}
166165

167166
/* UserInput form widgets */
168-
169167
.form-element .daterange-wrapper {
170168
display: flex;
171169
align-items: center;

webtool/templates/components/user-inputs/datasource-select.html

Lines changed: 0 additions & 8 deletions
This file was deleted.

webtool/templates/results.html

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,66 @@
99
<section class="dark result-list dataset-metadata">
1010
<h1><span>Datasets</span></h1>
1111

12-
<nav class="tabs">
12+
{# Which datasets are being looked at, over how they are narrowed
13+
down. The first row are links, so picking a set takes effect at
14+
once; it carries the filters along, so they keep applying within
15+
the set that was picked. The second row needs submitting, so the
16+
button doing that closes it off. #}
17+
<nav class="tabs dataset-filters">
1318
<form action="{{ url_for("dataset.show_results") }}" method="GET">
1419
<input type="hidden" name="depth" value="{{ depth }}">
15-
<ul>
20+
<ul class="dataset-filter-depth">
1621
{% if __user_config("privileges.can_view_all_datasets") %}
17-
<li class="button-like{% if depth == "all" %} current{% endif %}"><a
18-
href="{{ url_for('dataset.show_results') }}?{{ filter|http_query }}&amp;depth=all">All
19-
datasets</a></li>{% endif %}
20-
<li class="button-like{% if not depth or depth == "own" %} current{% endif %}"><a
21-
href="{{ url_for('dataset.show_results') }}?{{ filter|http_query }}&amp;depth=own">My
22+
<li><a class="button-like{% if depth == "all" %} current{% endif %}"
23+
{% if depth == "all" %}aria-current="page"{% endif %}
24+
href="{{ url_for('dataset.show_results') }}?{{ filter|http_query }}&amp;depth=all">All
25+
datasets</a></li>
26+
{% endif %}
27+
<li><a class="button-like{% if not depth or depth == "own" %} current{% endif %}"
28+
{% if not depth or depth == "own" %}aria-current="page"{% endif %}
29+
href="{{ url_for('dataset.show_results') }}?{{ filter|http_query }}&amp;depth=own">My
2230
own datasets</a></li>
23-
<li class="button-like{% if depth == "favourites" %} current{% endif %}"><a
24-
href="{{ url_for('dataset.show_results') }}?{{ filter|http_query }}&amp;depth=favourites">Favourites
31+
<li><a class="button-like{% if depth == "favourites" %} current{% endif %}"
32+
{% if depth == "favourites" %}aria-current="page"{% endif %}
33+
href="{{ url_for('dataset.show_results') }}?{{ filter|http_query }}&amp;depth=favourites">Favourites
2534
only</a></li>
35+
</ul>
2636

27-
<li><input aria-label="Filter by query or label" placeholder="Filter datasets..." name="filter"
28-
value="{{ filter.filter }}"></li>
37+
<ul class="dataset-filter-options">
38+
<li class="search-box">
39+
<input type="search" name="filter" value="{{ filter.filter }}"
40+
aria-label="Search datasets by query or label"
41+
placeholder="Search datasets...">
42+
</li>
2943
{% if current_user.is_admin %}
30-
<li><input aria-label="User" placeholder="User..." name="user"
31-
value="{{ filter.user }}"></li>
44+
<li class="search-box">
45+
<input type="search" name="user" value="{{ filter.user }}"
46+
aria-label="Search datasets by user" placeholder="Search by user...">
47+
</li>
3248
<li>
3349
<select aria-label="Sort datasets by" name="sort_by">
34-
<option value="timestamp"{% if filter.sort_by == "timestamp" %} selected{% endif %}>
35-
Sort by date
36-
</option>
37-
<option value="num_rows"{% if filter.sort_by == "num_rows" %} selected{% endif %}>
38-
Sort by size
39-
</option>
50+
<option value="timestamp"{% if filter.sort_by == "timestamp" %} selected{% endif %}>Sort by date</option>
51+
<option value="num_rows"{% if filter.sort_by == "num_rows" %} selected{% endif %}>Sort by size</option>
4052
</select>
4153
</li>
4254
{% endif %}
4355
<li>
44-
{% include 'components/user-inputs/datasource-select.html' %}
56+
<select name="datasource" aria-label="Filter by data source">
57+
<option value="all"{% if filter.datasource == "all" %} selected{% endif %}>All data sources</option>
58+
{% for datasource in datasources %}
59+
<option value="{{ datasource }}"{% if filter.datasource == datasource %} selected{% endif %}>{{ datasources[datasource].name }}</option>
60+
{% endfor %}
61+
</select>
4562
</li>
46-
<li><label><input type="checkbox" name="hide_empty" {% if filter.hide_empty %}
47-
checked="checked"{% endif %}> Hide empty datasets</label></li>
4863
<li>
49-
<button>Filter</button>
64+
<label><input type="checkbox" name="hide_empty"
65+
{% if filter.hide_empty %}checked="checked"{% endif %}> Hide empty
66+
datasets</label>
67+
</li>
68+
<li class="dataset-filter-submit">
69+
<button class="button-like">Filter</button>
5070
</li>
5171
</ul>
52-
5372
</form>
5473
</nav>
5574
{% if datasets %}

0 commit comments

Comments
 (0)