Skip to content

Commit

Permalink
Merge pull request #5681 from mannika763/Highlight-Syntax
Browse files Browse the repository at this point in the history
Code syntax highlighting for sistent components
  • Loading branch information
sudhanshutech authored Jul 20, 2024
2 parents da94763 + 612ca96 commit aef41d5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/sections/Projects/Sistent/components/button/code-block.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import React, { useState } from "react";

import Code from "../../../../../components/CodeBlock";
export const CodeBlock = ({ name, code }) => {
const [showCode, setShowCode] = useState(false);

const onChange = () => {
setShowCode((prev) => !prev);
};

return (
<div className="show-code">
<input type="checkbox" name={name} id={name} onChange={onChange} />
<label htmlFor={name} className="label">
Show Code
</label>
{showCode && (
<pre className="code">
<code lang="javascript">{code}</code>
</pre>
{showCode && (
<Code codeString={code} language="javascript" />
)}
</div>
);
Expand Down

0 comments on commit aef41d5

Please sign in to comment.