fix: hide Redocly logo for network without internet

This commit is contained in:
Anastasiia Derymarko 2022-08-01 11:52:34 +03:00
parent a08af6b204
commit a3966b9813
2 changed files with 20 additions and 4 deletions

View File

@ -0,0 +1,18 @@
import { useEffect, useState } from 'react';
import * as React from 'react';
export default function RedoclyLogo(): JSX.Element | null {
const [isDisplay, setDisplay] = useState(false);
useEffect(() => {
setDisplay(true);
}, []);
return isDisplay ? (
<img
alt={'redocly logo'}
onError={() => setDisplay(false)}
src={'https://cdn.redoc.ly/redoc/logo-mini.svg'}
/>
) : null;
}

View File

@ -8,6 +8,7 @@ import { MenuItems } from './MenuItems';
import { PerfectScrollbarWrap } from '../../common-elements/perfect-scrollbar'; import { PerfectScrollbarWrap } from '../../common-elements/perfect-scrollbar';
import { RedocAttribution } from './styled.elements'; import { RedocAttribution } from './styled.elements';
import RedoclyLogo from './Logo';
@observer @observer
export class SideMenu extends React.Component<{ menu: MenuStore; className?: string }> { export class SideMenu extends React.Component<{ menu: MenuStore; className?: string }> {
@ -27,10 +28,7 @@ export class SideMenu extends React.Component<{ menu: MenuStore; className?: str
<MenuItems items={store.items} onActivate={this.activate} root={true} /> <MenuItems items={store.items} onActivate={this.activate} root={true} />
<RedocAttribution> <RedocAttribution>
<a target="_blank" rel="noopener noreferrer" href="https://redocly.com/redoc/"> <a target="_blank" rel="noopener noreferrer" href="https://redocly.com/redoc/">
<img <RedoclyLogo />
src={'https://cdn.redoc.ly/redoc/logo-mini.svg'}
onError={event => event.currentTarget.remove()}
/>
API docs by Redocly API docs by Redocly
</a> </a>
</RedocAttribution> </RedocAttribution>