Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-3024: Implement a two column layout for large desktops #1772

Merged
merged 10 commits into from
Jul 24, 2024
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 @@ -11,11 +11,6 @@ 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();
}

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

const state = useMemo(
() => ({
Expand All @@ -58,14 +51,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 +67,19 @@ 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[getExtensionNameFromId(extension.id)];
jayasanka-sack marked this conversation as resolved.
Show resolved Hide resolved
const style = fullWidth ? { gridColumn: '1 / -1' } : {};
jayasanka-sack marked this conversation as resolved.
Show resolved Hide resolved
return (
<div className={styles.extension} style={style}>
<Extension state={state} className={styles.extensionWrapper} />
</div>
);
}}
</ExtensionSlot>
</div>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use '@carbon/styles/scss/type';
@use '@carbon/styles/scss/colors';
@import '@openmrs/esm-styleguide/src/vars';
jayasanka-sack marked this conversation as resolved.
Show resolved Hide resolved
@import "../../root.scss";
jayasanka-sack marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -9,13 +10,39 @@

.dashboard {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-columns: 1fr;
grid-auto-rows: auto;
grid-auto-columns: auto;
grid-gap: 25px;
jayasanka-sack marked this conversation as resolved.
Show resolved Hide resolved
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){
jayasanka-sack marked this conversation as resolved.
Show resolved Hide resolved
.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 / span 2;
}

: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
Loading