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/website/src/components/CodeTerminal/CodeTerminal.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

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-29 13:10:03 +00:00
<div className="bg-palette-400 rounded-t space-x-2 px-2">
<div style={{ height: "11px", width: "11px" }} className="inline-block rounded-full bg-error"></div>
<div style={{ height: "11px", width: "11px" }} className="inline-block rounded-full bg-warning"></div>
<div style={{ height: "11px", width: "11px" }} className="inline-block rounded-full bg-primary"></div>
</div>
<div className="p-4 bg-palette-500 text-sm" style={{ backgroundColor: "rgb(40, 44, 52)" }}>
<SyntaxHighlighter language="javascript" showLineNumbers={true} wrapLongLines={true} style={style}>
{codeString}
</SyntaxHighlighter>
</div>
</div>
);
};
CodeTerminal.propTypes = {};
CodeTerminal.defaultProps = {};
export default CodeTerminal;