A heading over store tabs, each showing that store on a map.

Last updated

Open block
Show code
---
/**
 * Features tabs map 01: A heading over store tabs, each showing that store on a map.
 *
 * @block contact
 * @order 19
 */
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 Badge from '@/components/apogee/Badge/Badge.astro'
import Tabs from '@/components/apogee/Tabs/Tabs.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { ContactContent } from '@/components/apogee/sections/_shared/contact.ts'

const slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, '-')

/** @composable */
interface Props extends ContactContent {}

const {
  eyebrow = 'Stores',
  heading = 'Our locations',
  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 },
  ],
} = Astro.props
---

<Section spacing="large">
  <div class="mb-12 flex flex-col items-start gap-4">
    {eyebrow && <Badge color="primary" rounded>{eyebrow}</Badge>}
    <SectionHeader heading={plain(heading)} description={description ?? undefined} />
  </div>
  {locations && <Tabs tabs={locations.map((s) => ({ label: s.name, value: slug(s.name) }))} fullWidth>
    {locations.map((s) => (
      <div slot={`panel-${slug(s.name)}`} class="mt-6 flex flex-col gap-4">
        <MapEmbed lat={s.lat} lon={s.lon} title={`Map of our ${s.name} store`} class="h-96 md:h-[30rem]" />
        <p class="apogee-store-address">{s.address}</p>
      </div>
    ))}
  </Tabs>}
</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/features-tabs-map-01

This copies the block to src/components/apogee/blocks/contact/ with everything it uses: Badge, MapEmbed, Section, SectionHeader, Tabs. 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 h2 by default, so the block slots into a page under its h1; item titles are one level down.
  • The department tabs are a tab list with one panel each; without JS every panel shows, one after another.