Skip to content

Commit

Permalink
Support link in logo
Browse files Browse the repository at this point in the history
  • Loading branch information
dmt0 committed Dec 5, 2023
1 parent 168b82b commit a39a1a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/DefaultEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Logo from './components/widgets/Logo';
import {TRANSFORMABLE_TRACES, TRACE_TO_AXIS} from './lib/constants';

const DefaultEditor = (
{logoSrc, children, menuPanelOrder},
{logoSrc, logoLinkUrl, children, menuPanelOrder},
{fullData, fullLayout, layout, localize: _}
) => {
const hasTransforms = () => fullData.some((d) => TRANSFORMABLE_TRACES.includes(d.type));
Expand Down Expand Up @@ -51,7 +51,7 @@ const DefaultEditor = (

return (
<PanelMenuWrapper menuPanelOrder={menuPanelOrder}>
{Boolean(logoSrc) && <Logo src={logoSrc} />}
{Boolean(logoSrc) && <Logo src={logoSrc} link={logoLinkUrl} />}
<GraphCreatePanel group={_('Structure')} name={_('Traces')} />
<GraphSubplotsPanel group={_('Structure')} name={_('Subplots')} />
{hasTransforms() && <GraphTransformsPanel group={_('Structure')} name={_('Transforms')} />}
Expand All @@ -74,6 +74,7 @@ const DefaultEditor = (
DefaultEditor.propTypes = {
children: PropTypes.node,
logoSrc: PropTypes.string,
logoLinkUrl: PropTypes.string,
menuPanelOrder: PropTypes.array,
};

Expand Down
6 changes: 5 additions & 1 deletion src/components/widgets/Logo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import PropTypes from 'prop-types';

const Logo = ({src}) => <img className="sidebar__logo" src={src} />;
const Logo = ({link, src}) => {
const image = <img className="sidebar__logo" src={src} />;
return link ? <a href={link}>{image}</a> : image;
};

export default Logo;

Logo.plotly_editor_traits = {sidebar_element: true};

Logo.propTypes = {
link: PropTypes.string,
src: PropTypes.string,
};

0 comments on commit a39a1a0

Please sign in to comment.