@comicrelief/component-library 8.48.2 → 8.49.1
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/Atoms/Button/Button.js +15 -42
- package/dist/components/Atoms/Button/Button.md +91 -1
- package/dist/components/Atoms/Button/Button.style.js +47 -0
- package/dist/components/Atoms/Button/Button.test.js +40 -12
- package/dist/components/Atoms/ButtonWithStates/ButtonWithStates.js +1 -1
- package/dist/components/Atoms/Link/Link.js +8 -5
- package/dist/components/Atoms/Link/Link.md +81 -78
- package/dist/components/Atoms/Link/Link.style.js +22 -18
- package/dist/components/Atoms/Link/Link.test.js +20 -19
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.js +0 -1
- package/dist/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -2
- package/dist/components/Molecules/CardDs/CardDs.md +3 -3
- package/dist/components/Molecules/CardDs/CardDs.test.js +1 -1
- package/dist/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +43 -41
- package/dist/components/Molecules/Countdown/Countdown.js +4 -8
- package/dist/components/Molecules/Descriptor/Descriptor.js +1 -2
- package/dist/components/Molecules/Descriptor/Descriptor.test.js +0 -2
- package/dist/components/Molecules/InfoBanner/InfoBanner.js +6 -12
- package/dist/components/Molecules/InfoBanner/__snapshots__/InfoBanner.test.js.snap +0 -1
- package/dist/components/Molecules/Lookup/Lookup.js +9 -16
- package/dist/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +42 -40
- package/dist/components/Molecules/SearchResult/SearchResult.js +2 -4
- package/dist/components/Molecules/SearchResult/__snapshots__/SearchResult.test.js.snap +0 -8
- package/dist/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +42 -40
- package/dist/components/Molecules/SingleMessageDS/SingleMessageDs.style.js +1 -1
- package/dist/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +20 -20
- package/dist/components/Organisms/CookieBanner/CookieBanner.test.js +21 -20
- package/dist/components/Organisms/Donate/Donate.js +1 -2
- package/dist/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +0 -4
- package/dist/components/Organisms/EmailSignUp/_EmailSignUp.js +2 -3
- package/dist/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +41 -18
- package/dist/components/Organisms/FooterNew/__snapshots__/FooterNew.test.js.snap +39 -12
- package/dist/components/Organisms/Header2025/Header2025.style.js +1 -1
- package/dist/components/Organisms/Header2025/HeaderNav2025/HeaderNav2025.style.js +1 -1
- package/dist/components/Organisms/ImpactSlider/ImpactSlider.js +0 -1
- package/dist/components/Organisms/ImpactSlider/_ImpactMoneybuys.js +0 -1
- package/dist/components/Organisms/WYMDCarousel/WYMDCarousel.js +0 -2
- package/dist/components/Organisms/WYMDCarousel/__snapshots__/WYMDCarousel.test.js.snap +0 -1
- package/dist/theme/crTheme/buttonColors.js +84 -72
- package/dist/theme/crTheme/buttonTypes.js +12 -0
- package/dist/theme/crTheme/colors.js +13 -1
- package/dist/theme/crTheme/fontConfig.js +3 -4
- package/dist/theme/crTheme/theme.js +2 -0
- package/package.json +1 -1
- package/playwright/components/organisms/emailSignUpForm.spec.js +1 -1
- package/src/components/Atoms/Button/Button.js +18 -36
- package/src/components/Atoms/Button/Button.md +91 -1
- package/src/components/Atoms/Button/Button.style.js +37 -0
- package/src/components/Atoms/Button/Button.test.js +44 -16
- package/src/components/Atoms/ButtonWithStates/ButtonWithStates.js +1 -1
- package/src/components/Atoms/Link/Link.js +15 -5
- package/src/components/Atoms/Link/Link.md +81 -78
- package/src/components/Atoms/Link/Link.style.js +32 -27
- package/src/components/Atoms/Link/Link.test.js +20 -19
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.js +0 -1
- package/src/components/Molecules/ArticleTeaser/ArticleTeaser.test.js +0 -2
- package/src/components/Molecules/CardDs/CardDs.md +3 -3
- package/src/components/Molecules/CardDs/CardDs.test.js +1 -1
- package/src/components/Molecules/CardDs/__snapshots__/CardDs.test.js.snap +43 -41
- package/src/components/Molecules/Countdown/Countdown.js +4 -4
- package/src/components/Molecules/Descriptor/Descriptor.js +0 -2
- package/src/components/Molecules/Descriptor/Descriptor.test.js +0 -2
- package/src/components/Molecules/InfoBanner/InfoBanner.js +6 -6
- package/src/components/Molecules/InfoBanner/__snapshots__/InfoBanner.test.js.snap +0 -1
- package/src/components/Molecules/Lookup/Lookup.js +4 -15
- package/src/components/Molecules/Promo/__snapshots__/Promo.test.js.snap +42 -40
- package/src/components/Molecules/SearchResult/SearchResult.js +2 -2
- package/src/components/Molecules/SearchResult/__snapshots__/SearchResult.test.js.snap +0 -8
- package/src/components/Molecules/SingleMessage/__snapshots__/SingleMessage.test.js.snap +42 -40
- package/src/components/Molecules/SingleMessageDS/SingleMessageDs.style.js +0 -1
- package/src/components/Molecules/SingleMessageDS/__snapshots__/SingleMessageDs.test.js.snap +20 -20
- package/src/components/Organisms/CookieBanner/CookieBanner.test.js +21 -20
- package/src/components/Organisms/Donate/Donate.js +1 -1
- package/src/components/Organisms/Donate/__snapshots__/Donate.test.js.snap +0 -4
- package/src/components/Organisms/EmailSignUp/_EmailSignUp.js +2 -2
- package/src/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +41 -18
- package/src/components/Organisms/FooterNew/__snapshots__/FooterNew.test.js.snap +39 -12
- package/src/components/Organisms/Header2025/Header2025.style.js +2 -1
- package/src/components/Organisms/Header2025/HeaderNav2025/HeaderNav2025.style.js +1 -1
- package/src/components/Organisms/ImpactSlider/ImpactSlider.js +1 -1
- package/src/components/Organisms/ImpactSlider/_ImpactMoneybuys.js +1 -1
- package/src/components/Organisms/WYMDCarousel/WYMDCarousel.js +2 -2
- package/src/components/Organisms/WYMDCarousel/__snapshots__/WYMDCarousel.test.js.snap +0 -1
- package/src/theme/crTheme/buttonColors.js +116 -76
- package/src/theme/crTheme/buttonTypes.js +7 -0
- package/src/theme/crTheme/colors.js +14 -1
- package/src/theme/crTheme/fontConfig.js +3 -4
- package/src/theme/crTheme/theme.js +3 -0
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const StyledButton = styled.button`
|
|
7
|
-
display: inline-flex;
|
|
8
|
-
position: relative;
|
|
9
|
-
padding: 0.5rem 1.25rem;
|
|
10
|
-
text-decoration: none;
|
|
11
|
-
font-weight: 700;
|
|
12
|
-
font-size: ${({ theme }) => theme.fontSize('s')};
|
|
13
|
-
border-radius: 2rem;
|
|
14
|
-
transition: all 0.3s;
|
|
15
|
-
height: 3.125rem;
|
|
16
|
-
width: 100%;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
align-items: center;
|
|
19
|
-
border: none;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
> a {
|
|
22
|
-
text-decoration: none;
|
|
23
|
-
}
|
|
24
|
-
${({ color, theme }) => (color ? theme.buttonColors(color) : theme.buttonColors('red'))};
|
|
25
|
-
|
|
26
|
-
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
27
|
-
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@media ${({ theme }) => theme.allBreakpoints('L')} {
|
|
31
|
-
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
32
|
-
padding: ${spacing('md')} ${spacing('l')};
|
|
33
|
-
margin: 0 auto ${spacing('l')};
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
3
|
+
import StyledButton from './Button.style';
|
|
4
|
+
import buttonTypes from '../../../theme/crTheme/buttonTypes';
|
|
36
5
|
|
|
37
6
|
const Button = React.forwardRef(({
|
|
38
|
-
children,
|
|
7
|
+
children,
|
|
8
|
+
color = 'red',
|
|
9
|
+
wrapper = false,
|
|
10
|
+
fullWidth = false,
|
|
11
|
+
buttonType = buttonTypes.PRIMARY,
|
|
12
|
+
...rest
|
|
39
13
|
}, ref) => (
|
|
40
|
-
<StyledButton {...rest} as={wrapper ? 'span' : 'button'} ref={ref} fullWidth={fullWidth}>
|
|
14
|
+
<StyledButton {...rest} as={wrapper ? 'span' : 'button'} ref={ref} fullWidth={fullWidth} color={color} buttonType={buttonType}>
|
|
41
15
|
{children}
|
|
42
16
|
</StyledButton>
|
|
43
17
|
));
|
|
@@ -45,7 +19,15 @@ const Button = React.forwardRef(({
|
|
|
45
19
|
Button.propTypes = {
|
|
46
20
|
children: PropTypes.node.isRequired,
|
|
47
21
|
wrapper: PropTypes.bool, // Buttons as span
|
|
48
|
-
fullWidth: PropTypes.bool
|
|
22
|
+
fullWidth: PropTypes.bool,
|
|
23
|
+
color: PropTypes.string,
|
|
24
|
+
// Primary will the default for the vast majority of contexts; with
|
|
25
|
+
// Secondary and Tertirary being manually set by developers where required
|
|
26
|
+
buttonType: PropTypes.oneOf([
|
|
27
|
+
buttonTypes.PRIMARY,
|
|
28
|
+
buttonTypes.SECONDARY,
|
|
29
|
+
buttonTypes.TERTIARY
|
|
30
|
+
])
|
|
49
31
|
};
|
|
50
32
|
|
|
51
33
|
export default Button;
|
|
@@ -1,5 +1,95 @@
|
|
|
1
1
|
```js
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import buttonTypes from '../../../theme/crTheme/buttonTypes';
|
|
4
|
+
|
|
5
|
+
<>
|
|
6
|
+
<h1>Primary</h1>
|
|
7
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
8
|
+
<Button type="button">Primary red button (default)</Button>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
12
|
+
<Button type="button" disabled>Primary red button (default): disabled</Button>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
16
|
+
<Button type="button" color="black">Primary black button</Button>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
20
|
+
<Button type="button" color="black" disabled>Primary black button: disabled</Button>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
24
|
+
<Button type="button" color="white">Primary white button</Button>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
28
|
+
<Button type="button" color="white" disabled>Primary white button: disabled</Button>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
32
|
+
<Button type="button" color="non-existent-colour">Using a non-existent colour will default to red</Button>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<br/>
|
|
36
|
+
<h1>Secondary</h1>
|
|
37
|
+
|
|
38
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px", borderRadius: "5px"}}>
|
|
39
|
+
<Button type="button" buttonType={buttonTypes.SECONDARY}>Secondary red button</Button>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
43
|
+
<Button type="button" buttonType={buttonTypes.SECONDARY} disabled>Secondary red button: disabled</Button>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
47
|
+
<Button type="button" color="black" buttonType={buttonTypes.SECONDARY}>Secondary black button</Button>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
51
|
+
<Button type="button" color="black" buttonType={buttonTypes.SECONDARY} disabled>Secondary black button: disabled</Button>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
56
|
+
<Button type="button" color="white" buttonType={buttonTypes.SECONDARY} buttonType={buttonTypes.SECONDARY}>Secondary white button</Button>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
60
|
+
<Button type="button" color="white" buttonType={buttonTypes.SECONDARY} disabled>Secondary white button: disabled</Button>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<br/>
|
|
64
|
+
<h1>Teritary</h1>
|
|
65
|
+
|
|
66
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
67
|
+
<Button type="button" buttonType={buttonTypes.TERTIARY}>Tertiary red button</Button>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
71
|
+
<Button type="button" buttonType={buttonTypes.TERTIARY} disabled>Tertiary red button: disabled</Button>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
75
|
+
<Button type="button" color="black" buttonType={buttonTypes.TERTIARY}>Tertiary black button</Button>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
79
|
+
<Button type="button" color="black" buttonType={buttonTypes.TERTIARY} disabled>Tertiary black button: disabled</Button>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
84
|
+
<Button type="button" color="white" buttonType={buttonTypes.TERTIARY} buttonType={buttonTypes.TERTIARY}>Tertiary white button</Button>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
88
|
+
<Button type="button" color="white" buttonType={buttonTypes.TERTIARY} disabled>Tertiary white button: disabled</Button>
|
|
89
|
+
</div>
|
|
90
|
+
</>
|
|
91
|
+
|
|
92
|
+
|
|
3
93
|
```
|
|
4
94
|
|
|
5
95
|
```js
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import fontHelper from '../../../theme/crTheme/fontHelper';
|
|
3
|
+
|
|
4
|
+
const StyledButton = styled.button`
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
position: relative;
|
|
7
|
+
text-decoration: none;
|
|
8
|
+
transition: all 0.2s;
|
|
9
|
+
height: 2.5rem;
|
|
10
|
+
width: 100%;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
border: none;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
padding: 0.6rem 1rem;
|
|
16
|
+
border-radius: 0.5rem;
|
|
17
|
+
|
|
18
|
+
> a {
|
|
19
|
+
text-decoration: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
${({ color, theme, buttonType }) => (theme.buttonColors(color, buttonType))};
|
|
23
|
+
|
|
24
|
+
${({ theme }) => css`${fontHelper(theme, 'button')}`}
|
|
25
|
+
|
|
26
|
+
@media ${({ theme }) => theme.allBreakpoints('M')} {
|
|
27
|
+
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media ${({ theme }) => theme.allBreakpoints('L')} {
|
|
31
|
+
// I don't *believe* this needs to be reinstated, but leaving in
|
|
32
|
+
// place for now, just to avoid breaking anything downstream...
|
|
33
|
+
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
export default StyledButton;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
3
|
-
import renderWithTheme from
|
|
4
|
-
import Button from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'jest-styled-components';
|
|
3
|
+
import renderWithTheme from '../../../../tests/hoc/shallowWithTheme';
|
|
4
|
+
import Button from './Button';
|
|
5
5
|
|
|
6
|
-
it(
|
|
6
|
+
it('renders a standard styled link correctly', () => {
|
|
7
7
|
const tree = renderWithTheme(
|
|
8
8
|
<Button type="submit">A standard link</Button>
|
|
9
9
|
).toJSON();
|
|
@@ -15,15 +15,11 @@ it("renders a standard styled link correctly", () => {
|
|
|
15
15
|
display: -ms-inline-flexbox;
|
|
16
16
|
display: inline-flex;
|
|
17
17
|
position: relative;
|
|
18
|
-
padding: 0.5rem 1.25rem;
|
|
19
18
|
-webkit-text-decoration: none;
|
|
20
19
|
text-decoration: none;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-webkit-transition: all 0.3s;
|
|
25
|
-
transition: all 0.3s;
|
|
26
|
-
height: 3.125rem;
|
|
20
|
+
-webkit-transition: all 0.2s;
|
|
21
|
+
transition: all 0.2s;
|
|
22
|
+
height: 2.5rem;
|
|
27
23
|
width: 100%;
|
|
28
24
|
-webkit-box-pack: center;
|
|
29
25
|
-webkit-justify-content: center;
|
|
@@ -35,8 +31,19 @@ it("renders a standard styled link correctly", () => {
|
|
|
35
31
|
align-items: center;
|
|
36
32
|
border: none;
|
|
37
33
|
cursor: pointer;
|
|
34
|
+
padding: 0.6rem 1rem;
|
|
35
|
+
border-radius: 0.5rem;
|
|
38
36
|
background-color: #E52630;
|
|
39
37
|
color: #FFFFFF;
|
|
38
|
+
font-family: 'Montserrat',Helvetica,Arial,sans-serif;
|
|
39
|
+
font-weight: 700;
|
|
40
|
+
text-transform: inherit;
|
|
41
|
+
-webkit-letter-spacing: 0;
|
|
42
|
+
-moz-letter-spacing: 0;
|
|
43
|
+
-ms-letter-spacing: 0;
|
|
44
|
+
letter-spacing: 0;
|
|
45
|
+
font-size: 1rem;
|
|
46
|
+
line-height: 1.25rem;
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
.c0 > a {
|
|
@@ -44,9 +51,31 @@ it("renders a standard styled link correctly", () => {
|
|
|
44
51
|
text-decoration: none;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
.c0:hover
|
|
54
|
+
.c0:hover,
|
|
55
|
+
.c0:focus,
|
|
56
|
+
.c0:focus-within,
|
|
57
|
+
.c0:focus-visible {
|
|
48
58
|
background-color: #890B11;
|
|
49
|
-
|
|
59
|
+
outline-offset: 3px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.c0:disabled {
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
opacity: 0.5;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@media (min-width:740px) {
|
|
68
|
+
.c0 {
|
|
69
|
+
font-size: 1rem;
|
|
70
|
+
line-height: 1.25rem;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@media (min-width:1024px) {
|
|
75
|
+
.c0 {
|
|
76
|
+
font-size: 1.125rem;
|
|
77
|
+
line-height: 1.375rem;
|
|
78
|
+
}
|
|
50
79
|
}
|
|
51
80
|
|
|
52
81
|
@media (min-width:740px) {
|
|
@@ -58,13 +87,12 @@ it("renders a standard styled link correctly", () => {
|
|
|
58
87
|
@media (min-width:1024px) {
|
|
59
88
|
.c0 {
|
|
60
89
|
width: auto;
|
|
61
|
-
padding: 1rem 2rem;
|
|
62
|
-
margin: 0 auto 2rem;
|
|
63
90
|
}
|
|
64
91
|
}
|
|
65
92
|
|
|
66
93
|
<button
|
|
67
94
|
className="c0"
|
|
95
|
+
color="red"
|
|
68
96
|
type="submit"
|
|
69
97
|
>
|
|
70
98
|
A standard link
|
|
@@ -4,21 +4,23 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import StyledLink, { HelperText, IconWrapper } from './Link.style';
|
|
5
5
|
import allowListed from '../../../utils/allowListed';
|
|
6
6
|
import { getDomain } from '../../../utils/internalLinkHelper';
|
|
7
|
+
import buttonTypes from '../../../theme/crTheme/buttonTypes';
|
|
7
8
|
|
|
8
9
|
let window = '';
|
|
9
10
|
|
|
10
11
|
const Link = ({
|
|
12
|
+
href,
|
|
11
13
|
children,
|
|
12
14
|
color = 'red',
|
|
13
|
-
mobileColour = null,
|
|
14
|
-
href,
|
|
15
|
-
target = null,
|
|
16
15
|
type = 'standard',
|
|
17
16
|
home = false,
|
|
18
17
|
underline = true,
|
|
19
|
-
icon = null,
|
|
20
18
|
iconFirst = false,
|
|
21
19
|
fullWidth = false,
|
|
20
|
+
buttonType = buttonTypes.PRIMARY,
|
|
21
|
+
target = null,
|
|
22
|
+
mobileColour = null,
|
|
23
|
+
icon = null,
|
|
22
24
|
...rest
|
|
23
25
|
}) => {
|
|
24
26
|
const [documentHost, setDocumentHost] = useState('');
|
|
@@ -64,6 +66,7 @@ const Link = ({
|
|
|
64
66
|
iconFirst={iconFirst}
|
|
65
67
|
underline={underline}
|
|
66
68
|
fullWidth={fullWidth}
|
|
69
|
+
buttonType={buttonType}
|
|
67
70
|
>
|
|
68
71
|
{children}
|
|
69
72
|
{window === '_blank' && <HelperText>(opens in new window)</HelperText>}
|
|
@@ -90,7 +93,14 @@ Link.propTypes = {
|
|
|
90
93
|
iconFirst: PropTypes.bool,
|
|
91
94
|
/** Embed icons */
|
|
92
95
|
icon: PropTypes.node,
|
|
93
|
-
fullWidth: PropTypes.bool
|
|
96
|
+
fullWidth: PropTypes.bool,
|
|
97
|
+
// Primary will the default for the vast majority of contexts; with
|
|
98
|
+
// Secondary and Tertirary being manually set by developers where required
|
|
99
|
+
buttonType: PropTypes.oneOf([
|
|
100
|
+
buttonTypes.PRIMARY,
|
|
101
|
+
buttonTypes.SECONDARY,
|
|
102
|
+
buttonTypes.TERTIARY
|
|
103
|
+
])
|
|
94
104
|
};
|
|
95
105
|
|
|
96
106
|
export default Link;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
```js
|
|
2
2
|
import { External, Download, Favourite, Internal } from '../Icons/index';
|
|
3
|
+
|
|
3
4
|
<div>
|
|
4
|
-
<div style={{
|
|
5
|
-
<Link href="#anchor" target="blank"
|
|
5
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
6
|
+
<Link href="#anchor" target="blank">
|
|
6
7
|
Link standard
|
|
7
8
|
</Link>
|
|
8
9
|
</div>
|
|
9
|
-
<div style={{
|
|
10
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
10
11
|
<Link
|
|
11
12
|
href="#anchor"
|
|
12
13
|
target="blank"
|
|
13
|
-
type="standard"
|
|
14
14
|
icon={<Download colour="black" />}
|
|
15
15
|
>
|
|
16
16
|
Link standard icon
|
|
17
17
|
</Link>
|
|
18
18
|
</div>
|
|
19
19
|
<div
|
|
20
|
-
style={{
|
|
21
|
-
display: 'block',
|
|
22
|
-
padding: '10px',
|
|
23
|
-
marginBottom: '10px',
|
|
24
|
-
backgroundColor: '#000'
|
|
25
|
-
}}
|
|
20
|
+
style={{backgroundColor:"#000", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}
|
|
26
21
|
>
|
|
27
22
|
<Link href="#anchor" type="standard_white">
|
|
28
23
|
Link standard white
|
|
@@ -31,13 +26,78 @@ import { External, Download, Favourite, Internal } from '../Icons/index';
|
|
|
31
26
|
</div>;
|
|
32
27
|
```
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
```js
|
|
30
|
+
|
|
31
|
+
import buttonTypes from '../../../theme/crTheme/buttonTypes';
|
|
32
|
+
|
|
33
|
+
<div>
|
|
34
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
35
|
+
<Link color="black" href="#anchor" target="self" type="button">
|
|
36
|
+
Link as button
|
|
37
|
+
</Link>
|
|
38
|
+
</div>
|
|
39
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
40
|
+
<Link color="red" href="/test" target="self" type="button">
|
|
41
|
+
Link as button
|
|
42
|
+
</Link>
|
|
43
|
+
</div>
|
|
44
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
45
|
+
<Link color="yellow" href="/test" target="blank" type="button">
|
|
46
|
+
Link as button
|
|
47
|
+
</Link>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
52
|
+
<Link color="red" href="#anchor" target="self" type="button" buttonType={buttonTypes.SECONDARY}>
|
|
53
|
+
Link as button (secondary)
|
|
54
|
+
</Link>
|
|
55
|
+
</div>
|
|
56
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
57
|
+
<Link color="black" href="/test" target="self" type="button"buttonType={buttonTypes.SECONDARY}>
|
|
58
|
+
Link as button (secondary)
|
|
59
|
+
</Link>
|
|
60
|
+
</div>
|
|
61
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
62
|
+
<Link color="white" href="/test" target="blank" type="button" buttonType={buttonTypes.SECONDARY}>
|
|
63
|
+
Link as button (secondary)
|
|
64
|
+
</Link>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
68
|
+
<Link color="red" href="#anchor" target="self" type="button" buttonType={buttonTypes.TERTIARY}>
|
|
69
|
+
Link as button (tertiary)
|
|
70
|
+
</Link>
|
|
71
|
+
</div>
|
|
72
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
73
|
+
<Link color="black" href="/test" target="self" type="button"buttonType={buttonTypes.TERTIARY}>
|
|
74
|
+
Link as button (tertiary)
|
|
75
|
+
</Link>
|
|
76
|
+
</div>
|
|
77
|
+
<div style={{backgroundColor:"#222222", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
78
|
+
<Link color="white" href="/test" target="blank" type="button" buttonType={buttonTypes.TERTIARY}>
|
|
79
|
+
Link as button (tertiary)
|
|
80
|
+
</Link>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
84
|
+
|
|
85
|
+
<div style={{ display: 'block', marginTop: '10px' }}>
|
|
86
|
+
<Link color="red" href="/test" target="blank" type="button" fullWidth>
|
|
87
|
+
Link as full-width red button
|
|
88
|
+
</Link>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
```
|
|
93
|
+
|
|
35
94
|
|
|
95
|
+
## Iconography
|
|
36
96
|
```js
|
|
37
97
|
import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from '../Icons/index';
|
|
38
98
|
|
|
39
99
|
<div>
|
|
40
|
-
<div style={{
|
|
100
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
41
101
|
<Link
|
|
42
102
|
color="red"
|
|
43
103
|
mobileColour="blue"
|
|
@@ -50,7 +110,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
50
110
|
</Link>
|
|
51
111
|
</div>
|
|
52
112
|
|
|
53
|
-
<div style={{
|
|
113
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
54
114
|
<Link
|
|
55
115
|
color="blue"
|
|
56
116
|
mobileColour="black"
|
|
@@ -63,7 +123,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
63
123
|
</Link>
|
|
64
124
|
</div>
|
|
65
125
|
|
|
66
|
-
<div style={{
|
|
126
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
67
127
|
<Link
|
|
68
128
|
color="red"
|
|
69
129
|
href="#anchor"
|
|
@@ -75,7 +135,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
75
135
|
</Link>
|
|
76
136
|
</div>
|
|
77
137
|
|
|
78
|
-
<div style={{
|
|
138
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
79
139
|
<Link
|
|
80
140
|
color="red"
|
|
81
141
|
href="#anchor"
|
|
@@ -87,7 +147,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
87
147
|
</Link>
|
|
88
148
|
</div>
|
|
89
149
|
|
|
90
|
-
<div style={{
|
|
150
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
91
151
|
<Link
|
|
92
152
|
color="red"
|
|
93
153
|
href="#anchor"
|
|
@@ -99,7 +159,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
99
159
|
</Link>
|
|
100
160
|
</div>
|
|
101
161
|
|
|
102
|
-
<div style={{
|
|
162
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
103
163
|
<Link
|
|
104
164
|
color="red"
|
|
105
165
|
href="#anchor"
|
|
@@ -111,7 +171,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
111
171
|
</Link>
|
|
112
172
|
</div>
|
|
113
173
|
|
|
114
|
-
<div style={{
|
|
174
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
115
175
|
<Link
|
|
116
176
|
color="red"
|
|
117
177
|
href="#anchor"
|
|
@@ -123,7 +183,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
123
183
|
</Link>
|
|
124
184
|
</div>
|
|
125
185
|
|
|
126
|
-
<div style={{
|
|
186
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
127
187
|
<Link
|
|
128
188
|
color="red"
|
|
129
189
|
href="#anchor"
|
|
@@ -135,7 +195,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
135
195
|
</Link>
|
|
136
196
|
</div>
|
|
137
197
|
|
|
138
|
-
<div style={{
|
|
198
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
139
199
|
<Link
|
|
140
200
|
color="red"
|
|
141
201
|
href="#anchor"
|
|
@@ -148,7 +208,7 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
148
208
|
</Link>
|
|
149
209
|
</div>
|
|
150
210
|
|
|
151
|
-
<div style={{
|
|
211
|
+
<div style={{backgroundColor:"#ddd", padding: "15px", marginBottom: "10px", borderRadius: "5px"}}>
|
|
152
212
|
<Link
|
|
153
213
|
color="red"
|
|
154
214
|
href="#anchor"
|
|
@@ -161,60 +221,3 @@ import { External, Download, Favourite, Internal, Chevron, Arrow, AtSign } from
|
|
|
161
221
|
</div>
|
|
162
222
|
</div>;
|
|
163
223
|
```
|
|
164
|
-
|
|
165
|
-
```js
|
|
166
|
-
<div>
|
|
167
|
-
<div style={{ display: 'block', marginBottom: '10px' }}>
|
|
168
|
-
<Link color="black" href="#anchor" target="self" type="button">
|
|
169
|
-
Link as button
|
|
170
|
-
</Link>
|
|
171
|
-
</div>
|
|
172
|
-
<div style={{ display: 'block', marginBottom: '10px' }}>
|
|
173
|
-
<Link color="red" href="/test" target="self" type="button">
|
|
174
|
-
Link as button
|
|
175
|
-
</Link>
|
|
176
|
-
</div>
|
|
177
|
-
<div style={{ display: 'block', marginBottom: '10px' }}>
|
|
178
|
-
<Link color="yellow" href="/test" target="blank" type="button">
|
|
179
|
-
Link as button
|
|
180
|
-
</Link>
|
|
181
|
-
</div>
|
|
182
|
-
<div style={{ display: 'block', marginBottom: '10px' }}>
|
|
183
|
-
<Link color="yellow_light" href="/test" target="blank" type="button">
|
|
184
|
-
Link as button
|
|
185
|
-
</Link>
|
|
186
|
-
</div>
|
|
187
|
-
<div style={{ display: 'block', marginBottom: '10px' }}>
|
|
188
|
-
<Link color="yellow_dark" href="/test" target="blank" type="button">
|
|
189
|
-
Link as button
|
|
190
|
-
</Link>
|
|
191
|
-
</div>
|
|
192
|
-
<div
|
|
193
|
-
style={{
|
|
194
|
-
display: 'block',
|
|
195
|
-
padding: '10px',
|
|
196
|
-
marginBottom: '10px',
|
|
197
|
-
backgroundColor: '#22CFD8'
|
|
198
|
-
}}
|
|
199
|
-
>
|
|
200
|
-
<div style={{ display: 'block', marginBottom: '10px' }}>
|
|
201
|
-
<Link color="grey" href="/test" target="blank" type="button">
|
|
202
|
-
Link as button
|
|
203
|
-
</Link>
|
|
204
|
-
</div>
|
|
205
|
-
<Link color="transparent" href="/test" target="blank" type="button">
|
|
206
|
-
Link as transparent button
|
|
207
|
-
</Link>
|
|
208
|
-
<div style={{ display: 'block', marginTop: '10px' }}>
|
|
209
|
-
<Link color="white" href="/test" target="blank" type="button">
|
|
210
|
-
White button
|
|
211
|
-
</Link>
|
|
212
|
-
</div>
|
|
213
|
-
<div style={{ display: 'block', marginTop: '10px' }}>
|
|
214
|
-
<Link color="red" href="/test" target="blank" type="button" fullWidth>
|
|
215
|
-
Full-width red button
|
|
216
|
-
</Link>
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
</div>
|
|
220
|
-
```
|