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

O3-943: Recent Results overview header style fixes #467

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TableCell,
TableBody,
} from 'carbon-components-react';
import { useLayoutType } from '@openmrs/esm-framework';
import { OBSERVATION_INTERPRETATION } from '@openmrs/esm-patient-common-lib';
import { OverviewPanelData } from '../overview/useOverviewData';
import styles from './common-datatable.scss';
Expand All @@ -24,45 +25,49 @@ interface CommonDataTableProps {
description?: React.ReactNode;
}

const CommonDataTable: React.FC<CommonDataTableProps> = ({ title, data, description, toolbar, tableHeaders }) => (
<DataTable rows={data} headers={tableHeaders} size="short">
{({ rows, headers, getHeaderProps, getRowProps, getTableProps, getTableContainerProps }) => (
<TableContainer
className={styles.tableContainer}
title={title}
description={description}
{...getTableContainerProps()}
>
{toolbar}
<Table {...getTableProps()} isSortable useZebraStyles>
<colgroup className={styles.columns}>
<col span={1} />
<col span={1} />
<col span={1} />
</colgroup>
<TableHead>
<TableRow>
{headers.map((header) => (
<TableHeader key={header.key} {...getHeaderProps({ header })} isSortable>
{header.header}
</TableHeader>
))}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row, i) => (
<TypedTableRow key={row.id} interpretation={data[i]?.interpretation} {...getRowProps({ row })}>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
const CommonDataTable: React.FC<CommonDataTableProps> = ({ title, data, description, toolbar, tableHeaders }) => {
const isTablet = useLayoutType() === 'tablet';

return (
<DataTable rows={data} headers={tableHeaders} size="short">
{({ rows, headers, getHeaderProps, getRowProps, getTableProps, getTableContainerProps }) => (
<TableContainer
className={`${styles.tableContainer} ${isTablet ? `${styles.tablet}` : `${styles.desktop}`}`}
title={title}
description={description}
{...getTableContainerProps()}
>
{toolbar}
<Table {...getTableProps()} isSortable useZebraStyles>
<colgroup className={styles.columns}>
<col span={1} />
<col span={1} />
<col span={1} />
</colgroup>
<TableHead>
<TableRow>
{headers.map((header) => (
<TableHeader key={header.key} {...getHeaderProps({ header })} isSortable>
{header.header}
</TableHeader>
))}
</TypedTableRow>
))}
</TableBody>
</Table>
</TableContainer>
)}
</DataTable>
);
</TableRow>
</TableHead>
<TableBody>
{rows.map((row, i) => (
<TypedTableRow key={row.id} interpretation={data[i]?.interpretation} {...getRowProps({ row })}>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
</TypedTableRow>
))}
</TableBody>
</Table>
</TableContainer>
)}
</DataTable>
);
};

const TypedTableRow: React.FC<{
interpretation: OBSERVATION_INTERPRETATION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@
*:not(:first-child) {
margin: 0.25rem 0rem;
}

h4 {
@include carbon--type-style("productive-heading-02");
max-width: 50%;
}
}

.tableContainer {
&.tablet {
h4 {
color: $text-01;
}
}

&.desktop {
h4 {
color: $text-02;
}
}
}

tr {
Expand Down