using dropdown and opening modal for preferences

This commit is contained in:
Rodrigo Antinarelli 2020-06-23 00:10:58 -03:00
parent 70cf31b449
commit 1441062d95
4 changed files with 97 additions and 23 deletions

View File

@ -3,10 +3,28 @@ import PropTypes from 'prop-types';
// TODO: This may fail if package is split from PWA build // TODO: This may fail if package is split from PWA build
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
// //
import { NavBar, Svg, Icon, IconButton } from '@ohif/ui'; import { NavBar, Svg, Icon, IconButton, Dropdown, useModal } from '@ohif/ui';
function Header({ children }) { function Header({ children }) {
const history = useHistory(); const history = useHistory();
const { show } = useModal();
const showAboutModal = () => {
const modalComponent = () => <div>About modal</div>;
show({
title: 'About',
content: modalComponent,
});
};
const showPreferencesModal = () => {
const modalComponent = () => <div>Preferences modal</div>;
show({
title: 'Preferences',
content: modalComponent,
});
};
// const dropdownContent = [ // const dropdownContent = [
// { // {
// name: 'Soft tissue', // name: 'Soft tissue',
@ -42,9 +60,12 @@ function Header({ children }) {
<span className="mr-3 text-lg text-common-light"> <span className="mr-3 text-lg text-common-light">
FOR INVESTIGATIONAL USE ONLY FOR INVESTIGATIONAL USE ONLY
</span> </span>
<Dropdown
titleElement={
<IconButton <IconButton
variant="text" variant="text"
color="inherit" color="inherit"
size="initial"
className="text-primary-active" className="text-primary-active"
onClick={() => {}} onClick={() => {}}
> >
@ -52,6 +73,16 @@ function Header({ children }) {
<Icon name="settings" /> <Icon name="chevron-down" /> <Icon name="settings" /> <Icon name="chevron-down" />
</React.Fragment> </React.Fragment>
</IconButton> </IconButton>
}
list={[
{ title: 'About', icon: 'info', onClick: () => showAboutModal() },
{
title: 'Preferences',
icon: 'settings',
onClick: () => showPreferencesModal(),
},
]}
/>
</div> </div>
</div> </div>
</NavBar> </NavBar>

View File

@ -0,0 +1,51 @@
import React from 'react';
import { Dropdown, IconButton, Icon, useModal } from '@ohif/ui';
const PreferencesDropdown = () => {
const { show } = useModal();
const showAboutModal = () => {
const modalComponent = () => <div>About modal</div>;
show({
content: modalComponent,
title: 'About',
});
};
const showPreferencesModal = () => {
const modalComponent = () => <div>Preferences modal</div>;
show({
content: modalComponent,
title: 'Preferences',
});
};
return (
<Dropdown
titleElement={
<IconButton
variant="text"
color="inherit"
size="initial"
className="text-primary-active"
onClick={() => {}}
>
<React.Fragment>
<Icon name="settings" /> <Icon name="chevron-down" />
</React.Fragment>
</IconButton>
}
list={[
{ title: 'About', icon: 'info', onClick: () => showAboutModal() },
{
title: 'Preferences',
icon: 'settings',
onClick: () => showPreferencesModal(),
},
]}
/>
);
};
export default PreferencesDropdown;

View File

@ -0,0 +1 @@
export { default } from './PreferencesDropdown';

View File

@ -9,13 +9,14 @@ import filtersMeta from './filtersMeta.js';
import { useAppConfig } from '@state'; import { useAppConfig } from '@state';
import { useDebounce, useQuery } from '@hooks'; import { useDebounce, useQuery } from '@hooks';
import PreferencesDropdown from '../../components/PreferencesDropdown';
import { import {
Icon, Icon,
StudyListExpandedRow, StudyListExpandedRow,
Button, Button,
NavBar, NavBar,
Svg, Svg,
IconButton,
EmptyStudies, EmptyStudies,
StudyListTable, StudyListTable,
StudyListPagination, StudyListPagination,
@ -364,17 +365,7 @@ function WorkList({ history, data: studies, dataSource }) {
<span className="mr-3 text-lg text-common-light"> <span className="mr-3 text-lg text-common-light">
FOR INVESTIGATIONAL USE ONLY FOR INVESTIGATIONAL USE ONLY
</span> </span>
<IconButton <PreferencesDropdown />
variant="text"
color="inherit"
className="text-primary-active"
onClick={() => {}}
>
<React.Fragment>
<Icon name="settings" />
<Icon name="chevron-down" />
</React.Fragment>
</IconButton>
</div> </div>
</NavBar> </NavBar>
<StudyListFilter <StudyListFilter