www_projectinca_archive/src/components/widgets/Hero.astro
2024-06-07 09:14:05 -04:00

103 lines
3.2 KiB
Plaintext

---
import Image from '~/components/common/Image.astro';
import Button from '~/components/ui/Button.astro';
import type { CallToAction } from '~/types';
export interface Props {
id?: string;
title?: string;
title2?: string;
subtitle?: string;
tagline?: string;
content?: string;
actions?: string | CallToAction[];
image?: string | unknown; // TODO: find HTMLElementProps
}
const {
id,
title = await Astro.slots.render('title'),
title2 = await Astro.slots.render('title2'),
subtitle = await Astro.slots.render('subtitle'),
tagline,
content = await Astro.slots.render('content'),
actions = await Astro.slots.render('actions'),
image = await Astro.slots.render('image'),
} = Astro.props;
---
<section class="relative md:-mt-[76px] not-prose" {...id ? { id } : {}}>
<div class="absolute inset-0 pointer-events-none" aria-hidden="true"></div>
<div class="relative max-w-7xl mx-auto px-4 sm:px-6">
<div class="pt-0 md:pt-12 pointer-events-none"></div>
<div class="py-8 md:py-20">
<div class="text-center pb-8 md:pb-16 max-w-5xl mx-auto">
{
tagline && (
<p
class="text-base text-secondary dark:text-blue-200 font-bold tracking-wide uppercase"
set:html={tagline}
/>
)
}
{
title && (
<h1
class="text-3xl md:text-6xl font-bold leading-tighter tracking-tighter mb-2 font-heading dark:text-gray-200"
set:html={title}
/>
)
}
{
title2 && (
<h3
class="text-xl md:text-4xl font-bold leading-tighter tracking-tighter mb-4 font-heading dark:text-gray-200"
set:html={title2}
/>
)
}
<div class="max-w-3xl mx-auto">
{subtitle && <p class="text-xl text-muted mb-8 dark:text-slate-300 max-w-m md:max-w-3xl" set:html={subtitle} />}
{
actions && (
<div class="max-w-xs sm:max-w-md m-auto flex flex-nowrap flex-col sm:flex-row sm:justify-center gap-4">
{Array.isArray(actions) ? (
actions.map((action) => (
<div class="flex w-full sm:w-auto">
<Button {...(action || {})} class="w-full sm:mb-0" />
</div>
))
) : (
<Fragment set:html={actions} />
)}
</div>
)
}
</div>
{content && <Fragment set:html={content} />}
</div>
<div>
{
image && (
<div class="relative m-auto max-w-5xl">
{typeof image === 'string' ? (
<Fragment set:html={image} />
) : (
<Image
class="mx-auto rounded-md w-full"
widths={[400, 768, 1024, 2040]}
sizes="(max-width: 767px) 400px, (max-width: 1023px) 768px, (max-width: 2039px) 1024px, 2040px"
loading="eager"
width={1024}
height={576}
{...image}
/>
)}
</div>
)
}
</div>
</div>
</div>
</section>