forked from Skyvern-AI/skyvern
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Settings and accordion update (Skyvern-AI#217)
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 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
44 changes: 44 additions & 0 deletions
44
skyvern-frontend/src/components/ui/hidden-copyable-input.tsx
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useState } from "react"; | ||
import { Button } from "./button"; | ||
import { Input } from "./input"; | ||
import { CheckIcon, CopyIcon } from "@radix-ui/react-icons"; | ||
|
||
type Props = { | ||
value: string; | ||
}; | ||
|
||
function HiddenCopyableInput({ value }: Props) { | ||
const [hidden, setHidden] = useState(true); | ||
const [copied, setCopied] = useState(false); | ||
|
||
const buttonText = hidden ? "Reveal" : copied ? "Copied" : "Copy"; | ||
const inputValue = hidden ? "**** **** **** ****" : value; | ||
|
||
return ( | ||
<div className="relative w-full"> | ||
<Input value={inputValue} className="h-10" readOnly /> | ||
<div className="absolute flex inset-y-0 items-center right-1"> | ||
<Button | ||
size="sm" | ||
variant="secondary" | ||
className="cursor-pointer" | ||
onClick={async () => { | ||
if (hidden) { | ||
setHidden(false); | ||
return; | ||
} | ||
await navigator.clipboard.writeText(value); | ||
setCopied(true); | ||
setTimeout(() => setCopied(false), 3000); | ||
}} | ||
> | ||
{!hidden && !copied && <CopyIcon className="mr-2 h-4 w-4" />} | ||
{!hidden && copied && <CheckIcon className="mr-2 h-4 w-4" />} | ||
{buttonText} | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export { HiddenCopyableInput }; |
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