forked from pakaminski/empty-reveal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
350 lines (347 loc) · 12.3 KB
/
index.html
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!DOCTYPE html >
<html>
<head>
<title>Introduction </title>
<meta charset="utf-8"/>
<meta name="author" content=" "/>
<meta name="description" content="Level Up 2017 "/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"/>
<link rel="icon" href="common/img/favicon.ico"/>
<link href="reveal.js-3.3.0/css/reveal.css" rel="stylesheet"/>
<link href="reveal.js-3.3.0/css/theme/black.css" rel="stylesheet"/>
<link href="common/css/common.css" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/><!-- Theme used for syntax highlighting of code -->
<link href="reveal.js-3.3.0/lib/css/zenburn.css" rel="stylesheet"/>
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js-3.3.0/css/print/pdf.css' : 'reveal.js-3.3.0/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
</html>
<body>
<div class="reveal">
<div class="slides">
<section id="title-0" data-transition="slide">
<h2>React 101</h2>
<body>
<p>30 minutes introduction to React framework</p>
<p>by Piotr Staniów </p>
<p class="small">(and Paweł Kamiński)</p>
<p class="credits">20 kwiecień 2018 Hotel Dębowy - Chapter day stuff :)</p>
</body>
</section>
<section id="jsx-1" data-transition="slide">
<h2> JSX</h2>
<body>
<pre class="fragment"><code class="js"> const element = <h1>Hello, world!</h1>;</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/introducing-jsx.html">Introducing JSX</a></p>
</body>
</section>
<section id="embedding-2" data-transition="slide">
<h2> Embedding Expressions in JSX</h2>
<body>
<pre class="fragment"><code class="js"> ReactDOM.render(
<h1>
Hello, {formatName(user)}!
</h1>,
document.getElementById('root')
);</code></pre>
<h3>
React app has single root</h3>
<p class="credits"><a href="https://reactjs.org/docs/introducing-jsx.html">Introducing JSX</a></p>
</body>
</section>
<section id="expression-3" data-transition="slide">
<h2> JSX is an Expression Too</h2>
<body>
<pre class="fragment"><code class="js"> function getGreeting(user) {
if (user) {
return <h1>Hello, {formatName(user)}!</h1>;
}
return <h1>Hello, Stranger.</h1>;
}</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/introducing-jsx.html">Introducing JSX</a></p>
</body>
</section>
<section id="objects-4" data-transition="slide">
<h2> JSX Represents Objects</h2>
<body>
<pre class="fragment"><code class="js"> const element = (
<h1 className="greeting">
Hello, world!
</h1>
);</code></pre>
<pre class="fragment"><code class="js"> const element = React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);</code></pre>
<pre class="fragment"><code class="js"> // Note: this structure is simplified
const element = {
type: 'h1',
props: {
className: 'greeting',
children: 'Hello, world!'
}
};</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/introducing-jsx.html">Introducing JSX</a></p>
</body>
</section>
<section id="writing-5" data-transition="slide">
<h2> Writing Components</h2>
<body>
<p>The main purpose of web frameworks is to encapsulate custom HTML elements logic </p>
</body>
</section>
<section id="funcional-6" data-transition="slide">
<h2> Functional and Class Components</h2>
<body>
<pre class="fragment"><code class="js"> function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}</code></pre>
<pre class="fragment"><code class="js">
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/components-and-props.html">Components and Props</a></p>
</body>
</section>
<section id="rendering-7" data-transition="slide">
<h2> Rendering a Component</h2>
<body>
<pre class="fragment"><code class="js">
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
const element = <welcome name="Sara">;
ReactDOM.render(
element,
document.getElementById('root')
);</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/components-and-props.html">Components and Props</a></p>
</body>
</section>
<section id="composing-8" data-transition="slide">
<h2> Composing Components</h2>
<body>
<pre class="fragment"><code class="js"> function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}</code></pre>
<pre class="fragment"><code class="js">
function App() {
return (
<div>
<Welcome name="Sara"/>
<Welcome name="Cahal"/>
<Welcome name="Edite"/>
</div>
);
}</code></pre>
<pre class="fragment"><code class="js">
ReactDOM.render(
<App />,
document.getElementById('root')
);</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/components-and-props.html">Components and Props</a></p>
</body>
</section>
<section id="extracting-9" data-transition="slide">
<h2> Extracting Components</h2>
<body>
<pre class="fragment"><code class="js small"> function Comment(props) {
return (
<div className="Comment">
<div className="UserInfo">
<img className="Avatar"
src={props.author.avatarUrl}
alt={props.author.name}
/>
<div className="UserInfo-name">
{props.author.name}
</div>
</div>
<div className="Comment-text"> {props.text} </div>
<div className="Comment-date"> {formatDate(props.date)}</div>
</div>
);
}</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/components-and-props.html">Components and Props</a></p>
</body>
</section>
<section id="extracting-10" data-transition="slide">
<h2> Extracting Components</h2>
<body>
<pre class="fragment"><code class="js"> function Avatar(props) {
return (
<img className="Avatar"
src={props.user.avatarUrl}
alt={props.user.name}
/>
);
}</code></pre>
<pre class="fragment"><code class="js"> function UserInfo(props) {
return (
<div className="UserInfo">
<Avatar user={props.user} />
<div className="UserInfo-name">
{props.user.name}
</div>
</div>
);
}</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/components-and-props.html">Components and Props</a></p>
</body>
</section>
<section id="extracting-11" data-transition="slide">
<h2> Extracting Components</h2>
<body>
<pre class="fragment"><code class="js small"> function Comment(props) {
return (
<div className="Comment">
<div className="UserInfo">
<Avatar user={props.author} />
<div className="UserInfo-name">
{props.author.name}
</div>
</div>
<div className="Comment-text">{props.text}</div>
<div className="Comment-date">{formatDate(props.date)}</div>
</div>
);
}</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/components-and-props.html">Components and Props</a></p>
</body>
</section>
<section id="extracting-12" data-transition="slide">
<h2> Extracting Components</h2>
<body>
<pre class="fragment"><code class="js"> function Comment(props) {
return (
<div className="Comment">
<UserInfo user={props.author} />
<div className="Comment-text">
{props.text}
</div>
<div className="Comment-date">
{formatDate(props.date)}
</div>
</div>
);
}</code></pre>
<p class="credits"><a href="https://reactjs.org/docs/components-and-props.html">Components and Props</a></p>
</body>
</section>
<section id="state-13" data-transition="slide">
<h2> Extracting Components</h2>
<body>
<pre class="fragment"><code class="js small"> class FancyInput extends React.Component {
constructor(props) {
super(props); // This is required
const { initialValue } = props;
this.state = {
value: initialValue,
};
}
render() {
const { value } = this.state;
return <input type="text" value={value} />;
}
}</code></pre>
</body>
</section>
<section id="event-14" data-transition="slide">
<h2> Adding complexity - event handling</h2>
<body>
<pre class="fragment"><code class="js small"> class FancyInput extends React.Component {
constructor(props) {
super(props); // This is required
const { initialValue } = props;
this.state = {
value: initialValue,
};
}
handleChange(event) {
console.log('Input value has changed!', event.target.value);
}
render() {
const { value } = this.state;
return <input type="text" value={value} onChange={this.handleChange}/>;
}
}</code></pre>
</body>
</section>
<section id="updating-15" data-transition="slide">
<h2>Adding complexity - updating state</h2>
<body>
<pre class="fragment"><code class="js small"> class FancyInput extends React.Component {
constructor(props) {
super(props); // This is required
const { initialValue } = props;
this.state = { value: initialValue, somethingElse: 5 };
}
handleChange(event) {
console.log('Input value has changed!', event.target.value);
this.setState({ value: event.target.value}); // Asynchronous!
}
render() {
const { value } = this.state;
return <input type="text" value={value} onChange={this.handleChange.bind(this)}/>;
}
}</code></pre>
</body>
</section>
<section id="styling-16" data-transition="slide">
<h2>Adding complexity - styling</h2>
<body>
<pre class="fragment"><code class="js small"> class FancyInput extends React.Component {
constructor(props) {
super(props); // This is required
const { initialValue } = props;
this.state = { value: initialValue, somethingElse: 5};
}
handleChange = ({target: {value}}) => {
this.setState({ value }); // Asynchronous!
}
render() {
const { value } = this.state;
const styles = {
border: `3px solid ${value === 'zielony' ? 'green' : 'red'}`,
};
return <input type="text" value={value} style={style} onChange={this.handleChange} />
}
}</code></pre>
</body>
</section>
<section id="end-17" data-transition="slide">
<h2></h2>
<body><img src="img/theend.png"/></body>
</section>
</div>
</div>
<script src="reveal.js-3.3.0/lib/js/head.min.js"></script>
<script src="reveal.js-3.3.0/js/reveal.js"></script>
<script>
Reveal.initialize({
// controls: true,
// progress: true,
history: true,
// center: true,
// rollingLinks: true,
// transition: "convex",
//- width: "90%",
//- height: 1.0,
dependencies: [
// Syntax highlight for <code> elements
{src: 'reveal.js-3.3.0/plugin/markdown/marked.js'},
{src: 'reveal.js-3.3.0/plugin/markdown/markdown.js'},
{src: 'reveal.js-3.3.0/plugin/notes/notes.js', async: true},
{ src: 'reveal.js-3.3.0/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
]
});
</script>
</body>