From 8f13da7a393005f3dc5f2b90b6a7db2b8676fc70 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 12 Feb 2019 14:18:31 +0000 Subject: [PATCH] Remove the secondary header and update the appbar instead. --- src/App.tsx | 12 +++++++----- src/Journal/index.tsx | 5 ++--- src/SyncGate.tsx | 31 ++++++++++++++++++------------ src/components/SecondaryHeader.tsx | 23 ---------------------- src/widgets/AppBarOverride.tsx | 20 +++++++++++++++++++ 5 files changed, 48 insertions(+), 43 deletions(-) delete mode 100644 src/components/SecondaryHeader.tsx create mode 100644 src/widgets/AppBarOverride.tsx diff --git a/src/App.tsx b/src/App.tsx index a5d11fe..dddb06f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,7 +23,6 @@ import SideMenu from './SideMenu'; import LoginGate from './LoginGate'; import { RouteResolver } from './routes'; -import * as C from './constants'; import * as store from './store'; import * as actions from './store/actions'; @@ -41,6 +40,11 @@ const muiTheme = createMuiTheme({ } }); +export let appBarPortals = { + 'title': null as Element | null, + 'buttons': null as Element | null, +}; + export const routeResolver = new RouteResolver({ home: '', pim: { @@ -127,11 +131,9 @@ const AppBarWitHistory = withRouter( } -
- {C.appName} -
+
-
+
{iconElementRight}
diff --git a/src/Journal/index.tsx b/src/Journal/index.tsx index 58c7ac3..7f028d0 100644 --- a/src/Journal/index.tsx +++ b/src/Journal/index.tsx @@ -8,10 +8,9 @@ import Contact from '../components/Contact'; import Calendar from '../components/Calendar'; import Event from '../components/Event'; +import AppBarOverride from '../widgets/AppBarOverride'; import Container from '../widgets/Container'; -import SecondaryHeader from '../components/SecondaryHeader'; - import JournalEntries from '../components/JournalEntries'; import journalView from './journalView'; @@ -88,7 +87,7 @@ class Journal extends React.PureComponent { return ( - {collectionInfo.displayName} + { ( - + <> + + + )} /> ( - + <> + + + )} /> { - const style = { - header: { - backgroundColor: props.theme.palette.primary.main, - color: props.theme.palette.primary.contrastText, - padding: 15, - textAlign: 'center' as any, - }, - headerText: { - margin: 0, - }, - }; - - return ( -
-

{props.children}

-
- ); -}); diff --git a/src/widgets/AppBarOverride.tsx b/src/widgets/AppBarOverride.tsx new file mode 100644 index 0000000..d9735f2 --- /dev/null +++ b/src/widgets/AppBarOverride.tsx @@ -0,0 +1,20 @@ +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; + +export default (props: {title: string, children?: React.ReactNode | React.ReactNode[]}) => { + const titleEl = document.querySelector('#appbar-title'); + const buttonsEl = document.querySelector('#appbar-buttons'); + + return ( + <> + {titleEl && ReactDOM.createPortal( + {props.title}, + titleEl + )} + {buttonsEl && props.children && ReactDOM.createPortal( + props.children, + buttonsEl + )} + + ); +};