/
index.js
164 lines (156 loc) · 4.74 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { spacing, typography } from '@govuk-react/lib';
import { FOOTER_BACKGROUND, FOOTER_TEXT, FOOTER_BORDER_TOP } from 'govuk-colours';
import WidthContainer from './atoms/width-container';
import Navigation from './atoms/navigation';
import Link from './atoms/link';
import SectionBreak from './atoms/section-break';
import MetaCustom from './atoms/meta-custom';
import MetaContainer from './molecules/meta-container';
import MetaLinks from './molecules/meta-links';
import NavigationLinks from './molecules/navigation-links';
const FooterContainer = styled('footer')(
{
borderTop: `1px solid ${FOOTER_BORDER_TOP}`,
background: `${FOOTER_BACKGROUND}`,
color: `${FOOTER_TEXT}`,
},
typography.font({ size: 16 }),
spacing.withWhiteSpace({ padding: [{ size: 7, direction: 'top' }, { size: 5, direction: 'bottom' }] })
);
/**
*
* ### Usage
*
* Simple
* ```jsx
* <Footer />
* ```
*
* Footer with Copyright information
* ```jsx
* // Import self hosted copyright image
* import crest from './govuk-crest.png';
*
* <Footer
* copyright={{
* text: 'Crown copyright',
* link:
* 'https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/',
* image: {
* source: crest,
* height: 102,
* width: 125,
* },
* }}
* />;
* ```
*
* Footer with navigation. There is also the option to provide footer links with, or without React/Reach Router.
* ```jsx
* import { Link } from 'react-router-dom';
*
* <Footer>
* <Footer.Navigation>
* <Footer.NavigationLinks heading="Two column list" listColumns={2}>
* <Footer.Link href="/">Navigation item 1</Footer.Link>
* <Footer.Link to="/footer-nav-item-2" as={Link}>Navigation item 2 (Router Link)</Footer.Link>
* <Footer.Link href="/">Navigation item 3</Footer.Link>
* <Footer.Link href="/">Navigation item 4</Footer.Link>
* <Footer.Link href="/">Navigation item 5</Footer.Link>
* <Footer.Link href="/">Navigation item 6</Footer.Link>
* </Footer.NavigationLinks>
* <Footer.NavigationLinks heading="Single column list">
* <Footer.Link href="/">Navigation item 1</Footer.Link>
* <Footer.Link href="/">Navigation item 2</Footer.Link>
* <Footer.Link href="/">Navigation item 3</Footer.Link>
* </Footer.NavigationLinks>
* </Footer.Navigation>
* </Footer>
* ```
*
* Footer with links in meta area
* ```jsx
* <Footer meta={
* <Footer.MetaLinks heading="Support links">
* <Footer.Link href="/">Item 1</Footer.Link>
* <Footer.Link to="/footer-meta-item-2" as={Link}>Item 2 (Router Link)</Footer.Link>
* <Footer.Link href="/">Item 3</Footer.Link>
* </Footer.MetaLinks>
* }
* />
* ```
*
* Footer with custom content in meta area
* ```jsx
* <Footer meta={
* <Footer.MetaCustom>
* Built by the <Footer.Link href="/">Government Digital Service</Footer.Link>
* </Footer.MetaCustom>
* }
* />
* ```
*
* NB <Footer.Link /> is styled extention of @govuk-react/link
*
* ### References:
* - https://design-system.service.gov.uk/components/footer/
* - https://github.com/alphagov/govuk-frontend/blob/master/src/components/footer/template.njk
* - https://github.com/alphagov/govuk-frontend/blob/master/src/components/footer/_footer.scss
*
*/
const Footer = ({ children, container: Container, copyright, meta, ...props }) => (
<FooterContainer role="contentinfo" {...props}>
<Container>
{children && (
<React.Fragment>
{children}
<SectionBreak />
</React.Fragment>
)}
<MetaContainer copyright={copyright}>{meta}</MetaContainer>
</Container>
</FooterContainer>
);
Footer.propTypes = {
/**
* Footer navigation links
*/
children: PropTypes.node,
/**
* Override the default footer container component.
* `children`, `copyright` and `meta` will be placed inside this component.
*/
container: PropTypes.func,
/**
* Copyright information
*/
copyright: PropTypes.shape({
text: PropTypes.string,
image: PropTypes.shape({
src: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
}),
link: PropTypes.string,
}),
/**
* Meta text and links
*/
meta: PropTypes.node,
};
Footer.Link = Link;
Footer.Navigation = Navigation;
Footer.MetaCustom = MetaCustom;
Footer.MetaLinks = MetaLinks;
Footer.NavigationLinks = NavigationLinks;
Footer.WidthContainer = WidthContainer;
Footer.defaultProps = {
children: undefined,
container: Footer.WidthContainer,
copyright: undefined,
meta: undefined,
};
export default Footer;