mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-12 16:09:33 +00:00
30 lines
817 B
TypeScript
30 lines
817 B
TypeScript
import clsx from 'classnames';
|
|
|
|
import { formatOpenAPIMethod } from './formatOpenAPIMethod';
|
|
|
|
/**
|
|
* Badge displaying the HTTP method of an OpenAPI operation.
|
|
*/
|
|
export function OpenAPIMethodBadge(props: {
|
|
method: string;
|
|
/** Abbreviate the label (DEL, OPTS) instead of the full method. */
|
|
short?: boolean;
|
|
size?: 'small' | 'medium';
|
|
className?: string;
|
|
}) {
|
|
const { method, short = false, size = 'medium', className } = props;
|
|
const normalized = method.toLowerCase();
|
|
return (
|
|
<span
|
|
className={clsx(
|
|
'openapi-method',
|
|
`openapi-method-${normalized}`,
|
|
`openapi-method-${size}`,
|
|
className
|
|
)}
|
|
>
|
|
{short ? formatOpenAPIMethod(normalized) : method}
|
|
</span>
|
|
);
|
|
}
|