Skip to content

Commit

Permalink
(feat) Anchor workspace actions to the bottom of the screen in tablet…
Browse files Browse the repository at this point in the history
… mode (#1650)
  • Loading branch information
donaldkibet authored Feb 9, 2024
1 parent e2f58d6 commit 10939bc
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import classNames from 'classnames';
import { ExtensionSlot } from '@openmrs/esm-framework';
import { ExtensionSlot, useLayoutType } from '@openmrs/esm-framework';
import styles from './action-menu.scss';

interface ActionMenuInterface {
Expand All @@ -10,7 +10,7 @@ interface ActionMenuInterface {
export const ActionMenu: React.FC<ActionMenuInterface> = ({ open }) => {
const [keyboardVisible, setKeyboardVisible] = useState(false);
const initialHeight = useRef(window.innerHeight);

const isTablet = useLayoutType() === 'tablet';
useEffect(() => {
const handleKeyboardVisibilityChange = () => {
setKeyboardVisible(initialHeight.current > window.innerHeight);
Expand All @@ -22,6 +22,10 @@ export const ActionMenu: React.FC<ActionMenuInterface> = ({ open }) => {
return () => window.removeEventListener('resize', handleKeyboardVisibilityChange);
}, [initialHeight]);

if (open && isTablet) {
return null;
}

return (
<aside
className={classNames(styles.sideRail, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const PatientChart: React.FC = () => {
</>
)}
</div>
<ActionMenu open={false} />
<ActionMenu open={active} />
</>
</main>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@
margin: 0.5rem 1rem;
}

.form {
display: flex;
flex-direction: column;
justify-content: space-between;
height: calc(100vh - 6rem);
}

.button {
height: 4rem;
Expand All @@ -58,8 +52,11 @@
}

.tablet {
padding: 1.5rem 1rem;
padding: 1rem;
background-color: $ui-02;
position: fixed;
bottom: 0rem;
width: 100%;
}

.desktop {
Expand Down Expand Up @@ -87,6 +84,17 @@
color: $text-02;
}

/* Desktop */
:global(.omrs-breakpoint-gt-tablet) {
.form {
display: flex;
flex-direction: column;
justify-content: space-between;
height: calc(100vh - 6rem);
}
}

/* Tablet */
:global(.omrs-breakpoint-lt-desktop) {
.container {
& section {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
}

.tablet {
padding: 1.5rem 1rem;
padding: 1rem;
background-color: $ui-02;
position: fixed;
bottom: 0rem;
width: 100%;
}

.desktop {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
.buttonSet {
padding: spacing.$spacing-06 spacing.$spacing-05;
background-color: $ui-02;
position: fixed;
bottom: 0;
width: 100%;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
}

.orderForm {
flex-grow:1;
flex-grow: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: layout.$spacing-03 0 0 layout.$spacing-05;


input[data-invalid]:focus {
outline: 2px solid colors.$red-60;
outline-offset: -2px;
outline: 2px solid colors.$red-60;
outline-offset: -2px;
}

:global(.cds--css-grid) {
Expand Down Expand Up @@ -101,7 +102,7 @@
margin-bottom: layout.$spacing-05;
}

.pullColumnContentRight > div {
.pullColumnContentRight>div {
float: right;
}

Expand All @@ -125,8 +126,8 @@

.numberInput {
:global(.cds--number__input-wrapper) input {
min-width: unset !important;
padding-right: layout.$spacing-05;
min-width: unset !important;
padding-right: layout.$spacing-05;
}
}

Expand All @@ -138,7 +139,8 @@

button {
display: flex;
padding-left: 0 !important;
padding-left: 0 !important;

svg {
order: 1;
margin-right: layout.$spacing-03;
Expand Down Expand Up @@ -225,6 +227,9 @@
.buttonSet {
padding: layout.$spacing-06 layout.$spacing-05;
background-color: colors.$white-0;
position: fixed;
bottom: 0rem;
width: 100%;
}
}

Expand All @@ -233,12 +238,12 @@
outline: 2.5px solid colors.$red-60;
}

input:focus, textarea:focus {
input:focus,
textarea:focus {
outline: 2.5px solid colors.$red-60;
}
}

.errorLabel {
color: colors.$red-60;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@
}

.tablet {
padding: 1.5rem 1rem;
padding: 1rem 1rem;
background-color: $ui-02;
position: fixed;
bottom: 0rem;
width: 100%;
}

.desktop {
Expand All @@ -93,7 +96,7 @@
display: flex;
flex-direction: column;
justify-content: space-between;
height: var(--desktop-workspace-window-height);
// height: var(--desktop-workspace-window-height);
}

.grid {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@
.buttonSet {
padding: 1.5rem 1rem;
background-color: $ui-02;
position: fixed;
bottom: 0rem;
width: 100%;
}
}

0 comments on commit 10939bc

Please sign in to comment.