Skip to content

Commit ddb0cd1

Browse files
UI/UX improvments (candice) and random filter
1 parent 93faf70 commit ddb0cd1

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

src/App.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div class="main-content">
2929
<router-view style="padding-right: 10px; padding-left: 10px" :restaurants="restaurants"/>
3030
</div>
31-
<Button v-if="isMobile" @click="openFilter" class="filter-button">
31+
<Button v-if="isMobile" @click="openFilter" class="filter-button bg-blue-400">
3232
<Filter class="w-4 h-4 mr-2"/> Filter
3333
</Button>
3434
</div>
@@ -65,12 +65,22 @@ const getButtonVariant = (targetPath) => {
6565
return route.path === targetPath ? 'default' : 'outline';
6666
};
6767
68-
// Initialize reactive data
69-
const restaurants = ref(restaurantService.localFetchRestaurants());
68+
// Fisher-Yates shuffle algorithm
69+
const shuffleArray = (array) => {
70+
const shuffledArray = [...array]; // Create a copy of the array
71+
for (let i = shuffledArray.length - 1; i > 0; i--) {
72+
const j = Math.floor(Math.random() * (i + 1));
73+
[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
74+
}
75+
return shuffledArray;
76+
};
77+
78+
// Initialize reactive data with shuffling
79+
const restaurants = ref(shuffleArray(restaurantService.localFetchRestaurants()));
7080
7181
// Update function to handle filtering in FilterComponent
7282
function updatedRestaurants(newData) {
73-
restaurants.value = newData;
83+
restaurants.value = shuffleArray(newData); // Shuffle the new data
7484
}
7585
7686
const isModalOpen = ref(false);
@@ -136,6 +146,7 @@ a {
136146
left: 50%; /* Position the button's left edge at the horizontal center */
137147
transform: translateX(-50%); /* Shift the button back by half its width to center it */
138148
max-width: 400px; /* Optional: Limit the maximum width to keep it visually appealing */
149+
width: 50%;
139150
padding: 10px 20px; /* Adjust for desired button size */
140151
border: none; /* Remove default border */
141152
border-radius: 5px; /* Round the corners */

src/components/FilterComponent.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</Button>
8383
</div>
8484
<div v-show='contentVisibleTags'>
85-
<ScrollArea class="h-28 rounded-md " type="always">
85+
<!-- <ScrollArea class="h-48 rounded-md " type="always"> -->
8686
<FormField name="tags">
8787
<FormItem>
8888
<div class="flex flex-wrap justify-center space-x-1 space-y-1">
@@ -111,12 +111,12 @@
111111
</div>
112112
</FormItem>
113113
</FormField>
114-
</ScrollArea>
114+
<!-- </ScrollArea> -->
115115
</div>
116116

117117
<div class="flex items-center justify-between w-full">
118118
<Button class="mt-3.5 ml-2" variant="ghost" @click="resetToggles">Effacer</Button>
119-
<Button class="mt-3.5 mr-2" type="submit">Chercher</Button>
119+
<Button class="mt-3.5 mr-2 bg-blue-500" type="submit">Chercher</Button>
120120
</div>
121121

122122
</form>
@@ -179,7 +179,7 @@ const applyFilters = (values) => {
179179
const tagMatches = values.tags.length === 0 || item.tags.some(tag => values.tags.includes(tag));
180180
return cravingMatches && cityMatches && tagMatches;
181181
});
182-
emit('filteredRestaurants', filteredRestaurants.value);
182+
emit('filteredRestaurants', filteredRestaurants.value);
183183
};
184184
185185
const onSubmit = handleSubmit((values) => {

src/components/Footer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h1>
44
Created with 💙 by <a href="https://www.instagram.com/camilledrs" target="_blank">@camilledrs</a> and <a href="https://www.instagram.com/quentinchichery" target="_blank">@quentinchichery</a>
55
</h1>
6-
<p>All rights reserved @ 2024</p>
6+
<p>All rights reserved @ 2024 - 2025</p>
77
</div>
88
</template>
99

src/components/RestaurantCard.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ img {
4444
text-align: center;
4545
color: white;
4646
font-weight: bold;
47-
background-color: #454545;
47+
background-color: #454545;
48+
padding: 7px;
4849
}
4950
</style>

src/data/restaurants.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)