forked from wdonet/react-certification-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact.html
More file actions
288 lines (250 loc) · 7.01 KB
/
Copy pathreact.html
File metadata and controls
288 lines (250 loc) · 7.01 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<html>
<head>
<title>MarioTube</title>
</head>
<body>
<!--
<div class="header">
<div class="header-logo"><img src="./m-vector_icon.jpg" /></div>
<div class="header-search">
<label>Search videos <input type="text" name="search" placeholder="🎥 Search for videos"/></label>
</div>
<div class="header-login">
<a>Sign in</a> <img src="./wize-logo.png" />
</div>
</div>
<div class="sidebar">
<ul>
<li>Home</li>
<li>Favorites</li>
</ul>
<div>Dark Mode</div>
</div>
<div class="content">
<div class="categories">Categories</div>
<div class="videos"><div class="video"></div></div>
</div>
<div class="footer"><div class="info"></div></div>
/**
* Sample JavaScript code for youtube.search.list
* See instructions for running APIs Explorer code samples locally:
* https://developers.google.com/explorer-help/guides/code_samples#javascript
*/-->
<script src="https://apis.google.com/js/api.js"></script>
<script>
function authenticate() {
console.log('authenticate...');
return gapi.auth2
.getAuthInstance()
.signIn({ scope: 'https://www.googleapis.com/auth/youtube.force-ssl' })
.then(
function () {
console.log('Sign-in successful');
},
function (err) {
console.error('Error signing in', err);
}
);
}
function loadClient() {
console.log('loadClient...');
console.log('--setApiKey...');
gapi.client.setApiKey('AIzaSyDpytkLvHqG_bnDtwfSklDRk-eU8O-fHL8');
return gapi.client
.load('https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest')
.then(
function () {
console.log('GAPI client loaded for API');
},
function (err) {
console.error('Error loading GAPI client for API', err);
}
);
}
// Make sure the client is loaded and sign-in is complete before calling this method.
function execute() {
console.log('execute...');
console.log('--search.list...');
return gapi.client.youtube.search
.list({
part: ['snippet'],
q: 'lacuna coil',
})
.then(
function (response) {
// Handle the results here (response.result has the parsed body).
console.log('--Response', response);
},
function (err) {
console.error('--Execute error', err);
}
);
}
gapi.load('client:auth2', function () {
console.log('load...');
console.log('--client:auth2...');
console.log('--init...');
gapi.auth2.init({
client_id:
'1088412977008-bt87ku9si9u48echferpm6i23rcv5jei.apps.googleusercontent.com',
});
});
</script>
<button onclick="authenticate().then(loadClient)">authorize and load</button>
<button onclick="execute()">execute</button>
<!--
html, body, #root {
width: 100%;
height: 100%;
}
.SplitPane {
width: 100%;
height: 100%;
}
.SplitPane-left {
float: left;
width: 10%;
height: 100%;
}
.SplitPane-right {
float: left;
width: 89%;
height: 100%;
}
.Contacts {
width: 100%;
height: 100%;
background: lightblue;
}
.Chat {
width: 100%;
height: 100%;
background: pink;
}
function Contacts() {
return <div className="Contacts" />;
}
function Chat() {
return <div className="Chat" />;
}
function SplitPane(props) {
return (
<div className="SplitPane">
<div className="SplitPane-left">
{props.left}
</div>
<div className="SplitPane-right">
{props.right}
</div>
</div>
);
}
function App() {
return (
<SplitPane
left={
<Contacts />
}
right={
<Chat />
} />
);
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
YouTube App
Menu Bar
Icon
Search bar
Login icon
Login
Account info
Logout
Side Bar
Home
Favorites
Dark mode
Main Body
Videos
Thumbnail
Title
Description
Author
Video View
Video
Title Views
Author Like/Dislike
Description
Footer
KNEWZ-1745
React.createElement(
"div",
{},
React.createElement("h1", {}, props.title),
React.createElement("h1", {}, props.subtitle),
)
class LoginControl extends React.Component {
constructor(props) {
super(props);
this.handleLoginClick = this.handleLoginClick.bind(this);
this.handleLogoutClick = this.handleLogoutClick.bind(this);
this.state = {isLoggedIn: false};
}
handleLoginClick() {
this.setState({isLoggedIn: true});
}
handleLogoutClick() {
this.setState({isLoggedIn: false});
}
render() {
const isLoggedIn = this.state.isLoggedIn;
let button;
if (isLoggedIn) {
button = <LogoutButton onClick={this.handleLogoutClick} />;
} else {
button = <LoginButton onClick={this.handleLoginClick} />;
}
return (
<div>
<Greeting isLoggedIn={isLoggedIn} />
{button}
</div>
);
}
}
function UserGreeting(props) {
return <h1>Welcome back!</h1>;
}
function GuestGreeting(props) {
return <h1>Please sign up.</h1>;
}
function Greeting(props) {
const isLoggedIn = props.isLoggedIn;
if (isLoggedIn) {
return <UserGreeting />;
}
return <GuestGreeting />;
}
function LoginButton(props) {
return (
<button onClick={props.onClick}>
Login
</button>
);
}
function LogoutButton(props) {
return (
<button onClick={props.onClick}>
Logout
</button>
);
}
ReactDOM.render(
<LoginControl />,
document.getElementById('root')
);
-->
</body>
</html>