1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00
conky/web/components/Docs.tsx

84 lines
2.9 KiB
TypeScript
Raw Normal View History

2022-09-30 22:20:17 +00:00
import { Documentation } from '../utils/doc-utils'
2022-10-01 20:32:01 +00:00
import { Link as LinkIcon } from 'react-feather'
import Link from 'next/link'
import { useRouter } from 'next/router'
export interface DocsProps {
2022-09-30 22:20:17 +00:00
docs: Documentation
braces: boolean
assign: boolean
}
2022-09-30 22:20:17 +00:00
export default function Docs({ docs, braces, assign }: DocsProps) {
2022-10-01 20:32:01 +00:00
const router = useRouter()
return (
2022-10-05 01:55:32 +00:00
<div className="prose dark:prose-invert prose-lg">
2022-10-01 20:32:01 +00:00
<div dangerouslySetInnerHTML={{ __html: docs.desc_md }} />
2022-10-04 16:18:21 +00:00
<div className="divide-y divide-gray-700/25 dark:divide-gray-300/25">
2022-10-01 20:32:01 +00:00
{docs.values.map((doc) => {
const target = router.asPath.endsWith(`#${doc.name}`)
return (
<div
id={doc.name}
key={doc.name}
className={
2022-10-05 01:55:32 +00:00
'pt-4 scroll-mt-16 ' +
(target
? 'bg-rose-300 dark:bg-rose-900'
: 'bg-slate-200 dark:bg-slate-800 target:bg-rose-300 target:dark:bg-rose-900') +
' hover:bg-opacity-25 dark:hover:bg-opacity-25 hover:ring-1 ring-black dark:ring-white ring-inset'
2022-10-01 20:32:01 +00:00
}
>
<div className="flex">
<div className="px-2 py-3">
<Link href={`#${doc.name}`}>
<a>
<LinkIcon size={20} />
</a>
</Link>
</div>
2022-10-01 20:32:01 +00:00
<div className="flex-col p-1">
2022-09-30 22:20:17 +00:00
<div>
2022-10-01 20:32:01 +00:00
{braces && <code>$&#123;</code>}
<code className="text-lg p-1 mx-1 bg-fuchsia-200 dark:bg-fuchsia-900 font-bold">
{doc.name}
2022-09-30 22:20:17 +00:00
</code>
2022-10-01 20:32:01 +00:00
{typeof doc.args != 'undefined' && doc.args.length > 0 && (
<>
{assign && <code>=</code>}
<em>
{doc.args.map((arg) => (
<code
className="text-lg p-1 mx-1 bg-slate-200 dark:bg-slate-800"
key={arg}
>
{arg}
</code>
))}
</em>
</>
)}
{braces && <code>&#125;</code>}
2022-09-30 22:20:17 +00:00
</div>
2022-10-01 20:32:01 +00:00
<div
className="py-2"
dangerouslySetInnerHTML={{ __html: doc.desc_md }}
/>
{typeof doc.default != 'undefined' && (
<div>
Default:{' '}
<code className="px-1 mx-1 bg-slate-200 dark:bg-slate-800">
{doc.default}
</code>
</div>
)}
</div>
2022-09-30 22:20:17 +00:00
</div>
</div>
2022-10-01 20:32:01 +00:00
)
})}
2022-09-30 22:20:17 +00:00
</div>
2022-09-30 21:15:06 +00:00
</div>
)
}