A brand-colour sidebar with contact methods and links (from lg) beside a form with a services checklist.

Last updated

Open block
Show code
---
/**
 * Simple form 05: A brand-colour sidebar with contact methods and links (from lg) beside a form with a services checklist.
 *
 * @block contact
 * @order 31
 */
import { AtSign, Globe, LifeBuoy, Mail, MapPin, MessageCircle, MessagesSquare, Phone, Rss, Users, Video } from '@lucide/astro'
import Section from '@/components/apogee/Section/Section.astro'
import SectionHeader from '@/components/apogee/SectionHeader/SectionHeader.astro'
import ContactForm from '@/components/apogee/ContactForm/ContactForm.astro'
import ContactMethod from '@/components/apogee/ContactMethod/ContactMethod.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { ContactContent } from '@/components/apogee/sections/_shared/contact.ts'

const icons = { mail: Mail, phone: Phone, 'map-pin': MapPin, 'message-circle': MessageCircle, 'messages-square': MessagesSquare, 'life-buoy': LifeBuoy } as const

/** @composable */
interface Props extends ContactContent {
  /** 1 when the block opens a page; its items move one level down with it. */
  headingLevel?: 1 | 2
  /** The heading over the form. @category content */
  formHeading?: string
  /** @category content */
  formDescription?: string | null
}
const {
  headingLevel = 2,
  heading = 'Get in touch',
  description = "We'd love to hear from you.",
  details = [
    { icon: 'message-circle', label: 'Live chat', description: 'Our friendly team is here to help.', value: 'Start new chat', href: '#chat' },
    { icon: 'map-pin', label: 'Office', description: 'Come say hello at our office HQ.', value: '100 Flinders Street, Melbourne VIC 3000 AU', href: '#map' },
    { icon: 'phone', label: 'Phone', description: 'Mon–Fri from 8am to 5pm.', value: '+1 (555) 000-0000', href: 'tel:+15550000000' },
  ],
  formHeading = 'Level up your brand',
  formDescription = 'You can reach us anytime via hi@example.com.',
  action,
  method,
  submitLabel = 'Send message',
} = Astro.props
const itemLevel = headingLevel === 1 ? (2 as const) : (3 as const)
---

<Section spacing="none" container={false}>
  <div class="grid lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]">
    <aside class="flex flex-col justify-between gap-12 bg-primary px-gutter py-section text-on-primary max-lg:hidden lg:px-12" aria-label="Contact details">
      <div>
        <SectionHeader headingLevel={headingLevel} heading={plain(heading)} description={description ?? undefined} background="primary" class="mb-12" />
        {details && <ul class="list-none p-0 flex flex-col gap-8">
    {details.map((d) => {
      const Icon = icons[d.icon]
      return <li><ContactMethod headingLevel={itemLevel} title={d.label} description={d.description} link={d.href ? { label: d.value, href: d.href } : undefined} inline><Icon slot="icon" class="size-6" aria-hidden="true" />{!d.href && <p>{d.value}</p>}</ContactMethod></li>
    })}
  </ul>}
      </div>
      <ul class="flex list-none gap-4 p-0" aria-label="Elsewhere">
        {[
          { icon: Globe, label: 'Website' },
          { icon: Rss, label: 'Blog' },
          { icon: Users, label: 'Community' },
          { icon: Video, label: 'Videos' },
          { icon: AtSign, label: 'Newsletter' },
        ].map((s) => (
          <li><a href="#" aria-label={s.label} class="grid size-6 place-items-center rounded-xs opacity-80 transition-opacity hover:opacity-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus"><s.icon class="size-6" aria-hidden="true" /></a></li>
        ))}
      </ul>
    </aside>
    <div class="px-gutter py-section lg:px-16">
      <div class="mx-auto max-w-xl">
        <SectionHeader heading={plain(formHeading)} description={formDescription ?? undefined} class="mb-12" />
        <ContactForm services={['Website design', 'Content creation', 'UX design', 'Strategy & consulting', 'User research', 'Other']} action={action} method={method} submitLabel={submitLabel} />
      </div>
    </div>
  </div>
</Section>

Add

npx @ava-ui/apogee add contact/simple-form-05

This copies the block to src/components/apogee/blocks/contact/ with everything it uses: ContactForm, ContactMethod, 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 h2 by default, so the block slots into a page under its h1; item titles are one level down.