A centred heading and two buttons over a video on a slanted band.

Last updated

Open block
Show code
---
/**
 * Abstract angles 01: A centred heading and two buttons over a video on a slanted band.
 *
 * @block hero
 * @order 9
 */
import { ArrowRight, CirclePlay } from '@lucide/astro'
import Section from '@/components/apogee/Section/Section.astro'
import Heading from '@/components/apogee/Heading/Heading.astro'
import Button from '@/components/apogee/Button/Button.astro'
import Link from '@/components/apogee/Link/Link.astro'
import Badge from '@/components/apogee/Badge/Badge.astro'
import VideoPlayer from '@/components/apogee/VideoPlayer/VideoPlayer.astro'
import { plain, type HeroContent } from '@/components/apogee/sections/_shared/spine.ts'

/** @composable */
interface Props extends HeroContent {
  /** Plays in place of an image; `captions` is a WebVTT file. @category content */
  video?: { src: string; poster: string; captions: string; title: string } | null
}

const {
  announcement = { badge: 'New feature', label: 'Check out the team dashboard', href: '#' },
  heading = 'High-performing remote teams. The future of work.',
  description = 'Self-serve team engagement tools and analytics. Support your managers and keep people engaged from anywhere.',
  primaryAction = { label: 'Sign up', href: '#' },
  secondaryAction = { label: 'Demo', href: '#' },
  video = { src: '/media/app-tour.mp4', poster: '/mockups/app-desktop-light.jpg', captions: '/media/app-tour.vtt', title: 'A tour of the dashboard' },
} = Astro.props
---

<Section spacing="large" class="overflow-hidden">
  <div class="flex flex-col gap-8 md:gap-12 md:items-center">
    <div class="flex flex-col gap-4 md:gap-6 items-start md:items-center md:text-center">
      {announcement && (
        <Link href={announcement.href} color="inherit" underline="none" class="inline-flex items-center gap-2 self-start md:self-center rounded-full py-1 ps-1 pe-3 text-sm font-medium bg-primary-faded text-primary">
          {announcement.badge && <Badge color="primary" rounded>{announcement.badge}</Badge>}{announcement.label}<ArrowRight class="size-4 rtl:-scale-x-100" aria-hidden="true" />
        </Link>
      )}
      <Heading as="h1" size="display" class="text-balance">{plain(heading)}</Heading>
      {description && <p class="max-w-2xl text-lg md:text-xl text-neutral-faded">{description}</p>}
    </div>
    {(primaryAction || secondaryAction) && (
      <div class="flex flex-col-reverse gap-3 sm:flex-row sm:justify-center ">
        {secondaryAction && <Button href={secondaryAction.href} size="large" variant="outline" color="neutral"><CirclePlay slot="start" aria-hidden="true" />{secondaryAction.label}</Button>}
        {primaryAction && <Button href={primaryAction.href} size="large">{primaryAction.label}</Button>}
      </div>
    )}
  </div>
  <div class="relative mt-16 md:mt-20">
    <div class="absolute inset-x-[-50vw] top-1/4 h-1/2 -skew-y-6 bg-primary-faded" aria-hidden="true"></div>
    {video && <div class="relative mx-auto max-w-5xl"><VideoPlayer src={video.src} poster={video.poster} captions={video.captions} title={video.title} ratio="16/9" /></div>}
  </div>
</Section>

Add

npx @ava-ui/apogee add hero/abstract-angles-01

This copies the block to src/components/apogee/blocks/hero/ with everything it uses: Badge, Button, Heading, Link, Section, VideoPlayer. 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 the page’s h1; the items below are one level down.
  • The play button is named after the video; once it plays, the browser’s own controls take over. The video has captions.