File size: 2,478 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Gridicon } from '@automattic/components';
import { Button } from '@wordpress/components';
import { useTranslate } from 'i18n-calypso';
import surveyImage from 'calypso/assets/images/illustrations/developer-survey.svg';

type DeveloperSurveyNoticeProps = {
	onClose: ( remindTimeInSeconds: number, buttonName: string ) => void;
	onSurveyClick: () => void;
	localeSlug: string;
};

const ONE_DAY_IN_SECONDS = 24 * 60 * 60;
const ONE_YEAR_IN_SECONDS = 365 * ONE_DAY_IN_SECONDS;

export const DeveloperSurveyNotice = ( {
	onClose,
	onSurveyClick,
	localeSlug,
}: DeveloperSurveyNoticeProps ) => {
	const translate = useTranslate();
	const href =
		localeSlug === 'es'
			? 'https://wordpressdotcom.survey.fm/developer-survey-es'
			: 'https://wordpressdotcom.survey.fm/developer-survey';

	return (
		<div className="developer-survey-notice">
			<Button
				className="developer-survey-notice__backdrop"
				onClick={ () => onClose( ONE_DAY_IN_SECONDS, 'backdrop' ) }
			/>
			<div className="developer-survey-notice__popup">
				<div className="developer-survey-notice__popup-head">
					<div className="developer-survey-notice__popup-head-title">
						{ translate( 'Developer Survey' ) }
					</div>
					<Button
						onClick={ () => onClose( ONE_YEAR_IN_SECONDS, 'close-button' ) }
						className="developer-survey-notice__popup-head-close"
					>
						<Gridicon icon="cross" size={ 16 } />
					</Button>
				</div>
				<div className="developer-survey-notice__popup-img">
					<img src={ surveyImage } alt={ translate( 'Code editor' ) } />
				</div>
				<div className="developer-survey-notice__popup-content">
					<div className="developer-survey-notice__popup-content-title">
						{ translate( 'Hey developer!' ) }
					</div>
					<div className="developer-survey-notice__popup-content-description">
						{ translate(
							"How do you use WordPress.com? Spare a moment? We'd love to hear what you think in a quick survey."
						) }
					</div>
					<div className="developer-survey-notice__popup-content-buttons">
						<Button
							variant="tertiary"
							onClick={ () => onClose( ONE_DAY_IN_SECONDS, 'remind-later-button' ) }
						>
							{ translate( 'Maybe later' ) }
						</Button>
						<Button
							variant="primary"
							href={ href }
							target="_blank"
							rel="noopener noreferrer"
							onClick={ onSurveyClick }
						>
							{ translate( 'Take survey' ) }
						</Button>
					</div>
				</div>
			</div>
		</div>
	);
};