-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathCardSection.tsx
More file actions
68 lines (62 loc) · 1.82 KB
/
CardSection.tsx
File metadata and controls
68 lines (62 loc) · 1.82 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import clsx from 'clsx'
import { CSSProperties, JSX, useState, useEffect } from 'react'
import { useColorMode } from '@docusaurus/theme-common'
import Card, { CardItem } from '@site/src/components/Card'
import styles from './CardSection.module.scss'
type CardSectionProps = {
title?: string
description?: string
cards: CardItem[]
colorPalette?: string
}
export default function CardSection({
title,
description,
cards,
colorPalette,
}: CardSectionProps): JSX.Element {
const { colorMode } = useColorMode()
const [theme, setTheme] = useState('')
useEffect(() => {
setTheme(colorMode)
}, [colorMode])
return (
<section className={styles.wrapper}>
<div className="container">
<div className={styles['grid-wrapper']}>
{/* header placed inside the grid-wrapper for column alignment */}
{(title || description) && (
<div className={styles['grid-col-center']}>
<div className={styles.header}>
{title && <h2>{title}</h2>}
{description && <p>{description}</p>}
</div>
</div>
)}
<div className={styles['grid-col-center']}>
<ul
className={styles.grid}
style={
colorPalette
? ({
'--color-palette': `var(--developer-${colorPalette})`,
} as CSSProperties)
: {}
}
>
{cards.map(({ title, description, href }, index) => (
<Card
key={index}
title={title}
description={description}
href={href}
theme={theme}
/>
))}
</ul>
</div>
</div>
</div>
</section>
)
}