@chakra-ui/icons#CopyIcon TypeScript Examples
The following examples show how to use
@chakra-ui/icons#CopyIcon.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PaymentMethodButtonModal.tsx From coindrop with GNU General Public License v3.0 | 5 votes |
PaymentMethodButtonModal: FunctionComponent<Props> = ({ isOpen, onClose, paymentMethod, paymentMethodDisplayName, paymentMethodValue }) => {
const { onCopy, hasCopied } = useClipboard(paymentMethodValue);
const { piggybankDbData } = useContext(PublicPiggybankDataContext);
const { name } = piggybankDbData;
const Icon = paymentMethodIcons[paymentMethod];
const addressIsUrl = isUrl(paymentMethodValue, {
require_protocol: true,
require_valid_protocol: true,
protocols: ['http', 'https'],
allow_protocol_relative_urls: false,
});
return (
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent mx={6}>
<ModalHeader
textAlign="center"
mt={3}
mx="auto"
>
{name}
{"'s "}
{paymentMethodDisplayName}
{' address'}
</ModalHeader>
<ModalCloseButton />
<ModalBody
pt={0}
mb={3}
mx="auto"
>
<Flex justify="center" align="center">
<Icon
mr={2}
boxSize="48px"
/>
<Text
wordBreak="break-all"
textAlign="center"
>
{paymentMethodValue}
</Text>
</Flex>
<Flex
my={2}
align="center"
justify="center"
>
{addressIsUrl ? (
<Link href={paymentMethodValue} isExternal>
<Button
leftIcon={<ExternalLinkIcon />}
href={paymentMethodValue}
mr={2}
>
Open
</Button>
</Link>
) : (
<Button
leftIcon={hasCopied ? <CheckIcon /> : <CopyIcon />}
onClick={onCopy}
>
{hasCopied ? "Copied" : "Copy"}
</Button>
)}
</Flex>
<Text mb={2} textAlign="center">or scan QR Code:</Text>
<Flex justify="center">
<QRCode
id="payment-method-qr-code"
value={paymentMethodValue}
size={225}
/>
</Flex>
</ModalBody>
</ModalContent>
</Modal>
);
}
Example #2
Source File: AccountModal.tsx From eth-dapps-nextjs-boiletplate with MIT License | 4 votes |
export default function AccountModal({ isOpen, onClose }: Props) {
const { globalState, dispatch } = useContext(globalContext)
const { account, provider } = globalState
const chainIdPaths = {
1: '', // mainnet
42: 'kovan.',
3: 'ropsten.',
4: 'rinkeby.',
5: 'goerli.',
}
const chainPath = provider && chainIdPaths[parseInt(provider.chainId)]
async function handleDeactivateAccount() {
//deactivate();
if (provider && !provider.isMetaMask) { // isWalletConnect then
await provider.disconnect()
}
dispatch({ type: 'CLEAR_STATE'})
onClose();
}
return (
<Modal isOpen={isOpen} onClose={onClose} isCentered size="md">
<ModalOverlay />
<ModalContent
background="gray.900"
border="1px"
borderStyle="solid"
borderColor="gray.700"
borderRadius="3xl"
>
<ModalHeader color="white" px={4} fontSize="lg" fontWeight="medium">
Account
</ModalHeader>
<ModalCloseButton
color="white"
fontSize="sm"
_hover={{
color: "whiteAlpha.700",
}}
/>
<ModalBody pt={0} px={4}>
<Box
borderRadius="3xl"
border="1px"
borderStyle="solid"
borderColor="gray.600"
px={5}
pt={4}
pb={2}
mb={3}
>
<Flex justifyContent="space-between" alignItems="center" mb={3}>
<Text color="gray.400" fontSize="sm">
Connected with {provider?.isMetaMask ? 'MetaMask' : 'WalletConnect'}
</Text>
<Button
variant="outline"
size="sm"
borderColor="blue.800"
borderRadius="3xl"
color="blue.500"
fontSize="13px"
fontWeight="normal"
px={2}
height="26px"
_hover={{
background: "none",
borderColor: "blue.300",
textDecoration: "underline",
}}
onClick={handleDeactivateAccount}
>
Disconnect
</Button>
</Flex>
<Flex alignItems="center" mt={2} mb={4} lineHeight={1}>
<Identicon />
<Text
color="white"
fontSize="xl"
fontWeight="semibold"
ml="2"
lineHeight="1.1"
>
{account &&
`${account.slice(0, 6)}...${account.slice(
account.length - 4,
account.length
)}`}
</Text>
</Flex>
<Flex alignContent="center" m={3}>
<Button
variant="link"
color="gray.400"
fontWeight="normal"
fontSize="sm"
_hover={{
textDecoration: "none",
color: "whiteAlpha.800",
}}
>
<CopyIcon mr={1} />
Copy Address
</Button>
{
chainPath?
<Link
fontSize="sm"
display="flex"
alignItems="center"
href={`https://${chainPath}etherscan.io/address/${account}`}
isExternal
color="gray.400"
ml={6}
_hover={{
color: "whiteAlpha.800",
textDecoration: "underline",
}}
>
<ExternalLinkIcon mr={1} />
View on Explorer
</Link>:''
}
</Flex>
</Box>
</ModalBody>
<ModalFooter
justifyContent="end"
background="gray.700"
borderBottomLeftRadius="3xl"
borderBottomRightRadius="3xl"
p={6}
>
<Text
color="white"
textAlign="left"
fontWeight="medium"
fontSize="md"
>
Your transactions will appear here...
</Text>
</ModalFooter>
</ModalContent>
</Modal>
);
}
Example #3
Source File: Inspector.tsx From openchakra with MIT License | 4 votes |
Inspector = () => {
const dispatch = useDispatch()
const component = useSelector(getSelectedComponent)
const { isOpen, onOpen, onClose } = useDisclosure()
const [componentName, onChangeComponentName] = useState('')
const componentsNames = useSelector(getComponentNames)
const { clearActiveProps } = useInspectorUpdate()
const saveComponent = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
dispatch.components.setComponentName({
componentId: component.id,
name: componentName,
})
onClose()
onChangeComponentName('')
}
const isValidComponentName = useMemo(() => {
return (
!!componentName.match(/^[A-Z]\w*$/g) &&
!componentsNames.includes(componentName) &&
// @ts-ignore
!componentsList.includes(componentName)
)
}, [componentName, componentsNames])
const { type, rootParentType, id, children } = component
const isRoot = id === 'root'
const parentIsRoot = component.parent === 'root'
const docType = rootParentType || type
const componentHasChildren = children.length > 0
useEffect(() => {
clearActiveProps()
}, [clearActiveProps])
return (
<>
<Box bg="white">
<Box
fontWeight="semibold"
fontSize="md"
color="yellow.900"
py={2}
px={2}
boxShadow="sm"
bg="yellow.100"
display="flex"
justifyContent="space-between"
flexDir="column"
>
{isRoot ? 'Document' : type}
{!!component.componentName && (
<Text fontSize="xs" fontWeight="light">
{component.componentName}
</Text>
)}
</Box>
{!isRoot && (
<Stack
direction="row"
py={2}
spacing={2}
align="center"
zIndex={99}
px={2}
flexWrap="wrap"
justify="flex-end"
>
<CodeActionButton />
{!component.componentName && (
<ActionButton
label="Name component"
icon={<EditIcon path="" />}
onClick={onOpen}
/>
)}
<ActionButton
label="Duplicate"
onClick={() => dispatch.components.duplicate()}
icon={<CopyIcon path="" />}
/>
<ActionButton
label="Reset props"
icon={<IoMdRefresh />}
onClick={() => dispatch.components.resetProps(component.id)}
/>
<ActionButton
label="Chakra UI Doc"
as={Link}
onClick={() => {
window.open(
`https://chakra-ui.com/${docType.toLowerCase()}`,
'_blank',
)
}}
icon={<GoRepo />}
/>
<ActionButton
bg="red.500"
label="Remove"
onClick={() => dispatch.components.deleteComponent(component.id)}
icon={<FiTrash2 />}
/>
</Stack>
)}
</Box>
<Box pb={1} bg="white" px={3}>
<Panels component={component} isRoot={isRoot} />
</Box>
<StylesPanel
isRoot={isRoot}
showChildren={componentHasChildren}
parentIsRoot={parentIsRoot}
/>
<Modal onClose={onClose} isOpen={isOpen} isCentered>
<ModalOverlay>
<ModalContent>
<form onSubmit={saveComponent}>
<ModalHeader>Save this component</ModalHeader>
<ModalCloseButton />
<ModalBody>
<FormControl isInvalid={!isValidComponentName}>
<FormLabel>Component name</FormLabel>
<Input
size="md"
autoFocus
variant="outline"
isFullWidth
focusBorderColor="blue.500"
errorBorderColor="red.500"
value={componentName}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
onChangeComponentName(e.target.value)
}
/>
{!isValidComponentName && (
<FormErrorMessage>
Component name must start with a capital character and
must not contain space or special character, and name
should not be already taken (including existing chakra-ui
components).
</FormErrorMessage>
)}
<FormHelperText>
This will name your component that you will see in the code
panel as a separated component.
</FormHelperText>
</FormControl>
</ModalBody>
<ModalFooter>
<Button
colorScheme="blue"
mr={3}
type="submit"
isDisabled={!isValidComponentName}
>
Save
</Button>
<Button onClick={onClose}>Cancel</Button>
</ModalFooter>
</form>
</ModalContent>
</ModalOverlay>
</Modal>
</>
)
}