import type { BlockUi } from '../context.js'
import type { LinksData } from '../data.js'
import { cx } from './cx.js'
/** The section's buttons in a row; nothing when there are none. */
export function Buttons({ className, CMSLink, links, locale }: { className?: string; CMSLink: BlockUi['CMSLink']; links?: LinksData; locale: string }) {
const rows = (links ?? []).filter((row) => row.link)
if (!rows.length) {return null}
return (
{rows.map((row, i) => (
))}
)
}
/** The id of a block's heading (aria-labelledby), when it has one. */
export function headingId(block: { blockType: string; header?: { heading?: null | string } | null; id?: null | string }): string | undefined {
return block.header?.heading && block.id ? `${block.blockType}-${block.id}-heading` : undefined
}
/** Grid columns from the `columns` select. */
export const GRID_COLUMNS: Record = {
four: 'sm:grid-cols-2 lg:grid-cols-4',
three: 'sm:grid-cols-2 lg:grid-cols-3',
two: 'sm:grid-cols-2',
}