initial structure for components rewrite
This commit is contained in:
1 parent
944afe4a3e
commit
c391c007ff
284 files changed
+68087
-17215
No files matched your search
@@ -1,144 +0,0 @@
|
||||
import './ExpandableToolMenu.styl';
|
||||
|
||||
import { OverlayTrigger } from '../components/overlayTrigger';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import ToolbarButton from './ToolbarButton.js';
|
||||
import { Tooltip } from '../components/tooltip';
|
||||
|
||||
class ExpandableToolMenu extends React.Component {
|
||||
static propTypes = {
|
||||
/** Button label */
|
||||
label: PropTypes.string.isRequired,
|
||||
/** Array of buttons to render when expanded */
|
||||
buttons: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
id: PropTypes.string,
|
||||
label: PropTypes.string.isRequired,
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.shape({
|
||||
name: PropTypes.string.isRequired,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
).isRequired,
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.shape({
|
||||
name: PropTypes.string.isRequired,
|
||||
}),
|
||||
]),
|
||||
onGroupMenuClick: PropTypes.func,
|
||||
activeCommand: PropTypes.string,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
buttons: [],
|
||||
icon: 'ellipse-circle',
|
||||
label: 'More',
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isExpanded: false,
|
||||
};
|
||||
}
|
||||
|
||||
toolbarMenuOverlay = () => (
|
||||
<Tooltip
|
||||
placement="bottom"
|
||||
className="tooltip-toolbar-overlay"
|
||||
id={`${Math.random()}_tooltip-toolbar-overlay}`}
|
||||
>
|
||||
{this.getButtons()}
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
getButtons = () => {
|
||||
return this.props.buttons.map((button, index) => {
|
||||
return (
|
||||
<ToolbarButton
|
||||
key={index}
|
||||
{...button}
|
||||
isActive={button.id === this.props.activeCommand}
|
||||
/>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
isActive = () => {
|
||||
let isActive = false;
|
||||
if (this.props.activeCommand) {
|
||||
this.props.buttons.forEach(button => {
|
||||
if (this.props.activeCommand === button.id) {
|
||||
isActive = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return isActive;
|
||||
};
|
||||
|
||||
activeIcon = () => {
|
||||
if (this.props.activeCommand) {
|
||||
return (
|
||||
this.props.buttons.find(btn => this.props.activeCommand === btn.id)
|
||||
.icon || this.props.icon
|
||||
);
|
||||
}
|
||||
|
||||
return this.props.icon;
|
||||
};
|
||||
|
||||
onExpandableToolClick = () => {
|
||||
if (this.props.onGroupMenuClick) {
|
||||
this.props.onGroupMenuClick();
|
||||
}
|
||||
this.setState({
|
||||
isExpanded: !this.state.isExpanded,
|
||||
});
|
||||
};
|
||||
|
||||
onOverlayHide = () => {
|
||||
this.setState({
|
||||
isExpanded: false,
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const getToolBarButtonComponent = () => {
|
||||
return (
|
||||
<ToolbarButton
|
||||
key="menu-button"
|
||||
type="tool"
|
||||
label={this.props.label}
|
||||
icon={this.activeIcon()}
|
||||
className={'toolbar-button expandableToolMenu'}
|
||||
isActive={this.isActive()}
|
||||
isExpandable={true}
|
||||
isExpanded={this.state.isExpanded}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const toolbarComponent = getToolBarButtonComponent();
|
||||
|
||||
return (
|
||||
<OverlayTrigger
|
||||
key="menu-button"
|
||||
trigger="click"
|
||||
placement="bottom"
|
||||
rootClose={true}
|
||||
handleHide={this.onOverlayHide}
|
||||
onClick={this.onExpandableToolClick}
|
||||
overlay={this.toolbarMenuOverlay()}
|
||||
>
|
||||
{toolbarComponent}
|
||||
</OverlayTrigger>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ExpandableToolMenu;
|
||||
@@ -1,136 +0,0 @@
|
||||
.toolbarOverlay
|
||||
border 2px solid var(--ui-border-color-dark)
|
||||
padding 5px
|
||||
|
||||
.tooltip-toolbar-overlay
|
||||
margin-top 40px
|
||||
background-color: var(--primary-background-color);
|
||||
border: 1px solid var(--default-color);
|
||||
border-radius: 8px;
|
||||
|
||||
.tooltip-arrow
|
||||
display none
|
||||
.tooltip-inner
|
||||
max-width: unset
|
||||
background: none
|
||||
|
||||
.tooltip
|
||||
position: absolute
|
||||
z-index: 1070
|
||||
display: block
|
||||
font-style: normal
|
||||
font-weight: normal
|
||||
letter-spacing: normal
|
||||
line-break: auto
|
||||
line-height: 1.42857143
|
||||
text-align: left
|
||||
text-align: start
|
||||
text-decoration: none
|
||||
text-shadow: none
|
||||
text-transform: none
|
||||
white-space: normal
|
||||
word-break: normal
|
||||
word-spacing: normal
|
||||
word-wrap: normal
|
||||
font-size: 12px
|
||||
opacity: 0
|
||||
|
||||
&.in
|
||||
opacity: 0.9
|
||||
|
||||
&.top
|
||||
margin-top: -3px
|
||||
padding: 5px 0
|
||||
|
||||
.tooltip-arrow
|
||||
bottom: 0
|
||||
left: 50%
|
||||
margin-left: -5px
|
||||
border-width: 5px 5px 0
|
||||
border-top-color: #000
|
||||
|
||||
&.right
|
||||
margin-left: 3px
|
||||
padding: 0 5px
|
||||
|
||||
.tooltip-arrow
|
||||
top: 50%
|
||||
left: 0
|
||||
margin-top: -5px
|
||||
border-width: 5px 5px 5px 0
|
||||
border-right-color: #000
|
||||
|
||||
&.bottom
|
||||
margin-top: 3px
|
||||
padding: 5px 0
|
||||
|
||||
.tooltip-arrow
|
||||
top: 0
|
||||
left: 50%
|
||||
margin-left: -5px
|
||||
border-width: 0 5px 5px
|
||||
border-bottom-color: #000
|
||||
|
||||
&.left
|
||||
margin-left: -3px
|
||||
padding: 0 5px
|
||||
|
||||
.tooltip-arrow
|
||||
top: 50%
|
||||
right: 0
|
||||
margin-top: -5px
|
||||
border-width: 5px 0 5px 5px
|
||||
border-left-color: #000
|
||||
|
||||
&.top-left .tooltip-arrow
|
||||
bottom: 0
|
||||
right: 5px
|
||||
margin-bottom: -5px
|
||||
border-width: 5px 5px 0
|
||||
border-top-color: #000
|
||||
|
||||
&.top-right .tooltip-arrow
|
||||
bottom: 0
|
||||
left: 5px
|
||||
margin-bottom: -5px
|
||||
border-width: 5px 5px 0
|
||||
border-top-color: #000
|
||||
|
||||
&.bottom-left .tooltip-arrow
|
||||
top: 0
|
||||
right: 5px
|
||||
margin-top: -5px
|
||||
border-width: 0 5px 5px
|
||||
border-bottom-color: #000
|
||||
|
||||
&.bottom-right .tooltip-arrow
|
||||
top: 0
|
||||
left: 5px
|
||||
margin-top: -5px
|
||||
border-width: 0 5px 5px
|
||||
border-bottom-color: #000
|
||||
|
||||
.tooltip-inner
|
||||
max-width: 200px
|
||||
padding: 3px 8px
|
||||
color: #fff
|
||||
text-align: center
|
||||
background-color: #000
|
||||
border-radius: 4px
|
||||
|
||||
.tooltip-arrow
|
||||
position: absolute
|
||||
width: 0
|
||||
height: 0
|
||||
border-color: transparent
|
||||
border-style: solid
|
||||
|
||||
.fade
|
||||
opacity: 0
|
||||
-webkit-transition: opacity 0.15s linear
|
||||
-o-transition: opacity 0.15s linear
|
||||
transition: opacity 0.15s linear
|
||||
|
||||
.fade.in
|
||||
opacity: 1
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { Icon } from './../elements/Icon';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export default class PlayClipButton extends Component {
|
||||
static propTypes = {
|
||||
isPlaying: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
isPlaying: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
const iconName = this.props.isPlaying ? 'stop' : 'play';
|
||||
|
||||
return (
|
||||
<div className="btn-group">
|
||||
<button
|
||||
id="playClip"
|
||||
type="button"
|
||||
className="imageViewerCommand btn btn-sm btn-default"
|
||||
data-container="body"
|
||||
data-toggle="tooltip"
|
||||
data-placement="bottom"
|
||||
title="Play/Stop Clip"
|
||||
>
|
||||
<Icon name={iconName} />
|
||||
</button>
|
||||
<button
|
||||
id="toggleCineDialog"
|
||||
type="button"
|
||||
className="imageViewerCommand btn btn-sm btn-default"
|
||||
data-container="body"
|
||||
data-toggle="tooltip"
|
||||
data-placement="bottom"
|
||||
title="Toggle CINE Dialog"
|
||||
>
|
||||
<Icon name="youtube" />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import ToolbarButton from './ToolbarButton.js';
|
||||
|
||||
const wLPresetIDs = [
|
||||
'setWLPresetSoftTissue',
|
||||
'setWLPresetLung',
|
||||
'setWLPresetLiver',
|
||||
'setWLPresetBrain',
|
||||
];
|
||||
|
||||
export default class PresetToggle extends Component {
|
||||
static propTypes = {
|
||||
buttons: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
label: PropTypes.string.isRequired,
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.shape({
|
||||
name: PropTypes.string.isRequired,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
).isRequired,
|
||||
setToolActive: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
presetSelected: null,
|
||||
};
|
||||
}
|
||||
render() {
|
||||
/*const items = this.props.buttons.map((item, index) => {
|
||||
return <ToolbarButton key={index} {...item} click={this.onClick} />;
|
||||
});*/
|
||||
|
||||
const wlPresetItems = this.props.buttons.map((button, index) => {
|
||||
if (wLPresetIDs.includes(button.command)) {
|
||||
return <ToolbarButton key={index} {...button} click={this.onClick} />;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
const toolItems = this.props.buttons.map((button, index) => {
|
||||
if (!wLPresetIDs.includes(button.command)) {
|
||||
return <ToolbarButton key={index} {...button} click={this.onClick} />;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
const selectedButton = this.props.buttons.find(button => {
|
||||
return button.id === this.state.selected;
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="PresetToggle">
|
||||
<div className="wlPresets">{wlPresetItems}</div>
|
||||
<div className="tools">{toolItems}</div>
|
||||
<span className="presetSelected">
|
||||
LEVELS:
|
||||
{selectedButton ? selectedButton.label : 'Manual'}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
onClick = id => {
|
||||
const buttonItem = this.props.buttons.find(button => button.command === id);
|
||||
|
||||
this.setState({
|
||||
selected: buttonItem.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { Icon } from './../elements/Icon';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
|
||||
export function SimpleToolbarButton(props) {
|
||||
const className = classnames(props.className, 'btn btn-sm btn-default');
|
||||
|
||||
return (
|
||||
<button
|
||||
id={props.id}
|
||||
type="button"
|
||||
className={className}
|
||||
data-container="body"
|
||||
data-toggle="tooltip"
|
||||
data-placement="bottom"
|
||||
title={props.title}
|
||||
>
|
||||
{props.icon && <Icon name={props.icon} />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
SimpleToolbarButton.propTypes = {
|
||||
icon: PropTypes.string,
|
||||
title: PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
export default SimpleToolbarButton;
|
||||
@@ -1,151 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import SimpleToolbarButton from './SimpleToolbarButton';
|
||||
import PlayClipButton from './PlayClipButton';
|
||||
import { LayoutButton } from './../components/layoutButton';
|
||||
|
||||
// TODO: This should not be built in the `@ohif/ui` component
|
||||
function getDefaultButtonData() {
|
||||
var buttonData = [
|
||||
{
|
||||
id: 'wwwc',
|
||||
title: 'WW/WC',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'sun',
|
||||
},
|
||||
{
|
||||
id: 'wwwcRegion',
|
||||
title: 'Window by Region',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'stop',
|
||||
},
|
||||
{
|
||||
id: 'magnify',
|
||||
title: 'Magnify',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'circle',
|
||||
},
|
||||
{
|
||||
id: 'annotate',
|
||||
title: 'Annotation',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'arrows-alt-h',
|
||||
},
|
||||
{
|
||||
id: 'invert',
|
||||
title: 'Invert',
|
||||
className: 'imageViewerCommand',
|
||||
icon: 'adjust',
|
||||
},
|
||||
{
|
||||
id: 'zoom',
|
||||
title: 'Zoom',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'search-plus',
|
||||
},
|
||||
{
|
||||
id: 'pan',
|
||||
title: 'Pan',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'arrows',
|
||||
},
|
||||
{
|
||||
id: 'stackScroll',
|
||||
title: 'Stack Scroll',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'bars',
|
||||
},
|
||||
{
|
||||
id: 'length',
|
||||
title: 'Length Measurement',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'arrows-alt-v',
|
||||
},
|
||||
{
|
||||
id: 'angle',
|
||||
title: 'Angle Measurement',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'fa fa-angle-left',
|
||||
},
|
||||
{
|
||||
id: 'dragProbe',
|
||||
title: 'Pixel Probe',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'fa fa-dot-circle-o',
|
||||
},
|
||||
{
|
||||
id: 'ellipticalRoi',
|
||||
title: 'Elliptical ROI',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'circle-o',
|
||||
},
|
||||
{
|
||||
id: 'rectangleRoi',
|
||||
title: 'Rectangle ROI',
|
||||
className: 'imageViewerTool',
|
||||
icon: 'square-o',
|
||||
},
|
||||
{
|
||||
id: 'resetViewport',
|
||||
title: 'Reset Viewport',
|
||||
className: 'imageViewerCommand',
|
||||
icon: 'reset',
|
||||
},
|
||||
{
|
||||
id: 'clearTools',
|
||||
title: 'Clear tools',
|
||||
className: 'imageViewerCommand',
|
||||
icon: 'trash',
|
||||
},
|
||||
];
|
||||
return buttonData;
|
||||
}
|
||||
|
||||
export default class Toolbar extends Component {
|
||||
static propTypes = {
|
||||
buttons: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
title: PropTypes.string.isRequired,
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.shape({
|
||||
name: PropTypes.string.isRequired,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
).isRequired,
|
||||
includeLayoutButton: PropTypes.bool.isRequired,
|
||||
includePlayClipButton: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
buttons: getDefaultButtonData(),
|
||||
includeLayoutButton: true,
|
||||
includePlayClipButton: true,
|
||||
};
|
||||
|
||||
render() {
|
||||
var maybePlayClipButton;
|
||||
if (this.props.includePlayClipButton) {
|
||||
maybePlayClipButton = <PlayClipButton />;
|
||||
}
|
||||
|
||||
var maybeLayoutButton;
|
||||
if (this.props.includeLayoutButton) {
|
||||
maybeLayoutButton = <LayoutButton />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div id="toolbar">
|
||||
<div className="btn-group">
|
||||
{this.props.buttons.map((button, i) => {
|
||||
return <SimpleToolbarButton {...button} key={i} />;
|
||||
})}
|
||||
{maybePlayClipButton}
|
||||
{maybeLayoutButton}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import './toolbar-button.styl';
|
||||
|
||||
import { Icon } from './../elements/Icon';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import { withTranslation } from '../contextProviders';
|
||||
|
||||
export function ToolbarButton(props) {
|
||||
const { isActive, icon, labelWhenActive, onClick, t } = props;
|
||||
const className = classnames(props.className, { active: isActive });
|
||||
const iconProps = typeof icon === 'string' ? { name: icon } : icon;
|
||||
const label = isActive && labelWhenActive ? labelWhenActive : props.label;
|
||||
|
||||
const arrowIconName = props.isExpanded ? 'caret-up' : 'caret-down';
|
||||
const arrowIcon = props.isExpandable && (
|
||||
<Icon name={arrowIconName} className="expand-caret" />
|
||||
);
|
||||
|
||||
const handleClick = event => {
|
||||
if (onClick) {
|
||||
onClick(event, props);
|
||||
}
|
||||
};
|
||||
|
||||
const cypressSelectorId = props.label.toLowerCase();
|
||||
|
||||
return (
|
||||
<div
|
||||
className={className}
|
||||
onClick={handleClick}
|
||||
data-cy={cypressSelectorId}
|
||||
>
|
||||
{iconProps && <Icon {...iconProps} />}
|
||||
<div className="toolbar-button-label">
|
||||
{t(label)}
|
||||
{arrowIcon}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
ToolbarButton.propTypes = {
|
||||
id: PropTypes.string,
|
||||
isActive: PropTypes.bool,
|
||||
/** Display label for button */
|
||||
label: PropTypes.string.isRequired,
|
||||
/** Alternative text to show when button is active */
|
||||
labelWhenActive: PropTypes.string,
|
||||
className: PropTypes.string.isRequired,
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.shape({
|
||||
name: PropTypes.string.isRequired,
|
||||
}),
|
||||
]),
|
||||
onClick: PropTypes.func,
|
||||
/** Determines if we show expandable 'caret' symbol */
|
||||
isExpandable: PropTypes.bool,
|
||||
/** Direction of expandable 'caret' symbol */
|
||||
isExpanded: PropTypes.bool,
|
||||
t: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
ToolbarButton.defaultProps = {
|
||||
isActive: false,
|
||||
className: 'toolbar-button',
|
||||
};
|
||||
|
||||
export default withTranslation('Buttons')(ToolbarButton);
|
||||
@@ -1,30 +0,0 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export function ViewportErrorIndicator(props) {
|
||||
return (
|
||||
<div
|
||||
className="loadingIndicator"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
margin: 'auto',
|
||||
textAlign: 'center',
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
<p>Error</p>
|
||||
<p className="description">An error has occurred.</p>
|
||||
<p className="details">{props.details}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
ViewportErrorIndicator.propTypes = {
|
||||
details: PropTypes.string,
|
||||
};
|
||||
|
||||
export default ViewportErrorIndicator;
|
||||
@@ -1,33 +0,0 @@
|
||||
.toolbar-button
|
||||
height: 48px;
|
||||
color: var(--default-color);
|
||||
float: left;
|
||||
text-align: center;
|
||||
padding: 0 10px;
|
||||
cursor: pointer;
|
||||
-webkit-touch-callout: none; /* iOS Safari */
|
||||
-webkit-user-select: none; /* Safari */
|
||||
-khtml-user-select: none; /* Konqueror HTML */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* Internet Explorer/Edge */
|
||||
user-select: none; /* Chrome and Opera */
|
||||
|
||||
.toolbar-button-label
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
|
||||
.expand-caret
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
transform: translate(2px, 2px);
|
||||
|
||||
svg
|
||||
height: 21px;
|
||||
width: 21px;
|
||||
margin: 2px;
|
||||
|
||||
&:hover
|
||||
color: var(--hover-color);
|
||||
|
||||
&.active, &:active
|
||||
color: var(--active-color);
|
||||
Reference in new issue
Block a user