@@ -2,23 +2,121 @@ import { css } from '@emotion/react';
22import {
33 from ,
44 palette as sourcePalette ,
5- textSansBold20 ,
5+ space ,
6+ textSansBold24 ,
7+ textSansBold28 ,
68} from '@guardian/source/foundations' ;
79import { Button , SvgExternal } from '@guardian/source/react-components' ;
10+ import { transparentColour } from '../lib/transparentColour' ;
811
9- type Props = {
12+ type CallToActionProps = {
1013 linkUrl : string ;
11- backgroundImage : string ;
12- text : string ;
13- buttonText : string ;
14+ backgroundImage ? : string ;
15+ text ? : string ;
16+ buttonText ? : string ;
1417} ;
1518
19+ const overlayMaskGradientStyles = ( angle : string , startPosition : number ) => {
20+ const positions = [ 0 , 8 , 16 , 24 , 32 , 40 , 48 , 56 , 64 ] . map (
21+ ( offset ) => startPosition + offset ,
22+ ) ;
23+ return css `
24+ mask-image : linear-gradient(
25+ ${ angle } ,
26+ transparent ${ positions [ 0 ] } px,
27+ rgba (0 , 0 , 0 , 0.0381 ) ${ positions [ 1 ] } px,
28+ rgba (0 , 0 , 0 , 0.1464 ) ${ positions [ 2 ] } px,
29+ rgba (0 , 0 , 0 , 0.3087 ) ${ positions [ 3 ] } px,
30+ rgba (0 , 0 , 0 , 0.5 ) ${ positions [ 4 ] } px,
31+ rgba (0 , 0 , 0 , 0.6913 ) ${ positions [ 5 ] } px,
32+ rgba (0 , 0 , 0 , 0.8536 ) ${ positions [ 6 ] } px,
33+ rgba (0 , 0 , 0 , 0.9619 ) ${ positions [ 7 ] } px,
34+ rgb (0 , 0 , 0 ) ${ positions [ 8 ] } px
35+ );
36+ ` ;
37+ } ;
38+
39+ const blurStyles = css `
40+ position : absolute;
41+ inset : 0 ;
42+ backdrop-filter : blur (12px ) brightness (0.5 );
43+ @supports not (backdrop-filter : blur (12px )) {
44+ background-color : ${ transparentColour ( sourcePalette . neutral [ 10 ] , 0.7 ) } ;
45+ }
46+ ${ overlayMaskGradientStyles ( '180deg' , 0 ) } ;
47+
48+ ${ from . mobileLandscape } {
49+ ${ overlayMaskGradientStyles ( '180deg' , 20 ) } ;
50+ }
51+
52+ ${ from . tablet } {
53+ ${ overlayMaskGradientStyles ( '180deg' , 80 ) } ;
54+ }
55+
56+ ${ from . desktop } {
57+ ${ overlayMaskGradientStyles ( '180deg' , 100 ) } ;
58+ }
59+
60+ ${ from . leftCol } {
61+ ${ overlayMaskGradientStyles ( '180deg' , 210 ) } ;
62+ }
63+ ` ;
64+
65+ const buttonWrapperStyles = css `
66+ ${ blurStyles }
67+ dis play: flex;
68+ position: absolute;
69+ flex- direction: column;
70+ justify- content: end;
71+ align- items: center;
72+ padding: 0 ${ space [ 2 ] } px ${ space [ 6 ] } px;
73+ botto m: 0;
74+ left: 0;
75+ right: 0;
76+
77+ butto n {
78+ width: 100%;
79+
80+ ${ from . tablet } {
81+ width: auto ;
82+ }
83+ }
84+
85+ ${ from . tablet } {
86+ flex- direction: row;
87+ justify- content: start;
88+ align- items: flex- end;
89+ padding: ${ space [ 5 ] } px;
90+ }
91+
92+ ${ from . desktop } {
93+ padding: ${ space [ 6 ] } px;
94+ }
95+ ` ;
96+
97+ const textStyles = css `
98+ ${ textSansBold24 }
99+ width: 100%;
100+ margin- botto m: ${ space [ 5 ] } px;
101+ color : ${ sourcePalette . neutral [ 100 ] } ;
102+
103+ ${ from . tablet } {
104+ ${ textSansBold28 }
105+ margin: 0;
106+ margin- right: ${ space [ 5 ] } px;
107+ }
108+
109+ ${ from . desktop } {
110+ width: auto ;
111+ }
112+ ` ;
113+
16114export const CallToActionAtom = ( {
17115 linkUrl,
18116 backgroundImage,
19117 text,
20118 buttonText,
21- } : Props ) => {
119+ } : CallToActionProps ) => {
22120 return (
23121 < a
24122 href = { linkUrl }
@@ -48,31 +146,16 @@ export const CallToActionAtom = ({
48146 }
49147 ` }
50148 />
51- < div
52- css = { css `
53- position : absolute;
54- bottom : 10% ;
55- left : 10% ;
56- transform : translate (-10% , -10% );
57- ` }
58- >
59- < h2
60- css = { css `
61- ${ textSansBold20 }
62- margin-bottom : 8px ;
63- color : white;
64- ` }
65- >
66- { text }
67- </ h2 >
149+ < div css = { buttonWrapperStyles } >
150+ { ! ! text && < h2 css = { textStyles } > { text } </ h2 > }
68151 < Button
69152 iconSide = "right"
70153 size = "small"
71154 icon = { < SvgExternal /> }
72155 theme = { {
73156 textPrimary : sourcePalette . neutral [ 7 ] ,
74- backgroundPrimary : sourcePalette . neutral [ 97 ] ,
75- backgroundPrimaryHover : sourcePalette . neutral [ 73 ] ,
157+ backgroundPrimary : sourcePalette . neutral [ 100 ] ,
158+ backgroundPrimaryHover : sourcePalette . neutral [ 86 ] ,
76159 } }
77160 >
78161 { buttonText }
0 commit comments