Skip to content

Commit 9e1cafd

Browse files
Export all multipart namespace components separately
1 parent dbc22c2 commit 9e1cafd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+489
-347
lines changed

src/__tests__/index.test.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,74 @@ describe('Index', () => {
1313
'BackLink',
1414
'BodyText',
1515
'Breadcrumb',
16+
'BreadcrumbBack',
17+
'BreadcrumbItem',
1618
'Button',
1719
'Card',
20+
'CardContent',
1821
'CardContext',
22+
'CardDescription',
23+
'CardGroup',
24+
'CardGroupItem',
25+
'CardHeading',
26+
'CardImage',
27+
'CardLink',
1928
'cardTypeIsCareCard',
2029
'CharacterCount',
2130
'Checkboxes',
2231
'CheckboxesContext',
32+
'CheckboxesDivider',
33+
'CheckboxesItem',
2334
'ChevronRightCircleIcon',
2435
'childIsOfComponentType',
2536
'Clearfix',
2637
'Col',
2738
'Container',
2839
'ContentsList',
40+
'ContentsListItem',
2941
'CrossIcon',
3042
'DateInput',
3143
'DateInputContext',
44+
'DateInputDay',
45+
'DateInputMonth',
46+
'DateInputYear',
3247
'Details',
48+
'DetailsExpanderGroup',
49+
'DetailsSummary',
50+
'DetailsText',
3351
'DoAndDontList',
52+
'DoAndDontListContext',
53+
'DoAndDontListItem',
3454
'ErrorMessage',
3555
'ErrorSummary',
56+
'ErrorSummaryList',
57+
'ErrorSummaryListItem',
58+
'ErrorSummaryTitle',
3659
'Fieldset',
3760
'Footer',
61+
'FooterCopyright',
62+
'FooterList',
63+
'FooterListItem',
64+
'FooterMeta',
3865
'Form',
3966
'FormContext',
4067
'FormGroup',
4168
'FormGroupContext',
4269
'Header',
70+
'HeaderAccount',
71+
'HeaderAccountItem',
4372
'HeaderContext',
73+
'HeaderLogo',
74+
'HeaderMenuToggle',
75+
'HeaderNavigation',
76+
'HeaderNavigationItem',
77+
'HeaderSearch',
78+
'HeaderServiceName',
4479
'HeadingLevel',
4580
'Hero',
81+
'HeroContent',
82+
'HeroHeading',
83+
'HeroText',
4684
'HintText',
4785
'Icon',
4886
'Images',
@@ -51,29 +89,52 @@ describe('Index', () => {
5189
'LedeText',
5290
'Legend',
5391
'NavAZ',
92+
'NavAZDisabledItem',
93+
'NavAZLinkItem',
5494
'Pagination',
95+
'PaginationLink',
5596
'Panel',
97+
'PanelTitle',
5698
'Radios',
5799
'RadiosContext',
100+
'RadiosDivider',
101+
'RadiosItem',
58102
'ReadingWidth',
59103
'ReviewDate',
60104
'Row',
61105
'SearchIcon',
62106
'Select',
107+
'SelectOption',
63108
'SkipLink',
64109
'SummaryList',
110+
'SummaryListActions',
111+
'SummaryListKey',
112+
'SummaryListRow',
113+
'SummaryListValue',
65114
'Table',
115+
'TableBody',
116+
'TableCaption',
117+
'TableCell',
118+
'TableContainer',
66119
'TableContext',
120+
'TableHead',
121+
'TablePanel',
122+
'TableRow',
67123
'TableSection',
68124
'TableSectionContext',
69125
'Tabs',
126+
'TabsContents',
127+
'TabsList',
128+
'TabsListItem',
129+
'TabsTitle',
70130
'Tag',
71131
'Textarea',
72132
'TextInput',
73133
'TickIcon',
74134
'useFormContext',
75135
'UserIcon',
76136
'WarningCallout',
137+
'WarningCalloutHeading',
77138
]);
78139
});
79140
});

src/components/content-presentation/details/Details.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const DetailsComponent = forwardRef<HTMLDetailsElement, DetailsProps>(
1515
),
1616
);
1717

18-
const DetailsSummary = forwardRef<HTMLElement, ComponentPropsWithoutRef<'div'>>(
18+
export const DetailsSummary = forwardRef<HTMLElement, ComponentPropsWithoutRef<'div'>>(
1919
({ children, className, ...rest }, forwardedRef) => (
2020
<summary
2121
className={classNames('nhsuk-details__summary', className)}
@@ -27,21 +27,22 @@ const DetailsSummary = forwardRef<HTMLElement, ComponentPropsWithoutRef<'div'>>(
2727
),
2828
);
2929

30-
const DetailsText: FC<ComponentPropsWithoutRef<'div'>> = ({ className, ...rest }) => (
30+
export const DetailsText: FC<ComponentPropsWithoutRef<'div'>> = ({ className, ...rest }) => (
3131
<div className={classNames('nhsuk-details__text', className)} {...rest} />
3232
);
3333

34-
const ExpanderGroup: FC<ComponentPropsWithoutRef<'div'>> = ({ className, ...rest }) => (
35-
<div className={classNames('nhsuk-expander-group', className)} {...rest} />
36-
);
34+
export const DetailsExpanderGroup: FC<ComponentPropsWithoutRef<'div'>> = ({
35+
className,
36+
...rest
37+
}) => <div className={classNames('nhsuk-expander-group', className)} {...rest} />;
3738

3839
DetailsComponent.displayName = 'Details';
3940
DetailsSummary.displayName = 'Details.Summary';
4041
DetailsText.displayName = 'Details.Text';
41-
ExpanderGroup.displayName = 'Details.ExpanderGroup';
42+
DetailsExpanderGroup.displayName = 'Details.ExpanderGroup';
4243

4344
export const Details = Object.assign(DetailsComponent, {
4445
Summary: DetailsSummary,
4546
Text: DetailsText,
46-
ExpanderGroup,
47+
ExpanderGroup: DetailsExpanderGroup,
4748
});
Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
'use client';
22

33
import classNames from 'classnames';
4-
import {
5-
createContext,
6-
forwardRef,
7-
useContext,
8-
type ComponentPropsWithoutRef,
9-
type FC,
10-
type ReactNode,
11-
} from 'react';
12-
import { CrossIcon, TickIcon } from '../icons/index.js';
4+
import { forwardRef, type ComponentPropsWithoutRef } from 'react';
135
import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';
14-
15-
type ListType = 'do' | 'dont';
6+
import { DoAndDontListContext, type DoAndDontListType } from './DoAndDontListContext.js';
7+
import { DoAndDontListItem } from './components/index.js';
168

179
export interface DoAndDontListProps
1810
extends ComponentPropsWithoutRef<'div'>,
1911
Pick<HeadingLevelProps, 'headingLevel'> {
20-
listType: ListType;
12+
listType: DoAndDontListType;
2113
heading?: string;
2214
}
2315

24-
const DoAndDontListContext = createContext<ListType>('do');
25-
2616
const DoAndDontListComponent = forwardRef<HTMLDivElement, DoAndDontListProps>(
2717
({ className, listType, children, heading, headingLevel, ...rest }, forwardedRef) => (
2818
<div className={classNames('nhsuk-do-dont-list', className)} ref={forwardedRef} {...rest}>
@@ -42,36 +32,8 @@ const DoAndDontListComponent = forwardRef<HTMLDivElement, DoAndDontListProps>(
4232
),
4333
);
4434

45-
export interface DoAndDontItemProps extends ComponentPropsWithoutRef<'li'> {
46-
listItemType?: ListType;
47-
prefixText?: ReactNode;
48-
}
49-
50-
const DoAndDontItem: FC<DoAndDontItemProps> = ({ prefixText, listItemType, children, ...rest }) => {
51-
const listItem = useContext(DoAndDontListContext);
52-
const defaultPrefix = (listItemType || listItem) === 'do' ? null : 'do not ';
53-
const actualPrefix = prefixText === undefined ? defaultPrefix : prefixText;
54-
return (
55-
<li {...rest}>
56-
{(listItemType || listItem) === 'do' ? (
57-
<>
58-
<TickIcon />
59-
{actualPrefix}
60-
</>
61-
) : (
62-
<>
63-
<CrossIcon />
64-
{actualPrefix}
65-
</>
66-
)}
67-
{children}
68-
</li>
69-
);
70-
};
71-
7235
DoAndDontListComponent.displayName = 'DoAndDontList';
73-
DoAndDontItem.displayName = 'DoAndDontList.Item';
7436

7537
export const DoAndDontList = Object.assign(DoAndDontListComponent, {
76-
Item: DoAndDontItem,
38+
Item: DoAndDontListItem,
7739
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client';
2+
3+
import { createContext } from 'react';
4+
5+
export type DoAndDontListType = 'do' | 'dont';
6+
7+
export const DoAndDontListContext = createContext<DoAndDontListType>('do');
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use client';
2+
3+
import { useContext, type ComponentPropsWithoutRef, type FC, type ReactNode } from 'react';
4+
import { CrossIcon, TickIcon } from '../../icons/index.js';
5+
import { DoAndDontListContext, type DoAndDontListType } from '../DoAndDontListContext.js';
6+
7+
export interface DoAndDontListItemProps extends ComponentPropsWithoutRef<'li'> {
8+
listItemType?: DoAndDontListType;
9+
prefixText?: ReactNode;
10+
}
11+
12+
export const DoAndDontListItem: FC<DoAndDontListItemProps> = ({
13+
prefixText,
14+
listItemType,
15+
children,
16+
...rest
17+
}) => {
18+
const listItem = useContext(DoAndDontListContext);
19+
const defaultPrefix = (listItemType || listItem) === 'do' ? null : 'do not ';
20+
const actualPrefix = prefixText === undefined ? defaultPrefix : prefixText;
21+
return (
22+
<li {...rest}>
23+
{(listItemType || listItem) === 'do' ? (
24+
<>
25+
<TickIcon />
26+
{actualPrefix}
27+
</>
28+
) : (
29+
<>
30+
<CrossIcon />
31+
{actualPrefix}
32+
</>
33+
)}
34+
{children}
35+
</li>
36+
);
37+
};
38+
39+
DoAndDontListItem.displayName = 'DoAndDontList.Item';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './DoAndDontListItem.js';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
export * from './components/index.js';
2+
export * from './DoAndDontListContext.js';
13
export * from './DoAndDontList.js';

src/components/content-presentation/hero/Hero.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface HeroContentProps extends ComponentPropsWithoutRef<'div'> {
77
hasImage: boolean;
88
}
99

10-
const HeroContent: FC<HeroContentProps> = ({ children, hasImage }) => {
10+
export const HeroContent: FC<HeroContentProps> = ({ children, hasImage }) => {
1111
if (!children) {
1212
return null;
1313
}
@@ -29,15 +29,15 @@ const HeroContent: FC<HeroContentProps> = ({ children, hasImage }) => {
2929
);
3030
};
3131

32-
const HeroHeading: FC<HeadingLevelProps> = ({ className, headingLevel = 'h1', ...rest }) => (
32+
export const HeroHeading: FC<HeadingLevelProps> = ({ className, headingLevel = 'h1', ...rest }) => (
3333
<HeadingLevel
3434
className={classNames('nhsuk-u-margin-bottom-3', className)}
3535
headingLevel={headingLevel}
3636
{...rest}
3737
/>
3838
);
3939

40-
const HeroText: FC<ComponentPropsWithoutRef<'p'>> = ({ className, ...rest }) => (
40+
export const HeroText: FC<ComponentPropsWithoutRef<'p'>> = ({ className, ...rest }) => (
4141
<p className={classNames('nhsuk-body-l nhsuk-u-margin-bottom-0', className)} {...rest} />
4242
);
4343

src/components/content-presentation/panel/Panel.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import classNames from 'classnames';
2-
import { Children, forwardRef, type ComponentPropsWithoutRef, type FC } from 'react';
3-
import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';
2+
import { Children, forwardRef, type ComponentPropsWithoutRef } from 'react';
43
import { childIsOfComponentType } from '#util/types/TypeGuards.js';
5-
6-
export type PanelTitleProps = HeadingLevelProps;
7-
8-
const PanelTitle: FC<PanelTitleProps> = ({ children, headingLevel = 'h1', ...rest }) => (
9-
<HeadingLevel className="nhsuk-panel__title" headingLevel={headingLevel} {...rest}>
10-
{children}
11-
</HeadingLevel>
12-
);
4+
import { PanelTitle } from './components/index.js';
135

146
export type PanelProps = ComponentPropsWithoutRef<'div'>;
157

@@ -29,7 +21,6 @@ const PanelComponent = forwardRef<HTMLDivElement, PanelProps>(
2921
);
3022

3123
PanelComponent.displayName = 'Panel';
32-
PanelComponent.displayName = 'Panel.Title';
3324

3425
export const Panel = Object.assign(PanelComponent, {
3526
Title: PanelTitle,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { type FC } from 'react';
2+
import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';
3+
4+
export type PanelTitleProps = HeadingLevelProps;
5+
6+
export const PanelTitle: FC<PanelTitleProps> = ({ children, headingLevel = 'h1', ...rest }) => (
7+
<HeadingLevel className="nhsuk-panel__title" headingLevel={headingLevel} {...rest}>
8+
{children}
9+
</HeadingLevel>
10+
);
11+
12+
PanelTitle.displayName = 'Panel.Title';

0 commit comments

Comments
 (0)