Centred map
A centred heading over store addresses on either side of a map.
Last updated
---
/**
* Centred map: A centred heading over store addresses on either side of a map.
*
* @block contact
* @order 18
*/
import Section from '@/components/apogee/Section/Section.astro'
import SectionHeader from '@/components/apogee/SectionHeader/SectionHeader.astro'
import MapEmbed from '@/components/apogee/MapEmbed/MapEmbed.astro'
import Heading from '@/components/apogee/Heading/Heading.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { ContactContent } from '@/components/apogee/sections/_shared/contact.ts'
/** @composable */
interface Props extends ContactContent {
/** 1 when the block opens a page; its items move one level down with it. */
headingLevel?: 1 | 2
}
const {
headingLevel = 2,
eyebrow = 'Locations',
heading = 'Visit our stores',
description = 'Find us at these locations.',
locations = [
{ name: 'Melbourne', address: '100 Flinders Street, Melbourne VIC 3000 AU', lat: -37.8183, lon: 144.9671 },
{ name: 'Sydney', address: '100 George Street, Sydney NSW 2000 AU', lat: -33.8615, lon: 151.2073 },
{ name: 'Byron Bay', address: '50 Jonson Street, Byron Bay NSW 2481 AU', lat: -28.6431, lon: 153.6139 },
{ name: 'London', address: '100 Oxford Street, London W1D 1LL UK', lat: 51.5154, lon: -0.141 },
{ name: 'San Francisco', address: '100 Market Street, San Francisco, CA 94105 US', lat: 37.7936, lon: -122.395 },
{ name: 'Stockholm', address: 'Drottninggatan 100, 111 60 Stockholm SE', lat: 59.3326, lon: 18.0649 },
],
} = Astro.props
const office = locations?.[0]
// Half the locations sit each side of the map.
const half = Math.ceil((locations?.length ?? 0) / 2)
const start = locations?.slice(0, half) ?? []
const end = locations?.slice(half) ?? []
const itemLevel = headingLevel === 1 ? (2 as const) : (3 as const)
---
<Section spacing="large">
<SectionHeader headingLevel={headingLevel} eyebrow={eyebrow ?? undefined} heading={plain(heading)} description={description ?? undefined} align="center" class="mb-16" />
<div class="grid gap-12 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.5fr)_minmax(0,1fr)]">
<ul class="list-none p-0 flex flex-col gap-8">
{start.map((s) => (
<li class="flex flex-col gap-1">
<Heading as={itemLevel === 2 ? 'h2' : 'h3'} size="h6">{s.name}</Heading>
<p class="apogee-store-address">{s.address}</p>
</li>
))}
</ul>
{office && <MapEmbed lat={office.lat} lon={office.lon} title={`Map of our ${office.name} office`} class="min-h-96 max-lg:hidden" />}
<ul class="list-none p-0 flex flex-col gap-8">
{end.map((s) => (
<li class="flex flex-col gap-1">
<Heading as={itemLevel === 2 ? 'h2' : 'h3'} size="h6">{s.name}</Heading>
<p class="apogee-store-address">{s.address}</p>
</li>
))}
</ul>
</div>
</Section>
<style>
.apogee-store-address {
color: var(--foreground-neutral-faded);
}
:global(:is(.bg-primary, .bg-inverted)) .apogee-store-address {
color: inherit;
opacity: 0.85;
}
</style>
Show codeHide code
---
/**
* Centred map: A centred heading over store addresses on either side of a map.
*
* @block contact
* @order 18
*/
import Section from '@/components/apogee/Section/Section.astro'
import SectionHeader from '@/components/apogee/SectionHeader/SectionHeader.astro'
import MapEmbed from '@/components/apogee/MapEmbed/MapEmbed.astro'
import Heading from '@/components/apogee/Heading/Heading.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { ContactContent } from '@/components/apogee/sections/_shared/contact.ts'
/** @composable */
interface Props extends ContactContent {
/** 1 when the block opens a page; its items move one level down with it. */
headingLevel?: 1 | 2
}
const {
headingLevel = 2,
eyebrow = 'Locations',
heading = 'Visit our stores',
description = 'Find us at these locations.',
locations = [
{ name: 'Melbourne', address: '100 Flinders Street, Melbourne VIC 3000 AU', lat: -37.8183, lon: 144.9671 },
{ name: 'Sydney', address: '100 George Street, Sydney NSW 2000 AU', lat: -33.8615, lon: 151.2073 },
{ name: 'Byron Bay', address: '50 Jonson Street, Byron Bay NSW 2481 AU', lat: -28.6431, lon: 153.6139 },
{ name: 'London', address: '100 Oxford Street, London W1D 1LL UK', lat: 51.5154, lon: -0.141 },
{ name: 'San Francisco', address: '100 Market Street, San Francisco, CA 94105 US', lat: 37.7936, lon: -122.395 },
{ name: 'Stockholm', address: 'Drottninggatan 100, 111 60 Stockholm SE', lat: 59.3326, lon: 18.0649 },
],
} = Astro.props
const office = locations?.[0]
// Half the locations sit each side of the map.
const half = Math.ceil((locations?.length ?? 0) / 2)
const start = locations?.slice(0, half) ?? []
const end = locations?.slice(half) ?? []
const itemLevel = headingLevel === 1 ? (2 as const) : (3 as const)
---
<Section spacing="large">
<SectionHeader headingLevel={headingLevel} eyebrow={eyebrow ?? undefined} heading={plain(heading)} description={description ?? undefined} align="center" class="mb-16" />
<div class="grid gap-12 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.5fr)_minmax(0,1fr)]">
<ul class="list-none p-0 flex flex-col gap-8">
{start.map((s) => (
<li class="flex flex-col gap-1">
<Heading as={itemLevel === 2 ? 'h2' : 'h3'} size="h6">{s.name}</Heading>
<p class="apogee-store-address">{s.address}</p>
</li>
))}
</ul>
{office && <MapEmbed lat={office.lat} lon={office.lon} title={`Map of our ${office.name} office`} class="min-h-96 max-lg:hidden" />}
<ul class="list-none p-0 flex flex-col gap-8">
{end.map((s) => (
<li class="flex flex-col gap-1">
<Heading as={itemLevel === 2 ? 'h2' : 'h3'} size="h6">{s.name}</Heading>
<p class="apogee-store-address">{s.address}</p>
</li>
))}
</ul>
</div>
</Section>
<style>
.apogee-store-address {
color: var(--foreground-neutral-faded);
}
:global(:is(.bg-primary, .bg-inverted)) .apogee-store-address {
color: inherit;
opacity: 0.85;
}
</style>Add
npx @ava-ui/apogee add contact/centered-map
This copies the block to src/components/apogee/blocks/contact/ with everything it uses: Heading, MapEmbed, Section, SectionHeader. Every piece of copy is a prop, with the sample copy as its default. Pass yours, or null to hide a part; see copy is props.
Accessibility
- The heading is an
h2by default, so the block slots into a page under itsh1; item titles are one level down.
Related
ContactFormThe message form contact pages share; names, email, an optional phone with a country code, the message, an optional services checklist and a privacy checkbox.
ContactMethodOne way to reach you; an icon, a title, a line about it and the address, number or link, plain or on a card.
MapEmbedAn embedded street map centred on a place, with a marker and a link to the full map; no key, no script.
WorldMapA dotted world map with office pins; each pin names its place on hover or focus and links to it on a full map.