Skip to content

Commit 684c112

Browse files
Fix/Responsive Home NavBar e Footer
1 parent 88fe278 commit 684c112

File tree

7 files changed

+92
-66
lines changed

7 files changed

+92
-66
lines changed

src/Footer/Components/BottFooter.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
<!-- Divider -->
2020
<hr class="w-11/12 mx-auto h-1 mb-6 text-gray-200">
2121

22-
<div class="text-[#BDAFA2] py-16">
22+
<div class="text-[#BDAFA2] py-16 sm:scale-90">
2323
<!-- Links -->
2424
<div class="flex justify-center space-x-8 mb-6 text-sm font-medium">
2525
<a

src/Footer/Components/TopFooter.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ export default {
1414
<template>
1515
<div class="w-full py-16">
1616
<!-- Contenitore del top footer -->
17-
<div class="flex flex-col md:flex-row items-center justify-between max-w-6xl mx-auto px-6 space-y-6 md:space-y-0">
17+
<div class="flex flex-col md:flex-row sm:flex-wrap sm:gap-9 sm:justify-center items-center justify-between max-w-6xl mx-auto px-6 space-y-6 md:space-y-0">
1818
<!-- Sezione di Testo -->
1919
<div class="text-center md:text-left">
2020
<h2 class="font-bold text-2xl drop-shadow-md text-white mb-2">
2121
Vuoi inserire i tuoi appartamenti?
2222
</h2>
23-
<p class="text-md text-white drop-shadow-md ">
23+
<p class="text-md text-white drop-shadow-md sm:text-center">
2424
Registrati o fai l'accesso per iniziare subito a condividere i tuoi spazi con gli altri!
2525
</p>
2626
</div>

src/Header/AppHeader.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default {
2222
<div>
2323
<NavBar/>
2424
</div>
25-
<div class="absolute top-[68px] left-0 right-0">
25+
<div class="absolute top-[50px] left-0 right-0">
2626
<JumboStatic />
2727
</div>
2828
</template>

src/Header/Components/JumboStatic.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default {
4141
></div>
4242

4343
<!-- SearchBar -->
44-
<SearchBar class="absolute top-[25%] z-20" />
44+
<SearchBar class="absolute top-[25%] z-20 sm:w-[270px]" />
4545

4646
<!-- Sfumatura graduale in basso -->
4747
<div

src/Header/Components/NavBar.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ export default {
6262
<template>
6363
<header
6464
class='w-full z-50 transition-all duration-300 shadow-nav fixed top-0 left-0 right-0 bg-[#B49578] py-4'>
65-
<div class="container mx-auto flex items-center justify-between px-4 md:px-8">
65+
<div class="container mx-auto flex items-center justify-between px-4 sm:px-3 md:px-8">
6666

6767
<!-- Logo -->
68-
<div class="text-[#EDEEF0] text-2xl w-14 h-10 font-bold">
68+
<div class="text-[#EDEEF0] text-2xl w-14 h-10 font-bold sm:hidden">
6969
<router-link to="/" class="transition-all ease-in-out duration-300 hover:opacity-70 flex items-center">
7070
<span>MilanBnB</span>
7171
</router-link>

src/components/ApartmentList.vue

+78-59
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ export default {
88
return {
99
store,
1010
apartments: [],
11-
perPage: 4,
12-
currentPage: 0,
13-
hasAnimated: false,
14-
transition: false
11+
currentIndex: 0,
12+
itemsPerPage: 4, // Numero di card visibili per volta
1513
};
1614
},
1715
@@ -21,6 +19,12 @@ export default {
2119
2220
mounted() {
2321
this.getApartments();
22+
this.updateItemsPerPage();
23+
window.addEventListener('resize', this.updateItemsPerPage);
24+
},
25+
26+
beforeDestroy() {
27+
window.removeEventListener('resize', this.updateItemsPerPage);
2428
},
2529
2630
watch: {
@@ -32,94 +36,104 @@ export default {
3236
methods: {
3337
getApartments() {
3438
axios
35-
.get('http://127.0.0.1:8000/api/apartments')
39+
.get('http://127.0.0.1:8000/api/apartments')
3640
.then((res) => {
3741
this.apartments = res.data.data.filter(
38-
apartment => apartment.is_visible && apartment.sponsorships && apartment.sponsorships.length > 0 && !apartment.sponsorships.some(sponsorship => sponsorship.name === 'No sponsorship')
42+
(apartment) =>
43+
apartment.is_visible &&
44+
apartment.sponsorships &&
45+
apartment.sponsorships.length > 0 &&
46+
!apartment.sponsorships.some((sponsorship) => sponsorship.name === 'No sponsorship')
3947
);
4048
4149
this.apartments.sort((a, b) => {
4250
const priority = { Gold: 1, Silver: 2, Bronze: 3 };
43-
const aSponsor = a.sponsorships[0]?.name || "Bronze";
44-
const bSponsor = b.sponsorships[0]?.name || "Bronze";
51+
const aSponsor = a.sponsorships[0]?.name || 'Bronze';
52+
const bSponsor = b.sponsorships[0]?.name || 'Bronze';
4553
return priority[aSponsor] - priority[bSponsor];
4654
});
4755
4856
store.suggestions = this.apartments.map((apartment) => apartment.address);
49-
5057
})
5158
.catch((error) => console.error('Errore:', error));
5259
},
5360
54-
NextPage() {
55-
if (this.currentPage < Math.ceil(this.apartments.length / this.perPage) - 1) {
56-
this.currentPage++;
57-
}
58-
this.hasAnimated = true;
59-
},
61+
updateItemsPerPage() {
62+
if (window.innerWidth >= 1024) {
63+
this.itemsPerPage = 4;
64+
} else if (window.innerWidth >= 768) {
65+
this.itemsPerPage = 3;
66+
} else {
67+
this.itemsPerPage = 1;
68+
}
69+
},
70+
71+
NextCard() {
72+
if (this.currentIndex < this.apartments.length - this.itemsPerPage) {
73+
this.currentIndex = this.currentIndex + this.itemsPerPage;
74+
}
75+
},
6076
61-
PrevPage() {
62-
if (this.currentPage > 0) {
63-
this.currentPage--;
77+
PrevCard() {
78+
if (this.currentIndex > 0) {
79+
this.currentIndex = this.currentIndex - this.itemsPerPage;
6480
}
65-
}
81+
},
6682
},
6783
6884
computed: {
69-
paginatedApartments() {
70-
const start = this.currentPage * this.perPage;
71-
const end = start + this.perPage;
72-
return this.apartments.slice(start, end);
85+
visibleApartments() {
86+
return this.apartments.slice(this.currentIndex, this.currentIndex + this.itemsPerPage);
7387
},
7488
},
7589
};
7690
</script>
7791
7892
<template>
79-
<div class="max-w-7xl mx-auto h-[432px] relative">
80-
<!-- Visualizzazione degli appartamenti -->
81-
<transition-group
82-
name="fade"
83-
tag="div"
84-
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6"
85-
:key="currentPage"
86-
>
87-
<Card
88-
v-for="(property, index) in paginatedApartments"
89-
:key="property.id"
90-
:id="property.id"
91-
:user_id="property.user_id"
92-
:title="property.title"
93-
:rooms="property.rooms"
94-
:beds="property.beds"
95-
:bathrooms="property.bathrooms"
96-
:square_meters="property.square_meters"
97-
:address="property.address"
98-
:latitude="property.latitude"
99-
:longitude="property.longitude"
100-
:image="property.cover_image"
101-
:services="property.services"
102-
:is_visible="Boolean(property.is_visible)"
103-
class="transform transition duration-500 ease-in-out hover:scale-105"
104-
/>
105-
</transition-group>
106-
107-
<!-- Bottone per la pagina precedente -->
93+
<div class="max-w-7xl mx-auto relative px-8 sm:px-6 lg:px-8 lg:scale-75 2xl:scale-90 md:w-full md:scale-75 xl:scale-90">
94+
<!-- Bottone per la slide precedente -->
10895
<button
109-
@click="PrevPage"
110-
class="absolute top-1/2 -left-20 transform -translate-y-1/2 w-10 h-10 flex items-center justify-center bg-[#B49578] text-white rounded-full shadow-md hover:bg-[#EDEEF0] hover:text-[#B49578] hover:shadow-lg transition-all hover:-translate-x-1 duration-300 ease-in-out"
96+
@click="PrevCard"
97+
class="absolute top-1/2 -left-12 transform -translate-y-1/2 w-8 h-8 sm:w-10 sm:h-10 flex items-center justify-center bg-[#B49578] text-white rounded-full shadow-md hover:bg-[#EDEEF0] hover:text-[#B49578] hover:shadow-lg transition-all hover:-translate-x-1 duration-300 ease-in-out z-10"
11198
>
112-
<span class="text-xl font-bold">
99+
<span class="text-sm sm:text-xl font-bold">
113100
<i class="fa-solid fa-arrow-left"></i>
114101
</span>
115102
</button>
116103
117-
<!-- Bottone per la pagina successiva -->
104+
<!-- Visualizzazione degli appartamenti in modalità carosello -->
105+
<div class="overflow-visible">
106+
<div
107+
class="flex gap-6 transition-all ease-in-out duration-500"
108+
:style="{ transform: `-translateX(${currentIndex * (100 / itemsPerPage)}%)` }"
109+
>
110+
<Card
111+
v-for="(property, index) in visibleApartments"
112+
:key="property.id"
113+
:id="property.id"
114+
:user_id="property.user_id"
115+
:title="property.title"
116+
:rooms="property.rooms"
117+
:beds="property.beds"
118+
:bathrooms="property.bathrooms"
119+
:square_meters="property.square_meters"
120+
:address="property.address"
121+
:latitude="property.latitude"
122+
:longitude="property.longitude"
123+
:image="property.cover_image"
124+
:services="property.services"
125+
:is_visible="Boolean(property.is_visible)"
126+
class="w-full md:w-full lg:w-1/3 sm:w-full transform transition duration-500 ease-in-out hover:scale-105"
127+
/>
128+
</div>
129+
</div>
130+
131+
<!-- Bottone per la slide successiva -->
118132
<button
119-
@click="NextPage"
120-
class="absolute top-1/2 -right-20 transform -translate-y-1/2 w-10 h-10 flex items-center justify-center bg-[#B49578] text-white rounded-full shadow-md hover:bg-[#EDEEF0] hover:text-[#B49578] hover:shadow-lg transition-all hover:translate-x-1 duration-300 ease-in-out"
133+
@click="NextCard"
134+
class="absolute top-1/2 -right-12 transform -translate-y-1/2 w-8 h-8 sm:w-10 sm:h-10 flex items-center justify-center bg-[#B49578] text-white rounded-full shadow-md hover:bg-[#EDEEF0] hover:text-[#B49578] hover:shadow-lg transition-all hover:translate-x-1 duration-300 ease-in-out z-10"
121135
>
122-
<span class="text-xl font-bold">
136+
<span class="text-sm sm:text-xl font-bold">
123137
<i class="fa-solid fa-arrow-right"></i>
124138
</span>
125139
</button>
@@ -133,6 +147,7 @@ export default {
133147
</div>
134148
</template>
135149
150+
136151
<style scoped>
137152
@keyframes fadeIn {
138153
from {
@@ -157,4 +172,8 @@ export default {
157172
opacity: 0;
158173
transform: translateX(20px);
159174
}
175+
176+
.scale-25{
177+
scale: 0.25;
178+
}
160179
</style>

tailwind.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
export default {
33
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
44
theme: {
5+
screens: {
6+
'2xl': {'max': '1535px'}, // => @media (max-width: 1535px) { ... }
7+
'xl': {'max': '1279px'}, // => @media (max-width: 1279px) { ... }
8+
'lg': {'max': '1023px'}, // => @media (max-width: 1023px) { ... }
9+
'md': {'max': '767px'}, // => @media (max-width: 767px) { ... }
10+
'sm': {'max': '639px'}, // => @media (max-width: 639px) { ... }
11+
},
512
extend: {},
613
},
714
plugins: [],

0 commit comments

Comments
 (0)