diff --git a/index.html b/index.html index 6c0fb33..14db6af 100644 --- a/index.html +++ b/index.html @@ -30,7 +30,8 @@

AirBnB Search Bar:

showSearch = false; selectedTab = 'Where'; destination = ''; - time = 'Any week'; + + totalMonths = 12; checkIn = ''; checkOut = ''; @@ -48,6 +49,31 @@

AirBnB Search Bar:

scrollPosition = 'middle'; SCROLL_OFFSET = 128; + + function getStartAndEndMonth(totalMonths) { + const today = new Date(); + const startMonth = today.getMonth() + 1; + const endMonth = today.getMonth() + 1 + totalMonths; + + const startDate = new Date(today.getFullYear(), startMonth, 1); + const endDate = new Date(today.getFullYear(), endMonth, 1); + return [startDate, endDate]; + } + + function getSliderValue(position) { + const rect = document.querySelector('.slider').getBoundingClientRect(); + const dx = position.x - rect.left - rect.width / 2; + const dy = position.y - rect.top - rect.height / 2; + const theta = Math.atan2(dy, dx); + const left = 50 + 50 * Math.cos(theta); + const top = 50 + 50 * Math.sin(theta); + let percentage = (theta + Math.PI / 2) / (2 * Math.PI) * 100; + + if (percentage < 0) + percentage += 100; + + return { left, top, percentage }; + }
@@ -213,7 +239,29 @@

AirBnB Search Bar:

@@ -371,7 +419,7 @@

AirBnB Search Bar:

type="button" class="py-2 px-6 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap rounded-full cursor-pointer transition-colors duration-100" :class="whenSelectedTab === 'Dates' ? 'bg-white ring-1 ring-gray-300' : 'hover:bg-gray-300'" - :click="whenSelectedTab = 'Dates'; selectedTab = 'Check In'; time = ''" + :click="whenSelectedTab = 'Dates'; selectedTab = 'Check In';" > Dates @@ -379,26 +427,7 @@

AirBnB Search Bar:

type="button" class="py-2 px-6 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap rounded-full cursor-pointer transition-colors duration-100" :class="whenSelectedTab === 'Months' ? 'bg-white ring-1 ring-gray-300' : 'hover:bg-gray-300'" - :click="whenSelectedTab = 'Months'; - selectedTab = 'When'; - const today = new Date(); - const startMonth = today.getMonth() + 1; - const endMonth = today.getMonth() + 1 + 3; - - const startDate = new Date(today.getFullYear(), startMonth, 1); - const endDate = new Date(today.getFullYear(), endMonth, 1); - - time = startDate.toLocaleString('default', { - month: 'short', - year: 'numeric', - day: 'numeric', - }); - time += ' - '; - time += endDate.toLocaleString('default', { - month: 'short', - year: 'numeric', - day: 'numeric', - });" + :click="whenSelectedTab = 'Months'; selectedTab = 'When';" > Months @@ -406,9 +435,7 @@

AirBnB Search Bar:

type="button" class="py-2 px-6 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap rounded-full cursor-pointer transition-colors duration-100" :class="whenSelectedTab === 'Flexible' ? 'bg-white ring-1 ring-gray-300' : 'hover:bg-gray-300'" - :click="whenSelectedTab = 'Flexible'; - selectedTab = 'When'; - time = 'Any week'" + :click="whenSelectedTab = 'Flexible'; selectedTab = 'When';" > Flexible @@ -426,10 +453,7 @@

AirBnB Search Bar:

type="button" class="py-2 px-4 text-base text-gray-900 rounded-full" :class="whenHowLong === 'Weekend' ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'" - :click="whenHowLong = 'Weekend'; - time = selectedMonths.length - ? `Weekend in ${selectedMonths.join(', ')}` - : 'Any weekend'" + :click="whenHowLong = 'Weekend';" > Weekend @@ -437,10 +461,7 @@

AirBnB Search Bar:

type="button" class="py-2 px-4 text-base text-gray-900 rounded-full" :class="whenHowLong === 'Week' ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'" - :click="whenHowLong = 'Week'; - time = selectedMonths.length - ? `Week in ${selectedMonths.join(', ')}` - : 'Any week'" + :click="whenHowLong = 'Week';" > Week @@ -448,10 +469,7 @@

AirBnB Search Bar:

type="button" class="py-2 px-4 text-base text-gray-900 rounded-full" :class="whenHowLong === 'Month' ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'" - :click="whenHowLong = 'Month'; - time = selectedMonths.length - ? `Month in ${selectedMonths.join(', ')}` - : 'Any month'" + :click="whenHowLong = 'Month';" > Month @@ -495,10 +513,7 @@

AirBnB Search Bar:

type="button" class="h-36 w-28 flex flex-col items-center justify-center gap-1 text-center text-gray-900 rounded-2xl" :class="selectedMonths.includes(month) ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'" - :click="selectedMonths = selectedMonths.toggle(month); - time = selectedMonths.length - ? `${whenHowLong} in ${selectedMonths.join(', ')}` - : `Any ${whenHowLong[0].toLowerCase() + whenHowLong.slice(1)}`" + :click="selectedMonths = selectedMonths.toggle(month);" >

AirBnB Search Bar:

When's your trip?
+ + + + +
+ + + + +
+
+
+
+
+
+
+ + +
+ + months +
+