Compare commits

...

166 Commits

Author SHA1 Message Date
dancingCycle ded47c9db5 feat(jszip-dev): add Export button 2024-04-25 09:22:05 +02:00
dancingCycle 63ff305d0a feat(jszip-dev): download 2 files as zip archive 2024-04-24 14:20:25 +02:00
dancingCycle 73a6c22ffe feat(jszip-dev): initial commit 2024-04-24 12:53:50 +02:00
dancingCycle 1878926306 feat(cnt-cmpnnt): initial commit 2024-04-23 15:53:55 +02:00
dancingCycle dfe5ac424a feat(wbpck-rct-bbl-slnt): adjust esling from "airbnb" to "eslint:recommended". 2024-04-23 14:53:04 +02:00
dancingCycle 6bfc03ba2c chore(webpack-react-babel): add eslint 2024-02-15 21:58:53 +01:00
dancingCycle 659ba0fe95 feat(wbpck-rct-bbl-slnt): initial commit 2024-02-15 21:20:06 +01:00
dancingCycle 98b42aa13b chore(webpack-react-babel): update webpack and babel dependencies 2024-02-15 21:18:22 +01:00
dancingCycle 9011a4c50b chore(webpack-react-babel-prettier): npm run prettier:fix 2024-02-15 20:47:17 +01:00
dancingCycle 85057f419b feat(webpack-react-babel-prettier): initial commit 2024-02-15 15:37:00 +01:00
dancingCycle 008294a954 chore(webpack-react-babel): update babel dependencies 2024-02-15 15:32:07 +01:00
dancingCycle 33d9884f39 feat(webpack-react-babel): initial commit 2024-02-15 15:28:23 +01:00
dancingCycle 0d0410ea96 chore(webpack-react): adjust node minimum dependency 2024-02-15 15:26:29 +01:00
dancingCycle eb5c837955 chore(webpack-react): adjust node minimum dependency 2024-02-15 15:14:03 +01:00
dancingCycle 7e4e4c7927 feat(pagination): initial commit 2024-01-31 21:45:13 +01:00
dancingCycle 65ba987f09 feat(radio-button): initial commit 2024-01-12 14:27:59 +01:00
dancingCycle f4de3318d1 feat(webpack-react): read *.json file 2024-01-04 15:39:29 +01:00
dancingCycle 810b53625a feat(webpack-react): read *.json file 2024-01-04 14:03:03 +01:00
dancingCycle 39edee0f72 feat(webpack-react): npm audit fix 2024-01-04 13:26:49 +01:00
dancingCycle 8178a30772 feat(webpack-react): adjust JavaScript version 2024-01-04 13:21:39 +01:00
dancingCycle 27f7c81237 feat(leaflet-js-intg): add layer control according to https://leafletjs.com/examples/layers-control/ 2023-12-30 22:50:05 +01:00
dancingCycle 3983ccb13a feat(leaflet-js-intg) add layer control according to https://leafletjs.com/examples/layers-control/ 2023-12-30 18:27:44 +01:00
dancingCycle 1e70ea67a9 feat(leaflet-js-intg) add map-1k-circle-fixed.jsx and map-circle-fixed.jsx 2023-09-21 14:58:57 +02:00
dancingCycle 132bf5dd82 chore(leaflet-js-intg): refactor 2023-09-21 13:57:04 +02:00
dancingCycle 5883681393 feat(react-router-v6-g4g): reload routes with Webpack 2023-09-21 13:56:21 +02:00
dancingCycle 5c0a528124 chore(my-todo-list-ui-no-ux): refactor 2023-09-21 13:52:02 +02:00
dancingCycle 221e5dc4d6 chore(crud): switch API from root server to https://v1rgncy.api.swingbe.de/entities/info 2023-09-21 13:49:54 +02:00
dancingCycle f26545b228 chore(webpack-react): update package dependencies 2023-09-21 13:40:22 +02:00
dancingCycle 452f4d8c77 test(leaflet-js-intg): add app/components/map-array.jsx test component 2023-09-20 14:08:17 +02:00
dancingCycle bf5c23cb46 test(leaflet-js-intg): add test components 2023-09-20 13:34:51 +02:00
dancingCycle b269097efd chore(leaflet-js): remove entire folder 2023-09-20 13:30:05 +02:00
dancingCycle 6271bb6a9d chore(leaflet-js-intg): cp from webpack-react folder 2023-09-19 14:40:50 +02:00
dancingCycle a2a1af574d test(leaflet-js): try source link in README.md 2023-09-19 14:38:21 +02:00
dancingCycle c6cdb7ca23 chore(leaflet-js): copy from webpack-react folder 2023-09-19 14:21:45 +02:00
dancingCycle cf0a3ec902 chore(webpack-react-no-css): refactor readme.md 2023-09-19 14:07:17 +02:00
dancingCycle 267d9141ba feat(my-todo-list-ui): adapt oidcConfig to data.vbn.de client in vbn realm 2023-08-15 10:39:01 +02:00
dancingCycle cf3770fb6d feat(my-todo-list-ui): initial commit 2023-08-15 10:17:33 +02:00
dancingCycle a3d147f7e3 feat(webpack-react-no-css): initial commit 2023-08-09 15:23:52 +02:00
dancingCycle 00ccdbc725 feat(input-csv-twice): adjust encoding to ISO-8859-1 and disable header encoding 2023-07-07 05:40:08 +02:00
dancingCycle e9a9afbb6e feat(csv-read2objects): disable header encoding 2023-07-07 05:39:06 +02:00
dancingCycle f4582051e8 feat(csv-read2objects): adjust encoding to ISO-8859-1 2023-07-07 05:33:46 +02:00
dancingCycle a8d96fbeaa feat(webpack): When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses. Enable devServer.historyApiFallback by setting it to true. 2023-06-26 05:50:45 +02:00
dancingCycle 023c002b2a feat(input-csv-twice): add alert to axios post callback 2023-06-26 05:48:36 +02:00
dancingCycle 22187e6564 feat(input-csv-twice): initial commit 2023-06-23 08:43:16 +02:00
dancingCycle aece34978e refactor(crud): adjust format 2023-06-22 10:02:22 +02:00
dancingCycle 94c8319a23 chore(form-csv-form-data): remove project 2023-06-22 09:41:11 +02:00
dancingCycle 51ec176e64 feat(csv-read2objects): app axios.post for csv object 2023-06-22 09:28:24 +02:00
dancingCycle 2bcc3775dd refactor(csv-read2objects): adjust format 2023-06-22 09:20:18 +02:00
dancingCycle d6b5f4b308 feat(csv-read2objects): initial commit 2023-06-22 06:30:51 +02:00
dancingCycle e63f058e35 refactor(csv-column-read2dom): get rid of excess file app/components/input.jsx 2023-06-22 06:28:55 +02:00
dancingCycle 98497ec1d6 refactor(webpack-react): make package.json static 2023-06-21 10:18:39 +02:00
dancingCycle 36c80d76be feat(csv-column-read2dom): initial commit 2023-06-21 10:17:32 +02:00
dancingCycle 37d34c89a3 feat(csv-read2dom): initial commit 2023-06-21 09:46:29 +02:00
dancingCycle 844df75b0a feat(form-csv-form-data): initial commit 2023-06-19 10:47:11 +02:00
dancingCycle 6f5c154050 feat(keycloak): initial commit 2023-05-24 11:15:36 +02:00
dancingCycle 818e18bf0a feat(webpack-react): update Loader dependencies 2023-04-21 13:33:22 +02:00
dancingCycle ff851f61c1 feat(webpack-react): update Webpack dependencies 2023-04-21 13:32:24 +02:00
dancingCycle 49729b803c feat(webpack-react): update Babel dependencies 2023-04-21 13:31:18 +02:00
dancingCycle 159c61a544 feat(webpack-react): update webpack dependencies 2023-04-21 13:27:26 +02:00
dancingCycle 0fc097b072 feat(crud): add lat and lon to Home page 2023-04-21 13:19:25 +02:00
dancingCycle 249dd82d97 feat(react-crud): refactor 2023-04-12 15:33:49 +02:00
dancingCycle 5cf964b74d feat(crud): add create page 2023-04-12 15:32:53 +02:00
dancingCycle 2228eb090b feat(crud): add update page 2023-04-12 12:10:50 +02:00
dancingCycle 5d7b0b4125 feat(crud): adjust home page 2023-04-06 17:53:37 +02:00
dancingCycle c92bd86ac5 feat(crud): add axios 2023-04-06 17:52:21 +02:00
dancingCycle 9863881e60 feat: remove react-bootstrap 2023-04-06 17:05:47 +02:00
dancingCycle 23e30ac60e feat(react-crud): add delete and home page 2023-04-05 19:13:28 +02:00
dancingCycle 174cd6383a feat(react-router-v6-g4g): adjust create and read page 2023-04-05 17:52:56 +02:00
dancingCycle b31698835d feat(react-router-v6): add create and read page 2023-04-04 18:56:02 +02:00
dancingCycle 4d8df95e32 feat(react-router-v6-g4g): initial commit 2023-04-04 17:57:11 +02:00
dancingCycle f4f2c0dbde feat(react-router-v6): initial commit 2023-04-04 16:11:18 +02:00
dancingCycle f95d7b7352 feat(react-crud): initial commit 2023-04-04 14:21:22 +02:00
dancingCycle a76c15d4a8 feat(react-bootstrap): adjust form 2023-03-08 11:46:34 +01:00
dancingCycle 16c5306099 feat(react-bootstrap): initial commit 2023-03-07 11:52:01 +01:00
dancingCycle ce34dcdde5 feat(axios-overpass-api): initial commit 2023-02-07 22:38:06 +01:00
dancingCycle 601d361bab chore: adjust dev config 2022-09-15 15:35:43 +02:00
renovate[bot] 4e57712e1a chore(deps): update dependency webpack to v5.74.0 2022-09-15 14:36:11 +02:00
renovate[bot] 994ea6ccd4 fix(deps): update dependency axios to ^0.27.0 2022-09-15 14:35:46 +02:00
renovate[bot] f644e9f41b chore(deps): update babel monorepo 2022-09-15 14:35:18 +02:00
renovate[bot] 54bed64aad fix(deps): update dependency react-bootstrap to v2.5.0 2022-09-15 14:34:06 +02:00
renovate[bot] c69faa5420 chore(deps): update dependency webpack-dev-server to v4.10.1 2022-09-15 14:33:32 +02:00
dancingCycle aaf767bd03 feat(leaflet): add vehicle positions to map 2022-09-14 22:41:47 +02:00
dancingCycle 8914909972 feat(leaflet): convert coordinates 2022-09-14 22:15:48 +02:00
dancingCycle bde18f1b2a feat(leaflet): add svg loader according to https://www.pluralsight.com/guides/how-to-load-svg-with-react-and-webpack 2022-09-14 21:25:30 +02:00
dancingCycle df3c4eedda feat(leaflet): add marker 2022-09-14 21:12:45 +02:00
dancingCycle 69b304a03e feat(leaflet): https://stackoverflow.com/questions/40365440/react-leaflet-map-not-correctly-displayed 2022-09-14 20:21:45 +02:00
dancingCycle 4d89166ae8 feat(leaflet): https://react-leaflet.js.org/docs/start-setup/ 2022-09-14 15:33:48 +02:00
dancingCycle 6e78f00b87 feat(leaflet): https://react-leaflet.js.org/docs/start-installation/ 2022-09-14 15:29:32 +02:00
dancingCycle 96f8d54ae3 feat(leaflet): initial commit 2022-09-14 15:14:45 +02:00
dancingCycle 15f98a481f feat(pbf): add map component 2022-09-14 15:09:44 +02:00
dancingCycle 16abe8b37a feat(pbf): read more from pbf 2022-09-14 14:20:27 +02:00
dancingCycle 6fb285e9de chore(pbf): bump version to v0.4.0 2022-09-14 11:29:33 +02:00
dancingCycle 7427f4029a feat(pbf): read more from pbf 2022-09-14 11:28:58 +02:00
dancingCycle 2e50472bb9 feat(gtfs-realtime-bindings): initial commit 2022-09-13 23:02:25 +02:00
dancingCycle 3d98a37f4c chore(pbf): bump version to v0.3.0 2022-09-13 23:00:13 +02:00
dancingCycle f93734790c feat(pbf): read pbf 2022-09-13 22:59:29 +02:00
dancingCycle 575461e037 chore(pbf): add gtfs-r js sources 2022-09-13 15:30:00 +02:00
dancingCycle e26a9c3342 chore(pbf): bump version to v0.2.0 2022-09-13 15:18:17 +02:00
dancingCycle bf9d0029cf feat(pbf): add axios get call to home page 2022-09-13 15:16:58 +02:00
dancingCycle f820f3e8da feat(axios): adjust function axiosGetVehiclePosition 2022-09-13 14:58:29 +02:00
dancingCycle 8b234c6be9 feat(axios): add function axiosGetVehiclePosition 2022-09-08 13:55:14 +02:00
dancingCycle c9df2b7134 chore(axios): add .gitignore 2022-09-08 13:43:09 +02:00
dancingCycle 2f02eea778 feat(pbf): initial commit 2022-09-08 13:41:44 +02:00
dancingCycle 6666665d55 feat(datepicker) add TableDatepicker 2022-08-30 14:27:17 +02:00
dancingCycle 2535c809a6 feat(datepicker) add child to DatePicker 2022-08-30 14:27:17 +02:00
dancingCycle e86038281a feat(datepicker) add open state callbacks 2022-08-30 14:27:17 +02:00
renovate[bot] 9e13830892 chore(deps): pin dependencies 2022-08-27 08:01:07 +02:00
dancingCycle dc173116cd feat(datepicker) initial commit 2022-08-26 15:22:44 +02:00
dancingCycle 06084cfc76 chore(webpack-react): adjust verion from 0.0.1 to 0.1.0 2022-08-26 12:48:35 +02:00
dancingCycle 0db548d0b7 feat(webpack-react): load CSS using Webpack 2022-08-26 12:47:31 +02:00
dancingCycle f8cae83a95 chore(fare-zones-table): add package lock 2022-07-21 22:11:32 +02:00
dancingCycle 1f49d0c498 feat(fare-zones-table): adjust DOM to React.js v18 2022-07-21 22:11:01 +02:00
dancingCycle 1194d0e5fb chore: add package-lock.json 2022-07-21 22:08:02 +02:00
dancingCycle 9b3143e6f9 doc(config-tutorial): add React v18 note 2022-07-21 22:04:39 +02:00
dancingCycle 7fdb97cd39 doc(auth0-blog): add React v18 note 2022-07-21 22:01:30 +02:00
dancingCycle 942d4f062b chore(axios): add package lock 2022-07-21 21:55:33 +02:00
dancingCycle 53ed1a3c0c feat(axios): adjust DOM to React.js v18 2022-07-21 21:54:43 +02:00
renovate[bot] ee2c25f7b2 fix(deps): update react monorepo to v18 2022-07-21 21:47:20 +02:00
dancingCycle 7746a44854 chore(pages): add package lock 2022-07-21 21:41:01 +02:00
dancingCycle 04618eb184 feat(pages): adjust to react-router-dom v6 2022-07-21 21:40:07 +02:00
renovate[bot] 39c5603c30 fix(deps): update dependency react-router-dom to v6 2022-07-21 21:30:49 +02:00
dancingCycle d3249b4280 feat(auth0) add Profile page and update React Router to version v6 2022-07-21 14:35:01 +02:00
renovate[bot] 4df4ed66bc fix(deps): pin dependencies 2022-07-21 13:40:42 +02:00
dancingCycle 4bb0b1c08d chore: adjust renovate config 2022-07-21 13:24:41 +02:00
dancingCycle a2dc968a25 chore: adjust renovate config 2022-07-21 13:02:01 +02:00
dancingCycle f1d669579e feat(auth0) add Loading component and Routes 2022-07-20 20:44:19 +02:00
dancingCycle 9e55024b00 feat(auth0) add Loading component 2022-07-20 19:32:52 +02:00
dancingCycle 694fd2cf78 chore(auth0-blog) initial commit 2022-07-18 22:23:30 +02:00
dancingCycle 2f495ba51c feat(auth0) add onClick prop to Button tag 2022-07-18 18:20:15 +02:00
dancingCycle ea29090eee feat(auth0) add LogoutButton component 2022-07-18 18:16:09 +02:00
dancingCycle 344108e536 feat(auth0) add LoginButton component 2022-07-18 18:14:10 +02:00
dancingCycle 61dc47ad54 feat(auth0) provide props props to Auth0Provider 2022-07-18 18:08:31 +02:00
dancingCycle ec0a2b205b feat(auth0): import and add Auth0Provider 2022-07-18 15:40:13 +02:00
dancingCycle 65d3b9b95a chore(auth0): add React.StrictMode 2022-07-18 15:36:12 +02:00
dancingCycle cc942a884e feat(webpack-react): add React.StrictMode 2022-07-18 15:34:18 +02:00
dancingCycle c6c07c935f chore(auth0) install Auth0 2022-07-18 15:25:47 +02:00
dancingCycle 87f8c2db80 chore(auth0) initial commit 2022-07-18 15:23:59 +02:00
dancingCycle b7b1a9630f chore(webpack-react): organize folder structure 2022-07-18 15:19:42 +02:00
dancingCycle 2b05256770 chore(webpack-react): mv src to app folder 2022-07-18 14:59:35 +02:00
dancingCycle ae068ea689 feat(api-with-paging): initial commit 2022-06-27 08:53:49 +02:00
dancingCycle a9f14d24e6 feat(cards): add card template 2022-06-26 07:07:11 +02:00
dancingCycle 0ed2571733 feat(cards): initial commit 2022-06-24 14:40:15 +02:00
dancingCycle 0a5e608ea6 chore: adjust renovate config 2022-06-23 22:16:41 +02:00
dancingCycle 63caa9342d feat(select): extend drop-down component 2022-06-22 14:03:13 +02:00
dancingCycle b9ba70cac5 feat(fare-zones-table): switch from tarifmatrix to data.vbn API 2022-06-22 12:41:59 +02:00
dancingCycle 6008ff4eed feat(select): initial commit 2022-06-21 22:32:04 +02:00
Stefan Begerad ce4671c2ba
Merge pull request #3 from Software-Ingenieur-Begerad/renovate/prettier-2.x
chore(deps): update dependency prettier to v2.7.1
2022-06-21 21:09:07 +02:00
dancingCycle fb93ec1246 chore: adjust renovate config 2022-06-20 21:05:11 +02:00
renovate[bot] 57bbd6e03d
chore(deps): update dependency prettier to v2.7.1 2022-06-20 18:56:49 +00:00
Stefan Begerad 7a492a4b61
Merge pull request #1 from Software-Ingenieur-Begerad/renovate/configure
Configure Renovate
2022-06-20 20:56:10 +02:00
renovate[bot] 2273a2dbdf
chore(deps): add renovate.json 2022-06-20 18:08:15 +00:00
dancingCycle 426868de20 feat(webpack-react): mv webpack config to config folder 2022-06-15 11:06:53 +02:00
dancingCycle 35ffd8187e feat(webpack-react): merge prod and dev config into common webpack config 2022-06-15 10:01:59 +02:00
dancingCycle ee698001fa feat(webpack-react): call npm install --save-dev webpack-merge 2022-06-15 07:17:15 +02:00
dancingCycle 9d343318c1 feat(string2fileDload): adjust download config 2022-06-15 07:13:31 +02:00
dancingCycle ca1bd36a0f feat(string2fileDload): initial commit 2022-06-10 10:06:59 +02:00
dancingCycle 81857e0349 feat(crud): adjust README 2022-06-10 08:17:19 +02:00
dancingCycle 497db065d3 feat(crud): initial commit 2022-06-09 14:29:12 +02:00
dancingCycle e27bae66a8 fix(toggle-btn): add missing prop-types 2022-06-08 10:23:12 +02:00
dancingCycle 91db4c3e8b feat(form): add form with multiple inputs 2022-06-08 10:21:23 +02:00
dancingCycle a3d072c505 feat(toggle-btn): initial commit 2022-06-07 20:34:27 +02:00
dancingCycle 0f911c0419 feat(form): initial commit 2022-06-07 12:26:42 +02:00
dancingCycle 123ac80de7 feat(webpack-react): install and add prop-types.js example 2022-06-07 11:19:58 +02:00
dancingCycle 63c89e072a feat(wp-js): initial commit 2022-06-07 09:42:58 +02:00
dancingCycle 640b2fdff3 feat(webpack-react): add *.jsx transpiling to *.js for React.js 2022-06-07 09:39:54 +02:00
dancingCycle 438d627d68 feat(webpack-react): initial commit 2022-06-07 08:41:20 +02:00
603 changed files with 351348 additions and 151 deletions

View File

@ -1,4 +1,16 @@
# Links
[React.js login form example with basic auth](https://jasonwatmore.com/post/2018/09/11/react-basic-http-authentication-tutorial-example)
[React.js axios REST tutorial](https://www.positronx.io/react-axios-tutorial-make-http-get-post-requests/)
[React.js login and authentication](https://www.digitalocean.com/community/tutorials/how-to-add-login-authentication-to-react-applications)
# sandbox-react
## Table of Contents
0. [General](#general)
# General
This is a sandbox for projects using react.js.
* [axios](./axios)
* [config-tutorial](./config-tutorial)
* [fare-zones-table](./fare-zones-table)
* [login-auth](./login-auth)
* [pages](./pages)
* [webpack for vanilla JavaScript](./webpack-js)
* [webpack for react with vanilla JavaScript](./wp-react)

6
api-with-paging/.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}

108
api-with-paging/.gitignore vendored Normal file
View File

@ -0,0 +1,108 @@
# Others
package-lock.json
build*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

14
api-with-paging/README.md Normal file
View File

@ -0,0 +1,14 @@
# React.js Example
## Table of Contents
0. [General](#general)
1. [Links](#links)
# General
# Links
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
* [Production](https://webpack.js.org/guides/production/)
* [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
* [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)

View File

@ -0,0 +1,36 @@
//generate a HTML5 file including all webpack bundles in the body using script tags
const HtmlWebpackPlugin = require('html-webpack-plugin');
//path is used to resolve properly across the OS
const path = require('path');
module.exports = {
//bundle *.js from this entry point
entry: path.resolve(__dirname, '../src/index.jsx'),
//create output file to be linked to index.html
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../dist'),
clean: true,
},
module: {
rules: [
{
//test all *.js using babel-loader
//test all *.jsx (e.g. React.js) using babel-loader
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, '../src'),
use: ['babel-loader'],
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [
// create a plugin instance so that you can use it several times anywhere
new HtmlWebpackPlugin({
title: 'Production',
template: path.resolve(__dirname, "../public/index.html")
}),
],
};

View File

@ -0,0 +1,14 @@
//path is used to resolve properly across the OS
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
//merge() calls in the environment-specific configuration to include commons
module.exports = merge(common, {
//set development mode
mode: 'development',
//enable strong source mapping
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, '../dist'),
},
});

View File

@ -0,0 +1,8 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
//source maps encouraged in production
//choose mapping with fairly quick build speed like source-map
devtool: 'source-map',
});

View File

@ -0,0 +1,37 @@
{
"private": true,
"name": "react-example",
"description": "React.js example",
"version": "0.0.1",
"main": "index.js",
"keywords": [
"react",
"webpack"
],
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
"license": "GPL-3.0-or-later",
"engines": {
"node": ">=10"
},
"scripts": {
"start": "webpack serve --open --config config/webpack.dev.js",
"build": "webpack --config config/webpack.prod.js"
},
"devDependencies": {
"@babel/core": "7.18.13",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"babel-loader": "8.2.5",
"html-webpack-plugin": "5.5.0",
"webpack": "5.74.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.10.1",
"webpack-merge": "5.8.0"
},
"dependencies": {
"axios": "0.27.2",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>React Example</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@ -0,0 +1,73 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import DropDownSelect from '../components/drop-down-select';
const selectOptions=[10,25,50,100,250,500,1000,2500,5000,10000];
import TableAry from '../components/table-ary';
const ApiPaging = () => {
/*store and initialise data in function component state*/
const [oset, setOset] = useState(1);
const [limit, setLimit] = useState(selectOptions[2]);
const [ary, setAry] = useState([]);
/*fetch ary in a JavaScript function*/
const fetch = async () => {
try {
/*TODO make route available using config*/
/*TODO handle errors: https://www.valentinog.com/blog/await-react/*/
const address=`https://www.v1gtfs.delfi.api.swingbe.de/shapes-oset-limit?oset=${oset}&limit=${limit}`;
const res = await axios.get(address);
/*set state*/
setAry(res.data);
} catch (err) {
console.log('err.message: ' + err.message);
}
};
/*this hook is run after a DOM update. Changing state migh result in an infinite loop*/
useEffect(() => {
/*effect goes here*/
/*hook need to be placed in body of the function component in which it is used*/
fetch();
/*use an empty dependency array to ensure the hook is running only once*/
/*TODO study dependency array: https://reactjs.org/docs/hooks-effect.html*/
}, [oset,limit]);
const handleClickPrev=()=>{
setOset((oset)=>oset>1?--oset:oset);
};
const handleClickNext=()=>{
setOset((oset)=> ++oset);
};
const handleChangeLimit = (event) => {
//console.log('event.target.value: '+event.target.value);
setLimit((limit)=>event.target.value);
};
const select = (
<DropDownSelect
name="Limit"
onChange={handleChangeLimit}
options={selectOptions}
defaultValue={selectOptions[2]}
/>
);
/*element representing user-defined React component*/
const table = <TableAry aryData={ary} />;
return (
<>
<p>ApiPaging</p>
<button
onClick={handleClickPrev}
autoFocus
>prev</button>
<button
onClick={handleClickNext}
>next</button>
{select}
{table}
</>
);
};
export default ApiPaging;

View File

@ -0,0 +1,42 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import PropTypes from 'prop-types';
//destructure props
const Card = ({name}) => {
/*store count as array in function component state*/
/*initialise as empty array*/
const [count, setCount] = useState(null);
/*fetch count in a JavaScript function*/
const getCount = async () => {
try {
/*TODO make route available using config*/
/*TODO handle errors: https://www.valentinog.com/blog/await-react/*/
const address=`https://www.v1gtfs.delfi.api.swingbe.de/table-${name}-count`;
const count = await axios.get(address);
/*set state*/
setCount(count.data[0]['count']);
} catch (err) {
console.log('err.message: ' + err.message);
}
};
/*this hook is run after a DOM update. Changing state migh result in an infinite loop*/
useEffect(() => {
/*effect goes here*/
/*hook need to be placed in body of the function component in which it is used*/
getCount();
/*use an empty dependency array to ensure the hook is running only once*/
/*TODO study dependency array: https://reactjs.org/docs/hooks-effect.html*/
}, []);
return <p>{name}: {count?count:'loading...'}</p>;
};
Card.propTypes = {
name: PropTypes.string
};
export default Card;

View File

@ -0,0 +1,65 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import Card from './card';
const Cards = () => {
/*store and initialise data in function component state*/
const [tables, setTables] = useState([]);
/*fetch data in a JavaScript function*/
const getTables = async () => {
try {
/*TODO make route available using config*/
/*TODO handle errors: https://www.valentinog.com/blog/await-react/*/
const tables = await axios.get(
'https://www.v1gtfs.delfi.api.swingbe.de/table-names'
);
/*set state*/
setTables(tables.data);
} catch (err) {
console.log('err.message: ' + err.message);
}
};
/*this hook is run after a DOM update. Changing state migh result in an infinite loop*/
useEffect(() => {
/*effect goes here*/
/*hook need to be placed in body of the function component in which it is used*/
getTables();
/*use an empty dependency array to ensure the hook is running only once*/
/*TODO study dependency array: https://reactjs.org/docs/hooks-effect.html*/
}, []);
if(tables){
return(
<>
<p>GTFS tables</p>
{tables.map((item,index)=>{
return <Card key={index} name={item['table_name']}/>
})
}
</>
);
}else{
return(
<>
<p>GTFS tables loading...</p>
</>
);
}
}
export default Cards

View File

@ -0,0 +1,43 @@
import React from 'react'
import PropTypes from 'prop-types';
/*controlled component: input form value controlled by React*/
const DropDownSelect = (props) => {
/*destructuring*/
const {options,name,onChange,defaultValue}=props;
if(options){
return(
<div>
<strong>{name}</strong>:
<select
name={name}
id={name}
className={name}
onChange={onChange}
defaultValue={defaultValue}
>
{options.map((item, index) => (
<option key={index} value={item}>
{item}
</option>
))}
</select>
</div>
);
}else{
return (
<div>
<p>Select failed.</p>
</div>
);
}
};
export default DropDownSelect
DropDownSelect.propTypes = {
name: PropTypes.string,
defaultValue: PropTypes.number,
onChange: PropTypes.func,
options: PropTypes.array,
};

View File

@ -0,0 +1,44 @@
import React from 'react';
import PropTypes from 'prop-types';
import Entry from './table-entry';
import Head from './table-head';
/*the simplest way to define a component is to write a JavaScript function*/
/*destructure props object*/
function TableAry ({ aryData }) {
const handleAryData = () => {
if (aryData) {
//iterate over array
return aryData.map((item, index) => {
return (
<Entry
shape_id={item.shape_id}
shape_pt_lat={item.shape_pt_lat}
shape_pt_lon={item.shape_pt_lon}
shape_pt_sequence={item.shape_pt_sequence}
key={index}
/>
);
});
} else {
console.log('aryData NOT available');
return <p>loading...</p>;
}
};
/*return a React element*/
return (
<>
<table>
<thead>
<Head />
</thead>
<tbody>{handleAryData()}</tbody>
</table>
</>
);
}
TableAry.propTypes = {
aryData: PropTypes.array
};
export default TableAry;

View File

@ -0,0 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';
/*destructure props object*/
const TableEntry = ({ shape_id, shape_pt_lat, shape_pt_lon, shape_pt_sequence }) => {
return (
<tr>
<td>{shape_id}</td>
<td>{shape_pt_lat}</td>
<td>{shape_pt_lon}</td>
<td>{shape_pt_sequence}</td>
</tr>
);
};
TableEntry.propTypes = {
shape_id: PropTypes.string,
shape_pt_lat: PropTypes.number,
shape_pt_lon: PropTypes.number,
shape_pt_sequence: PropTypes.number
};
export default TableEntry;

View File

@ -0,0 +1,14 @@
import React from 'react';
const TableHead = () => {
return (
<tr>
<td>shape_id</td>
<td>shape_pt_lat</td>
<td>shape_pt_lon</td>
<td>shape_pt_sequence</td>
</tr>
);
};
export default TableHead;

View File

@ -0,0 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Home from './pages/home';
//TODO remove debugging
if (process.env.NODE_ENV !== 'production') {
console.log('development mode');
}
//since react 18
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById("root"));
//render root app
root.render(<Home />);

View File

@ -0,0 +1,13 @@
import React from 'react';
import ApiPaging from '../components/api-paging';
const Home = () => {
return (
<>
<p>Home</p>
<ApiPaging />
</>
);
}
export default Home

6
auth0-blog/.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}

108
auth0-blog/.gitignore vendored Normal file
View File

@ -0,0 +1,108 @@
# Others
package-lock.json
build*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

16
auth0-blog/README.md Normal file
View File

@ -0,0 +1,16 @@
# Auth0 Example
## Table of Contents
0. [General](#general)
1. [Links](#links)
# General
# Links
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
* [Production](https://webpack.js.org/guides/production/)
* [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
* [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)
* [Auth0 with React}(https://auth0.com/blog/complete-guide-to-react-user-authentication/)
* [React/JavaScript +React Router 6: Authentication Code Sample](https://auth0.com/developers/hub/code-samples/spa/react-javascript/basic-authentication-with-react-router-6)

29
auth0-blog/app/app.jsx Normal file
View File

@ -0,0 +1,29 @@
import React, {Fragment} from 'react';
import { Route, Routes} from 'react-router-dom';
import { useAuth0 } from '@auth0/auth0-react';
import NavBar from "./components/nav-bar";
import Loading from "./components/loading";
import Profile from "./pages/profile";
import Home from './pages/home';
import ProtectedRoute from './auth/protected-route';
export default function App() {
const { isLoading } = useAuth0();
if (isLoading) {
return <Loading />;
}
return (
<Fragment>
<NavBar/>
<Routes>
<Route
path="/"
element={<Home/>} />
<Route
path="/profile"
element={<ProtectedRoute component={Profile} />}
/>
</Routes>
</Fragment>
);
}

View File

@ -0,0 +1,24 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { Auth0Provider } from '@auth0/auth0-react';
const Auth0ProviderWithNavigate = ({ children }) => {
const domain = 'swingbe.eu.auth0.com';
const clientId = 'OySbj7SzpZeKxKGm8lGDNZW0pcGQBiJr';
const navigate = useNavigate();
const onRedirectCallback = (appState) => {
navigate.push(appState?.returnTo || window.location.pathname);
};
return (
<Auth0Provider
domain={domain}
clientId={clientId}
redirectUri={window.location.origin}
onRedirectCallback={onRedirectCallback}
>
{children}
</Auth0Provider>
);
};
export default Auth0ProviderWithNavigate;

View File

@ -0,0 +1,11 @@
import { withAuthenticationRequired } from "@auth0/auth0-react";
import React from "react";
import Loading from "../components/loading";
const ProtectedRoute = ({ component }) => {
const Component = withAuthenticationRequired(component, {
onRedirecting: () => <Loading />,
});
return <Component />;
};
export default ProtectedRoute;

View File

@ -0,0 +1,10 @@
import React from 'react';
import AuthenticationButton from './authentication-button';
const AuthNav = () => (
<div className="navbar-nav ml-auto">
<AuthenticationButton />
</div>
);
export default AuthNav;

View File

@ -0,0 +1,14 @@
import React from 'react';
import LoginButton from './login-button';
import LogoutButton from './logout-button';
import { useAuth0 } from '@auth0/auth0-react';
const AuthenticationButton = () => {
const { isAuthenticated } = useAuth0();
return isAuthenticated ? <LogoutButton /> : <LoginButton />;
};
export default AuthenticationButton;

View File

@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
//destructure props
const Hello = ({msg}) => {
return (
<>
<div>{msg}</div>
</>
);
}
export default Hello
Hello.propTypes = {
msg: PropTypes.string,
};

View File

@ -0,0 +1,11 @@
import React from "react";
const loadingImg =
"https://cdn.auth0.com/blog/auth0-react-sample/assets/loading.svg";
const Loading = () => (
<div className="spinner">
<img src={loadingImg} alt="Loading..." />
</div>
);
export default Loading;

View File

@ -0,0 +1,15 @@
import React from 'react';
import { useAuth0 } from '@auth0/auth0-react';
const LoginButton = () => {
const { loginWithRedirect } = useAuth0();
return (
<button
onClick={() => loginWithRedirect()}
>
Log In
</button>
);
};
export default LoginButton;

View File

@ -0,0 +1,19 @@
import React from 'react';
import { useAuth0 } from '@auth0/auth0-react';
const LogoutButton = () => {
const { logout } = useAuth0();
return (
<button
onClick={() =>
logout({
returnTo: window.location.origin,
})
}
>
Log Out
</button>
);
};
export default LogoutButton;

View File

@ -0,0 +1,19 @@
import {NavLink} from "react-router-dom";
import React from "react";
const MainNav = () => (
<div>
<NavLink
to="/"
>
Home
</NavLink>
<NavLink
to="/profile"
>
Profile
</NavLink>
</div>
);
export default MainNav;

View File

@ -0,0 +1,20 @@
import React from 'react';
import MainNav from './main-nav';
import AuthNav from './auth-nav';
const NavBar = () => {
return (
<div className="nav-container mb-3">
<nav className="navbar navbar-expand-md navbar-light bg-light">
<div className="container">
<div className="navbar-brand logo" />
<MainNav />
<AuthNav />
</div>
</nav>
</div>
);
};
export default NavBar;

View File

@ -0,0 +1,20 @@
import React from 'react';
import { useAuth0 } from '@auth0/auth0-react';
const SignupButton = () => {
const { loginWithRedirect } = useAuth0();
return (
<button
className="btn btn-primary btn-block"
onClick={() =>
loginWithRedirect({
screen_hint: 'signup',
})
}
>
Sign Up
</button>
);
};
export default SignupButton;

24
auth0-blog/app/index.jsx Normal file
View File

@ -0,0 +1,24 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from "react-router-dom";
import App from './app';
import Auth0ProviderWithHistory from './auth/auth0-provider-with-history';
//TODO remove debugging
if (process.env.NODE_ENV !== 'production') {
console.log('development mode');
}
/*ReactDOM.render is no longer supported in React 18. Use createRoot instead.*/
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById("root"));
//render root app
root.render(
<React.StrictMode>
<BrowserRouter>
<Auth0ProviderWithHistory>
<App />
</Auth0ProviderWithHistory>
</BrowserRouter>
</React.StrictMode>
);

View File

@ -0,0 +1,14 @@
import React from 'react';
import Hello from '../components/hello';
const Home = () => {
return (
<>
<h1>Home</h1>
<h2>(React.js Lambda Function Component)</h2>
<Hello msg="Hello World!" />
</>
);
}
export default Home

View File

@ -0,0 +1,32 @@
import React from 'react';
import { useAuth0 } from '@auth0/auth0-react';
import Loading from '../components/loading';
const Profile = () => {
const { user } = useAuth0();
const { name, picture, email } = user;
return (
<div>
<div>
<div>
<img
src={picture}
alt="Profile"
/>
</div>
<div>
<h2>{name}</h2>
<p>{email}</p>
</div>
</div>
<div>
<pre>
{JSON.stringify(user, null, 2)}
</pre>
</div>
</div>
);
};
export default Profile;

View File

@ -0,0 +1,36 @@
//generate a HTML5 file including all webpack bundles in the body using script tags
const HtmlWebpackPlugin = require('html-webpack-plugin');
//path is used to resolve properly across the OS
const path = require('path');
module.exports = {
//bundle *.js from this entry point
entry: path.resolve(__dirname, '../app/index.jsx'),
//create output file to be linked to index.html
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../dist'),
clean: true,
},
module: {
rules: [
{
//test all *.js using babel-loader
//test all *.jsx (e.g. React.js) using babel-loader
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, '../app'),
use: ['babel-loader'],
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [
// create a plugin instance so that you can use it several times anywhere
new HtmlWebpackPlugin({
title: 'Production',
template: path.resolve(__dirname, "../public/index.html")
}),
],
};

View File

@ -0,0 +1,15 @@
//path is used to resolve properly across the OS
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
//merge() calls in the environment-specific configuration to include commons
module.exports = merge(common, {
//set development mode
mode: 'development',
//enable strong source mapping
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, '../dist'),
port: 4040,
},
});

View File

@ -0,0 +1,8 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
//source maps encouraged in production
//choose mapping with fairly quick build speed like source-map
devtool: 'source-map',
});

39
auth0-blog/package.json Normal file
View File

@ -0,0 +1,39 @@
{
"private": true,
"name": "auth0-example",
"description": "Auth0 example",
"version": "0.0.1",
"main": "index.js",
"keywords": [
"react",
"webpack",
"auth0"
],
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
"license": "GPL-3.0-or-later",
"engines": {
"node": ">=10"
},
"scripts": {
"start": "webpack serve --open --config config/webpack.dev.js",
"build": "webpack --config config/webpack.prod.js"
},
"devDependencies": {
"@babel/core": "7.18.13",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"babel-loader": "8.2.5",
"html-webpack-plugin": "5.5.0",
"webpack": "5.74.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.10.1",
"webpack-merge": "5.8.0"
},
"dependencies": {
"@auth0/auth0-react": "1.10.2",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-router-dom": "6.3.0"
}
}

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>React Example</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

6
auth0/.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}

108
auth0/.gitignore vendored Normal file
View File

@ -0,0 +1,108 @@
# Others
package-lock.json
build*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

15
auth0/README.md Normal file
View File

@ -0,0 +1,15 @@
# Auth0 Example
## Table of Contents
0. [General](#general)
1. [Links](#links)
# General
# Links
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
* [Production](https://webpack.js.org/guides/production/)
* [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
* [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)
* [Auth0 with React}(https://blog.suhailkakar.com/integrate-auth0-with-react-js-a-step-by-step-tutorial)

20
auth0/app/app.jsx Normal file
View File

@ -0,0 +1,20 @@
import React from 'react';
import Home from './pages/home';
import LoginButton from './components/login-button';
import LogoutButton from './components/logout-button';
export default function App() {
return (
<>
<div>
<h1>Auth0 with React.js</h1>
<Home />
</div>
<div>
<LoginButton />
</div>
<div>
<LogoutButton />
</div>
</>
);
}

View File

@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
//destructure props
const Hello = ({msg}) => {
return (
<>
<div>{msg}</div>
</>
);
}
export default Hello
Hello.propTypes = {
msg: PropTypes.string,
};

View File

@ -0,0 +1,18 @@
import { useAuth0 } from '@auth0/auth0-react';
import React from 'react';
function LoginButton(props) {
const { loginWithRedirect } = useAuth0()
return (
<div>
<button
onClick={()=>loginWithRedirect()}
className="loginButton"
>
Login
</button>
</div>
)
}
export default LoginButton;

View File

@ -0,0 +1,18 @@
import { useAuth0 } from '@auth0/auth0-react';
import React from 'react';
function LogoutButton(props) {
const { loginWithRedirect } = useAuth0()
return (
<div>
<button
onClick={()=>loginWithRedirect()}
className="loginButton"
>
Logout
</button>
</div>
)
}
export default LogoutButton;

24
auth0/app/index.jsx Normal file
View File

@ -0,0 +1,24 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './app';
import { Auth0Provider } from "@auth0/auth0-react";
//TODO remove debugging
if (process.env.NODE_ENV !== 'production') {
console.log('development mode');
}
//since react 18
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById("root"));
//render root app
root.render(
<Auth0Provider
domain="swingbe.eu.auth0.com"
clientId="0DZCL8TWnttm6zYbxmU675EmATaIEDfn"
redirectUri={window.location.origin}
>
<React.StrictMode>
<App />
</React.StrictMode>
</Auth0Provider>
);

14
auth0/app/pages/home.jsx Normal file
View File

@ -0,0 +1,14 @@
import React from 'react';
import Hello from '../components/hello';
const Home = () => {
return (
<>
<h1>Home</h1>
<h2>(React.js Lambda Function Component)</h2>
<Hello msg="Hello World!" />
</>
);
}
export default Home

View File

@ -0,0 +1,36 @@
//generate a HTML5 file including all webpack bundles in the body using script tags
const HtmlWebpackPlugin = require('html-webpack-plugin');
//path is used to resolve properly across the OS
const path = require('path');
module.exports = {
//bundle *.js from this entry point
entry: path.resolve(__dirname, '../app/index.jsx'),
//create output file to be linked to index.html
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../dist'),
clean: true,
},
module: {
rules: [
{
//test all *.js using babel-loader
//test all *.jsx (e.g. React.js) using babel-loader
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, '../app'),
use: ['babel-loader'],
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [
// create a plugin instance so that you can use it several times anywhere
new HtmlWebpackPlugin({
title: 'Production',
template: path.resolve(__dirname, "../public/index.html")
}),
],
};

View File

@ -0,0 +1,14 @@
//path is used to resolve properly across the OS
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
//merge() calls in the environment-specific configuration to include commons
module.exports = merge(common, {
//set development mode
mode: 'development',
//enable strong source mapping
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, '../dist'),
},
});

View File

@ -0,0 +1,8 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
//source maps encouraged in production
//choose mapping with fairly quick build speed like source-map
devtool: 'source-map',
});

38
auth0/package.json Normal file
View File

@ -0,0 +1,38 @@
{
"private": true,
"name": "auth0-example",
"description": "Auth0 example",
"version": "0.0.1",
"main": "index.js",
"keywords": [
"react",
"webpack",
"auth0"
],
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
"license": "GPL-3.0-or-later",
"engines": {
"node": ">=10"
},
"scripts": {
"start": "webpack serve --open --config config/webpack.dev.js",
"build": "webpack --config config/webpack.prod.js"
},
"devDependencies": {
"@babel/core": "7.18.13",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"babel-loader": "8.2.5",
"html-webpack-plugin": "5.5.0",
"webpack": "5.74.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.10.1",
"webpack-merge": "5.8.0"
},
"dependencies": {
"@auth0/auth0-react": "1.10.2",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}

10
auth0/public/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>React Example</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}

107
axios-overpass-api/.gitignore vendored Normal file
View File

@ -0,0 +1,107 @@
# Others
build*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

View File

@ -0,0 +1,17 @@
# React.js Example
## Table of Contents
0. [General](#general)
1. [Links](#links)
# General
# Links
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
* [Production](https://webpack.js.org/guides/production/)
* [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
* [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)
* [load CSS](https://masteringjs.io/tutorials/webpack/css-loader)
* [load CSS](https://webpack.js.org/loaders/css-loader/)
* [load CSS](https://blog.jakoblind.no/css-modules-webpack/)

View File

@ -0,0 +1,10 @@
import React from 'react';
import Home from './pages/home';
export default function App() {
return (
<div>
<h1>App</h1>
<Home />
</div>
)
}

View File

@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
//destructure props
const Hello = ({msg}) => {
return (
<>
<div>{msg}</div>
</>
);
}
export default Hello
Hello.propTypes = {
msg: PropTypes.string,
};

View File

@ -0,0 +1,65 @@
import React from 'react';
import axios from 'axios';
import qs from 'qs';
var data = qs.stringify({
'data': '[bbox:51.990800124058914,10.045623779296875,52.552976197007524,11.01104736328125][out:json];(node["shop"="second_hand"];way["shop"="second_hand"];relation["shop"="second_hand"];);out center;'
});
var config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://overpass-api.de/api/interpreter',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data : data
};
function myFunction(value,key) {
//console.log("key: "+key+",type: "+value.type);
if(value.tags.name===undefined){
console.log('ERROR: OSM element does NOT include name tag');
}else if(value.type==='node'){
console.log('node');
console.log('name: '+value.tags.name);
console.log('lat: '+value.lat);
console.log('lon: '+value.lon);
}else if(value.type==='way'){
console.log('way');
console.log('name: '+value.tags.name);
console.log('lat: '+value.center.lat);
console.log('lon: '+value.center.lon);
}else{
console.log('ERROR: OSM element NOT supported');
}
}
function post () {
console.log('post() started...');
console.log('data: '+data);
axios(config)
.then(function (response) {
//log JSON
const dataObj=response.data;
//console.log("dataObj: "+dataObj);
const elemAry=dataObj.elements;
const elemAryLength=elemAry.length;
console.log("no: "+elemAryLength)
elemAry.forEach(myFunction);
})
.catch(function (error) {
console.log(error);
});
console.log('post() done.');
}
export default function Map() {
return (
<>
<p>Map</ p>
<button onClick={post}>post</button>
</>
);
}

View File

@ -0,0 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './app';
//TODO remove debugging
if (process.env.NODE_ENV !== 'production') {
console.log('development mode');
}
//since react 18
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById("root"));
//render root app
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View File

@ -0,0 +1,16 @@
import React from 'react';
import Hello from '../components/hello';
import Map from '../components/map';
import '../style.css';
const Home = () => {
return (
<>
<h2>Home</h2>
<h3>(React.js Lambda Function Component)</h3>
<Hello msg="Hello World!" />
<Map />
</>
);
}
export default Home

View File

@ -0,0 +1,3 @@
h1 { color: red; }
h2 { color: green; }
h3 { color: blue; }

View File

@ -0,0 +1,41 @@
//generate a HTML5 file including all webpack bundles in the body using script tags
const HtmlWebpackPlugin = require('html-webpack-plugin');
//path is used to resolve properly across the OS
const path = require('path');
module.exports = {
//bundle *.js from this entry point
entry: path.resolve(__dirname, '../app/index.jsx'),
//create output file to be linked to index.html
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../dist'),
clean: true,
},
module: {
rules: [
{
//test all *.js using babel-loader
//test all *.jsx (e.g. React.js) using babel-loader
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, '../app'),
use: ['babel-loader'],
},
{
//test all *.css using style-loader and css-loader
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
]
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [
// create a plugin instance so that you can use it several times anywhere
new HtmlWebpackPlugin({
title: 'Production',
template: path.resolve(__dirname, "../public/index.html")
}),
],
};

View File

@ -0,0 +1,14 @@
//path is used to resolve properly across the OS
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
//merge() calls in the environment-specific configuration to include commons
module.exports = merge(common, {
//set development mode
mode: 'development',
//enable strong source mapping
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, '../dist'),
},
});

View File

@ -0,0 +1,8 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
//source maps encouraged in production
//choose mapping with fairly quick build speed like source-map
devtool: 'source-map',
});

11207
axios-overpass-api/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
{
"private": true,
"name": "react-example",
"description": "React.js example",
"version": "0.1.0",
"main": "index.js",
"keywords": [
"react",
"webpack"
],
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
"license": "GPL-3.0-or-later",
"engines": {
"node": ">=10"
},
"scripts": {
"start": "webpack serve --config config/webpack.dev.js",
"build": "webpack --config config/webpack.prod.js"
},
"devDependencies": {
"@babel/core": "7.18.13",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"babel-loader": "8.2.5",
"css-loader": "6.7.1",
"html-webpack-plugin": "5.5.0",
"style-loader": "3.3.1",
"webpack": "5.74.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.10.1",
"webpack-merge": "5.8.0"
},
"dependencies": {
"axios": "1.3.2",
"prop-types": "15.8.1",
"qs": "6.11.0",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>React Example</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

107
axios/.gitignore vendored Normal file
View File

@ -0,0 +1,107 @@
# Others
build*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

14031
axios/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "axios-ex",
"version": "1.0.0",
"version": "1.0.1",
"description": "axios example",
"main": "index.js",
"scripts": {
@ -13,28 +13,28 @@
"author": "Stefan Begerad",
"license": "GPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.4",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"axios": "^0.27.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.4",
"@babel/preset-react": "^7.14.5",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"css-loader": "^6.2.0",
"eslint": "^7.32.0",
"eslint-config-react": "^1.1.7",
"eslint-loader": "^4.0.2",
"eslint-plugin-react": "^7.25.1",
"html-webpack-plugin": "^5.3.2",
"less": "^4.1.1",
"less-loader": "^10.0.1",
"prettier": "2.4.0",
"style-loader": "^3.2.1",
"webpack": "^5.52.0",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.1.1"
"@babel/core": "7.18.13",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"babel-eslint": "10.1.0",
"babel-loader": "8.2.5",
"css-loader": "6.7.1",
"eslint": "7.32.0",
"eslint-config-react": "1.1.7",
"eslint-loader": "4.0.2",
"eslint-plugin-react": "7.30.1",
"html-webpack-plugin": "5.5.0",
"less": "4.1.3",
"less-loader": "10.2.0",
"prettier": "2.7.1",
"style-loader": "3.3.1",
"webpack": "5.74.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.10.1"
}
}

View File

@ -1,5 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Main from './main';
ReactDOM.render(<Main />, document.getElementById('root'));
/*ReactDOM.render is no longer supported in React 18. Use createRoot instead.*/
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById('root'));
//render root app
root.render(
<React.StrictMode>
<Main />
</React.StrictMode>
);

View File

@ -1,7 +1,7 @@
import React from 'react';
import './style/main.less';
import axios from 'axios';
/*
function axiosGet () {
console.log('axiosGet() started...');
@ -36,6 +36,31 @@ function axiosGet () {
});
console.log('axiosGet() done.');
}
*/
function axiosGetVehiclePosition () {
console.log('axiosGetVehiclePosition() started...');
//axios.defaults.baseURL = 'https://test-tarifmatrix.vbn.de:4245';
//axios.defaults.baseURL = 'https://tarifmatrix.vbn.de:4445';
axios.defaults.baseURL = 'https://soll.vbn.de';
//axios.defaults.headers.get['Access-Control-Allow-Origin'] = '*';
axios
.get('vehicle-positions')
//handle rsp in async manner
.then((response) => {
if (response.data) {
console.log('axiosGetVehiclePosition() response.data: ', response.data);
} else {
console.log('axiosGetVehiclePosition() response.data unavailable ');
}
})
.catch(function (error) {
console.log(error);
});
console.log('axiosGetVehiclePosition() done.');
}
/*
*component Main
@ -47,7 +72,7 @@ class Main extends React.Component {
return (
<div>
<p>main</p>
<button onClick={axiosGet}>axios</button>
<button onClick={axiosGetVehiclePosition}>axios</button>
</div>
);
}

6
cards/.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}

108
cards/.gitignore vendored Normal file
View File

@ -0,0 +1,108 @@
# Others
package-lock.json
build*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

14
cards/README.md Normal file
View File

@ -0,0 +1,14 @@
# React.js Example
## Table of Contents
0. [General](#general)
1. [Links](#links)
# General
# Links
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
* [Production](https://webpack.js.org/guides/production/)
* [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
* [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)

View File

@ -0,0 +1,36 @@
//generate a HTML5 file including all webpack bundles in the body using script tags
const HtmlWebpackPlugin = require('html-webpack-plugin');
//path is used to resolve properly across the OS
const path = require('path');
module.exports = {
//bundle *.js from this entry point
entry: path.resolve(__dirname, '../src/index.js'),
//create output file to be linked to index.html
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../dist'),
clean: true,
},
module: {
rules: [
{
//test all *.js using babel-loader
//test all *.jsx (e.g. React.js) using babel-loader
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, '../src'),
use: ['babel-loader'],
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [
// create a plugin instance so that you can use it several times anywhere
new HtmlWebpackPlugin({
title: 'Production',
template: path.resolve(__dirname, "../public/index.html")
}),
],
};

View File

@ -0,0 +1,14 @@
//path is used to resolve properly across the OS
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
//merge() calls in the environment-specific configuration to include commons
module.exports = merge(common, {
//set development mode
mode: 'development',
//enable strong source mapping
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, '../dist'),
},
});

View File

@ -0,0 +1,8 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production',
//source maps encouraged in production
//choose mapping with fairly quick build speed like source-map
devtool: 'source-map',
});

37
cards/package.json Normal file
View File

@ -0,0 +1,37 @@
{
"private": true,
"name": "react-example",
"description": "React.js example",
"version": "0.0.1",
"main": "index.js",
"keywords": [
"react",
"webpack"
],
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
"license": "GPL-3.0-or-later",
"engines": {
"node": ">=10"
},
"scripts": {
"start": "webpack serve --open --config config/webpack.dev.js",
"build": "webpack --config config/webpack.prod.js"
},
"devDependencies": {
"@babel/core": "7.18.13",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"babel-loader": "8.2.5",
"html-webpack-plugin": "5.5.0",
"webpack": "5.74.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.10.1",
"webpack-merge": "5.8.0"
},
"dependencies": {
"axios": "0.27.2",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}

10
cards/public/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>React Example</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@ -0,0 +1,42 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import PropTypes from 'prop-types';
//destructure props
const Card = ({name}) => {
/*store count as array in function component state*/
/*initialise as empty array*/
const [count, setCount] = useState(null);
/*fetch count in a JavaScript function*/
const getCount = async () => {
try {
/*TODO make route available using config*/
/*TODO handle errors: https://www.valentinog.com/blog/await-react/*/
const address=`https://www.v1gtfs.delfi.api.swingbe.de/table-${name}-count`;
const count = await axios.get(address);
/*set state*/
setCount(count.data[0]['count']);
} catch (err) {
console.log('err.message: ' + err.message);
}
};
/*this hook is run after a DOM update. Changing state migh result in an infinite loop*/
useEffect(() => {
/*effect goes here*/
/*hook need to be placed in body of the function component in which it is used*/
getCount();
/*use an empty dependency array to ensure the hook is running only once*/
/*TODO study dependency array: https://reactjs.org/docs/hooks-effect.html*/
}, []);
return <p>{name}: {count?count:'loading...'}</p>;
};
Card.propTypes = {
name: PropTypes.string
};
export default Card;

View File

@ -0,0 +1,65 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import Card from './card';
const Cards = () => {
/*store and initialise data in function component state*/
const [tables, setTables] = useState([]);
/*fetch data in a JavaScript function*/
const getTables = async () => {
try {
/*TODO make route available using config*/
/*TODO handle errors: https://www.valentinog.com/blog/await-react/*/
const tables = await axios.get(
'https://www.v1gtfs.delfi.api.swingbe.de/table-names'
);
/*set state*/
setTables(tables.data);
} catch (err) {
console.log('err.message: ' + err.message);
}
};
/*this hook is run after a DOM update. Changing state migh result in an infinite loop*/
useEffect(() => {
/*effect goes here*/
/*hook need to be placed in body of the function component in which it is used*/
getTables();
/*use an empty dependency array to ensure the hook is running only once*/
/*TODO study dependency array: https://reactjs.org/docs/hooks-effect.html*/
}, []);
if(tables){
return(
<>
<p>GTFS tables</p>
{tables.map((item,index)=>{
return <Card key={index} name={item['table_name']}/>
})
}
</>
);
}else{
return(
<>
<p>GTFS tables loading...</p>
</>
);
}
}
export default Cards

13
cards/src/index.js Normal file
View File

@ -0,0 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Home from './pages/home';
//TODO remove debugging
if (process.env.NODE_ENV !== 'production') {
console.log('development mode');
}
//since react 18
import { createRoot } from 'react-dom/client';
//create root container
const root = createRoot(document.getElementById("root"));
//render root app
root.render(<Home />);

13
cards/src/pages/home.jsx Normal file
View File

@ -0,0 +1,13 @@
import React from 'react';
import Cards from '../components/cards';
const Home = () => {
return (
<>
<p>Home</p>
<Cards />
</>
);
}
export default Home

14
cnt-cmpnnt/.babelrc Normal file
View File

@ -0,0 +1,14 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
]
}

19
cnt-cmpnnt/.eslintrc Normal file
View File

@ -0,0 +1,19 @@
{
"parser": "@babel/eslint-parser",
"extends": "eslint:recommended",
"env": {
"es6": 1,
"node": 1
},
"parserOptions": {
"ecmaVersion": 2020
},
"ignorePatterns": [
"node_modules",
"dist"
],
"rules": {
"no-console": "error",
"no-mixed-spaces-and-tabs": 0
}
}

107
cnt-cmpnnt/.gitignore vendored Normal file
View File

@ -0,0 +1,107 @@
# Others
build*
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port

2
cnt-cmpnnt/.npmrc Normal file
View File

@ -0,0 +1,2 @@
# .npmrc
engine-strict=true

View File

@ -0,0 +1,50 @@
// generate a HTML5 file including all webpack bundles in the body using script tags
const HtmlWebpackPlugin = require('html-webpack-plugin');
// path is used to resolve properly across the OS
const path = require('path');
module.exports = {
// bundle *.js from this entry point
entry: path.resolve(__dirname, '../src/index.jsx'),
// create output file to be linked to index.html
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, '../dist'),
clean: true,
},
module: {
rules: [
{
// test all *.js using babel-loader
// test all *.jsx (e.g. React.js) using babel-loader
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, '../src'),
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
],
},
},
},
{
// test all *.css using style-loader and css-loader
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [
// create a plugin instance so that you can use it several times anywhere
new HtmlWebpackPlugin({
title: 'Production',
template: path.resolve(__dirname, '../public/index.html'),
}),
],
};

View File

@ -0,0 +1,20 @@
// path is used to resolve properly across the OS
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common');
// merge() calls in the environment-specific configuration to include commons
module.exports = merge(common, {
// set development mode
mode: 'development',
// enable strong source mapping
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, '../dist'),
/*
When using the HTML5 History API,
the index.html page will likely have to be served in place of any 404 responses.
Enable devServer.historyApiFallback by setting it to true.
*/
historyApiFallback: true,
},
});

View File

@ -0,0 +1,9 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common');
module.exports = merge(common, {
mode: 'production',
// source maps encouraged in production
// choose mapping with fairly quick build speed like source-map
devtool: 'source-map',
});

8500
cnt-cmpnnt/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

47
cnt-cmpnnt/package.json Normal file
View File

@ -0,0 +1,47 @@
{
"private": true,
"name": "react-example",
"description": "React.js example",
"version": "0.1.0",
"main": "index.js",
"keywords": [
"react",
"webpack"
],
"author": "Software Ingenieur Begerad <dialog@SwIngBe.de>",
"license": "GPL-3.0-or-later",
"engines": {
"node": ">=18.17.0"
},
"scripts": {
"start": "webpack serve --config config/webpack.dev.js",
"build": "webpack --config config/webpack.prod.js",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint .",
"lint:fix": "eslint --fix ."
},
"devDependencies": {
"@babel/core": "7.23.9",
"@babel/eslint-parser": "7.23.10",
"@babel/plugin-transform-runtime": "7.23.9",
"@babel/preset-env": "7.23.9",
"@babel/preset-react": "7.23.3",
"@babel/runtime": "7.23.9",
"babel-loader": "9.1.3",
"css-loader": "6.10.0",
"eslint": "8.56.0",
"eslint-webpack-plugin": "4.0.1",
"style-loader": "3.3.4",
"webpack": "5.90.2",
"webpack-cli": "5.1.4",
"webpack-dev-server": "5.0.1"
},
"dependencies": {
"axios": "1.6.8",
"html-webpack-plugin": "5.6.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"webpack-merge": "5.10.0"
}
}

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>React Example</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

17
cnt-cmpnnt/readme.md Normal file
View File

@ -0,0 +1,17 @@
# React.js Example
## Table of Contents
0. [General](#general)
1. [Links](#links)
# General
# Links
* [React setup with webpack for beginners](https://dev.to/deepanjangh/react-setup-with-webpack-for-beginners-2a8k)
* [Production](https://webpack.js.org/guides/production/)
* [Setup Development and Production Environment for React App](https://medium.com/freestoneinfotech/setup-development-and-production-environment-for-react-app-397c4cc9e382)
* [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/)
* [load CSS](https://masteringjs.io/tutorials/webpack/css-loader)
* [load CSS](https://webpack.js.org/loaders/css-loader/)
* [load CSS](https://blog.jakoblind.no/css-modules-webpack/)

View File

@ -0,0 +1,32 @@
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import config from '../config';
import {getAbsEntityCount} from '../utils/axios-utils';
export default function AbsEntityCount() {
const [absEntityCount, setAbsCount] = useState(null);
const handleAbsEntityCount = async () => {
let absEntityCount = null;
try {
absEntityCount = await getAbsEntityCount(`${config.API}stops-count`);
} catch (err) {
console.error('handleAbsEntityCount(): err.message: ' + err.message);
}
setAbsCount(absEntityCount);
};
useEffect(() => {
handleAbsEntityCount();
}, []);
return (
<>
<p>
Abs Count: {absEntityCount ? absEntityCount : 'loading...'}&nbsp;
</p>
</>
);
};

View File

@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
//destructure props
const Hello = ({msg}) => {
return (
<>
<div>{msg}</div>
</>
);
}
export default Hello
Hello.propTypes = {
msg: PropTypes.string,
};

Some files were not shown because too many files have changed in this diff Show More