-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkCard.mjs
42 lines (35 loc) · 1.07 KB
/
LinkCard.mjs
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
// @ts-check
import classNameProp from "class-name-prop";
import React from "react";
/** CSS dependency URLs for the React component {@linkcode LinkCard}. */
export const css = new Set([new URL("./LinkCard.css", import.meta.url).href]);
/** React component for a card {@link HTMLAnchorElement link}. */
const LinkCard = React.forwardRef(
(
/**
* @type {LinkCardProps
* & React.ComponentPropsWithoutRef<"a">
* & { [dataAttribute: `data-${string}`]: unknown }}
*/
{ active, className, ...props },
/** @type {React.ForwardedRef<HTMLAnchorElement>} */
ref
) =>
React.createElement("a", {
className: classNameProp(
"daui-LinkCard",
active && "daui-LinkCard--active",
className
),
...props,
ref,
})
);
LinkCard.displayName = "LinkCard";
export default LinkCard;
/**
* Props for the {@linkcode LinkCard} React component, excluding additional
* props for the {@linkcode HTMLAnchorElement}.
* @typedef {object} LinkCardProps
* @prop {boolean} [active] Does the link refer to the current page.
*/