-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathindex.js
134 lines (126 loc) · 3.42 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
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useContext, useEffect, useCallback } from '@wordpress/element';
/**
* Internal dependencies
*/
import { Navigation } from '../../components/navigation-context-provider';
import { User } from '../../../components/user-context-provider';
import { User1, User2 } from '../../../components/svg/user-icons';
import { Selectable } from '../../../components/selectable';
import './style.css';
import { Loading } from '../../../components/loading';
/**
* Screen for selecting the user's technical background.
*/
export function TechnicalBackground() {
const { setCanGoForward } = useContext(Navigation);
const { developerToolsOption, fetchingUser, setDeveloperToolsOption } =
useContext(User);
const onChange = useCallback(
(newValue) => {
setDeveloperToolsOption(newValue);
},
[setDeveloperToolsOption]
);
/**
* Allow moving forward.
*/
useEffect(() => {
if ('boolean' === typeof developerToolsOption) {
setCanGoForward(true);
}
}, [developerToolsOption, setCanGoForward]);
const disableInputID = 'technical-background-disable';
const enableInputID = 'technical-background-enable';
if (fetchingUser) {
return <Loading />;
}
return (
<div className="technical-background">
<div className="technical-background__header">
<h1>{__('Technical Background', 'amp')}</h1>
<p>
{__(
'To recommend the best AMP experience we’d like to know if you’re a more technical user, or less technical.',
'amp'
)}
</p>
</div>
<form>
<Selectable
className={`technical-background-option-container`}
selected={true === developerToolsOption}
>
<div className="technical-background-option">
<div className="technical-background-option__input-container">
<input
type="radio"
id={enableInputID}
checked={true === developerToolsOption}
onChange={() => {
onChange(true);
}}
/>
</div>
<User1 />
<label
htmlFor={enableInputID}
className="technical-background-option__description"
>
<h2>
{__('Developer or technically savvy', 'amp')}
</h2>
<p>
{__(
'I can do WordPress development by modifying themes and plugins. I am familiar with PHP, JavaScript, HTML, and CSS.',
'amp'
)}
</p>
</label>
</div>
</Selectable>
<Selectable
className={`technical-background-option-container`}
selected={false === developerToolsOption}
>
<div
htmlFor={disableInputID}
className="technical-background-option"
>
<div className="technical-background-option__input-container">
<input
type="radio"
id={disableInputID}
checked={false === developerToolsOption}
onChange={() => {
onChange(false);
}}
/>
</div>
<User2 />
<label
htmlFor={disableInputID}
className="technical-background-option__description"
>
<h2>
{__(
'Non-technical or wanting a simpler setup',
'amp'
)}
</h2>
<p>
{__(
'I am not responsible for configuring and fixing issues on my site. I am a site owner and/or content creator who wants to take advantage of AMP performance.',
'amp'
)}
</p>
</label>
</div>
</Selectable>
</form>
</div>
);
}