uikit-react-public 0.40.2 → 0.40.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Footer/Footer.d.ts +10 -5
- package/dist/components/Footer/Footer.stories.d.ts +1 -1
- package/dist/components/Footer/FooterNavLink.d.ts +1 -1
- package/dist/components/Footer/SocialLink.d.ts +1 -1
- package/dist/components/FooterNew/FooterNavLink.d.ts +1 -1
- package/dist/components/FooterNew/SocialLink.d.ts +1 -1
- package/dist/index.js +3238 -3184
- package/lib/components/Footer/Footer.tsx +83 -6
- package/lib/components/Footer/FooterColumn.tsx +2 -3
- package/lib/components/Footer/FooterNavLink.tsx +3 -1
- package/lib/components/Footer/SocialLink.tsx +4 -1
- package/lib/components/Footer/__tests__/Footer.test.tsx +42 -9
- package/lib/components/FooterNew/BackToTop.tsx +1 -1
- package/lib/components/FooterNew/Footer.tsx +1 -1
- package/lib/components/FooterNew/FooterColumn.tsx +1 -1
- package/lib/components/FooterNew/FooterLinks.tsx +1 -1
- package/lib/components/FooterNew/FooterNavLink.tsx +3 -1
- package/lib/components/FooterNew/LegalAndCopyright.tsx +1 -1
- package/lib/components/FooterNew/LogoAddressAndSocial.tsx +2 -1
- package/lib/components/FooterNew/SocialLink.tsx +4 -1
- package/package.json +1 -1
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { memo, HTMLAttributes } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import {
|
|
3
|
+
import { themes, useTheme } from '../../theme';
|
|
4
|
+
import Divider from '../Divider';
|
|
5
|
+
import { UclLogo } from '../UclLogo';
|
|
4
6
|
import FooterColumn from './FooterColumn';
|
|
7
|
+
import type { FooterColumnProps } from './FooterColumn';
|
|
5
8
|
import SocialLink from './SocialLink';
|
|
6
9
|
import FooterNavLink from './FooterNavLink';
|
|
10
|
+
import type { FooterNavLinkProps } from './FooterNavLink';
|
|
11
|
+
import FooterNew from '../FooterNew';
|
|
7
12
|
|
|
8
13
|
export const NAME = 'ucl-uikit-footer';
|
|
9
14
|
|
|
10
15
|
export interface FooterProps extends HTMLAttributes<HTMLElement> {
|
|
11
16
|
testId?: string;
|
|
17
|
+
addressFormat?: 'compact' | 'full';
|
|
18
|
+
showSocialLinks?: boolean;
|
|
12
19
|
disclaimer?: string;
|
|
13
20
|
freedomOfInformation?: string;
|
|
14
21
|
accessibility?: string;
|
|
15
22
|
cookies?: string;
|
|
16
23
|
privacy?: string;
|
|
17
24
|
slaveryStatement?: string;
|
|
25
|
+
login?: string;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
const
|
|
28
|
+
const LegacyFooter = ({
|
|
21
29
|
testId = NAME,
|
|
22
30
|
className,
|
|
23
31
|
disclaimer = 'https://www.ucl.ac.uk/legal-services/disclaimer',
|
|
@@ -257,17 +265,86 @@ const Footer = ({
|
|
|
257
265
|
);
|
|
258
266
|
};
|
|
259
267
|
|
|
268
|
+
const Footer = ({
|
|
269
|
+
testId = NAME,
|
|
270
|
+
className,
|
|
271
|
+
addressFormat,
|
|
272
|
+
showSocialLinks,
|
|
273
|
+
disclaimer,
|
|
274
|
+
freedomOfInformation,
|
|
275
|
+
accessibility,
|
|
276
|
+
cookies,
|
|
277
|
+
privacy,
|
|
278
|
+
slaveryStatement,
|
|
279
|
+
login,
|
|
280
|
+
children,
|
|
281
|
+
...props
|
|
282
|
+
}: FooterProps) => {
|
|
283
|
+
const [theme] = useTheme();
|
|
284
|
+
|
|
285
|
+
if (theme === themes.default) {
|
|
286
|
+
return (
|
|
287
|
+
<LegacyFooter
|
|
288
|
+
testId={testId}
|
|
289
|
+
className={className}
|
|
290
|
+
disclaimer={disclaimer}
|
|
291
|
+
freedomOfInformation={freedomOfInformation}
|
|
292
|
+
accessibility={accessibility}
|
|
293
|
+
cookies={cookies}
|
|
294
|
+
privacy={privacy}
|
|
295
|
+
slaveryStatement={slaveryStatement}
|
|
296
|
+
{...props}
|
|
297
|
+
>
|
|
298
|
+
{children}
|
|
299
|
+
</LegacyFooter>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<FooterNew
|
|
305
|
+
testId={testId}
|
|
306
|
+
className={className}
|
|
307
|
+
addressFormat={addressFormat}
|
|
308
|
+
showSocialLinks={showSocialLinks}
|
|
309
|
+
disclaimer={disclaimer}
|
|
310
|
+
freedomOfInformation={freedomOfInformation}
|
|
311
|
+
accessibility={accessibility}
|
|
312
|
+
cookies={cookies}
|
|
313
|
+
privacy={privacy}
|
|
314
|
+
slaveryStatement={slaveryStatement}
|
|
315
|
+
login={login}
|
|
316
|
+
{...props}
|
|
317
|
+
>
|
|
318
|
+
{children}
|
|
319
|
+
</FooterNew>
|
|
320
|
+
);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const FooterColumnBridge = (props: FooterColumnProps) => {
|
|
324
|
+
const [theme] = useTheme();
|
|
325
|
+
const Column = theme === themes.default ? FooterColumn : FooterNew.Column;
|
|
326
|
+
|
|
327
|
+
return <Column {...props} />;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
const FooterNavLinkBridge = (props: FooterNavLinkProps) => {
|
|
331
|
+
const [theme] = useTheme();
|
|
332
|
+
const NavLink = theme === themes.default ? FooterNavLink : FooterNew.NavLink;
|
|
333
|
+
|
|
334
|
+
return <NavLink {...props} />;
|
|
335
|
+
};
|
|
336
|
+
|
|
260
337
|
const MemoFooter = memo(Footer);
|
|
261
338
|
|
|
262
339
|
export interface IFooterSubComponents {
|
|
263
|
-
Column: typeof
|
|
264
|
-
NavLink: typeof
|
|
340
|
+
Column: typeof FooterColumnBridge;
|
|
341
|
+
NavLink: typeof FooterNavLinkBridge;
|
|
265
342
|
}
|
|
266
343
|
|
|
267
344
|
const FooterWithSubComponents = MemoFooter as typeof MemoFooter &
|
|
268
345
|
IFooterSubComponents;
|
|
269
346
|
|
|
270
|
-
FooterWithSubComponents.Column =
|
|
271
|
-
FooterWithSubComponents.NavLink =
|
|
347
|
+
FooterWithSubComponents.Column = FooterColumnBridge;
|
|
348
|
+
FooterWithSubComponents.NavLink = FooterNavLinkBridge;
|
|
272
349
|
|
|
273
350
|
export default FooterWithSubComponents;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { memo, HTMLAttributes } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import { useTheme } from '
|
|
3
|
+
import { useTheme } from '../../theme';
|
|
4
4
|
|
|
5
5
|
export const NAME = 'ucl-uikit-footer__column';
|
|
6
6
|
|
|
7
|
-
export interface FooterColumnProps
|
|
8
|
-
extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
export interface FooterColumnProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
8
|
heading: string;
|
|
10
9
|
testId?: string;
|
|
11
10
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import {
|
|
3
|
+
import { useTheme } from '../../theme';
|
|
4
|
+
import Link from '../Link';
|
|
5
|
+
import type { LinkProps } from '../Link';
|
|
4
6
|
|
|
5
7
|
export const NAME = 'ucl-uikit-footer__nav-link';
|
|
6
8
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import {
|
|
3
|
+
import { useTheme } from '../../theme';
|
|
4
|
+
import Icon from '../Icon';
|
|
5
|
+
import Link from '../Link';
|
|
6
|
+
import type { LinkProps } from '../Link';
|
|
4
7
|
|
|
5
8
|
export const NAME = 'ucl-uikit-footer__social-link';
|
|
6
9
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import Footer from '../Footer';
|
|
4
4
|
import { ThemeContextProvider } from '../../../theme/useTheme';
|
|
5
5
|
|
|
@@ -12,9 +12,7 @@ describe('Footer', () => {
|
|
|
12
12
|
<Footer />
|
|
13
13
|
</ThemeContextProvider>
|
|
14
14
|
);
|
|
15
|
-
expect(
|
|
16
|
-
renderResult.container.firstChild
|
|
17
|
-
).toMatchSnapshot();
|
|
15
|
+
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
18
16
|
});
|
|
19
17
|
|
|
20
18
|
test('snapshot: footer links provided', () => {
|
|
@@ -30,9 +28,7 @@ describe('Footer', () => {
|
|
|
30
28
|
/>
|
|
31
29
|
</ThemeContextProvider>
|
|
32
30
|
);
|
|
33
|
-
expect(
|
|
34
|
-
renderResult.container.firstChild
|
|
35
|
-
).toMatchSnapshot();
|
|
31
|
+
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
36
32
|
});
|
|
37
33
|
|
|
38
34
|
test('snapshot: nav links', () => {
|
|
@@ -50,8 +46,45 @@ describe('Footer', () => {
|
|
|
50
46
|
</Footer>
|
|
51
47
|
</ThemeContextProvider>
|
|
52
48
|
);
|
|
49
|
+
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('uses the legacy footer for the default theme', () => {
|
|
53
|
+
render(
|
|
54
|
+
<ThemeContextProvider>
|
|
55
|
+
<Footer />
|
|
56
|
+
</ThemeContextProvider>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(
|
|
60
|
+
screen.queryByRole('button', { name: /back to top/i })
|
|
61
|
+
).not.toBeInTheDocument();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('uses the new footer for light and dark themes', () => {
|
|
65
|
+
render(
|
|
66
|
+
<ThemeContextProvider theme='light'>
|
|
67
|
+
<Footer
|
|
68
|
+
login='https://www.ucl.ac.uk/login'
|
|
69
|
+
showSocialLinks={false}
|
|
70
|
+
>
|
|
71
|
+
<Footer.Column heading='Category 1'>
|
|
72
|
+
<Footer.NavLink href='#'>Item 1</Footer.NavLink>
|
|
73
|
+
</Footer.Column>
|
|
74
|
+
</Footer>
|
|
75
|
+
</ThemeContextProvider>
|
|
76
|
+
);
|
|
77
|
+
|
|
53
78
|
expect(
|
|
54
|
-
|
|
55
|
-
).
|
|
79
|
+
screen.getByRole('button', { name: /back to top/i })
|
|
80
|
+
).toBeInTheDocument();
|
|
81
|
+
expect(screen.getByRole('link', { name: 'Login' })).toHaveAttribute(
|
|
82
|
+
'href',
|
|
83
|
+
'https://www.ucl.ac.uk/login'
|
|
84
|
+
);
|
|
85
|
+
expect(screen.getByText('Category 1')).toBeInTheDocument();
|
|
86
|
+
expect(screen.getByRole('link', { name: 'Item 1' })).toHaveClass(
|
|
87
|
+
'ucl-uikit-footer__nav-link'
|
|
88
|
+
);
|
|
56
89
|
});
|
|
57
90
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo, HTMLAttributes } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import { useTheme } from '
|
|
3
|
+
import { useTheme } from '../../theme';
|
|
4
4
|
import FooterColumn from './FooterColumn';
|
|
5
5
|
import FooterNavLink from './FooterNavLink';
|
|
6
6
|
import LogoAddressAndSocial from './LogoAddressAndSocial';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import {
|
|
3
|
+
import { useTheme } from '../../theme';
|
|
4
|
+
import Link from '../Link';
|
|
5
|
+
import type { LinkProps } from '../Link';
|
|
4
6
|
|
|
5
7
|
export const NAME = 'ucl-uikit-footer__nav-link';
|
|
6
8
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import {
|
|
3
|
+
import { useTheme } from '../../theme';
|
|
4
|
+
import UclLogoNew from '../UclLogoNew/UclLogo';
|
|
4
5
|
import SocialLink from './SocialLink';
|
|
5
6
|
|
|
6
7
|
export const NAME = 'ucl-uikit-footer__logo-address-social';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { css, cx } from '@emotion/css';
|
|
3
|
-
import {
|
|
3
|
+
import { useTheme } from '../../theme';
|
|
4
|
+
import Icon from '../Icon';
|
|
5
|
+
import Link from '../Link';
|
|
6
|
+
import type { LinkProps } from '../Link';
|
|
4
7
|
|
|
5
8
|
export const NAME = 'ucl-uikit-footer__social-link';
|
|
6
9
|
|