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 Nov 8, 2023
1 parent ca4c4e6 commit 7e8685f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/DefaultEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ class DefaultEditor extends Component {

render() {
const _ = this.context.localize;
const logo = this.props.logoSrc && <Logo src={this.props.logoSrc} />;
const {logoSrc, logoLinkUrl, menuPanelOrder, children} = this.props;
const logo = logoSrc && <Logo src={logoSrc} link={logoLinkUrl} />;

return (
<PanelMenuWrapper menuPanelOrder={this.props.menuPanelOrder}>
{logo ? logo : null}
<PanelMenuWrapper menuPanelOrder={menuPanelOrder}>
{logo || null}
<GraphCreatePanel group={_('Structure')} name={_('Traces')} />
<GraphSubplotsPanel group={_('Structure')} name={_('Subplots')} />
{this.hasTransforms() && (
Expand All @@ -99,7 +100,7 @@ class DefaultEditor extends Component {
<StyleImagesPanel group={_('Annotate')} name={_('Images')} />
{this.hasSliders() && <StyleSlidersPanel group={_('Control')} name={_('Sliders')} />}
{this.hasMenus() && <StyleUpdateMenusPanel group={_('Control')} name={_('Menus')} />}
{this.props.children ? this.props.children : null}
{children || null}
</PanelMenuWrapper>
);
}
Expand All @@ -108,6 +109,7 @@ class DefaultEditor extends Component {
DefaultEditor.propTypes = {
children: PropTypes.node,
logoSrc: PropTypes.string,
logoLinkUrl: PropTypes.string,
menuPanelOrder: PropTypes.array,
};

Expand Down
5 changes: 4 additions & 1 deletion src/components/widgets/Logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import React, {Component} from 'react';

export default class Logo extends Component {
render() {
return <img className="sidebar__logo" src={this.props.src} />;
const {link, src} = this.props;
const image = <img className="sidebar__logo" src={src} />;
return link ? <a href={this.props.link}>{image}</a> : image;
}
}

Logo.plotly_editor_traits = {sidebar_element: true};

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

0 comments on commit 7e8685f

Please sign in to comment.