-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (35 loc) · 1.18 KB
/
index.js
File metadata and controls
40 lines (35 loc) · 1.18 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
import React from 'react';
import clsx from 'clsx'; // clsx helps manage conditional className names in a clean and concise manner.
import Link from '@docusaurus/Link';
const Card = ({
className, // Custom classes for the container card
style, // Custom styles for the container card
children, // Content to be included within the card
shadow, // Used to add shadow under your card. Expected values are: low (lw), medium (md), tall (tl)
href, // Link URL for the card
title, // Title for the card header
icon, // Icon for the card header
}) => {
const cardShadow = shadow ? `item shadow--${shadow}` : '';
const Header = (title || icon) ? (
<div className="card__header">
{icon && <span className={`icon icon-${icon}`} aria-hidden="true"></span>}
{title && <h3 className="card__title">{title}</h3>}
</div>
) : null;
if (href) {
return (
<Link to={href} className={clsx('card', className, cardShadow)} style={style} aria-label={title}>
{Header}
{children}
</Link>
);
}
return (
<div className={clsx('card', className, cardShadow)} style={style}>
{Header}
{children}
</div>
);
};
export default Card;