microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
docs/docusaurus/src/components/Cards/BoxCard.tsx
43lines · modecode
| 1 | import React from 'react'; |
| 2 | import Link from '@docusaurus/Link'; |
| 3 | import useBaseUrl from '@docusaurus/useBaseUrl'; |
| 4 | import styles from './styles.module.css'; |
| 5 | |
| 6 | interface BoxCardLink { |
| 7 | label: string; |
| 8 | href: string; |
| 9 | } |
| 10 | |
| 11 | interface BoxCardProps { |
| 12 | title: string; |
| 13 | description?: string; |
| 14 | links: BoxCardLink[]; |
| 15 | icon?: string; |
| 16 | } |
| 17 | |
| 18 | export default function BoxCard({ |
| 19 | title, |
| 20 | description, |
| 21 | links, |
| 22 | icon, |
| 23 | }: BoxCardProps): React.ReactElement { |
| 24 | const iconUrl = icon ? useBaseUrl(icon) : undefined; |
| 25 | return ( |
| 26 | <div className={styles.boxCard}> |
| 27 | {iconUrl && ( |
| 28 | <div className={styles.boxCardIcon}> |
| 29 | <img src={iconUrl} alt="" width="48" height="48" /> |
| 30 | </div> |
| 31 | )} |
| 32 | <h3 className={styles.boxCardTitle}>{title}</h3> |
| 33 | {description && <p className={styles.cardDescription}>{description}</p>} |
| 34 | <ul className={styles.boxCardLinks}> |
| 35 | {links.map((link) => ( |
| 36 | <li key={link.href}> |
| 37 | <Link to={link.href}>{link.label}</Link> |
| 38 | </li> |
| 39 | ))} |
| 40 | </ul> |
| 41 | </div> |
| 42 | ); |
| 43 | } |
| 44 | |