This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/sia-skynet/src/components/CodeExamples/CodeExamples.js

57 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-02-12 17:23:10 +00:00
import React, { useState } from 'react'
import SyntaxHighlighter from 'react-syntax-highlighter'
import classNames from 'classnames'
import './CodeExamples.scss'
import Colors from './Colors'
import { python, curl, node, go } from './Code'
export default function CodeExamples() {
const [active, setActive] = useState(1)
return (
<div className="code-examples">
<ul className="code-examples-tabs">
<li onClick={() => setActive(1)} className={classNames({ active: active === 1 })}>
2020-02-14 22:08:14 +00:00
CURL
2020-02-12 17:23:10 +00:00
</li>
<li onClick={() => setActive(2)} className={classNames({ active: active === 2 })}>
2020-02-14 22:08:14 +00:00
Python
2020-02-12 17:23:10 +00:00
</li>
<li onClick={() => setActive(3)} className={classNames({ active: active === 3 })}>
Node.js
</li>
<li onClick={() => setActive(4)} className={classNames({ active: active === 4 })}>
Go
</li>
</ul>
<div className="code-examples-body">
{active === 1 && (
2020-02-14 22:08:14 +00:00
<SyntaxHighlighter wrapLines showLineNumbers={true} language="curl" style={Colors}>
{curl}
2020-02-12 17:23:10 +00:00
</SyntaxHighlighter>
)}
{active === 2 && (
2020-02-14 22:08:14 +00:00
<SyntaxHighlighter wrapLines showLineNumbers={true} language="python" style={Colors}>
{python}
2020-02-12 17:23:10 +00:00
</SyntaxHighlighter>
)}
{active === 3 && (
<SyntaxHighlighter wrapLines showLineNumbers={true} language="node" style={Colors}>
{node}
</SyntaxHighlighter>
)}
{active === 4 && (
<SyntaxHighlighter wrapLines showLineNumbers={true} language="go" style={Colors}>
{go}
</SyntaxHighlighter>
)}
</div>
</div>
)
}