Backfill api keys

This commit is contained in:
David Corbitt
2023-08-07 13:08:33 -07:00
parent c9f59bfb79
commit 8f49bace53
5 changed files with 167 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
import { HStack, Icon, IconButton, Tooltip, Text } from "@chakra-ui/react";
import { useCallback, useState } from "react";
import { MdContentCopy } from "react-icons/md";
const CopiableCode = ({ code }: { code: string }) => {
const [copied, setCopied] = useState(false);
const copyToClipboard = useCallback(() => {
const onCopy = async () => {
console.log("copied!");
await navigator.clipboard.writeText(code);
setCopied(true);
};
void onCopy();
}, [code]);
return (
<HStack
backgroundColor="blackAlpha.800"
color="white"
borderRadius={4}
padding={3}
w="full"
justifyContent="space-between"
>
<Text fontFamily="inconsolata" fontWeight="bold" letterSpacing={0.5}>
{code}
</Text>
<Tooltip closeOnClick={false} label={copied ? "Copied!" : "Copy to clipboard"}>
<IconButton
aria-label="Copy"
icon={<Icon as={MdContentCopy} boxSize={5} />}
size="xs"
colorScheme="white"
variant="ghost"
onClick={copyToClipboard}
onMouseLeave={() => setCopied(false)}
/>
</Tooltip>
</HStack>
);
};
export default CopiableCode;