Skip to content

Commit

Permalink
refactor: implement the new popup for implementer tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsereko committed Jul 13, 2023
1 parent 69a36f5 commit 9190cfe
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import React, { useState } from "react";
import {
Tablet,
Laptop,
Download,
Document,
Development,
Touch_1,
} from "@carbon/react/icons";
import {
Layer,
Header,
HeaderContainer,
Tile,
Theme,
HeaderGlobalBar,
HeaderGlobalAction,
SideNav,
HeaderMenuItem,
HeaderNavigation,
HeaderPanel,
} from "@carbon/react";
import { BrowserRouter } from "react-router-dom";
import { ConfigurableLink, useConfig, useStore } from "@openmrs/esm-framework";
import { implementerToolsStore } from "./store";
import styles from "./implementer-tools.styles.scss";
import { useTranslation } from "react-i18next";

const ImplementerNavbar: React.FC = () => {
const { isOpen } = useStore(implementerToolsStore);
const { t } = useTranslation();
const [showPages, setShowPages] = useState(false);
const { logo } = useConfig();

return isOpen ? (
<BrowserRouter>
<div>
<HeaderContainer
render={({ isSideNavExpanded, onClickSideNavExpand }) => (
<>
<Theme theme="g90">
<Header
className={styles.implementerToolsHeader}
aria-label="OpenMRS Implementer Tools"
>
<ConfigurableLink
className={styles.navLogo}
to="${openmrsSpaBase}/home"
>
<div className={styles.spacedLogo}>
{logo?.src ? (
<img
className={styles.logo}
src={logo.src}
alt={logo.alt}
width={110}
height={40}
/>
) : logo?.name ? (
logo.name
) : (
<svg role="img" width={110} height={40}>
<use xlinkHref="#omrs-logo-white"></use>
</svg>
)}
</div>
</ConfigurableLink>
<HeaderNavigation>
<HeaderMenuItem>UI editor</HeaderMenuItem>
<HeaderMenuItem>Module Manager</HeaderMenuItem>
</HeaderNavigation>
<HeaderGlobalBar>
<HeaderGlobalAction
className={styles.implementerToolsGlobalBar}
>
<Tablet size={20} />
</HeaderGlobalAction>
<HeaderGlobalAction
className={styles.implementerToolsGlobalBar}
>
<Laptop size={20} />
</HeaderGlobalAction>
<HeaderGlobalAction
className={styles.implementerToolsGlobalBar}
aria-label="Downloads"
onClick={() => {}}
>
<Download size={20} />
</HeaderGlobalAction>
</HeaderGlobalBar>
<div className={styles.sideRailNav}>
<div>
<Document
onClick={() => {
setShowPages(!showPages);
}}
size={20}
/>
</div>
<div>
<Development
onClick={() => {
setShowPages(!showPages);
}}
size={20}
/>
</div>
</div>
<SideNav
className={styles.sideNavComponents}
isFixedNav
expanded={showPages && isOpen}
>
<p>
Select an element from the canvas to activate this panel
</p>
</SideNav>
<HeaderPanel style={{ backgroundColor: "#393939" }} expanded>
<Layer className={styles.selectElement}>
<Tile className={styles.selectionText}>
<Touch_1 size={30} />
<h5>Nothing selected</h5>
<p>
Select an element from the canvas to activate this
panel
</p>
</Tile>
</Layer>
</HeaderPanel>
</Header>
</Theme>
</>
)}
/>
</div>
</BrowserRouter>
) : null;
};
export default ImplementerNavbar;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const GlobalImplementerToolsButton: React.FC = () => {
data-testid="globalImplementerToolsButton"
>
<div onClick={togglePopup} role="button" tabIndex={0}>
{isOpen ? <ChevronDown size={16} /> : <ChevronUp size={16} />}
{isOpen ? <ChevronUp size={16} /> : <ChevronDown size={16} />}
</div>
</div>
</UserHasAccess>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ function PopupHandler() {
const frontendModules = useFrontendModules();
const backendDependencies = useBackendDependencies();
const [shouldShowNotification, setShouldShowNotification] = useState(false);
const { isOpen, isUIEditorEnabled, openTabIndex } = useStore(
implementerToolsStore
);

const { t } = useTranslation();

useEffect(() => {
// displaying toast if modules are missing
setShouldShowNotification(
Expand All @@ -47,9 +52,17 @@ function PopupHandler() {
}
}, [t, shouldShowNotification]);

const { isOpen, isUIEditorEnabled, openTabIndex } = useStore(
implementerToolsStore
);
useEffect(() => {
if (!isOpen) {
const homeDivElement = document.querySelector(
`div[id^="single-spa-application:@openmrs/esm-home-app-page"]`
) as HTMLDivElement;
if (homeDivElement) {
homeDivElement.style.display = "unset";
}
}
}, [isOpen]);

return (
<>
{isOpen ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// Chevron button - implementer-tools component
.chevronImplementerToolsButton {
position: fixed;
bottom: 0;
top: 0;
left: calc(50vw - spacing.$spacing-05);
z-index: 9999;

Expand All @@ -33,8 +33,103 @@
cursor: pointer;
transition: all 0.1s ease-in-out;
}
}

.spacedLogo {
margin-left: 1rem;
padding-right: 1rem;
}

.implementerToolsHeader,
.implementerToolsGlobalBar {
border-bottom: 1px solid $color-gray-90;
}

.implementerToolsHeader,
.implementerToolsHeader button,
.implementerToolsHeader a,
.implementerToolsHeader nav {
background-color: $color-gray-80;
color: $ui-03;
}

.implementerToolsHeader button:hover,
.implementerToolsHeader button:active,
.implementerToolsHeader button:focus,
.implementerToolsHeader a:hover,
.implementerToolsHeader a:active,
.implementerToolsHeader a:focus {
background-color: $color-gray-70;
border-color: transparent !important;
color: $ui-02;
}

.implementerToolsHeader nav::before {
background-color: #525252;
}

.selectElement {
position: relative;
top: 6.25rem;
padding-left: 1rem;
padding-right: 1rem;
text-align: center;
}

.selectElement div {
height: 12rem;
}

.selectionText {
h5,
svg,
p {
margin-top: 1rem;
}

h5,
svg {
color: white;
}

p {
font-size: small;
}
}

.sideNavComponents {
left: 3rem;
}

div:hover {
padding: spacing.$spacing-03 0;
.sideRailNav {
height: 100%;
width: 3rem;
position: fixed;
z-index: 1;
top: 3rem;
left: 0;
background-color: $color-gray-80;
transition: 0.5s ease;
overflow-x: hidden;
display: flex;
flex-direction: column;
align-items: center;
border-right: 1px solid $color-gray-90;

div {
text-align: center;
background-color: $color-gray-80;
color: $ui-03;
height: 3rem;
width: 3rem;
display: grid;
place-items: center;
}
div:hover,
div:active,
div:focus {
background-color: $color-gray-70;
border-color: transparent !important;
color: $ui-02;
}
}
Loading

0 comments on commit 9190cfe

Please sign in to comment.