Skip to content

Commit a8b837e

Browse files
committed
style(Exercices): move search bar into the exercise panel and make it bigger
1 parent 4acdcae commit a8b837e

File tree

5 files changed

+81
-41
lines changed

5 files changed

+81
-41
lines changed

assets/css/_container.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@
7474

7575
.input-wrapper--with-icon {
7676
position: relative;
77-
height: 40px;
7877
width: 100%;
7978
max-width: 400px;
79+
height: 45px;
8080

8181
input {
8282
max-width: 400px;

assets/css/form.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,17 @@ input[type=file] {
9595

9696
input:not([type=radio]) {
9797
padding-left: 50px;
98+
font-weight: normal;
99+
line-height: 3em;
100+
101+
font-size: 0.9em;
102+
&::placeholder {
103+
font-size: 1em;
104+
}
98105
}
99106

100107
svg {
101-
width: 15px;
108+
width: 20px;
102109
position: absolute;
103110
top: 50%;
104111
left: 20px;
@@ -138,7 +145,7 @@ form {
138145
Custom theme of textarea
139146
*/
140147

141-
@include input-theme(primary-color, $PRIMARY_COLOR, $PRIMARY_COLOR_LIGHT);
148+
@include input-theme(primary-color, $PRIMARY_COLOR, $PRIMARY_COLOR);
142149
@include input-theme(secondary-color, $SECONDARY_COLOR, lighten($SECONDARY_COLOR, 10));
143150
@include input-theme(ternary-color, $TERNARY_COLOR, lighten($TERNARY_COLOR, 10));
144151
@include input-theme(grey, $GREY, lighten($GREY, 20));

components/Exercise/ExercisesPanel.vue

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
<section id="ExercisesPanel" class="exercises-wrapper">
33
<header ref="headerExercise">
44
<div class="header-wrapper">
5-
<h1>
6-
Résultats de recherche
7-
<span v-if="!isEmptySearchModel"> - {{searchModel}}</span>
8-
</h1>
5+
6+
<div class="input-wrapper--with-icon input-with--enter-icon">
7+
<Icon type="search"/>
8+
<input ref="inputText" class="input--primary-color" type="text" @input="resetIfEmpty" @keydown.enter="debounceInput"
9+
placeholder="Rechercher">
10+
</div>
911

1012
<div class="results">
1113
{{nbOfResults}} résultats - <span @click.self="reset" class="init">réinitialiser la recherche</span>
@@ -39,11 +41,13 @@
3941
import PreviewExercise from '~/components/Exercise/PreviewExercise.vue'
4042
import IntersectMixins from "~/components/Mixins/IntersectMixins.vue";
4143
import {Exercise, SelectedTag, TagLabelObjectEmitted, TagState} from "~/types";
44+
import Icon from "~/components/Symbols/Icon.vue";
4245
4346
const ratio = .2;
4447
4548
@Component({
4649
components: {
50+
Icon,
4751
Tag,
4852
PreviewExercise
4953
}
@@ -52,6 +56,9 @@
5256
@Ref() headerExercise!: HTMLElement;
5357
@Ref() bodyExercise!: HTMLElement;
5458
@Ref() anchor!: Element;
59+
@Ref() inputText!: HTMLInputElement;
60+
61+
5562
5663
intersectionObserverOptions: IntersectionObserverInit = {
5764
root: null,
@@ -188,7 +195,38 @@
188195
}
189196
});
190197
191-
this.$emit('reset');
198+
this.resetInput();
199+
}
200+
201+
debounceInput(e: any) {
202+
const value = e.target.value;
203+
this.$accessor.exercises.fetch({data: {title: value}});
204+
this.$accessor.historical.addHistorical({
205+
tags: this.$accessor.tags.selectedTags,
206+
title: value,
207+
vote: this.$accessor.exercises.search_criterion.vote
208+
})
209+
}
210+
211+
resetInput() {
212+
this.inputText.value = ""
213+
}
214+
215+
resetIfEmpty(e:any) {
216+
const value:string = e.target.value;
217+
218+
if(value === '') {
219+
this.$accessor.exercises.fetch({data: {title: ""}});
220+
}
221+
}
222+
223+
refreshInput() {
224+
this.inputText.value = this.$accessor.exercises.search_criterion.title || '';
225+
}
226+
227+
setInput() {
228+
const title = this.$accessor.exercises.search_criterion.title;
229+
this.inputText.value = !!title ? title : '';
192230
}
193231
194232
handleIntersect(entries: IntersectionObserverEntry[]) {
@@ -202,6 +240,10 @@
202240
targets(): Element[] {
203241
return [this.anchor]
204242
}
243+
244+
mounted() {
245+
this.setInput();
246+
}
205247
}
206248
</script>
207249

@@ -236,6 +278,16 @@
236278
}
237279
}
238280
281+
.input-wrapper--with-icon {
282+
width: 100%;
283+
max-width: 400px;
284+
margin-bottom: 15px;
285+
286+
input {
287+
width: 100%;
288+
}
289+
}
290+
239291
.exercises-content-wrapper {
240292
overflow-y: scroll;
241293
max-height: calc(100% - 66px);

pages/exercices/_id.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<div class="banner__nav banner__nav--with-link">
66
<span>
7-
Exercices > {{exercise.title}}
7+
Bibliothèque > {{exercise.title}}
88
</span>
99
<nuxt-link to="/exercices" tag="span">
1010
<Icon type="arrowLeft" class="reversed-arrow" theme="theme--primary-color-light"/>

pages/exercices/index.vue

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div class="container--with-menu">
3-
<div class="banner search-banner">
4-
<div class="input-wrapper--with-icon one-third input-with--enter-icon">
5-
<Icon type="search"/>
6-
<input ref="inputText" class="input--primary-color" type="text" @input="resetIfEmpty" @keydown.enter="debounceInput"
7-
placeholder="Rechercher">
3+
<div class="banner banner--with-shadow-bottom">
4+
<div class="banner__nav">
5+
<span>
6+
Bibliothèque
7+
</span>
88
</div>
99
</div>
1010

@@ -23,7 +23,7 @@
2323
<FavoritePanel @fetch="setInput"/>
2424
</PanelItem>
2525
</Panel>
26-
<ExercisesPanel @reset="resetInput"/>
26+
<ExercisesPanel ref="exercisesPanel"/>
2727
</div>
2828
</div>
2929
</template>
@@ -73,41 +73,22 @@
7373
middleware: 'exercises-store'
7474
})
7575
export default class extends Vue {
76-
@Ref() inputText!: HTMLInputElement;
7776
78-
debounceInput(e: any) {
79-
const value = e.target.value;
80-
this.$accessor.exercises.fetch({data: {title: value}});
81-
this.$accessor.historical.addHistorical({
82-
tags: this.$accessor.tags.selectedTags,
83-
title: value,
84-
vote: this.$accessor.exercises.search_criterion.vote
85-
})
86-
}
77+
@Ref() exercisesPanel!: ExercisesPanel;
8778
8879
resetInput() {
89-
this.inputText.value = ""
90-
}
91-
92-
resetIfEmpty(e:any) {
93-
const value:string = e.target.value;
94-
95-
if(value === '') {
96-
this.$accessor.exercises.fetch({data: {title: ""}});
97-
}
80+
// @ts-ignore
81+
this.exercisesPanel.resetInput();
9882
}
9983
10084
refreshInput() {
101-
this.inputText.value = this.$accessor.exercises.search_criterion.title || '';
85+
// @ts-ignore
86+
this.exercisesPanel.refreshInput();
10287
}
10388
10489
setInput() {
105-
const title = this.$accessor.exercises.search_criterion.title;
106-
this.inputText.value = !!title ? title : '';
107-
}
108-
109-
mounted() {
110-
this.setInput();
90+
// @ts-ignore
91+
this.exercisesPanel.setInput();
11192
}
11293
}
11394
</script>

0 commit comments

Comments
 (0)