Skip to content

Commit

Permalink
(feat) O3-3024: Implement a two column layout for large desktops (#1772)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayasanka-sack authored Jul 24, 2024
1 parent 64a4c88 commit fba902f
Show file tree
Hide file tree
Showing 39 changed files with 111 additions and 131 deletions.
2 changes: 1 addition & 1 deletion packages/esm-generic-patient-widgets-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"online": true,
"offline": true,
"meta": {
"columnSpan": 4
"fullWidth": false
}
}
]
Expand Down
1 change: 0 additions & 1 deletion packages/esm-patient-allergies-app/src/dashboard.meta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const dashboardMeta = {
slot: 'patient-chart-allergies-dashboard-slot',
columns: 1,
path: 'Allergies',
title: 'Allergies',
};
6 changes: 1 addition & 5 deletions packages/esm-patient-allergies-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
"component": "allergiesDetailedSummary",
"slot": "patient-chart-allergies-dashboard-slot",
"online": true,
"offline": true,
"meta": {
"columnSpan": 4
}
"offline": true
},
{
"name": "allergies-summary-dashboard",
Expand All @@ -31,7 +28,6 @@
"offline": true,
"order": 6,
"meta": {
"columns": 1,
"slot": "patient-chart-allergies-dashboard-slot",
"path": "Allergies"
}
Expand Down
1 change: 0 additions & 1 deletion packages/esm-patient-attachments-app/src/dashboard.meta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const dashboardMeta = {
slot: 'patient-chart-attachments-dashboard-slot',
columns: 1,
path: 'Attachments',
title: 'Attachments',
};
5 changes: 2 additions & 3 deletions packages/esm-patient-attachments-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"slot": "patient-chart-dashboard-slot",
"meta": {
"slot": "patient-chart-attachments-dashboard-slot",
"path": "Attachments",
"columns": 1
"path": "Attachments"
},
"order": 9
},
Expand All @@ -35,4 +34,4 @@
}
],
"pages": []
}
}
2 changes: 0 additions & 2 deletions packages/esm-patient-chart-app/src/dashboard.meta.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
export const summaryDashboardMeta = {
slot: 'patient-chart-summary-dashboard-slot',
columns: 4,
path: 'Patient Summary',
title: 'Patient Summary',
};

export const encountersDashboardMeta = {
slot: 'patient-chart-encounters-dashboard-slot',
columns: 1,
path: 'Visits',
title: 'Visits',
};
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ describe('ChartReview: ', () => {
name: 'charts-summary-dashboard',
meta: {
slot: 'patient-chart-summary-dashboard-slot',
config: {
columns: 4,
},
path: 'Patient Summary',
title: 'Patient Summary',
},
Expand All @@ -74,9 +71,6 @@ describe('ChartReview: ', () => {
name: 'test-results-summary-dashboard',
meta: {
slot: 'patient-chart-test-results-dashboard-slot',
config: {
columns: 1,
},
path: 'Test Results',
title: 'Test Results',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import {
import { dashboardPath } from '../../constants';
import styles from './dashboard-view.scss';
import { launchPatientWorkspace, launchStartVisitPrompt } from '@openmrs/esm-patient-common-lib';

function getColumnsLayoutStyle(dashboard: DashboardConfig) {
const numberOfColumns = dashboard.columns ?? 2;
return '1fr '.repeat(numberOfColumns).trimEnd();
}
import classNames from 'classnames';

/**
* The layout mode dictates the width occuppied by the chart dashboard widgets.
Expand All @@ -29,7 +25,6 @@ export interface DashboardConfig {
slot: string;
title: string | (() => string | Promise<string>);
path: string;
columns: number;
hideDashboardTitle?: boolean;
layoutMode?: LayoutMode;
}
Expand All @@ -45,7 +40,6 @@ export function DashboardView({ dashboard, patientUuid, patient }: DashboardView
const {
params: { view },
} = useMatch(dashboardPath);
const gridTemplateColumns = getColumnsLayoutStyle(dashboard);

const state = useMemo(
() => ({
Expand All @@ -58,14 +52,6 @@ export function DashboardView({ dashboard, patientUuid, patient }: DashboardView
[patient, patientUuid, view],
);

const wrapItem = useCallback(
(slot: ReactNode, extension: ExtensionData) => {
const { columnSpan = 1 } = widgetMetas[getExtensionNameFromId(extension.extensionId)];
return <div style={{ gridColumn: `span ${columnSpan}` }}>{slot}</div>;
},
[widgetMetas],
);

const [resolvedTitle, setResolvedTitle] = useState<string | undefined>();

useEffect(() => {
Expand All @@ -82,14 +68,18 @@ export function DashboardView({ dashboard, patientUuid, patient }: DashboardView
<>
<ExtensionSlot state={state} name="top-of-all-patient-dashboards-slot" />
{!dashboard.hideDashboardTitle && resolvedTitle && <h1 className={styles.dashboardTitle}>{resolvedTitle}</h1>}
<ExtensionSlot
key={dashboard.slot}
name={dashboard.slot}
className={styles.dashboard}
style={{ gridTemplateColumns }}
>
<Extension state={state}>{wrapItem}</Extension>
</ExtensionSlot>
<div className={styles.dashboardContainer}>
<ExtensionSlot key={dashboard.slot} name={dashboard.slot} className={styles.dashboard}>
{(extension) => {
const { fullWidth = false } = widgetMetas[extension.id];
return (
<div className={classNames(styles.extension, fullWidth && styles.fullWidth)}>
<Extension state={state} className={styles.extensionWrapper} />
</div>
);
}}
</ExtensionSlot>
</div>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use '@carbon/styles/scss/type';
@import '@openmrs/esm-styleguide/src/vars';
@import "../../root.scss";
@use '@carbon/styles/scss/colors';
@use '@openmrs/esm-styleguide/src/vars' as *;
@use "../../root.scss" as *;

.dashboardTitle {
@include type.type-style("heading-03");
Expand All @@ -9,13 +10,43 @@

.dashboard {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-columns: 1fr;
grid-auto-rows: auto;
grid-auto-columns: auto;
grid-gap: 25px;
grid-gap: 1.3125rem;
margin: 1.3125rem;
}

.dashboardContainer {
container-name: dashboard;
container-type: inline-size;
}

// Using 1100px here to account for the widget loading area, this ensures it collapses when the
// workspace opens and lacks sufficient space.
@container dashboard (width > 1100px){
.dashboard {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}

.extensionWrapper {
height: 100%;

> * {
height: 100%;
display: flex;
flex-direction: column;
}
}

.extension:only-child {
grid-column: 1 / -1;
}

.fullWidth {
grid-column: 1 / -1
}

:global(.omrs-breakpoint-lt-desktop) .dashboard {
grid-template-columns: 1fr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ $actionPanelExpandedOffset: $actionNavOffset+$actionPanelOffset;
max-width: 60rem;
}

:global(.omrs-breakpoint-gt-small-desktop) .widthContained {
max-width: 80rem;
}

.chartContainer {
flex: 1;
display: flex;
Expand Down
10 changes: 4 additions & 6 deletions packages/esm-patient-chart-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"order": 0,
"meta": {
"slot": "patient-chart-summary-dashboard-slot",
"columns": 4,
"path": "Patient Summary"
},
"online": true,
Expand Down Expand Up @@ -92,7 +91,6 @@
"component": "encountersSummaryDashboardLink",
"meta": {
"slot": "patient-chart-encounters-dashboard-slot",
"columns": 1,
"path": "Visits"
},
"order": 5,
Expand Down Expand Up @@ -201,11 +199,11 @@
{
"name": "current-visit-summary",
"component": "currentVisitSummary",
"meta": {
"columnSpan": 4
},
"online": true,
"offline": true
"offline": true,
"meta": {
"fullWidth": true
}
},
{
"name": "edit-visit-action-button",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ export const genericDashboardConfigSchema = {
_default: '',
_type: Type.String,
},
columns: {
_default: 1,
_type: Type.Number,
_description:
'The number of columns that widgets in the dashboard ' +
"can use to display themselves in. Note that '2' will not " +
'necessarily result in a two-column layout—rather that widgets ' +
'will be able to occupy either one or both of those columns.',
},
};

export interface GenericDashboardConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const EmptyState: React.FC<EmptyStateProps> = (props) => {
const isTablet = useLayoutType() === 'tablet';

return (
<Layer>
<Layer className={styles.layer}>
<Tile className={styles.tile}>
<div className={isTablet ? styles.tabletHeading : styles.desktopHeading}>
<h4>{props.headerTitle}</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
background-color: $ui-02;
padding-left: 1rem;
align-items: center;
border-top: 1px solid $ui-03;
}

.desktop :global(.cds--pagination) {
Expand Down
5 changes: 0 additions & 5 deletions packages/esm-patient-common-lib/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { type OpenmrsResource } from '@openmrs/esm-framework';

export * from './test-results';

export interface DashbardConfig {
columns: number;
}

export interface DashboardLinkConfig {
path: string;
title: string;
Expand All @@ -14,7 +10,6 @@ export interface DashboardLinkConfig {

export interface DashboardConfig extends DashboardLinkConfig {
slot: string;
config: DashbardConfig;
}

export interface PatientProgram {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const ConditionsOverview: React.FC<ConditionsOverviewProps> = ({ patientUuid })
>
{({ rows, headers, getHeaderProps, getTableProps }) => (
<>
<TableContainer>
<TableContainer className={styles.tableContainer}>
<Table {...getTableProps()}>
<TableHead>
<TableRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@
@include type.type-style('body-compact-01');
color: $text-02;
}

.tableContainer {
flex: 1;
}
1 change: 0 additions & 1 deletion packages/esm-patient-conditions-app/src/dashboard.meta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const dashboardMeta = {
slot: 'patient-chart-conditions-dashboard-slot',
columns: 1,
path: 'Conditions',
title: 'Conditions',
};
5 changes: 2 additions & 3 deletions packages/esm-patient-conditions-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"component": "conditionsOverview",
"order": 3,
"meta": {
"columnSpan": 4
"fullWidth": false
}
},
{
"name": "conditions-details-widget",
"slot": "patient-chart-conditions-dashboard-slot",
"component": "conditionsDetailedSummary",
"meta": {
"columnSpan": 4
"fullWidth": false
}
},
{
Expand All @@ -29,7 +29,6 @@
"order": 7,
"meta": {
"slot": "patient-chart-conditions-dashboard-slot",
"columns": 1,
"path": "Conditions"
}
},
Expand Down
10 changes: 5 additions & 5 deletions packages/esm-patient-flags-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"name": "patient-flags-overview",
"slot": "patient-chart-summary-dashboard-slot",
"component": "flagsOverview",
"meta": {
"columnSpan": 4
},
"order": 0,
"featureFlag": "patientFlags"
"featureFlag": "patientFlags",
"meta": {
"fullWidth": false
}
}
],
"pages": []
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const dashboardMeta = {
slot: 'patient-chart-immunizations-dashboard-slot',
columns: 1,
path: 'Immunizations',
title: 'Immunizations',
};
Loading

0 comments on commit fba902f

Please sign in to comment.