shelving
Version:
Toolkit for using data in JavaScript.
31 lines (30 loc) • 1.01 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { Tag } from "../misc/Tag.js";
/** Mapping from a documented symbol's `kind` to its raw colour variant. */
const KIND_COLOR = {
module: "red",
function: "blue",
class: "purple",
interface: "aqua",
type: "pink",
constant: "green",
method: "orange",
property: "yellow",
};
/**
* Get the raw colour variant for a documented symbol's `kind`, or `undefined` for an unknown kind.
* - Shared source of truth so the kind tag and its surrounding card pick the same hue.
*/
export function getDocumentationKindColor(kind) {
return KIND_COLOR[kind];
}
/**
* Colour-coded tag for a documented symbol's kind.
* - Thin wrapper over `<Tag>` that maps the kind string to a raw colour variant.
*
* @example <DocumentationKind kind="function" />
*/
export function DocumentationKind({ kind }) {
const color = getDocumentationKindColor(kind);
return _jsx(Tag, { ...(color ? { [color]: true } : {}), children: kind });
}