From f53768612b1e2268697b5444e502032ef9f3fb3c Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Tue, 23 May 2023 23:45:12 -0400
Subject: copying from old repo

---
 extension/react-app/src/components/CodeBlock.tsx | 57 ++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 extension/react-app/src/components/CodeBlock.tsx

(limited to 'extension/react-app/src/components/CodeBlock.tsx')

diff --git a/extension/react-app/src/components/CodeBlock.tsx b/extension/react-app/src/components/CodeBlock.tsx
new file mode 100644
index 00000000..4c10ab23
--- /dev/null
+++ b/extension/react-app/src/components/CodeBlock.tsx
@@ -0,0 +1,57 @@
+import hljs from "highlight.js";
+import { useEffect } from "react";
+import styled from "styled-components";
+import { defaultBorderRadius, vscBackground } from ".";
+
+import { Clipboard } from "@styled-icons/heroicons-outline";
+
+const StyledPre = styled.pre`
+  overflow: scroll;
+  border: 1px solid gray;
+  border-radius: ${defaultBorderRadius};
+  background-color: ${vscBackground};
+`;
+
+const StyledCode = styled.code`
+  background-color: ${vscBackground};
+`;
+
+const StyledCopyButton = styled.button`
+  float: right;
+  border: none;
+  background-color: ${vscBackground};
+  cursor: pointer;
+  padding: 0;
+  margin: 4px;
+  &:hover {
+    color: #fff;
+  }
+`;
+
+function CopyButton(props: { textToCopy: string }) {
+  return (
+    <>
+      <StyledCopyButton
+        onClick={() => {
+          navigator.clipboard.writeText(props.textToCopy);
+        }}
+      >
+        <Clipboard color="white" size="1.4em" />
+      </StyledCopyButton>
+    </>
+  );
+}
+
+function CodeBlock(props: { language?: string; children: string }) {
+  useEffect(() => {
+    hljs.highlightAll();
+  }, [props.children]);
+  return (
+    <StyledPre>
+      <CopyButton textToCopy={props.children} />
+      <StyledCode>{props.children}</StyledCode>
+    </StyledPre>
+  );
+}
+
+export default CodeBlock;
-- 
cgit v1.2.3-70-g09d2

