Skip to content

Commit

Permalink
Merge pull request #186 from sei-protocol/feat/docs-revamp-6
Browse files Browse the repository at this point in the history
feat: new docs structure (6/n)
  • Loading branch information
seiyan-writer authored Jan 4, 2025
2 parents a85491f + 5a003a3 commit 711f73a
Show file tree
Hide file tree
Showing 71 changed files with 2,730 additions and 1,987 deletions.
25 changes: 17 additions & 8 deletions components/ChooseVM/CollapsibleSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Collapse, Button, Box, Text } from '@mantine/core';
import { Collapse, Button, Box, Text, Group } from '@mantine/core';
import { IconChevronDown, IconChevronUp } from '@tabler/icons-react';

interface CollapsibleSectionProps {
Expand All @@ -12,12 +12,11 @@ const CollapsibleSection: React.FC<CollapsibleSectionProps> = ({ title, children

return (
<Box mb="md">
<Button
<Button
fullWidth
variant="light"
color="#001B2A"
onClick={() => setOpened(!opened)}
rightSection={opened ? <IconChevronUp size={16} /> : <IconChevronDown size={16} />}
styles={{
root: {
borderRadius: '8px',
Expand All @@ -28,16 +27,26 @@ const CollapsibleSection: React.FC<CollapsibleSectionProps> = ({ title, children
backgroundColor: '#9E1F19',
},
},
inner: {
justifyContent: 'space-between',
},
}}
>
<Text fw={500}>{title}</Text>
<Group justify="space-between" style={{ width: '100%' }}>
<Text fw={500}>{title}</Text>
{opened ? <IconChevronUp size={16} /> : <IconChevronDown size={16} />}
</Group>
</Button>

<Collapse in={opened}>
<Box mt="sm" p="md" style={{ borderRadius: '0 0 8px 8px', backgroundColor: '#001B2A', borderColor: '#9E1F19', borderWidth: '1px', borderStyle: 'solid' }}>
<Box
mt="sm"
p="md"
style={{
borderRadius: '0 0 8px 8px',
backgroundColor: '#001B2A',
borderColor: '#9E1F19',
borderWidth: '1px',
borderStyle: 'solid',
}}
>
{children}
</Box>
</Collapse>
Expand Down
2 changes: 1 addition & 1 deletion components/ChooseVM/ToolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const VMCard: React.FC<VMCardProps> = ({
}}
>
<Card.Section withBorder inheritPadding py="xs">
<Group justify="apart" mb="xs">
<Group justify="space-between" mb="xs">
<Group>
<Text fw={700} size="xl" color="#ECEDEE">{title}</Text>
{ecosystemSize && (
Expand Down
96 changes: 60 additions & 36 deletions components/ChooseVM/VMCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,56 @@ interface VMCardProps {
ecosystemSize?: 'Large' | 'Medium' | 'Growing';
}

const VMCard: React.FC<VMCardProps> = ({
title,
benefits,
considerations,
const VMCard: React.FC<VMCardProps> = ({
title,
benefits,
considerations,
useCases,
description,
documentation,
ecosystemSize
ecosystemSize,
}) => {
return (
<Card
shadow="sm"
p="lg"
radius="md"
withBorder
style={{
backgroundColor: '#001B2A',
border: '1px solid #9E1F19',
transition: 'transform 0.2s ease',
'&:hover': {
transform: 'translateY(-2px)'
}
<Card
shadow="sm"
p="lg"
radius="md"
withBorder
styles={{
root: {
backgroundColor: '#001B2A',
border: '1px solid #9E1F19',
transition: 'transform 0.2s ease',
'&:hover': {
transform: 'translateY(-2px)',
},
},
}}
>
<Card.Section withBorder inheritPadding py="xs">
<Group justify="apart" mb="xs">
<Group justify="space-between" mb="xs">
<Group>
<Text fw={700} size="xl" color="#ECEDEE">{title}</Text>
<Text fw={700} size="xl" color="#ECEDEE">
{title}
</Text>
{ecosystemSize && (
<Badge
color={ecosystemSize === 'Large' ? 'green' : ecosystemSize === 'Medium' ? 'yellow' : 'blue'}
<Badge
color={
ecosystemSize === 'Large'
? 'green'
: ecosystemSize === 'Medium'
? 'yellow'
: 'blue'
}
variant="light"
>
{ecosystemSize} Ecosystem
</Badge>
)}
</Group>
<Badge color="#9E1F19" variant="filled">Virtual Machine</Badge>
<Badge color="#9E1F19" variant="filled">
Virtual Machine
</Badge>
</Group>
{description && (
<Text size="sm" color="#8CABA9" mt="xs">
Expand All @@ -59,60 +71,72 @@ const VMCard: React.FC<VMCardProps> = ({
</Card.Section>

<Box my="md">
<Text fw={700} mb="xs" color="#ECEDEE">Key Benefits</Text>
<List
<Text fw={700} mb="xs" color="#ECEDEE">
Key Benefits
</Text>
<List
spacing="sm"
size="sm"
size="sm"
icon={
<ThemeIcon color="#8CABA9" size={24} radius="xl">
<IconCheck size={16} />
</ThemeIcon>
}
>
{benefits.map((benefit, index) => (
<List.Item key={index} color="#ECEDEE">{benefit}</List.Item>
<List.Item key={index} color="#ECEDEE">
{benefit}
</List.Item>
))}
</List>
</Box>

<Box my="md">
<Text fw={700} mb="xs" color="#ECEDEE">Important Considerations</Text>
<List
<Text fw={700} mb="xs" color="#ECEDEE">
Important Considerations
</Text>
<List
spacing="sm"
size="sm"
size="sm"
icon={
<ThemeIcon color="#9E1F19" size={24} radius="xl">
<IconAlertTriangle size={16} />
</ThemeIcon>
}
>
{considerations.map((consideration, index) => (
<List.Item key={index} color="#ECEDEE">{consideration}</List.Item>
<List.Item key={index} color="#ECEDEE">
{consideration}
</List.Item>
))}
</List>
</Box>

<Box my="md">
<Text fw={700} mb="xs" color="#ECEDEE">Ideal Use Cases</Text>
<List
<Text fw={700} mb="xs" color="#ECEDEE">
Ideal Use Cases
</Text>
<List
spacing="sm"
size="sm"
size="sm"
icon={
<ThemeIcon color="#8CABA9" size={24} radius="xl">
<IconUsersGroup size={16} />
</ThemeIcon>
}
>
{useCases.map((useCase, index) => (
<List.Item key={index} color="#ECEDEE">{useCase}</List.Item>
<List.Item key={index} color="#ECEDEE">
{useCase}
</List.Item>
))}
</List>
</Box>

{documentation && (
<Card.Section withBorder inheritPadding py="xs" mt="md">
<Text
component="a"
<Text
component="a"
href={documentation}
target="_blank"
rel="noopener noreferrer"
Expand Down
85 changes: 85 additions & 0 deletions components/CodeBlock/CodeBlock.tsx
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;
1 change: 1 addition & 0 deletions components/CodeBlock/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as CodeBlock } from './CodeBlock';
76 changes: 76 additions & 0 deletions components/CodeBlock/styles.css
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;
}
Loading

0 comments on commit 711f73a

Please sign in to comment.