Skip to content

Commit d291a07

Browse files
Split summary list into child components
1 parent 8cdd499 commit d291a07

File tree

7 files changed

+44
-20
lines changed

7 files changed

+44
-20
lines changed

src/components/content-presentation/summary-list/SummaryList.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import classNames from 'classnames';
2-
import { forwardRef, type ComponentPropsWithoutRef, type FC } from 'react';
2+
import { forwardRef, type ComponentPropsWithoutRef } from 'react';
33

4-
export const SummaryListRow: FC<ComponentPropsWithoutRef<'div'>> = ({ className, ...rest }) => (
5-
<div className={classNames('nhsuk-summary-list__row', className)} {...rest} />
6-
);
7-
8-
export const SummaryListKey: FC<ComponentPropsWithoutRef<'dt'>> = ({ className, ...rest }) => (
9-
<dt className={classNames('nhsuk-summary-list__key', className)} {...rest} />
10-
);
11-
12-
export const SummaryListValue: FC<ComponentPropsWithoutRef<'dd'>> = ({ className, ...rest }) => (
13-
<dd className={classNames('nhsuk-summary-list__value', className)} {...rest} />
14-
);
15-
16-
export const SummaryListActions: FC<ComponentPropsWithoutRef<'dd'>> = ({ className, ...rest }) => (
17-
<dd className={classNames('nhsuk-summary-list__actions', className)} {...rest} />
18-
);
4+
import {
5+
SummaryListActions,
6+
SummaryListKey,
7+
SummaryListRow,
8+
SummaryListValue,
9+
} from './components/index.js';
1910

2011
export interface SummaryListProps extends ComponentPropsWithoutRef<'dl'> {
2112
noBorder?: boolean;
@@ -36,10 +27,6 @@ const SummaryListComponent = forwardRef<HTMLDListElement, SummaryListProps>(
3627
);
3728

3829
SummaryListComponent.displayName = 'SummaryList';
39-
SummaryListRow.displayName = 'SummaryList.Row';
40-
SummaryListKey.displayName = 'SummaryList.Key';
41-
SummaryListValue.displayName = 'SummaryList.Value';
42-
SummaryListActions.displayName = 'SummaryList.Actions';
4330

4431
export const SummaryList = Object.assign(SummaryListComponent, {
4532
Row: SummaryListRow,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import classNames from 'classnames';
2+
import { type ComponentPropsWithoutRef, type FC } from 'react';
3+
4+
export const SummaryListActions: FC<ComponentPropsWithoutRef<'dd'>> = ({ className, ...rest }) => (
5+
<dd className={classNames('nhsuk-summary-list__actions', className)} {...rest} />
6+
);
7+
8+
SummaryListActions.displayName = 'SummaryList.Actions';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import classNames from 'classnames';
2+
import { type ComponentPropsWithoutRef, type FC } from 'react';
3+
4+
export const SummaryListKey: FC<ComponentPropsWithoutRef<'dt'>> = ({ className, ...rest }) => (
5+
<dt className={classNames('nhsuk-summary-list__key', className)} {...rest} />
6+
);
7+
8+
SummaryListKey.displayName = 'SummaryList.Key';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import classNames from 'classnames';
2+
import { type ComponentPropsWithoutRef, type FC } from 'react';
3+
4+
export const SummaryListRow: FC<ComponentPropsWithoutRef<'div'>> = ({ className, ...rest }) => (
5+
<div className={classNames('nhsuk-summary-list__row', className)} {...rest} />
6+
);
7+
8+
SummaryListRow.displayName = 'SummaryList.Row';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import classNames from 'classnames';
2+
import { type ComponentPropsWithoutRef, type FC } from 'react';
3+
4+
export const SummaryListValue: FC<ComponentPropsWithoutRef<'dd'>> = ({ className, ...rest }) => (
5+
<dd className={classNames('nhsuk-summary-list__value', className)} {...rest} />
6+
);
7+
8+
SummaryListValue.displayName = 'SummaryList.Value';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './SummaryListActions.js';
2+
export * from './SummaryListKey.js';
3+
export * from './SummaryListRow.js';
4+
export * from './SummaryListValue.js';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './components/index.js';
12
export * from './SummaryList.js';

0 commit comments

Comments
 (0)