From 8d8463c6200f789487adc97c406348246a7c545f Mon Sep 17 00:00:00 2001 From: flexykrn Date: Wed, 17 Jun 2026 17:54:44 +0530 Subject: [PATCH] Docusaurus migration - website-src-theme Part 72 of the Docusaurus migration split. --- website/src/theme/CodeBlock/index.tsx | 111 ++++ website/src/theme/Footer/index.tsx | 117 ++++ website/src/theme/Footer/styles.module.css | 258 +++++++++ website/src/theme/MDXComponents/index.tsx | 35 ++ website/src/theme/Navbar/index.tsx | 532 ++++++++++++++++++ website/src/theme/Navbar/styles.module.css | 606 +++++++++++++++++++++ website/src/theme/Root.tsx | 15 + 7 files changed, 1674 insertions(+) create mode 100644 website/src/theme/CodeBlock/index.tsx create mode 100644 website/src/theme/Footer/index.tsx create mode 100644 website/src/theme/Footer/styles.module.css create mode 100644 website/src/theme/MDXComponents/index.tsx create mode 100644 website/src/theme/Navbar/index.tsx create mode 100644 website/src/theme/Navbar/styles.module.css create mode 100644 website/src/theme/Root.tsx diff --git a/website/src/theme/CodeBlock/index.tsx b/website/src/theme/CodeBlock/index.tsx new file mode 100644 index 00000000..28d3663c --- /dev/null +++ b/website/src/theme/CodeBlock/index.tsx @@ -0,0 +1,111 @@ +import React, { useState, useCallback, useRef } from 'react'; +import OriginalCodeBlock from '@theme-original/CodeBlock'; +import { Check, Copy } from 'lucide-react'; +import { cn } from '@site/src/lib/utils'; + +// Map common language identifiers to display labels +const LANG_LABELS: Record = { + solidity: 'Solidity', + sol: 'Solidity', + javascript: 'JavaScript', + js: 'JavaScript', + typescript: 'TypeScript', + ts: 'TypeScript', + python: 'Python', + py: 'Python', + bash: 'Bash', + sh: 'Shell', + shell: 'Shell', + yaml: 'YAML', + yml: 'YAML', + json: 'JSON', + toml: 'TOML', + go: 'Go', + rust: 'Rust', + sql: 'SQL', + dockerfile: 'Dockerfile', + html: 'HTML', + css: 'CSS', + jsx: 'JSX', + tsx: 'TSX', + xml: 'XML', + graphql: 'GraphQL', +}; + +type CodeBlockProps = React.ComponentProps; + +export default function CodeBlockWrapper(props: CodeBlockProps) { + const [copied, setCopied] = useState(false); + const [toastVisible, setToastVisible] = useState(false); + const toastTimer = useRef>(); + + // Resolve language label from className prop (e.g. "language-solidity") + const langClass = (props.className || '') as string; + const langKey = langClass.replace(/^language-/, '').toLowerCase(); + const langLabel = LANG_LABELS[langKey] || (langKey || ''); + + const handleCopy = useCallback(async () => { + const code = typeof props.children === 'string' ? props.children : ''; + if (!code) return; + try { + await navigator.clipboard.writeText(code); + setCopied(true); + + // Show toast + setToastVisible(true); + if (toastTimer.current) clearTimeout(toastTimer.current); + toastTimer.current = setTimeout(() => { + setToastVisible(false); + setCopied(false); + }, 2000); + } catch { + // Ignore — clipboard may not be available in all contexts + } + }, [props.children]); + + return ( +
+ {/* Language label — top-left */} + {langLabel && ( +
+ {langLabel} +
+ )} + + + + {/* Copy button — top-right, appears on group hover */} + + + {/* Inline toast */} + {toastVisible && ( +
+ + Copied! +
+ )} +
+ ); +} diff --git a/website/src/theme/Footer/index.tsx b/website/src/theme/Footer/index.tsx new file mode 100644 index 00000000..7910c486 --- /dev/null +++ b/website/src/theme/Footer/index.tsx @@ -0,0 +1,117 @@ +import React from 'react'; +import { useThemeConfig } from '@docusaurus/theme-common'; +import Link from '@docusaurus/Link'; +import useBaseUrl from '@docusaurus/useBaseUrl'; +import { Github, Twitter, MessageCircle, Send, Heart } from 'lucide-react'; +import styles from './styles.module.css'; + +interface FooterLinkItem { + label: string; + to?: string; + href?: string; +} + +interface FooterLinkColumn { + title: string; + items: FooterLinkItem[]; +} + +const socialLinks = [ + { icon: Github, href: 'https://github.com/XinFinOrg', label: 'GitHub' }, + { icon: Twitter, href: 'https://twitter.com/XinFin_Official', label: 'Twitter / X' }, + { icon: MessageCircle, href: 'https://discord.gg/xdc', label: 'Discord' }, + { icon: Send, href: 'https://t.me/xinfintalk', label: 'Telegram' }, +]; + +export default function Footer() { + const { footer } = useThemeConfig(); + const footerLinks = (footer?.links as FooterLinkColumn[]) ?? []; + const logoSrc = useBaseUrl('img/logo-dark.svg'); + const logoSrcDark = useBaseUrl('img/logo.svg'); + + const renderLink = (item: FooterLinkItem) => { + const content = ( + <> + {item.label} +