Skip to content

Commit e4aab8e

Browse files
committed
Affichage de la recherche en utilisant le DSFR
1 parent 8361ef4 commit e4aab8e

File tree

3 files changed

+49
-72
lines changed

3 files changed

+49
-72
lines changed

templates/components/search/_search_result.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
focus:!no-underline
77
focus:!bg-none
88
focus:!qf-bg-grey-1000-50-hover
9+
focus:!qf-z-20 {# Prevent that focus is well displayed #}
910
hover:!no-underline
1011
hover:!bg-none
1112
hover:!qf-bg-grey-1000-50-hover
1213
qf-py-1w md:qf-py-3v qf-pl-3w
13-
qf-text-xs md:qf-text-base qf-font-bold
14+
qf-border-b qf-border-t-0 qf-border-x-0 qf-border-solid qf-border-grey-1000-50-hover qf-bg-white
1415
"
1516
tabindex="0"
1617
>

templates/components/search/view.html

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,36 @@
77
keydown.esc->search#clear:prevent
88
keydown.up->search#up:prevent
99
keydown.down->search#down:prevent"
10-
class="
11-
{# Z-index here helps prevent autocomplete overlapping on the accordion on the homepage #}
12-
qf-relative qf-z-10
13-
qf-rounded-3xl qf-overflow-hidden
14-
group-data-[home]:qf-rounded-[2rem]
15-
max-md:qf-rounded-[2rem]
16-
qf-border-solid qf-border-[3px] qf-border-green-menthe-sun-373-moon-652-hover qf-bg-white
17-
qf-flex qf-flex-col"
10+
{% comment %} Z-index here helps prevent autocomplete overlapping on the accordion on the homepage {% endcomment %}
11+
class="qf-relative qf-z-10 qf-overflow-hidden"
1812
>
1913
<form
2014
data-search-target="form"
2115
data-turbo-frame="{{ id }}:search-results"
2216
action="{% url 'qfdmd:search' %}"
23-
class="qf-pl-4w {# should match the svg icon width #}
24-
qf-flex qf-flex-row-reverse qf-relative
25-
md:group-data-[home]:qf-h-7w
26-
qf-h-5w
27-
qf-content-center
28-
"
17+
class="qf-p-1w {# Padding is required to prevent focus is well displayed #}"
2918
>
3019
{% for field in search_form %}
3120
{{ field }}
3221
{% endfor %}
33-
<button
34-
type="submit"
35-
class="qf-absolute qf-top-0 qf-bottom-0 qf-left-0
36-
qf-m-auto qf-pl-1v
37-
fr-btn fr-icon-search-line fr-btn--tertiary-no-outline
38-
focus:qf-bg-green-menthe-sun-373-moon-652-hover
39-
focus:qf-ring focus:qf-ring-inset focus:qf-ring-blue-france-sun-113-625-hover
40-
qf-rounded-l-full
41-
focus:qf-text-white
42-
focus:!qf-outline-none
43-
qf-h-full
44-
!qf-max-h-[none]
45-
qf-text-green-menthe-sun-373-moon-652-hover"
46-
><span class="qf-sr-only">Rechercher</span></button>
22+
<turbo-frame
23+
id="{{ id }}:search-results"
24+
data-search-target="results"
25+
class=" qf-flex qf-flex-col"
26+
>
27+
{% if search_form.results %}
28+
<div class="qf-flex qf-flex-col qf-border-x qf-border-y-0 qf-border-solid qf-border-grey-1000-50-hover qf-bg-white">
29+
{% for result in search_form.results %}
30+
{% if beta %}
31+
{% include "./_search_result_beta.html" %}
32+
{% else %}
33+
{% include "./_search_result.html" %}
34+
{% endif %}
35+
{% endfor %}
36+
</div>
37+
{% endif %}
38+
</turbo-frame>
4739
</form>
48-
49-
<turbo-frame
50-
id="{{ id }}:search-results"
51-
data-search-target="results"
52-
class="qf-flex qf-flex-col"
53-
>
54-
{% if search_form.results %}
55-
{% for result in search_form.results %}
56-
{% if beta %}
57-
{% include "./_search_result_beta.html" %}
58-
{% else %}
59-
{% include "./_search_result.html" %}
60-
{% endif %}
61-
{% endfor %}
62-
{% endif %}
63-
</turbo-frame>
6440
</div>
6541
</turbo-frame>
6642
{% endwith %}

templates/components/search/widget.html

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44

55
It is used mainly for styles, to add clasnames.
66
{% endcomment %}
7-
<label for="{{ widget.attrs.id }}" class="qf-sr-only">Entrez un déchet :</label>
8-
<input
9-
class="qf-pl-1w qf-pr-2w
10-
qf-rounded-r-full
11-
qf-ml-1w
12-
focus:qf-outline-none
13-
focus:qf-ring-inset focus:qf-ring-blue-france-sun-113-625-hover
14-
focus:qf-ring
15-
qf-w-full
16-
qf-text-base
17-
md:group-data-[home]:qf-text-2xl
18-
qf-text-grey-425 qf-font-bold
19-
placeholder:qf-text-grey-425
20-
"
21-
autocomplete="off"
22-
autocorrect="off"
23-
autocapitalize="off"
24-
spellcheck="false"
25-
placeholder="Entrez un objet ou un déchet"
26-
type="{{ widget.type }}"
27-
name="{{ widget.name }}"{% if widget.value != None %}
28-
value="{{ widget.value|stringformat:'s' }}"{% endif %}
29-
data-action="search#submitForm keydown.enter->search#submitFirstItem"
30-
data-search-target="input"
31-
role="search"
32-
{% include "django/forms/widgets/attrs.html" %}
33-
>
7+
8+
<div class="fr-search-bar" role="search">
9+
<label class="fr-label" for="{{ widget.attrs.id }}">
10+
Rechercher, {{ widget.attrs.label }}
11+
</label>
12+
<input
13+
class="fr-input"
14+
aria-describedby="search-input-messages"
15+
id="search-input"
16+
autocomplete="off"
17+
autocorrect="off"
18+
autocapitalize="off"
19+
spellcheck="false"
20+
placeholder="Entrez un objet ou un déchet"
21+
type="{{ widget.type }}"
22+
name="{{ widget.name }}"{% if widget.value != None %}
23+
value="{{ widget.value|stringformat:'s' }}"{% endif %}
24+
data-action="search#submitForm keydown.enter->search#submitFirstItem"
25+
data-search-target="input"
26+
type="search"
27+
role="search"
28+
{% include "django/forms/widgets/attrs.html" %}
29+
>
30+
<div class="fr-messages-group" id="search-input-messages" aria-live="polite">
31+
</div>
32+
<button title="Rechercher" type="button" class="fr-btn">Rechercher</button>
33+
</div>

0 commit comments

Comments
 (0)