File tree Expand file tree Collapse file tree
src/components/CodeBlockWithCopy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import PropTypes from "prop-types" ;
22import { useEffect , useRef , useState } from "react" ;
3- import "./CodeBlockWithCopy.scss" ;
3+ // Tailwind CSS is now used for styling. Custom SCSS removed.
44
55export default function CodeBlockWithCopy ( { children } ) {
66 const preRef = useRef ( null ) ;
@@ -115,11 +115,19 @@ export default function CodeBlockWithCopy({ children }) {
115115 ) ;
116116
117117 return (
118- < div className = "code-block-wrapper " >
118+ < div className = "relative mb-6 group " >
119119 < button
120120 onClick = { handleCopy }
121- className = { `copy-button ${ copyStatus } ` }
122121 aria-label = "Copy code to clipboard"
122+ className = { `absolute top-2 right-2 z-10 px-3 py-1.5 rounded-md border-none cursor-pointer text-xs font-medium opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-all duration-300
123+ ${
124+ copyStatus === "copied"
125+ ? "bg-green-600 hover:bg-green-700 text-gray-100"
126+ : copyStatus === "error"
127+ ? "bg-red-600 hover:bg-red-700 text-gray-100"
128+ : "bg-blue-700 hover:bg-blue-600 text-blue-100"
129+ }
130+ active:scale-95 focus:outline-none` }
123131 >
124132 { copyStatus === "copied"
125133 ? "Copied!"
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments