The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/components/Logo.tsx

33 lines
848 B

import { Box } from '@rocket.chat/fuselage';
import { RocketChatLogo } from '@rocket.chat/logo';
import React, { ComponentProps, ReactElement, useState } from 'react';
type LogoProps = Omit<ComponentProps<typeof Box>, 'src'> & {
src?: string;
};
const Logo = ({ src = 'images/logo/logo.svg', ...props }: LogoProps): ReactElement => {
const [isLoaded, setLoaded] = useState(false);
const isPlaceholderVisible = !src || !isLoaded;
const handleLoad = (): void => {
setLoaded(true);
};
const handleError = (): void => {
setLoaded(false);
};
return (
<>
{isPlaceholderVisible && (
<Box display='inline-flex' alignItems='center' {...props}>
<RocketChatLogo />
</Box>
)}
{src && <Box {...props} is='img' src={src} hidden={!isLoaded} onLoad={handleLoad} onError={handleError} />}
</>
);
};
export default Logo;