Files
web/apps/scandic-web/components/Blocks/ShortcutsList/index.tsx
Erik Tiekstra 689e9d72cb fix(SW-1886): Removed "firstItem" props from blocks as it generates multiple h1 tags on those pages
* feat(SW-1886): Removed "firstItem" props from blocks as it generates multiple h1 tags on those pages


Approved-by: Fredrik Thorsson
Approved-by: Simon.Emanuelsson
2025-03-12 14:09:20 +00:00

56 lines
1.3 KiB
TypeScript

import SectionContainer from "@/components/Section/Container"
import SectionHeader from "@/components/Section/Header"
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 (
<SectionContainer>
<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>
</SectionContainer>
)
}