2024-02-12 03:50:38 +04:00
---
2024-02-18 07:39:53 +04:00
// Import the necessary dependencies
2024-02-20 07:51:14 +04:00
import TabNav from "../../ui/blocks/TabNav.astro";
import TabContent from "../../ui/blocks/TabContent.astro";
2024-03-22 04:43:19 +04:00
import Icon from "../../ui/icons/Icon.astro";
2024-02-12 03:50:38 +04:00
2024-03-22 04:43:19 +04:00
// Define props from Astro
const { title, tabs } = Astro.props;
// Define TypeScript interface for tab object
interface Tab {
heading: string;
content: string;
svg: string;
src: any;
alt: string;
first?: boolean;
second?: boolean;
}
// Define TypeScript interface for props
interface Props {
title?: string;
tabs: Tab[];
}
2024-02-12 03:50:38 +04:00
---
2024-02-19 09:36:37 +04:00
<section
2024-02-12 03:50:38 +04:00
class="mx-auto max-w-[85rem] px-4 py-10 sm:px-6 lg:px-8 lg:py-14 2xl:max-w-full"
>
<div class="relative p-6 md:p-16">
<div
class="relative z-10 lg:grid lg:grid-cols-12 lg:items-center lg:gap-16"
>
2024-02-18 07:39:53 +04:00
<!-- Section's heading and tab navigation -->
2024-02-12 03:50:38 +04:00
<div class="mb-10 lg:order-2 lg:col-span-6 lg:col-start-8 lg:mb-0">
<h2
class="text-2xl font-bold text-neutral-800 dark:text-neutral-200 sm:text-3xl"
>
<!-- About Fragment: https://docs.astro.build/en/basics/astro-syntax/#fragments -->
<Fragment set:html={title} />
</h2>
<!-- Tab navigation - use the attribute 'first' in the first TabNav for the component to work -->
<nav class="mt-5 grid gap-4 md:mt-10" aria-label="Tabs" role="tablist">
2024-03-22 04:43:19 +04:00
{
tabs.map((tab, index) => (
<TabNav
id={`tabs-with-card-item-${index + 1}`}
dataTab={`#tabs-with-card-${index + 1}`}
aria={`tabs-with-card-${index + 1}`}
heading={tab.heading}
content={tab.content}
first={tab.first}
>
<Icon name={tab.svg} />
</TabNav>
))
}
2024-02-12 03:50:38 +04:00
</nav>
</div>
<!-- Contents for each tab - the 'first' attribute should be used in the first tab for that tab to be initially visible, 'second' changes the styles -->
<div class="lg:col-span-6">
<div class="relative">
<div>
2024-03-22 04:43:19 +04:00
{
tabs.map((tab, index) => (
<TabContent
id={`tabs-with-card-${index + 1}`}
aria={`tabs-with-card-item-${index + 1}`}
src={tab.src}
alt={tab.alt}
first={tab.first}
second={tab.second}
/>
))
}
2024-02-12 03:50:38 +04:00
</div>
</div>
</div>
</div>
<div class="absolute inset-0 grid h-full w-full grid-cols-12">
<!-- Decorative background and sizing -->
<div
class="col-span-full h-5/6 w-full rounded-xl bg-neutral-100 dark:bg-white/[.075] sm:h-3/4 lg:col-span-7 lg:col-start-6 lg:h-full"
>
</div>
</div>
</div>
2024-02-19 09:36:37 +04:00
</section>
2024-02-18 07:39:53 +04:00
<!--Import the necessary Tabs plugin-->
<!--https://preline.co/plugins/html/tabs.html-->
<script is:inline src="/scripts/vendor/preline/tabs/index.js"></script>