summaryrefslogtreecommitdiff
path: root/src/components/ui/WidgetWrapper.astro
blob: c42c7515be5598ccf875545588c9e91420a821b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
import type { HTMLTag } from 'astro/types';
import type { Widget } from '~/types';
import { twMerge } from 'tailwind-merge';
import Background from './Background.astro';

export interface Props extends Widget {
  containerClass?: string;
  ['as']?: HTMLTag;
}

const { id, isDark = false, containerClass = '', bg, as = 'section' } = Astro.props;

const WrapperTag = as;
---

<WrapperTag class="relative not-prose scroll-mt-[72px]" {...id ? { id } : {}}>
  <div class="absolute inset-0 pointer-events-none -z-[1]" aria-hidden="true">
    <slot name="bg">
      {bg ? <Fragment set:html={bg} /> : <Background isDark={isDark} />}
    </slot>
  </div>
  <div
    class:list={[
      twMerge(
        'relative mx-auto max-w-7xl px-4 md:px-6 py-12 md:py-16 lg:py-20 text-default intersect-once intersect-quarter intercept-no-queue motion-safe:md:opacity-0 motion-safe:md:intersect:animate-fade',
        containerClass
      ),
      { dark: isDark },
    ]}
  >
    <slot />
  </div>
</WrapperTag>