feat(SW-68): add static map component
This commit is contained in:
@@ -42,3 +42,5 @@ OPENSSL_MODULES="/var/lang/lib/ossl-modules"
|
|||||||
PUBLIC_URL="http://localhost:3000"
|
PUBLIC_URL="http://localhost:3000"
|
||||||
AUTH_URL="$PUBLIC_URL/api/web/auth"
|
AUTH_URL="$PUBLIC_URL/api/web/auth"
|
||||||
NEXTAUTH_URL="$PUBLIC_URL/api/web/auth"
|
NEXTAUTH_URL="$PUBLIC_URL/api/web/auth"
|
||||||
|
|
||||||
|
NEXT_PUBLIC_GOOGLE_STATIC_MAP_KEY=""
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
.main {
|
.main {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, minmax(min-content, max-content));
|
grid-template-columns: repeat(2, minmax(min-content, max-content));
|
||||||
|
gap: var(--Spacing-x4);
|
||||||
padding: var(--Spacing-x4) var(--Spacing-x4) 0 var(--Spacing-x4);
|
padding: var(--Spacing-x4) var(--Spacing-x4) 0 var(--Spacing-x4);
|
||||||
height: 100dvh;
|
height: 100dvh;
|
||||||
background-color: var(--Scandic-Brand-Warm-White);
|
background-color: var(--Scandic-Brand-Warm-White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
padding-left: var(--Spacing-x0);
|
||||||
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: var(--Spacing-x4);
|
gap: var(--Spacing-x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: var(--Spacing-x2) var(--Spacing-x0);
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import { serverClient } from "@/lib/trpc/server"
|
|||||||
|
|
||||||
import HotelCard from "@/components/HotelReservation/HotelCard"
|
import HotelCard from "@/components/HotelReservation/HotelCard"
|
||||||
import HotelFilter from "@/components/HotelReservation/SelectHotel/HotelFilter"
|
import HotelFilter from "@/components/HotelReservation/SelectHotel/HotelFilter"
|
||||||
|
import { ChevronRightIcon } from "@/components/Icons"
|
||||||
|
import StaticMap from "@/components/Maps/StaticMap"
|
||||||
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
|
import { getIntl } from "@/i18n"
|
||||||
|
|
||||||
import styles from "./page.module.css"
|
import styles from "./page.module.css"
|
||||||
|
|
||||||
@@ -10,6 +14,8 @@ import { LangParams, PageArgs } from "@/types/params"
|
|||||||
export default async function SelectHotelPage({
|
export default async function SelectHotelPage({
|
||||||
params,
|
params,
|
||||||
}: PageArgs<LangParams>) {
|
}: PageArgs<LangParams>) {
|
||||||
|
const { formatMessage } = await getIntl()
|
||||||
|
|
||||||
const { attributes } = await serverClient().hotel.getHotel({
|
const { attributes } = await serverClient().hotel.getHotel({
|
||||||
hotelId: "d98c7ab1-ebaa-4102-b351-758daf1ddf55",
|
hotelId: "d98c7ab1-ebaa-4102-b351-758daf1ddf55",
|
||||||
language: params.lang,
|
language: params.lang,
|
||||||
@@ -20,14 +26,36 @@ export default async function SelectHotelPage({
|
|||||||
hotelId: "d98c7ab1-ebaa-4102-b351-758daf1ddf55",
|
hotelId: "d98c7ab1-ebaa-4102-b351-758daf1ddf55",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const tempSearchTerm = "Stockholm"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className={styles.main}>
|
<>
|
||||||
<HotelFilter filters={hotelFilters} />
|
<main className={styles.main}>
|
||||||
<section className={styles.section}>
|
<nav className={styles.nav}>
|
||||||
{hotels.map((hotel) => (
|
<StaticMap
|
||||||
<HotelCard key={hotel.name} hotel={hotel} />
|
city={tempSearchTerm}
|
||||||
))}
|
width={340}
|
||||||
</section>
|
height={180}
|
||||||
</main>
|
zoomLevel={11}
|
||||||
|
mapType="roadmap"
|
||||||
|
/>
|
||||||
|
<Link
|
||||||
|
className={styles.link}
|
||||||
|
color="burgundy"
|
||||||
|
variant="underscored"
|
||||||
|
href="#"
|
||||||
|
>
|
||||||
|
{formatMessage({ id: "Show map" })}
|
||||||
|
<ChevronRightIcon color="burgundy" className={styles.icon} />
|
||||||
|
</Link>
|
||||||
|
<HotelFilter filters={hotelFilters} />
|
||||||
|
</nav>
|
||||||
|
<section className={styles.section}>
|
||||||
|
{hotels.map((hotel) => (
|
||||||
|
<HotelCard key={hotel.name} hotel={hotel} />
|
||||||
|
))}
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
background-color: var(--Base-Surface-Primary-light-Normal);
|
background-color: var(--Base-Surface-Primary-light-Normal);
|
||||||
border: 1px solid var(--Base-Border-Subtle);
|
border: 1px solid var(--Base-Border-Subtle);
|
||||||
border-radius: var(--Corner-radius-Small);
|
border-radius: var(--Corner-radius-Small);
|
||||||
|
overflow: hidden;
|
||||||
height: 460px;
|
height: 460px;
|
||||||
width: 480px;
|
width: 480px;
|
||||||
}
|
}
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
height: auto;
|
height: auto;
|
||||||
max-height: 180px;
|
max-height: 180px;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
overflow: hidden;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
components/Maps/StaticMap/index.tsx
Normal file
24
components/Maps/StaticMap/index.tsx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import Image from "@/components/Image"
|
||||||
|
|
||||||
|
import { StaticMapProps } from "@/types/components/maps/staticMap/staticMap"
|
||||||
|
|
||||||
|
export default function StaticMap({
|
||||||
|
city,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
zoomLevel,
|
||||||
|
mapType,
|
||||||
|
}: StaticMapProps) {
|
||||||
|
const apiKey = process.env.NEXT_PUBLIC_GOOGLE_STATIC_MAP_KEY
|
||||||
|
const mapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${city}&zoom=${zoomLevel}&size=${width}x${height}&maptype=${mapType}&key=${apiKey}`
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Image
|
||||||
|
src=""
|
||||||
|
overrideSrc={mapUrl}
|
||||||
|
alt={`Map of ${city} city center`}
|
||||||
|
width={width}
|
||||||
|
height={height}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -126,5 +126,6 @@
|
|||||||
"Zip code": "Postnummer",
|
"Zip code": "Postnummer",
|
||||||
"Room facilities": "Værelsesfaciliteter",
|
"Room facilities": "Værelsesfaciliteter",
|
||||||
"Hotel facilities": "Hotel faciliteter",
|
"Hotel facilities": "Hotel faciliteter",
|
||||||
"Hotel surroundings": "Hotel omgivelser"
|
"Hotel surroundings": "Hotel omgivelser",
|
||||||
|
"Show map": "Vis kort"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,5 +126,6 @@
|
|||||||
"Zip code": "PLZ",
|
"Zip code": "PLZ",
|
||||||
"Room facilities": "Zimmerausstattung",
|
"Room facilities": "Zimmerausstattung",
|
||||||
"Hotel facilities": "Hotel-Infos",
|
"Hotel facilities": "Hotel-Infos",
|
||||||
"Hotel surroundings": "Umgebung des Hotels"
|
"Hotel surroundings": "Umgebung des Hotels",
|
||||||
|
"Show map": "Karte anzeigen"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,5 +131,6 @@
|
|||||||
"Zip code": "Zip code",
|
"Zip code": "Zip code",
|
||||||
"Room facilities": "Room facilities",
|
"Room facilities": "Room facilities",
|
||||||
"Hotel facilities": "Hotel facilities",
|
"Hotel facilities": "Hotel facilities",
|
||||||
"Hotel surroundings": "Hotel surroundings"
|
"Hotel surroundings": "Hotel surroundings",
|
||||||
|
"Show map": "Show map"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,5 +126,6 @@
|
|||||||
"Zip code": "Postinumero",
|
"Zip code": "Postinumero",
|
||||||
"Room facilities": "Huoneen varustelu",
|
"Room facilities": "Huoneen varustelu",
|
||||||
"Hotel facilities": "Hotellin palvelut",
|
"Hotel facilities": "Hotellin palvelut",
|
||||||
"Hotel surroundings": "Hotellin ympäristö"
|
"Hotel surroundings": "Hotellin ympäristö",
|
||||||
|
"Show map": "Näytä kartta"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,5 +126,6 @@
|
|||||||
"Zip code": "Post kode",
|
"Zip code": "Post kode",
|
||||||
"Room facilities": "Romfasiliteter",
|
"Room facilities": "Romfasiliteter",
|
||||||
"Hotel facilities": "Hotelfaciliteter",
|
"Hotel facilities": "Hotelfaciliteter",
|
||||||
"Hotel surroundings": "Hotellomgivelser"
|
"Hotel surroundings": "Hotellomgivelser",
|
||||||
|
"Show map": "Vis kart"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,5 +129,6 @@
|
|||||||
"Zip code": "Postnummer",
|
"Zip code": "Postnummer",
|
||||||
"Room facilities": "Rumlfaciliteter",
|
"Room facilities": "Rumlfaciliteter",
|
||||||
"Hotel facilities": "Hotellfaciliteter",
|
"Hotel facilities": "Hotellfaciliteter",
|
||||||
"Hotel surroundings": "Hotellomgivning"
|
"Hotel surroundings": "Hotellomgivning",
|
||||||
|
"Show map": "Visa karta"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ const nextConfig = {
|
|||||||
protocol: "https",
|
protocol: "https",
|
||||||
hostname: "imagevault.scandichotels.com",
|
hostname: "imagevault.scandichotels.com",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
protocol: "https",
|
||||||
|
hostname: "maps.googleapis.com",
|
||||||
|
pathname: "/maps/api/staticmap?**",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
7
types/components/maps/staticMap/staticMap.ts
Normal file
7
types/components/maps/staticMap/staticMap.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export type StaticMapProps = {
|
||||||
|
city: string
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
zoomLevel: number
|
||||||
|
mapType: "roadmap" | "satellite" | "terrain" | "hybrid"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user