generated from shuding/nextra-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from sei-protocol/feat/docs-revamp-6
feat: new docs structure (6/n)
- Loading branch information
Showing
71 changed files
with
2,730 additions
and
1,987 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { useState } from 'react'; | ||
import { IconCopy, IconCheck, IconChevronDown } from '@tabler/icons-react'; | ||
import Prism from 'prismjs'; | ||
import 'prismjs/themes/prism-tomorrow.css'; | ||
import 'prismjs/components/prism-bash'; | ||
import 'prismjs/components/prism-jsx'; | ||
|
||
interface CodeBlockProps { | ||
code: string; | ||
language: string; | ||
title?: string; | ||
flags?: Record<string, string>; | ||
} | ||
|
||
const CodeBlock = ({ code, language, title, flags }: CodeBlockProps) => { | ||
const [copied, setCopied] = useState(false); | ||
const [showFlags, setShowFlags] = useState(true); | ||
|
||
const copyToClipboard = async () => { | ||
await navigator.clipboard.writeText(code); | ||
setCopied(true); | ||
setTimeout(() => setCopied(false), 2000); | ||
}; | ||
|
||
return ( | ||
<div className="my-6 overflow-hidden rounded-lg bg-[#1A1A1A] ring-1 ring-white/10"> | ||
{title && ( | ||
<div className="flex items-center justify-between px-4 py-2"> | ||
<span className="text-sm font-medium text-white/60">{title}</span> | ||
<button | ||
onClick={copyToClipboard} | ||
className="flex items-center gap-1.5 rounded-md bg-white/5 px-2.5 py-1 text-xs text-white/60 hover:bg-white/10 hover:text-white/90 transition-all" | ||
> | ||
{copied ? <IconCheck size={14} /> : <IconCopy size={14} />} | ||
{copied ? 'Copied' : 'Copy'} | ||
</button> | ||
</div> | ||
)} | ||
|
||
<div className="relative"> | ||
<pre className="overflow-x-auto p-4 text-sm"> | ||
<code | ||
className={`language-${language}`} | ||
dangerouslySetInnerHTML={{ | ||
__html: Prism.highlight(code, Prism.languages[language], language) | ||
}} | ||
/> | ||
</pre> | ||
</div> | ||
|
||
{flags && ( | ||
<> | ||
<div className="border-t border-white/10 px-4 py-2"> | ||
<button | ||
onClick={() => setShowFlags(!showFlags)} | ||
className="flex w-full items-center justify-between text-xs font-medium text-white/40" | ||
> | ||
FLAGS | ||
<IconChevronDown | ||
size={14} | ||
className={`transition-transform duration-200 ${showFlags ? 'rotate-180' : ''}`} | ||
/> | ||
</button> | ||
</div> | ||
{showFlags && ( | ||
<div className="px-4 pb-4"> | ||
<div className="grid grid-cols-1 md:grid-cols-2 gap-2"> | ||
{Object.entries(flags).map(([flag, description]) => ( | ||
<div key={flag} className="flex items-start gap-2"> | ||
<code className="text-xs bg-white/5 px-1.5 py-0.5 rounded text-white/70"> | ||
{flag} | ||
</code> | ||
<span className="text-xs text-white/60">{description}</span> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default CodeBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as CodeBlock } from './CodeBlock'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* styles.css */ | ||
.code-block { | ||
@apply flex flex-col w-full; | ||
} | ||
|
||
.code-header { | ||
@apply bg-purple-600 text-white text-sm font-medium px-4 py-2 rounded-t-lg; | ||
} | ||
|
||
.code-content { | ||
@apply bg-[#1E1E1E] text-white font-mono text-sm p-4 overflow-x-auto; | ||
} | ||
|
||
.flags-section { | ||
@apply bg-[#1F2937] border-t border-gray-700 p-4; | ||
} | ||
|
||
.flag-item { | ||
@apply flex items-start gap-3 text-sm mb-2 last:mb-0; | ||
} | ||
|
||
.flag-name { | ||
@apply text-yellow-500 font-mono; | ||
} | ||
|
||
.flag-description { | ||
@apply text-gray-400; | ||
} | ||
|
||
/* Syntax highlighting */ | ||
.token.keyword { | ||
@apply text-purple-400; | ||
} | ||
|
||
.token.string { | ||
@apply text-green-400; | ||
} | ||
|
||
.token.function { | ||
@apply text-blue-400; | ||
} | ||
|
||
.token.constant { | ||
@apply text-cyan-400; | ||
} | ||
|
||
.token.comment { | ||
@apply text-gray-500; | ||
} | ||
|
||
/* Section headers */ | ||
.section-title { | ||
@apply text-white text-xl font-medium mb-4; | ||
} | ||
|
||
.subsection-title { | ||
@apply text-white text-lg font-medium mb-3; | ||
} | ||
|
||
/* Dark mode optimizations */ | ||
.dark { | ||
@apply bg-[#121212]; | ||
} | ||
|
||
/* Scrollbar styling */ | ||
.code-content::-webkit-scrollbar { | ||
@apply h-2 w-2; | ||
} | ||
|
||
.code-content::-webkit-scrollbar-track { | ||
@apply bg-gray-800; | ||
} | ||
|
||
.code-content::-webkit-scrollbar-thumb { | ||
@apply bg-gray-600 rounded-full; | ||
} |
Oops, something went wrong.