2022-11-25 20:25:03 +00:00
|
|
|
import * as React from 'react';
|
2022-06-20 15:17:33 +00:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
interface CodeProps {
|
|
|
|
dark?: boolean | undefined;
|
2022-06-20 19:28:27 +00:00
|
|
|
className?: string;
|
2022-06-20 15:17:33 +00:00
|
|
|
children: React.ReactChild | React.ReactFragment | React.ReactPortal;
|
|
|
|
}
|
|
|
|
|
2022-06-20 19:28:27 +00:00
|
|
|
export default ({ dark, className, children }: CodeProps) => (
|
2022-06-20 15:17:33 +00:00
|
|
|
<code
|
2022-06-20 19:28:27 +00:00
|
|
|
className={classNames('font-mono text-sm px-2 py-1 inline-block rounded', className, {
|
2022-06-20 15:17:33 +00:00
|
|
|
'bg-neutral-700': !dark,
|
|
|
|
'bg-neutral-900 text-gray-100': dark,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</code>
|
|
|
|
);
|