Merge pull request #205 from widgeter/main

Refactor CallToAction widget
This commit is contained in:
André B
2023-08-04 13:25:06 -04:00
committed by GitHub

View File

@ -1,41 +1,39 @@
--- ---
import { Icon } from 'astro-icon/components'; import { Icon } from 'astro-icon/components';
import WidgetWrapper from '../ui/WidgetWrapper.astro';
import type { CallToAction, Widget } from '~/types';
import Headline from '../ui/Headline.astro';
export interface CallToAction { interface Props extends Widget {
text: string;
href: string;
icon?: string;
}
export interface Props {
title?: string; title?: string;
subtitle?: string; subtitle?: string;
description?: string; tagline?: string;
callToAction?: string | CallToAction; callToAction?: CallToAction;
} }
const { const {
title = await Astro.slots.render('title'), title = await Astro.slots.render('title'),
subtitle = await Astro.slots.render('subtitle'), subtitle = await Astro.slots.render('subtitle'),
tagline = await Astro.slots.render('tagline'),
callToAction = await Astro.slots.render('callToAction'), callToAction = await Astro.slots.render('callToAction'),
} = Astro.props;
id,
isDark = false,
classes = {},
bg = await Astro.slots.render('bg'),
} = Astro.props as Props;
--- ---
<section class="relative not-prose"> <WidgetWrapper id={id} isDark={isDark} containerClass={`max-w-6xl mx-auto ${classes?.container ?? ''}`} bg={bg}>
<div class="max-w-6xl mx-auto px-4 sm:px-6"> <div class="max-w-3xl mx-auto text-center p-6 rounded-md shadow-xl">
<div class="py-12 md:py-20"> <Headline
<div title={title}
class="max-w-3xl mx-auto text-center p-6 rounded-md shadow-xl dark:shadow-none dark:border dark:border-slate-600" subtitle={subtitle}
> tagline={tagline}
{ classes={{
title && ( container: 'mb-0 md:mb-0 dark:shadow-none dark:border dark:border-slate-600',
<h2 }}
class="text-4xl md:text-4xl font-bold leading-tighter tracking-tighter mb-4 font-heading"
set:html={title}
/> />
)
}
{subtitle && <p class="text-xl text-muted dark:text-slate-400" set:html={subtitle} />}
{ {
typeof callToAction === 'string' ? ( typeof callToAction === 'string' ? (
<Fragment set:html={callToAction} /> <Fragment set:html={callToAction} />
@ -53,6 +51,4 @@ const {
) )
} }
</div> </div>
</div> </WidgetWrapper>
</div>
</section>