Skip to content

Commit

Permalink
Add id,bg with types to Hero and Hero2. Fix onwidget#448
Browse files Browse the repository at this point in the history
  • Loading branch information
prototypa committed Jun 23, 2024
1 parent f680e38 commit e804000
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
23 changes: 11 additions & 12 deletions src/components/widgets/Hero.astro
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
---
import Image from '~/components/common/Image.astro';
import Button from '~/components/ui/Button.astro';
import type { CallToAction } from '~/types';
import Background from '~/components/ui/Background.astro';
export interface Props {
id?: string;
title?: string;
subtitle?: string;
tagline?: string;
content?: string;
actions?: string | CallToAction[];
image?: string | unknown; // TODO: find HTMLElementProps
}
import type { Hero as Props } from '~/types';
const {
id,
title = await Astro.slots.render('title'),
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'),
id,
bg = await Astro.slots.render('bg'),
} = 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="absolute inset-0 pointer-events-none" aria-hidden="true">
<slot name="bg">
{bg ? <Fragment set:html={bg} /> : null}
</slot>
</div>
<div class="relative max-w-7xl mx-auto px-4 sm:px-6">
<div class="pt-0 md:pt-[76px] pointer-events-none"></div>
<div class="py-12 md:py-20">
Expand Down
23 changes: 12 additions & 11 deletions src/components/widgets/Hero2.astro
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
---
import Image from '~/components/common/Image.astro';
import type { CallToAction } from '~/types';
import Button from '~/components/ui/Button.astro';
import Background from '~/components/ui/Background.astro';
export interface Props {
title?: string;
subtitle?: string;
tagline?: string;
content?: string;
actions?: string | CallToAction[];
image?: string | unknown; // TODO: find HTMLElementProps
}
import type { Hero as Props } from '~/types';
const {
title = await Astro.slots.render('title'),
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'),
id,
bg = await Astro.slots.render('bg'),
} = Astro.props;
---

<section class="relative md:-mt-[76px] not-prose">
<div class="absolute inset-0 pointer-events-none" aria-hidden="true"></div>
<section class="relative md:-mt-[76px] not-prose" {...id ? { id } : {}}>
<div class="absolute inset-0 pointer-events-none" aria-hidden="true">
<slot name="bg">
{bg ? <Fragment set:html={bg} /> : null}
</slot>
</div>
<div class="relative max-w-7xl mx-auto px-4 sm:px-6">
<div class="pt-0 md:pt-[76px] pointer-events-none"></div>
<div class="py-12 md:py-20 lg:py-0 lg:flex lg:items-center lg:h-screen lg:gap-8">
Expand Down
6 changes: 2 additions & 4 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,10 @@ export interface Form {
}

// WIDGETS
export interface Hero extends Omit<Headline, 'classes'>, Widget {
export interface Hero extends Omit<Headline, 'classes'>, Omit<Widget, 'isDark' | 'classes'> {
content?: string;
actions?: string | CallToAction[];
image?: string | unknown;
callToAction1?: CallToAction;
callToAction2?: CallToAction;
isReversed?: boolean;
}

export interface Team extends Omit<Headline, 'classes'>, Widget {
Expand Down

0 comments on commit e804000

Please sign in to comment.