Skip to content

Commit

Permalink
Update table actions column styles
Browse files Browse the repository at this point in the history
  • Loading branch information
vesnushka committed Dec 19, 2024
1 parent e7191d4 commit 2586f8d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/containers/PatientResourceListExample/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PlusOutlined } from '@ant-design/icons';
import { t, Trans } from '@lingui/macro';
import { Button } from 'antd';
import { Patient } from 'fhir/r4b';

import { SearchBarColumnType } from 'src/components/SearchBar/types';
Expand All @@ -11,6 +10,7 @@ import { renderHumanName } from 'src/utils/fhir';
import { matchCurrentUserRole, Role } from 'src/utils/role';

import { getPatientSearchParamsForPractitioner } from './utils';
import { S } from './styles';

export function PatientResourceListExample() {
/*
Expand Down Expand Up @@ -72,7 +72,7 @@ export function PatientResourceListExample() {
getRecordActions={(record) => [
navigationAction('Open', `/patients/${record.resource.id}`),
questionnaireAction('Edit', 'patient-edit'),
customAction(<Button type="link">Custom action</Button>),
customAction(<S.LinkButton type="link">Custom action</S.LinkButton>),
]}
getHeaderActions={() => [
questionnaireAction(<Trans>Add patient</Trans>, 'patient-create', { icon: <PlusOutlined /> }),
Expand Down
9 changes: 9 additions & 0 deletions src/containers/PatientResourceListExample/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from 'styled-components';

import { Button } from 'antd';

export const S = {
LinkButton: styled(Button)`
padding: 0;
`,
};
8 changes: 5 additions & 3 deletions src/uberComponents/ResourceListPage/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useNavigate } from 'react-router-dom';
import { ModalTrigger } from 'src/components/ModalTrigger';
import { QuestionnaireResponseForm, QRFProps } from 'src/components/QuestionnaireResponseForm';
import { questionnaireIdLoader } from 'src/hooks/questionnaire-response-form-data';
import { S } from './styles';

export interface NavigationActionType {
type: 'navigation';
Expand Down Expand Up @@ -77,7 +78,7 @@ export function RecordQuestionnaireAction<R extends Resource>({
defaultLaunchContext: ParametersParameter[];
}) {
return (
<ModalTrigger title={action.title} trigger={<Button type="link">{action.title}</Button>}>
<ModalTrigger title={action.title} trigger={<S.LinkButton type="link">{action.title}</S.LinkButton>}>
{({ closeModal }) => (
<QuestionnaireResponseForm
questionnaireLoader={questionnaireIdLoader(action.questionnaireId)}
Expand Down Expand Up @@ -189,8 +190,9 @@ export function NavigationAction<R extends Resource>({
resource: R;
}) {
const navigate = useNavigate();

return (
<Button
<S.LinkButton
type="link"
style={{ padding: 0 }}
onClick={() =>
Expand All @@ -201,6 +203,6 @@ export function NavigationAction<R extends Resource>({
icon={action.icon}
>
{action.title}
</Button>
</S.LinkButton>
);
}
10 changes: 6 additions & 4 deletions src/uberComponents/ResourceListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
export { navigationAction, customAction, questionnaireAction } from './actions';
import { useResourceListPage } from './hooks';
import { SearchBarColumn } from '../../components/SearchBar/types';
import { S } from './styles';
import React from 'react';

type RecordType<R extends Resource> = { resource: R; bundle: Bundle };

Expand Down Expand Up @@ -268,9 +270,9 @@ function getRecordActionsColumn<R extends Resource>({
key: 'actions',
render: (_text: any, record: { resource: R; bundle: Bundle }) => {
return (
<Row wrap={false}>
<S.Actions>
{getRecordActions(record, { reload }).map((action, index) => (
<Col key={index}>
<React.Fragment key={index}>
{isQuestionnaireAction(action) ? (
<RecordQuestionnaireAction
action={action}
Expand All @@ -285,9 +287,9 @@ function getRecordActionsColumn<R extends Resource>({
) : (
<Text>Unsupported action</Text>
)}
</Col>
</React.Fragment>
))}
</Row>
</S.Actions>
);
},
};
Expand Down
13 changes: 13 additions & 0 deletions src/uberComponents/ResourceListPage/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from 'styled-components';

import { Button } from 'antd';

export const S = {
Actions: styled.div`
display: flex;
gap: 8px 16px;
`,
LinkButton: styled(Button)`
padding: 0;
`,
};

0 comments on commit 2586f8d

Please sign in to comment.