From da7feb13482a67db3fafdb718db4684c69ebf117 Mon Sep 17 00:00:00 2001 From: Prasad Ashok Chavan Date: Sun, 24 Sep 2023 11:20:38 +0530 Subject: [PATCH 1/3] Added CopyBtn --- components/codePreview/index.tsx | 20 +++++++++++++++++++- styles/globals.css | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/components/codePreview/index.tsx b/components/codePreview/index.tsx index 962d9d18..e98c7580 100644 --- a/components/codePreview/index.tsx +++ b/components/codePreview/index.tsx @@ -44,6 +44,16 @@ export default function CodePreview({ algorithm }: { algorithm: Algorithm }) { const theme = useTheme(); const fabRef = useRef(); const [mobileMoreMenuOpen, setMobileMoreMenuOpen] = useState(false); + const copyCode = () => + { + var str = document.querySelector(".style_pre__k555n").textContent; + const el = document.createElement('textarea'); + el.value = str; + document.body.appendChild(el); + el.select(); + document.execCommand('copy'); + document.body.removeChild(el); + }; return (
@@ -116,7 +126,7 @@ export default function CodePreview({ algorithm }: { algorithm: Algorithm }) { href={`/playground?algorithm=${algorithm.slug}&language=${selectedLanguague}`} passHref > -
)} diff --git a/styles/globals.css b/styles/globals.css index 5e76ecbc..13cc03fe 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -79,6 +79,7 @@ body { } .dark .section a { + margin-right: 6px; color: #00bcb4; } From e84bf2989e0c7c9e945bca717e204e8546af62ca Mon Sep 17 00:00:00 2001 From: Prasad Ashok Chavan Date: Tue, 26 Sep 2023 09:30:38 +0530 Subject: [PATCH 2/3] Updated Copy Btn --- components/codePreview/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/codePreview/index.tsx b/components/codePreview/index.tsx index e98c7580..8c16a207 100644 --- a/components/codePreview/index.tsx +++ b/components/codePreview/index.tsx @@ -141,7 +141,7 @@ export default function CodePreview({ algorithm }: { algorithm: Algorithm }) { className={classes.tryCode} onClick = {() => copyCode()} > - {("Copy This Code")} + {("Copy Code")} From bb7373a12871be227adb58c393df710a7f40d3da Mon Sep 17 00:00:00 2001 From: Prashuu <97186762+prasad-chavan1@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:00:41 +0530 Subject: [PATCH 3/3] Update README.md Added one audience catchy line in Readme file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 161ada65..d5843b62 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@

-This is a static [Next.js](https://nextjs.org/) site providing a searchable library of all the algorithms in [The Algorithms](https://github.com/TheAlgorithms). All the data about the algorithms gets scraped directly from the git repositories. +This is a static [Next.js](https://nextjs.org/) site providing a searchable library of all the algorithms in [The Algorithms](https://github.com/TheAlgorithms). All the data about the algorithms gets scraped directly from the git repositories. Unlock the world of algorithms with a single click and explore the magic of code in action. ## Translating the website