-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
527 lines (483 loc) · 23.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Resources for online development with React! 🌐 No Build Tools Needed! 🚧">
<title>Awesome Web Based React</title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="apple-touch-icon" href="img/favicons/apple-touch-icon-120.png">
<link rel="apple-touch-icon" sizes="152x152" href="img/favicons/apple-touch-icon-152.png">
<link rel="apple-touch-icon" sizes="167x167" href="img/favicons/apple-touch-icon-167.png">
<link rel="apple-touch-icon" sizes="180x180" href="img/favicons/apple-touch-icon-180.png">
<link rel="icon" sizes="32x32" href="img/favicons/awesome-web-react-32.png">
<link rel="icon" sizes="144x144" href="img/favicons/awesome-web-react-144.png">
<link rel="icon" sizes="192x192" href="img/favicons/awesome-web-react-192.png">
<link rel="icon" sizes="196x196" href="img/favicons/awesome-web-react-196.png">
<style>
/* Reset */
* { margin:0; padding:0; }
/* Using 'Native font stack' - See Bootstrap 4 Docs for info on 'Native font stack' */
html {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
/*
The body color is generated by using 95% of HSLA on the main React logo/blue color (#61dafb).
Some of the additional colors in this file are also based on this color.
*/
body { background-color: hsla(193, 95%, 95%, 1); }
body,
#root {
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
}
#root {
flex-direction: row;
flex-wrap: wrap;
padding-bottom: 40px;
column-gap: 30px;
}
body,
a { color: #494368; }
a:visited { color:#494368; }
a:hover { text-decoration: none; color:hsla(250, 22%, 68%, 1); }
h1 {
display: flex;
justify-content: center;
padding: 20px;
}
section {
box-shadow: 0 1px 5px 0 rgba(0,0,0,.5);
padding: 30px 20px;
margin: 40px auto;
background-color: white;
}
section.about { max-width: 800px; }
section.category {
background-color: hsla(193, 95%, 98%, 1);
align-self: self-start;
}
@media (min-width: 640px) {
body { padding: 40px; }
section {
padding: 30px 60px;
border-radius: 20px;
}
section.category { padding: 60px; }
}
.filter-container { width:100%; }
section.filter {
display: flex;
flex-direction: column;
align-items: center;
max-width: 800px;
}
/*
The <label> is included for Accessibility for users that use a screen reader,
however it is hidden on screen and a default placeholder is used.
The current version of Chrome DevTools Lighthouse (Chrome v84) will
report the label is missing if `display: none` is used however it works
when simply moving the label off screen.
*/
label { position: absolute; top:-1000px; left:-1000px; }
input {
padding: 1em 2em;
border-radius: 2em;
width: 80%;
max-width: 350px;
outline: none;
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), 0 0 2px 1px rgba(0, 0, 0, 0.1);
border: none;
background-color: hsla(193, 95%, 98%, 1);
/* For Safari on iOS */
-webkit-appearance: none;
}
input:focus {
box-shadow: 0 0 0 3px hsl(193, 95%, 45%, 1), 0 0 3px 1px hsl(193, 95%, 65%, 1);
}
.site-link { display: inline-flex; align-items: center; }
.site-link img { margin-right:1em; }
.site-link span { display:none; }
@media (min-width: 600px) {
.site-link span { display:initial; }
}
.filter-count { margin-top:1em; }
section.category > ul {
padding: 0;
margin: 0;
margin-top: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: start;
padding-bottom: 20px;
}
li.link {
box-shadow: 0 1px 5px 0 rgba(0,0,0,.5);
border-radius: 10px;
width: 100%;
margin: 20px;
background-color: white;
text-align: center;
}
@media (min-width: 450px) {
/*
Using a specific width is needed in some cases otherwise
a flex-wrap bug appears for the [Charts and Maps] topic.
Found to happen in both Chrome and Firefox. Didn't happen
prior to adding 2 items to [Charts and Maps].
*/
li.link { width:350px; }
}
li.link img {
max-width: 100%;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
box-shadow: 0 1px 2px 0 rgba(0,0,0,.5);
}
li.link .details {
padding: 20px;
}
section h2 { margin:0 auto 1em auto; }
section h2.reasons { margin-top: 1.5em; }
section ul { text-align:left; list-style-type: none; }
section ul li { margin-bottom:1em; margin-left:.5em; }
section.about ul li[data-emoji]::before { content:attr(data-emoji); margin-right:10px; }
section ul li span.emoji { margin:0 5px; }
section.category ul li { margin-bottom: 2em; }
section ul li:last-child { margin-bottom: 0; }
section ul li p { margin: 1em 0; }
section ul li .links { margin: 1em 1em 0; }
section ul li .links a { margin: 0 1em 0.5em; font-weight: bold; display: inline-block; }
section.category ul li ul { margin-left:1em; margin-top:1em; margin-bottom: 1em; }
section.category ul li ul { list-style-type:disc; }
section.category ul li ul li { margin: .5em; }
section.about p { margin: 1.5em; }
section.about h2 span { margin-top: .4em; display: inline-block; }
section.category a:visited { color: hsla(250, 22%, 50%, 1); }
section.category > p {
text-align: center;
padding: 1em 0;
font-style: italic;
}
/* Show the loading screen only if it appears for longer than half a second */
.loading {
background-color: lightblue;
border: 1px solid hsla(195, 53%, 40%, 1);
color: white;
padding: 1em 2em;
border-radius: .5em;
opacity: 0;
animation-name: show-after-delay;
animation-delay: 0.5s;
animation-duration: 0s;
animation-timing-function: linear;
animation-fill-mode: forwards;
}
@keyframes show-after-delay {
0% { opacity: 0; }
100% { opacity: 1; }
}
.error {
background-color: red;
color: white;
padding: 1em 2em;
border: 1px solid darkred;
border-radius: .5em;
}
/* Specific images based on class from [links.json] */
li.link img.width100_pt20 {
padding-top: 20px;
width: 100px;
box-shadow: none;
}
li.link img.width200_pt20 {
padding-top: 20px;
width: 200px;
box-shadow: none;
}
li.link img.pt20 {
padding-top: 20px;
box-shadow: none;
}
li.link img.react-flux {
padding-top: 40px;
padding-bottom: 30px;
width: 100px;
box-shadow: none;
}
li.link img.react-hook-form {
max-height: 150px;
border-radius: 12px;
margin-top: 20px;
box-shadow: none;
}
</style>
<script nomodule>
// Fix for IE 11
var style = document.createElement('style');
var css = '@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {';
css += ' #root { flex-direction: column; }'
css += ' section,';
css += ' section.category > ul { max-width: 100vw; }'
css += '}';
style.innerHTML = css;
document.head.appendChild(style);
</script>
</head>
<body>
<h1>
<img width="312" height="350" src="img/awesome-web-react.svg" alt="Awesome Web Based React" />
</h1>
<section class="about">
<h2>Develop online with <a href="https://reactjs.org/" target="blank" rel="noopener">React</a>!<br><span>No Build Tools Needed!</span></h2>
<p>
<a href="https://github.com/dataformsjs/awesome-web-react" class="site-link">
<img src="https://raw.githubusercontent.com/dataformsjs/website/master/public/img/logos/GitHub-Mark-32px.png" alt="GitHub">
<span>https://github.com/dataformsjs/awesome-web-react</span>
</a>
</p>
<ul>
<li data-emoji="🚀">This site provides a list with examples of libraries and components that you can use to develop web pages and apps with React without any build tools.</li>
<li data-emoji="🚧">Development build tools and projects such as <code>webpack</code>, <code>babel</code>, and <code>create-react-app</code> are great but they do not make sense for all sites, web pages, and development workflows.</li>
<li data-emoji="🌐">With browser based options for JSX you can <strong>easily include React Components on any page</strong> without having to build the entire site using React or JSX.</li>
</ul>
<h2 class="reasons">Reasons for online React Development</h2>
<ul>
<li data-emoji="🚀"><strong>Fast Development</strong> <span class="emoji">🚀</span> Because there is no build process you can create and update sites using any editor on any system.</li>
<li data-emoji="🤝"><strong>Easily Share</strong> <span class="emoji">🤝</span> Provide React code snippets to designers or web developers who do not know or use JavaScript.</li>
<li data-emoji="📦"><strong>Project Size</strong> <span class="emoji">📦</span> This site includes many example mini apps and each one is typically less than 10 kB in size while a standard React app using <code>create-react-app</code> is between 150 and 250 MB and includes over 30,000 files.</li>
<li data-emoji="📄"><strong>Add to any Page</strong> <span class="emoji">📄</span> Add React to legacy and existing sites or web pages. Often React is used on new projects only but with online development options you can include React and Libraries directly from a CDN or JavaScript files.</li>
<li data-emoji="🏫"><strong>Learn React</strong> <span class="emoji">🏫</span> Web Development with only a Browser and a Text Editor is any easy way to get started with React or try new ideas and features.</li>
<li data-emoji="🚆"><strong>Rapid Prototyping</strong> <span class="emoji">🚆</span> Instantly develop ideas and into quick apps and then migrate to a build process later if you want to.</li>
</ul>
</section>
<div id="root"></div>
<!--
React
https://reactjs.org/
-->
<script src="https://cdn.jsdelivr.net/npm/react@17.0.2/umd/react.production.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@17.0.2/umd/react-dom.production.min.js" crossorigin="anonymous"></script>
<!--
DataFormsJS JSX Loader and React Components
https://www.dataformsjs.com/
-->
<script src="https://cdn.jsdelivr.net/npm/dataformsjs@5/js/react/jsxLoader.min.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/dataformsjs@5/js/react/es6/DataFormsJS.min.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/dataformsjs@5/js/react/es5/DataFormsJS.min.js"></script>
<script>
// Set to `true` to view compiler details
jsxLoader.logCompileTime = false;
jsxLoader.logCompileDetails = false;
</script>
<!-- App Code -->
<script type="text/babel">
'use strict';
function ShowLoading() {
return <h3 className="loading">Loading...</h3>;
}
function ShowError(props) {
return <p className="error">{props.error}</p>;
}
function Categories(props) {
const placeholder = "Enter filter, example 'design', 'hook', or 'state'";
return (
<>
<div className="filter-container">
<section className="filter">
<h2>Filter Code List and Examples</h2>
<label for="filter">{placeholder}</label>
<InputFilter
id="filter"
filter-selector="section.category ul li.link"
filter-results-selector=".filter-count"
filter-results-text-all="Showing all {totalCount} Items"
filter-results-text-filtered="Showing {displayCount} of {totalCount} Items"
placeholder={placeholder}
afterFilter={afterFilter} />
<span class="filter-count"></span>
</section>
</div>
{props.data && props.data.categories && props.data.categories.map(category => {
return <Category {...category} />
})}
</>
);
}
function afterFilter() {
// Hide the main category section if all links under it are hidden.
// Note - this code uses `Array.prototype.forEach.call` instead of
// `for (const section of sections) {` because the generated code by
// Babel doesn't work well for IE.
const sections = document.querySelectorAll('section.category');
Array.prototype.forEach.call(sections, function(section) {
const ul = section.querySelector('ul');
const items = ul.querySelectorAll('li.link');
let hasVisibleItems = false;
for (let n = 0, m = items.length; n < m; n++) {
if (items[n].style.display !== 'none') {
hasVisibleItems = true;
break;
}
}
section.style.display = (hasVisibleItems ? '' : 'none');
});
// See comments near the bottom of this file.
// if (window.chrome && keepScrollPosition) {
// localStorage.setItem('filter', document.getElementById('filter').value);
// }
}
function Category(props) {
return (
<section className="category">
<h2>{props.category}</h2>
{props.description && <p>{props.description}</p>}
<ul>
{props.links && props.links.map(link => {
return <Card directory={props.directory} category={props.category} {...link} />
})}
</ul>
</section>
);
}
function Card(props) {
return (
<li class="link">
<CardImage {...props} />
<div class="details">
<strong>{props.name}</strong>
{props.description ?
<p>{props.description}</p> :
<DescriptionList descList={props.descList} />
}
<div class="links">
{props.example && <a href={'examples/' + props.directory + '/' + props.example}>Example</a>}
{props.site && <a href={props.site} target="_blank" rel="noopener">Site</a>}
{props.github && <a href={props.github} target="_blank" rel="noopener">GitHub</a>}
</div>
{/* Category is included but hidden so that all Items for the category will show on a filter */}
<div style={{display:'none'}}>{props.category}</div>
</div>
</li>
)
}
function CardImage(props) {
if (!props.image) {
return null;
}
let url = null;
let target = '_blank';
let rel = 'noopener';
if (props.example) {
url = 'examples/' + props.directory + '/' + props.example;
target = null;
rel = null;
} else if (props.site) {
url = props.site;
} else {
url = props.github;
}
return (
<a href={url} target={target} rel={rel}>
<img src={props.image} alt={props.name} class={props.imageClassName || ""} />
</a>
)
}
function DescriptionList(props) {
return (
<ul>
{props.descList && props.descList.map(description => {
return <li>{description}</li>
})}
</ul>
)
}
class App extends React.Component {
render() {
return (
<ErrorBoundary>
<JsonData
url="links.json"
isLoading={<ShowLoading />}
hasError={<ShowError />}
isLoaded={<Categories />} />
</ErrorBoundary>
)
}
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
// Removed for User Experience (UX) on 2021-02-05 but code is being
// kept in case it will be added back in the future.
//
// ** If adding back:
// 1) Uncomment code block below
// 2) Search code above for "keepScrollPosition" and uncomment
// 3) Added prop [onViewUpdated={onViewUpdated}] to the JsonData Component
//
// All code below is for use with Google Chrome so that then the user clicks
// back and forth between pages the position on screen will be kept.
// This provides a better experience for users who view examples one at
// a time in the same tab and keep going back to the main page.
//
// This issue does not affect Firefox, Safari, or IE 11 because those
// browsers display the previously rendered HTML when clicking back.
//
// Most recently tested with Chrome Version 84. If the behavior changes
// for Chrome in the future then this code can be removed or if it starts
// happening in other browsers then those browsers can use this code as well.
//
// The input filter is also saved to local storage from `afterFilter()`
// as it changes the layout of the page when the user clicks back.
/*
let keepScrollPosition = false;
if (window.chrome) {
document.addEventListener('scroll', function () {
if (keepScrollPosition) {
localStorage.setItem('scrollY', window.scrollY);
localStorage.setItem('lastSet', (new Date()).getTime());
}
});
}
function onViewUpdated() {
// Only run if Chrome and wait until content loads
if (!window.chrome || !document.querySelectorAll('li.link img').length) {
return;
}
// If the user has waited longer than 10 minutes before coming back to
// this page then ignore.
var now = (new Date()).getTime();
var lastSet = parseInt(localStorage.getItem('lastSet'), 10);
var seconds = (now - lastSet) / 1000;
if (seconds > (10 * 60)) {
keepScrollPosition = true;
return;
}
// Update filter text using previously set value
const filterText = localStorage.getItem('filter');
if (filterText) {
// https://stackoverflow.com/a/46012210
const filter = document.getElementById('filter');
var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
nativeInputValueSetter.call(filter, filterText);
var evt = new Event('input', { bubbles: true});
filter.dispatchEvent(evt);
}
// Get previous scroll position and wait half a second before scrolling
const scrollY = parseInt(localStorage.getItem('scrollY'), 10);
window.setTimeout(() => {
if (scrollY) {
window.scrollTo(0, scrollY);
}
keepScrollPosition = true;
}, 500);
}
*/
</script>
</body>
</html>