Files
web/apps/scandic-web/components/Blocks/ShortcutsList/index.tsx
Erik Tiekstra 339e7195dc fix(BOOK-436): Added new section component and deprecated the other
Approved-by: Chuma Mcphoy (We Ahead)
2025-10-13 08:31:26 +00:00

56 lines
1.3 KiB
TypeScript

import { Section } from "@/components/Section"
import SectionHeader from "@/components/Section/Header/Deprecated"
import ShortcutsListItems from "./ShortcutsListItems"
import styles from "./shortcutsList.module.css"
import type { ShortcutsListProps } from "@/types/components/blocks/shortcuts"
export default function ShortcutsList({
shortcuts,
subtitle,
title,
hasTwoColumns,
}: ShortcutsListProps) {
const middleIndex = Math.ceil(shortcuts.length / 2)
const columns =
hasTwoColumns && shortcuts.length > 1
? [
{
id: "shortcuts-column-1",
column: shortcuts.slice(0, middleIndex),
},
{
id: "shortcuts-column-2",
column: shortcuts.slice(middleIndex),
},
]
: [
{
id: "shortcuts-column",
column: shortcuts,
},
]
return (
<Section>
<SectionHeader
preamble={subtitle}
title={title}
headingAs="h3"
headingLevel="h2"
/>
<section className={styles.section}>
{columns.map(({ id, column }) => (
<ShortcutsListItems
key={id}
shortcutsListItems={column}
className={styles.column}
/>
))}
</section>
</Section>
)
}