Skip to content

Commit

Permalink
Merge pull request #30 from pheralb/next
Browse files Browse the repository at this point in the history
🛠️ Fix some bugs.
  • Loading branch information
pheralb committed Aug 10, 2023
2 parents 52faf94 + d70ce7f commit 08d36fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions website/src/components/card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ReactNode } from "react"
import { useState } from "react"
import { toast } from "sonner"
import {
Tooltip,
Expand All @@ -16,14 +17,16 @@ interface CardProps {
}

const Card = (props: CardProps) => {
const [value, copy] = useCopyToClipboard()
const [copy] = useCopyToClipboard()
const [isCopied, setIsCopied] = useState<Boolean>(false)

const copyToClipboard = async (txt: string) => {
copy(txt)
setIsCopied(true)
toast("Copied to clipboard!", {
icon: <Copy className="h-5 w-5 text-neutral-300" />,
description: `${txt}`,
onAutoClose: () => copy(""),
onAutoClose: () => setIsCopied(false),
})
}

Expand All @@ -37,7 +40,7 @@ const Card = (props: CardProps) => {
>
{props.icon}
<p className="mt-2 font-medium text-gray-300">
{value ? "Copied!" : props.name}
{isCopied ? "Copied!" : props.name}
</p>
</div>
</TooltipTrigger>
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ExternalArrow from "../icons/externalArrow"
import useCopyToClipboard from "@/hooks/useCopyToClipboard"

const Hero = () => {
const [value, copy] = useCopyToClipboard()
const [copy, value] = useCopyToClipboard()
const [popoverOpen, setPopoverOpen] = useState(false)

const handleCopy = (command: iCommand) => {
Expand Down
4 changes: 2 additions & 2 deletions website/src/hooks/useCopyToClipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react"
type CopiedValue = string | null
type CopyFn = (text: string) => Promise<boolean>

function useCopyToClipboard(): [CopiedValue, CopyFn] {
function useCopyToClipboard(): [CopyFn, CopiedValue] {
const [copiedText, setCopiedText] = useState<CopiedValue>(null)

const copy: CopyFn = async (text) => {
Expand All @@ -22,7 +22,7 @@ function useCopyToClipboard(): [CopiedValue, CopyFn] {
}
}

return [copiedText, copy]
return [copy, copiedText]
}

export default useCopyToClipboard

1 comment on commit 08d36fe

@vercel
Copy link

@vercel vercel bot commented on 08d36fe Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-symbols – ./

react-symbols-pheralb.vercel.app
react-symbols-git-main-pheralb.vercel.app
react-symbols.vercel.app

Please sign in to comment.