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
|
2023-01-12 19:31:47 +00:00
|
|
|
className={classNames('inline-block rounded px-2 py-1 font-mono text-sm', className, {
|
2022-06-20 15:17:33 +00:00
|
|
|
'bg-neutral-700': !dark,
|
2022-12-16 02:06:14 +00:00
|
|
|
'bg-neutral-900 text-slate-100': dark,
|
2022-06-20 15:17:33 +00:00
|
|
|
})}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</code>
|
|
|
|
);
|