Skip to content
Snippets Groups Projects
Unverified Commit 48a06a3f authored by Jessie Keck's avatar Jessie Keck Committed by GitHub
Browse files

Merge pull request #2875 from ProjectMirador/plugin-utility

Update plugin utilities
parents 7f064644 e6da06fd
No related branches found
No related tags found
No related merge requests found
import React from 'react';
import PropTypes from 'prop-types';
import MenuItem from '@material-ui/core/MenuItem';
import Typography from '@material-ui/core/Typography';
import ExtensionIcon from '@material-ui/icons/ExtensionOutlined';
/** */
function PluginListItem(props) {
const { onClick, icon, title } = props;
return (
<MenuItem onClick={onClick}>
{ icon || <ExtensionIcon /> }
<Typography inline style={{ paddingLeft: '12px' }}>
{ title }
</Typography>
</MenuItem>
);
}
PluginListItem.propTypes = {
icon: PropTypes.node,
onClick: PropTypes.func,
title: PropTypes.string,
};
PluginListItem.defaultProps = {
icon: null,
onClick: null,
title: 'Plugin without title',
};
export default PluginListItem;
import React from 'react';
import PropTypes from 'prop-types';
export const OSDReferences = {
/** */
get(windowId) {
return this.refs[windowId];
},
refs: {},
/** */
set(windowId, ref) {
this.refs[windowId] = ref;
},
};
/** */
class OSDReferenceComponent extends React.Component {
/** */
constructor(props) {
super(props);
const { windowId } = props.targetProps;
this.osdRef = React.createRef();
OSDReferences.set(windowId, this.osdRef);
}
/** */
render() {
const { targetProps } = this.props;
return <this.props.TargetComponent {...targetProps} ref={this.osdRef} />;
}
}
OSDReferenceComponent.propTypes = {
targetProps: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
};
export default {
component: OSDReferenceComponent,
mode: 'wrap',
name: 'OSD Reference',
target: 'OpenSeadragonViewer',
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment