2021-03-29 13:10:03 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
|
|
import js from "react-syntax-highlighter/dist/esm/languages/hljs/javascript";
|
|
|
|
import style from "react-syntax-highlighter/dist/esm/styles/hljs/atom-one-dark";
|
|
|
|
|
|
|
|
SyntaxHighlighter.registerLanguage("javascript", js);
|
|
|
|
|
|
|
|
const CodeTerminal = () => {
|
|
|
|
const codeString = `import { SkynetClient } from "skynet-js";
|
|
|
|
|
|
|
|
// create a client
|
|
|
|
const client = new SkynetClient();
|
|
|
|
|
|
|
|
// Assume we have a file from an input form.
|
|
|
|
|
|
|
|
async function example() {
|
|
|
|
try {
|
|
|
|
// upload
|
|
|
|
const { skylink } = await client.uploadFile(file);
|
|
|
|
|
|
|
|
// download
|
|
|
|
await client.downloadFile(skylink);
|
|
|
|
|
|
|
|
console.log('Download successful');
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error)
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
|
|
|
|
return (
|
2021-03-29 21:32:17 +00:00
|
|
|
<div>
|
2021-03-31 16:12:18 +00:00
|
|
|
<div className="bg-palette-400 rounded-t space-x-2 px-2">
|
2021-03-31 11:24:05 +00:00
|
|
|
<div className="circle bg-error"></div>
|
|
|
|
<div className="circle bg-warning"></div>
|
|
|
|
<div className="circle bg-primary"></div>
|
2021-03-29 13:10:03 +00:00
|
|
|
</div>
|
|
|
|
<div className="p-4 bg-palette-500 text-sm" style={{ backgroundColor: "rgb(40, 44, 52)" }}>
|
2021-03-31 11:24:05 +00:00
|
|
|
<SyntaxHighlighter language="javascript" showLineNumbers={true} style={style}>
|
2021-03-29 13:10:03 +00:00
|
|
|
{codeString}
|
|
|
|
</SyntaxHighlighter>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
CodeTerminal.propTypes = {};
|
|
|
|
|
|
|
|
CodeTerminal.defaultProps = {};
|
|
|
|
|
|
|
|
export default CodeTerminal;
|