-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(): Replace bg-transpernt with card.
- Loading branch information
Showing
11 changed files
with
271 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,40 @@ | ||
'use client' | ||
import React from "react" | ||
"use client"; | ||
import React from "react"; | ||
|
||
import {Button, cn} from 'src' | ||
import { Check, Copy } from "lucide-react" | ||
export const CodeCopy = (props: {textToCopy: string, className?: string}) => { | ||
import { Button, cn } from "src"; | ||
import { Check, Copy } from "lucide-react"; | ||
export const CodeCopy = (props: { textToCopy: string; className?: string }) => { | ||
const [copied, setHasCopied] = React.useState(false); | ||
|
||
const [copied, setHasCopied] = React.useState(false) | ||
|
||
return <div className="dark:text-foreground text-background w-full flex items-center justify-center self-start whitespace-nowrap rounded bg-gradient-to-r from-zinc-600 to-slate-600 py-0.5 pl-4 text-center text-sm font-semibold dark:from-zinc-600 dark:to-slate-600"> | ||
<code className="font-mono">{props.textToCopy}</code> | ||
return ( | ||
<div className='dark:text-foreground text-background w-full flex items-center justify-center self-start whitespace-nowrap rounded bg-gradient-to-r from-zinc-600 to-slate-600 py-0.5 pl-4 text-center text-sm font-semibold dark:from-zinc-600 dark:to-slate-600'> | ||
<code className='font-mono'>{props.textToCopy}</code> | ||
|
||
<Button | ||
variant="ghost" | ||
size="icon" | ||
className={cn(`${copied ? ' hover:bg-transparent' : 'hover:bg-background/50 hover:text-foreground/75'} ml-1`, props.className)} | ||
<Button | ||
variant='ghost' | ||
size='icon' | ||
className={cn( | ||
`${ | ||
copied | ||
? " hover:bg-card" | ||
: "hover:bg-background/50 hover:text-foreground/75" | ||
} ml-1`, | ||
props.className | ||
)} | ||
onClick={() => { | ||
window.navigator.clipboard.writeText(props.textToCopy) | ||
setHasCopied(true) | ||
window.navigator.clipboard.writeText(props.textToCopy); | ||
setHasCopied(true); | ||
setTimeout(() => { | ||
setHasCopied(false) | ||
}, 2500) | ||
setHasCopied(false); | ||
}, 2500); | ||
}} | ||
> | ||
{copied ? ( | ||
<Check className="text-background h-5 w-5"></Check> | ||
<Check className='text-background h-5 w-5'></Check> | ||
) : ( | ||
<Copy className="aspect-square h-4 w-4"></Copy> | ||
<Copy className='aspect-square h-4 w-4'></Copy> | ||
)} | ||
</Button> | ||
</div> | ||
} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.