@chakra-ui/react#AlertDescription JavaScript Examples
The following examples show how to use
@chakra-ui/react#AlertDescription.
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: PageNotFound.js From web-client with Apache License 2.0 | 6 votes |
PageNotFound = () => {
return <Alert
status='error'
variant='subtle'
flexDirection='column'
alignItems='center'
justifyContent='center'
textAlign='center'
>
<AlertIcon boxSize='40px' mr={0} />
<AlertTitle mt={4} mb={1} fontSize='lg'>
Page not found
</AlertTitle>
<AlertDescription>
There is nothing at this address. Please navigate to another place.
</AlertDescription>
</Alert>
}
Example #2
Source File: components.js From idena-web with MIT License | 5 votes |
export function Toast({
title,
description,
icon = 'info',
status = 'info',
actionContent,
actionColor = status === 'error' ? 'red.500' : 'brandBlue.500',
color,
onAction,
duration,
...props
}) {
return (
<Alert
status={status}
bg="white"
boxShadow="0 3px 12px 0 rgba(83, 86, 92, 0.1), 0 2px 3px 0 rgba(83, 86, 92, 0.2)"
color={color || 'brandGray.500'}
fontSize="md"
pl={4}
pr={actionContent ? 2 : 5}
pt="10px"
pb={3}
mb={5}
minH="44px"
rounded="lg"
{...props}
>
<AlertIcon
name={icon}
size={5}
color={color || (status === 'error' ? 'red.500' : 'blue.500')}
/>
<Flex direction="column" align="flex-start" maxW={['90vw', 'sm']}>
<AlertTitle fontWeight={500} lineHeight="base">
{title}
</AlertTitle>
<AlertDescription
color={color || 'muted'}
lineHeight="base"
textAlign="left"
maxW={['77vw', 'none']}
w="full"
isTruncated
>
{description}
</AlertDescription>
</Flex>
{actionContent && (
<Button
variant="ghost"
color={actionColor}
fontWeight={500}
lineHeight="base"
px={3}
py="3/2"
_hover={{bg: 'unset'}}
_active={{bg: 'unset'}}
_focus={{boxShadow: 'none'}}
onClick={onAction}
>
{actionContent}
</Button>
)}
<Box
bg="gray.100"
height="3px"
roundedBottom={2}
pos="absolute"
bottom={0}
left={0}
right={0}
animation={`${escape} ${duration}ms linear forwards`}
/>
</Alert>
)
}
Example #3
Source File: NotificationsBadge.js From web-client with Apache License 2.0 | 5 votes |
NotificationsBadge = () => {
const [notifications, fetchNotifications] = useFetch('/notifications?status=unread');
const onMessageHandler = () => {
fetchNotifications();
}
useWebsocketMessage(onMessageHandler);
const markAsRead = notification => {
secureApiFetch(`/notifications/${notification.id}`, {
method: 'PUT',
body: JSON.stringify({ status: 'read' })
}).then(() => {
fetchNotifications();
})
}
return <Popover placement="bottom-end" closeOnBlur={true}>
<PopoverTrigger>
<Button pr={null !== notifications && notifications.length > 0 ? 1 : 2} variant="ghost" aria-label="Notifications" >
<BellIcon fontSize="xl" color="gray.500" />
{null !== notifications && notifications.length > 0 && (
<Tag colorScheme='red' >{notifications.length}</Tag>
)}
</Button>
</PopoverTrigger>
<PopoverContent>
<PopoverArrow />
<PopoverHeader px="3" pb="3" color="gray.500">
<Link to="/notifications">Notifications</Link>
</PopoverHeader>
<PopoverBody>
{null !== notifications && notifications.length > 0 ? (
<Stack>
{notifications.map(notification =>
<Alert key={notification.id} status='info' variant="top-accent">
<Box flex='1'>
<AlertTitle>{notification.time} <strong><Link to="/vulnerabilities">{notification.title}</Link></strong></AlertTitle>
<AlertDescription display='block'>{notification.content}</AlertDescription>
</Box>
<CloseButton position='absolute' right='8px' top='8px' onClick={() => markAsRead(notification)} />
</Alert>
)}
</Stack>
) : <span>Nothing to see here.</span>}
</PopoverBody>
</PopoverContent>
</Popover>
}
Example #4
Source File: components.js From idena-web with MIT License | 4 votes |
export function DeactivateMiningDrawer({
isLoading,
delegatee,
canUndelegate,
onDeactivate,
onClose,
...props
}) {
const {t} = useTranslation()
const sizeInput = useBreakpointValue(['lg', 'md'])
const sizeButton = useBreakpointValue(['mdx', 'md'])
const variantPrimary = useBreakpointValue(['primaryFlat', 'primary'])
const variantSecondary = useBreakpointValue(['secondaryFlat', 'secondary'])
const isDelegator = typeof delegatee === 'string'
return (
<AdDrawer isMining={isLoading} onClose={onClose} {...props}>
<DrawerHeader>
<Flex
direction="column"
textAlign={['center', 'start']}
justify={['space-between', 'flex-start']}
>
<Flex
order={[2, 1]}
mt={[6, 0]}
align="center"
justify="center"
bg="blue.012"
h={12}
w={12}
rounded="xl"
>
<UserIcon boxSize={6} color="blue.500" />
</Flex>
<Heading
order={[1, 2]}
color="brandGray.500"
fontSize={['base', 'lg']}
fontWeight={[['bold', 500]]}
lineHeight="base"
mt={[0, 4]}
>
{isDelegator
? t('Deactivate delegation status')
: t('Deactivate mining status')}
</Heading>
</Flex>
</DrawerHeader>
<DrawerBody>
<Stack spacing={6} mt={[2, 30]}>
<Text fontSize={['mdx', 'md']} mb={[0, 3]}>
{isDelegator
? t(`Submit the form to deactivate your delegation status.`)
: t(
`Submit the form to deactivate your mining status. You can activate it again afterwards.`
)}
</Text>
{isDelegator && (
<FormControl as={Stack} spacing={[0, 3]}>
<FormLabel fontSize={['base', 'md']}>
{t('Delegation address')}
</FormLabel>
<Input size={sizeInput} defaultValue={delegatee} isDisabled />
</FormControl>
)}
{isDelegator && !canUndelegate && (
<Alert
status="error"
rounded="md"
bg="red.010"
borderColor="red.050"
borderWidth={1}
>
<AlertIcon name="info" alignSelf="flex-start" color="red.500" />
<AlertDescription
color="brandGray.500"
fontSize="md"
fontWeight={500}
>
{t('You can disable delegation at the next epoch only')}
</AlertDescription>
</Alert>
)}
</Stack>
<PrimaryButton
display={['flex', 'none']}
mt={4}
w="100%"
fontSize="mobile"
size="lg"
isDisabled={isDelegator && !canUndelegate}
isLoading={isLoading}
onClick={onDeactivate}
loadingText={t('Waiting...')}
>
{t('Submit')}
</PrimaryButton>
</DrawerBody>
<DrawerFooter display={['none', 'flex']} mt={[6, 0]} px={0}>
<Flex width="100%" justify={['space-evenly', 'flex-end']}>
<Button
variant={variantSecondary}
order={[3, 1]}
size={sizeButton}
type="button"
onClick={onClose}
>
{t('Cancel')}
</Button>
<Divider
order="2"
display={['block', 'none']}
h={10}
orientation="vertical"
color="gray.100"
/>
<Button
variant={variantPrimary}
order={[1, 3]}
size={sizeButton}
ml={[0, 2]}
isDisabled={isDelegator && !canUndelegate}
isLoading={isLoading}
onClick={onDeactivate}
loadingText={t('Waiting...')}
>
{t('Submit')}
</Button>
</Flex>
</DrawerFooter>
</AdDrawer>
)
}