mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 12:13:11 +00:00
32 lines
824 B
TypeScript
32 lines
824 B
TypeScript
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*/
|
|
|
|
import cn from 'classnames';
|
|
import type {HTMLAttributes} from 'react';
|
|
|
|
interface InlineCodeProps {
|
|
isLink?: boolean;
|
|
meta?: string;
|
|
}
|
|
function InlineCode({
|
|
isLink,
|
|
...props
|
|
}: HTMLAttributes<HTMLElement> & InlineCodeProps) {
|
|
return (
|
|
<code
|
|
dir="ltr" // This is needed to prevent the code from inheriting the RTL direction of <html> in case of RTL languages to avoid like `()console.log` to be rendered as `console.log()`
|
|
className={cn(
|
|
'inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline',
|
|
{
|
|
'bg-gray-30 bg-opacity-10 py-px': !isLink,
|
|
'bg-highlight dark:bg-highlight-dark py-0': isLink,
|
|
}
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default InlineCode;
|