├── .gitignore ├── LICENSE ├── NOTICE ├── README.md ├── json-server ├── db.json └── routes.json ├── package-lock.json ├── package.json ├── public └── index.html └── src ├── app.js ├── auth0-provider-with-navigate.js ├── components ├── auth0-feature.js ├── auth0-features.js ├── authentication-guard.js ├── buttons │ ├── login-button.js │ ├── logout-button.js │ └── signup-button.js ├── code-snippet.js ├── hero-banner.js ├── navigation │ ├── desktop │ │ ├── nav-bar-brand.js │ │ ├── nav-bar-buttons.js │ │ ├── nav-bar-tab.js │ │ ├── nav-bar-tabs.js │ │ └── nav-bar.js │ └── mobile │ │ ├── mobile-menu-toggle-button.js │ │ ├── mobile-nav-bar-brand.js │ │ ├── mobile-nav-bar-buttons.js │ │ ├── mobile-nav-bar-tab.js │ │ ├── mobile-nav-bar-tabs.js │ │ └── mobile-nav-bar.js ├── page-footer-hyperlink.js ├── page-footer.js ├── page-layout.js └── page-loader.js ├── index.js ├── pages ├── admin-page.js ├── callback-page.js ├── home-page.js ├── not-found-page.js ├── profile-page.js ├── protected-page.js └── public-page.js ├── services ├── external-api.service.js └── message.service.js └── styles ├── components ├── angular.css ├── auth0-features.css ├── button.css ├── code-snippet.css ├── grids │ ├── index.css │ ├── messages-grid.css │ └── profile-grid.css ├── hero-banner.css ├── index.css ├── layouts │ ├── content-layout.css │ ├── index.css │ └── page-layout.css ├── mobile-nav-bar.css ├── nav-bar.css ├── page-footer.css └── page-loader.css ├── general.css ├── styles.css └── theme.css /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/macos,windows,jetbrains+all,visualstudiocode,node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,jetbrains+all,visualstudiocode,node 4 | 5 | ### JetBrains+all ### 6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 8 | 9 | # User-specific stuff 10 | .idea/**/workspace.xml 11 | .idea/**/tasks.xml 12 | .idea/**/usage.statistics.xml 13 | .idea/**/dictionaries 14 | .idea/**/shelf 15 | 16 | # AWS User-specific 17 | .idea/**/aws.xml 18 | 19 | # Generated files 20 | .idea/**/contentModel.xml 21 | 22 | # Sensitive or high-churn files 23 | .idea/**/dataSources/ 24 | .idea/**/dataSources.ids 25 | .idea/**/dataSources.local.xml 26 | .idea/**/sqlDataSources.xml 27 | .idea/**/dynamic.xml 28 | .idea/**/uiDesigner.xml 29 | .idea/**/dbnavigator.xml 30 | 31 | # Gradle 32 | .idea/**/gradle.xml 33 | .idea/**/libraries 34 | 35 | # Gradle and Maven with auto-import 36 | # When using Gradle or Maven with auto-import, you should exclude module files, 37 | # since they will be recreated, and may cause churn. Uncomment if using 38 | # auto-import. 39 | # .idea/artifacts 40 | # .idea/compiler.xml 41 | # .idea/jarRepositories.xml 42 | # .idea/modules.xml 43 | # .idea/*.iml 44 | # .idea/modules 45 | # *.iml 46 | # *.ipr 47 | 48 | # CMake 49 | cmake-build-*/ 50 | 51 | # Mongo Explorer plugin 52 | .idea/**/mongoSettings.xml 53 | 54 | # File-based project format 55 | *.iws 56 | 57 | # IntelliJ 58 | out/ 59 | 60 | # mpeltonen/sbt-idea plugin 61 | .idea_modules/ 62 | 63 | # JIRA plugin 64 | atlassian-ide-plugin.xml 65 | 66 | # Cursive Clojure plugin 67 | .idea/replstate.xml 68 | 69 | # Crashlytics plugin (for Android Studio and IntelliJ) 70 | com_crashlytics_export_strings.xml 71 | crashlytics.properties 72 | crashlytics-build.properties 73 | fabric.properties 74 | 75 | # Editor-based Rest Client 76 | .idea/httpRequests 77 | 78 | # Android studio 3.1+ serialized cache file 79 | .idea/caches/build_file_checksums.ser 80 | 81 | ### JetBrains+all Patch ### 82 | # Ignores the whole .idea folder and all .iml files 83 | # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 84 | 85 | .idea/ 86 | 87 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 88 | 89 | *.iml 90 | modules.xml 91 | .idea/misc.xml 92 | *.ipr 93 | 94 | # Sonarlint plugin 95 | .idea/sonarlint 96 | 97 | ### macOS ### 98 | # General 99 | .DS_Store 100 | .AppleDouble 101 | .LSOverride 102 | 103 | # Icon must end with two \r 104 | Icon 105 | 106 | 107 | # Thumbnails 108 | ._* 109 | 110 | # Files that might appear in the root of a volume 111 | .DocumentRevisions-V100 112 | .fseventsd 113 | .Spotlight-V100 114 | .TemporaryItems 115 | .Trashes 116 | .VolumeIcon.icns 117 | .com.apple.timemachine.donotpresent 118 | 119 | # Directories potentially created on remote AFP share 120 | .AppleDB 121 | .AppleDesktop 122 | Network Trash Folder 123 | Temporary Items 124 | .apdisk 125 | 126 | ### Node ### 127 | # Logs 128 | logs 129 | *.log 130 | npm-debug.log* 131 | yarn-debug.log* 132 | yarn-error.log* 133 | lerna-debug.log* 134 | .pnpm-debug.log* 135 | 136 | # Diagnostic reports (https://nodejs.org/api/report.html) 137 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 138 | 139 | # Runtime data 140 | pids 141 | *.pid 142 | *.seed 143 | *.pid.lock 144 | 145 | # Directory for instrumented libs generated by jscoverage/JSCover 146 | lib-cov 147 | 148 | # Coverage directory used by tools like istanbul 149 | coverage 150 | *.lcov 151 | 152 | # nyc test coverage 153 | .nyc_output 154 | 155 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 156 | .grunt 157 | 158 | # Bower dependency directory (https://bower.io/) 159 | bower_components 160 | 161 | # node-waf configuration 162 | .lock-wscript 163 | 164 | # Compiled binary addons (https://nodejs.org/api/addons.html) 165 | build/Release 166 | 167 | # Dependency directories 168 | node_modules/ 169 | jspm_packages/ 170 | 171 | # Snowpack dependency directory (https://snowpack.dev/) 172 | web_modules/ 173 | 174 | # TypeScript cache 175 | *.tsbuildinfo 176 | 177 | # Optional npm cache directory 178 | .npm 179 | 180 | # Optional eslint cache 181 | .eslintcache 182 | 183 | # Microbundle cache 184 | .rpt2_cache/ 185 | .rts2_cache_cjs/ 186 | .rts2_cache_es/ 187 | .rts2_cache_umd/ 188 | 189 | # Optional REPL history 190 | .node_repl_history 191 | 192 | # Output of 'npm pack' 193 | *.tgz 194 | 195 | # Yarn Integrity file 196 | .yarn-integrity 197 | 198 | # dotenv environment variables file 199 | .env 200 | .env.test 201 | .env.production 202 | 203 | # parcel-bundler cache (https://parceljs.org/) 204 | .cache 205 | .parcel-cache 206 | 207 | # Next.js build output 208 | .next 209 | out 210 | 211 | # Nuxt.js build / generate output 212 | .nuxt 213 | dist 214 | 215 | # Gatsby files 216 | .cache/ 217 | # Comment in the public line in if your project uses Gatsby and not Next.js 218 | # https://nextjs.org/blog/next-9-1#public-directory-support 219 | # public 220 | 221 | # vuepress build output 222 | .vuepress/dist 223 | 224 | # Serverless directories 225 | .serverless/ 226 | 227 | # FuseBox cache 228 | .fusebox/ 229 | 230 | # DynamoDB Local files 231 | .dynamodb/ 232 | 233 | # TernJS port file 234 | .tern-port 235 | 236 | # Stores VSCode versions used for testing VSCode extensions 237 | .vscode-test 238 | 239 | # yarn v2 240 | .yarn/cache 241 | .yarn/unplugged 242 | .yarn/build-state.yml 243 | .yarn/install-state.gz 244 | .pnp.* 245 | 246 | ### Node Patch ### 247 | # Serverless Webpack directories 248 | .webpack/ 249 | 250 | # Optional stylelint cache 251 | .stylelintcache 252 | 253 | # SvelteKit build / generate output 254 | .svelte-kit 255 | 256 | ### VisualStudioCode ### 257 | .vscode/* 258 | !.vscode/settings.json 259 | !.vscode/tasks.json 260 | !.vscode/launch.json 261 | !.vscode/extensions.json 262 | *.code-workspace 263 | 264 | # Local History for Visual Studio Code 265 | .history/ 266 | 267 | ### VisualStudioCode Patch ### 268 | # Ignore all local history of files 269 | .history 270 | .ionide 271 | 272 | # Support for Project snippet scope 273 | !.vscode/*.code-snippets 274 | 275 | ### Windows ### 276 | # Windows thumbnail cache files 277 | Thumbs.db 278 | Thumbs.db:encryptable 279 | ehthumbs.db 280 | ehthumbs_vista.db 281 | 282 | # Dump file 283 | *.stackdump 284 | 285 | # Folder config file 286 | [Dd]esktop.ini 287 | 288 | # Recycle Bin used on file shares 289 | $RECYCLE.BIN/ 290 | 291 | # Windows Installer files 292 | *.cab 293 | *.msi 294 | *.msix 295 | *.msm 296 | *.msp 297 | 298 | # Windows shortcuts 299 | *.lnk 300 | 301 | # End of https://www.toptal.com/developers/gitignore/api/macos,windows,jetbrains+all,visualstudiocode,node 302 | 303 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 304 | 305 | # dependencies 306 | /node_modules 307 | /.pnp 308 | .pnp.js 309 | 310 | # testing 311 | /coverage 312 | 313 | # production 314 | /build 315 | 316 | # misc 317 | .env.local 318 | .env.development.local 319 | .env.test.local 320 | .env.production.local 321 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React/JavaScript: Basic User Authentication Code Sample 2 | 3 | This JavaScript code sample demonstrates **how to implement user authentication** in React applications using Auth0. This React code sample builds the Single-Page Application (SPA) using the React Router 6 library. 4 | 5 | This code sample is part of the ["Auth0 Developer Resources"](https://developer.auth0.com/resources), a place where you can explore the authentication and authorization features of the Auth0 Identity Platform. 6 | 7 | Visit the ["React/JavaScript + React Router 6 Code Sample: User Authentication For Basic Apps"](https://developer.auth0.com/resources/code-samples/spa/react/basic-authentication) page for instructions on how to configure and run this code sample and how to integrate it with an API server of your choice to [create a full-stack code sample](https://developer.auth0.com/resources/code-samples/full-stack/hello-world/basic-access-control/spa). 8 | 9 | ## Why Use Auth0? 10 | 11 | Auth0 is a flexible drop-in solution to add authentication and authorization services to your applications. Your team and organization can avoid the cost, time, and risk that come with building your own solution to authenticate and authorize users. We offer tons of guidance and SDKs for you to get started and [integrate Auth0 into your stack easily](https://developer.auth0.com/resources/code-samples/full-stack). 12 | -------------------------------------------------------------------------------- /json-server/db.json: -------------------------------------------------------------------------------- 1 | { 2 | "api-messages-public": { 3 | "text": "This is a public message." 4 | }, 5 | "api-messages-protected": { 6 | "text": "This is a protected message." 7 | }, 8 | "api-messages-admin": { 9 | "text": "This is an admin message." 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json-server/routes.json: -------------------------------------------------------------------------------- 1 | { 2 | "/api/messages/public": "/api-messages-public", 3 | "/api/messages/protected": "/api-messages-protected", 4 | "/api/messages/admin": "/api-messages-admin" 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spa_react_javascript_hello-world", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@auth0/auth0-react": "^2.0.0", 7 | "axios": "^0.27.2", 8 | "react": "^18.2.0", 9 | "react-dom": "^18.2.0", 10 | "react-router-dom": "^6.3.0", 11 | "react-scripts": "5.0.1" 12 | }, 13 | "scripts": { 14 | "start": "cross-env PORT=4040 react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject", 18 | "lint": "eslint . --ext .js,.jsx --fix --ignore-path .gitignore", 19 | "api": "json-server --host 0.0.0.0 --port 6060 --watch json-server/db.json --routes json-server/routes.json" 20 | }, 21 | "eslintConfig": { 22 | "extends": [ 23 | "react-app", 24 | "react-app/jest" 25 | ], 26 | "rules": { 27 | "react/prop-types": 0 28 | } 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.2%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | }, 42 | "devDependencies": { 43 | "cross-env": "^7.0.3", 44 | "eslint-config-prettier": "^8.5.0", 45 | "eslint-plugin-prettier": "^4.1.0", 46 | "json-server": "^0.17.0", 47 | "prettier": "^2.7.1" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 16 | 17 | 21 | 22 | 23 | 27 | Auth0 React Sample 28 | 29 | 30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { Route, Routes } from "react-router-dom"; 4 | import { PageLoader } from "./components/page-loader"; 5 | import { AuthenticationGuard } from "./components/authentication-guard"; 6 | import { AdminPage } from "./pages/admin-page"; 7 | import { CallbackPage } from "./pages/callback-page"; 8 | import { HomePage } from "./pages/home-page"; 9 | import { NotFoundPage } from "./pages/not-found-page"; 10 | import { ProfilePage } from "./pages/profile-page"; 11 | import { ProtectedPage } from "./pages/protected-page"; 12 | import { PublicPage } from "./pages/public-page"; 13 | 14 | export const App = () => { 15 | const { isLoading } = useAuth0(); 16 | 17 | if (isLoading) { 18 | return ( 19 |
20 | 21 |
22 | ); 23 | } 24 | 25 | return ( 26 | 27 | } /> 28 | } 31 | /> 32 | } /> 33 | } 36 | /> 37 | } 40 | /> 41 | } /> 42 | } /> 43 | 44 | ); 45 | }; 46 | -------------------------------------------------------------------------------- /src/auth0-provider-with-navigate.js: -------------------------------------------------------------------------------- 1 | import { Auth0Provider } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | 5 | export const Auth0ProviderWithNavigate = ({ children }) => { 6 | const navigate = useNavigate(); 7 | 8 | const domain = process.env.REACT_APP_AUTH0_DOMAIN; 9 | const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID; 10 | const redirectUri = process.env.REACT_APP_AUTH0_CALLBACK_URL; 11 | 12 | const onRedirectCallback = (appState) => { 13 | navigate(appState?.returnTo || window.location.pathname); 14 | }; 15 | 16 | if (!(domain && clientId && redirectUri)) { 17 | return null; 18 | } 19 | 20 | return ( 21 | 29 | {children} 30 | 31 | ); 32 | }; 33 | -------------------------------------------------------------------------------- /src/components/auth0-feature.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const Auth0Feature = ({ title, description, resourceUrl, icon }) => ( 4 | 10 |

11 | external link icon 16 | {title} 17 |

18 |

{description}

19 |
20 | ); 21 | -------------------------------------------------------------------------------- /src/components/auth0-features.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Auth0Feature } from "./auth0-feature"; 3 | 4 | export const Auth0Features = () => { 5 | const featuresList = [ 6 | { 7 | title: "Identity Providers", 8 | description: 9 | "Auth0 supports social providers such as Google, Facebook, and Twitter, along with Enterprise providers such as Microsoft Office 365, Google Apps, and Azure. You can also use any OAuth 2.0 Authorization Server.", 10 | resourceUrl: "https://auth0.com/docs/connections", 11 | icon: "https://cdn.auth0.com/blog/hello-auth0/identity-providers-logo.svg", 12 | }, 13 | { 14 | title: "Multi-Factor Authentication", 15 | description: 16 | "You can require your users to provide more than one piece of identifying information when logging in. MFA delivers one-time codes to your users via SMS, voice, email, WebAuthn, and push notifications.", 17 | resourceUrl: "https://auth0.com/docs/multifactor-authentication", 18 | icon: "https://cdn.auth0.com/blog/hello-auth0/mfa-logo.svg", 19 | }, 20 | { 21 | title: "Attack Protection", 22 | description: 23 | "Auth0 can detect attacks and stop malicious attempts to access your application such as blocking traffic from certain IPs and displaying CAPTCHA. Auth0 supports the principle of layered protection in security that uses a variety of signals to detect and mitigate attacks.", 24 | resourceUrl: "https://auth0.com/docs/attack-protection", 25 | icon: "https://cdn.auth0.com/blog/hello-auth0/advanced-protection-logo.svg", 26 | }, 27 | { 28 | title: "Serverless Extensibility", 29 | description: 30 | "Actions are functions that allow you to customize the behavior of Auth0. Each action is bound to a specific triggering event on the Auth0 platform. Auth0 invokes the custom code of these Actions when the corresponding triggering event is produced at runtime.", 31 | resourceUrl: "https://auth0.com/docs/actions", 32 | icon: "https://cdn.auth0.com/blog/hello-auth0/private-cloud-logo.svg", 33 | }, 34 | ]; 35 | 36 | return ( 37 |
38 |

Explore Auth0 Features

39 |
40 | {featuresList.map((feature) => ( 41 | 48 | ))} 49 |
50 |
51 | ); 52 | }; 53 | -------------------------------------------------------------------------------- /src/components/authentication-guard.js: -------------------------------------------------------------------------------- 1 | import { withAuthenticationRequired } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { PageLoader } from "./page-loader"; 4 | 5 | export const AuthenticationGuard = ({ component }) => { 6 | const Component = withAuthenticationRequired(component, { 7 | onRedirecting: () => ( 8 |
9 | 10 |
11 | ), 12 | }); 13 | 14 | return ; 15 | }; 16 | -------------------------------------------------------------------------------- /src/components/buttons/login-button.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | 4 | export const LoginButton = () => { 5 | const { loginWithRedirect } = useAuth0(); 6 | 7 | const handleLogin = async () => { 8 | await loginWithRedirect({ 9 | appState: { 10 | returnTo: "/profile", 11 | }, 12 | authorizationParams: { 13 | prompt: "login", 14 | }, 15 | }); 16 | }; 17 | 18 | return ( 19 | 22 | ); 23 | }; 24 | -------------------------------------------------------------------------------- /src/components/buttons/logout-button.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | 4 | export const LogoutButton = () => { 5 | const { logout } = useAuth0(); 6 | 7 | const handleLogout = () => { 8 | logout({ 9 | logoutParams: { 10 | returnTo: window.location.origin, 11 | }, 12 | }); 13 | }; 14 | 15 | return ( 16 | 19 | ); 20 | }; 21 | -------------------------------------------------------------------------------- /src/components/buttons/signup-button.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | 4 | export const SignupButton = () => { 5 | const { loginWithRedirect } = useAuth0(); 6 | 7 | const handleSignUp = async () => { 8 | await loginWithRedirect({ 9 | appState: { 10 | returnTo: "/profile", 11 | }, 12 | authorizationParams: { 13 | prompt: "login", 14 | screen_hint: "signup", 15 | }, 16 | }); 17 | }; 18 | 19 | return ( 20 | 23 | ); 24 | }; 25 | -------------------------------------------------------------------------------- /src/components/code-snippet.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const CodeSnippet = ({ title, code = "" }) => ( 4 |
5 | {title} 6 |
7 |
8 |
{code}
9 |
10 |
11 |
12 | ); 13 | -------------------------------------------------------------------------------- /src/components/hero-banner.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const HeroBanner = () => { 4 | const logo = "https://cdn.auth0.com/blog/developer-hub/react-logo.svg"; 5 | 6 | return ( 7 |
8 |
9 | React logo 10 |
11 |

Hello, React World!

12 |

13 | This is a sample application that demonstrates the authentication flow 14 | for React apps using Auth0. 15 |

16 | 23 | Check out the React code sample → 24 | 25 |
26 | ); 27 | }; 28 | -------------------------------------------------------------------------------- /src/components/navigation/desktop/nav-bar-brand.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { NavLink } from "react-router-dom"; 3 | 4 | export const NavBarBrand = () => { 5 | return ( 6 |
7 | 8 | Auth0 shield logo 15 | 16 |
17 | ); 18 | }; 19 | -------------------------------------------------------------------------------- /src/components/navigation/desktop/nav-bar-buttons.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { LoginButton } from "../../buttons/login-button"; 4 | import { LogoutButton } from "../../buttons/logout-button"; 5 | import { SignupButton } from "../../buttons/signup-button"; 6 | 7 | export const NavBarButtons = () => { 8 | const { isAuthenticated } = useAuth0(); 9 | 10 | return ( 11 |
12 | {!isAuthenticated && ( 13 | <> 14 | 15 | 16 | 17 | )} 18 | {isAuthenticated && ( 19 | <> 20 | 21 | 22 | )} 23 |
24 | ); 25 | }; 26 | -------------------------------------------------------------------------------- /src/components/navigation/desktop/nav-bar-tab.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { NavLink } from "react-router-dom"; 3 | 4 | export const NavBarTab = ({ path, label }) => { 5 | return ( 6 | 10 | "nav-bar__tab " + (isActive ? "nav-bar__tab--active" : "") 11 | } 12 | > 13 | {label} 14 | 15 | ); 16 | }; 17 | -------------------------------------------------------------------------------- /src/components/navigation/desktop/nav-bar-tabs.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { NavBarTab } from "./nav-bar-tab"; 4 | 5 | export const NavBarTabs = () => { 6 | const { isAuthenticated } = useAuth0(); 7 | 8 | return ( 9 |
10 | 11 | 12 | {isAuthenticated && ( 13 | <> 14 | 15 | 16 | 17 | )} 18 |
19 | ); 20 | }; 21 | -------------------------------------------------------------------------------- /src/components/navigation/desktop/nav-bar.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { NavBarBrand } from "./nav-bar-brand"; 3 | import { NavBarButtons } from "./nav-bar-buttons"; 4 | import { NavBarTabs } from "./nav-bar-tabs"; 5 | 6 | export const NavBar = () => { 7 | return ( 8 |
9 | 14 |
15 | ); 16 | }; 17 | -------------------------------------------------------------------------------- /src/components/navigation/mobile/mobile-menu-toggle-button.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const MobileMenuToggleButton = ({ icon, handleClick }) => { 4 | return ( 5 | 10 | {icon} 11 | 12 | ); 13 | }; 14 | -------------------------------------------------------------------------------- /src/components/navigation/mobile/mobile-nav-bar-brand.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { NavLink } from "react-router-dom"; 3 | 4 | export const MobileNavBarBrand = ({ handleClick }) => { 5 | return ( 6 |
7 | 8 | Auth0 shield logo 15 | 16 |
17 | ); 18 | }; 19 | -------------------------------------------------------------------------------- /src/components/navigation/mobile/mobile-nav-bar-buttons.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { LoginButton } from "../../buttons/login-button"; 4 | import { LogoutButton } from "../../buttons/logout-button"; 5 | import { SignupButton } from "../../buttons/signup-button"; 6 | 7 | export const MobileNavBarButtons = () => { 8 | const { isAuthenticated } = useAuth0(); 9 | 10 | return ( 11 |
12 | {!isAuthenticated && ( 13 | <> 14 | 15 | 16 | 17 | )} 18 | {isAuthenticated && ( 19 | <> 20 | 21 | 22 | )} 23 |
24 | ); 25 | }; 26 | -------------------------------------------------------------------------------- /src/components/navigation/mobile/mobile-nav-bar-tab.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { NavLink } from "react-router-dom"; 3 | 4 | export const MobileNavBarTab = ({ path, label, handleClick }) => { 5 | return ( 6 | 11 | "mobile-nav-bar__tab " + (isActive ? "mobile-nav-bar__tab--active" : "") 12 | } 13 | > 14 | {label} 15 | 16 | ); 17 | }; 18 | -------------------------------------------------------------------------------- /src/components/navigation/mobile/mobile-nav-bar-tabs.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { MobileNavBarTab } from "./mobile-nav-bar-tab"; 4 | 5 | export const MobileNavBarTabs = ({ handleClick }) => { 6 | const { isAuthenticated } = useAuth0(); 7 | 8 | return ( 9 |
10 | 15 | 20 | {isAuthenticated && ( 21 | <> 22 | 27 | 32 | 33 | )} 34 |
35 | ); 36 | }; 37 | -------------------------------------------------------------------------------- /src/components/navigation/mobile/mobile-nav-bar.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { MobileMenuToggleButton } from "./mobile-menu-toggle-button"; 3 | import { MobileNavBarBrand } from "./mobile-nav-bar-brand"; 4 | import { MobileNavBarButtons } from "./mobile-nav-bar-buttons"; 5 | import { MobileNavBarTabs } from "./mobile-nav-bar-tabs"; 6 | 7 | const MobileMenuState = { 8 | CLOSED: "closed", 9 | OPEN: "open", 10 | }; 11 | 12 | const MobileMenuIcon = { 13 | CLOSE: "close", 14 | MENU: "menu", 15 | }; 16 | 17 | export const MobileNavBar = () => { 18 | const [mobileMenuState, setMobileMenuState] = React.useState( 19 | MobileMenuState.CLOSED 20 | ); 21 | const [mobileMenuIcon, setMobileMenuIcon] = React.useState( 22 | MobileMenuIcon.MENU 23 | ); 24 | 25 | const isMobileMenuOpen = () => { 26 | return mobileMenuState === MobileMenuState.OPEN; 27 | }; 28 | 29 | const closeMobileMenu = () => { 30 | document.body.classList.remove("mobile-scroll-lock"); 31 | setMobileMenuState(MobileMenuState.CLOSED); 32 | setMobileMenuIcon(MobileMenuIcon.MENU); 33 | }; 34 | 35 | const openMobileMenu = () => { 36 | document.body.classList.add("mobile-scroll-lock"); 37 | setMobileMenuState(MobileMenuState.OPEN); 38 | setMobileMenuIcon(MobileMenuIcon.CLOSE); 39 | }; 40 | 41 | const toggleMobileMenu = () => { 42 | if (isMobileMenuOpen()) { 43 | closeMobileMenu(); 44 | } else { 45 | openMobileMenu(); 46 | } 47 | }; 48 | 49 | return ( 50 |
51 | 65 |
66 | ); 67 | }; 68 | -------------------------------------------------------------------------------- /src/components/page-footer-hyperlink.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const PageFooterHyperlink = ({ children, path }) => { 4 | return ( 5 | 11 | {children} 12 | 13 | ); 14 | }; 15 | -------------------------------------------------------------------------------- /src/components/page-footer.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { PageFooterHyperlink } from "./page-footer-hyperlink"; 3 | 4 | export const PageFooter = () => { 5 | const resourceList = [ 6 | { 7 | path: "https://auth0.com/why-auth0/", 8 | label: "Why Auth0", 9 | }, 10 | { 11 | path: "https://auth0.com/docs/get-started", 12 | label: "How It Works", 13 | }, 14 | { 15 | path: "https://auth0.com/blog/developers/", 16 | label: "Developer Blog", 17 | }, 18 | { 19 | path: "https://auth0.com/contact-us", 20 | label: "Contact an Expert", 21 | }, 22 | ]; 23 | 24 | return ( 25 | 85 | ); 86 | }; 87 | -------------------------------------------------------------------------------- /src/components/page-layout.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { NavBar } from "./navigation/desktop/nav-bar"; 3 | import { MobileNavBar } from "./navigation/mobile/mobile-nav-bar"; 4 | import { PageFooter } from "./page-footer"; 5 | 6 | export const PageLayout = ({ children }) => { 7 | return ( 8 |
9 | 10 | 11 |
{children}
12 | 13 |
14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /src/components/page-loader.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const PageLoader = () => { 4 | const loadingImg = "https://cdn.auth0.com/blog/hello-auth0/loader.svg"; 5 | 6 | return ( 7 |
8 | Loading... 9 |
10 | ); 11 | }; 12 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { createRoot } from "react-dom/client"; 3 | import { BrowserRouter } from "react-router-dom"; 4 | import { App } from "./app"; 5 | import { Auth0ProviderWithNavigate } from "./auth0-provider-with-navigate"; 6 | import "./styles/styles.css"; 7 | 8 | const container = document.getElementById("root"); 9 | const root = createRoot(container); 10 | 11 | root.render( 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ); 20 | -------------------------------------------------------------------------------- /src/pages/admin-page.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import { CodeSnippet } from "../components/code-snippet"; 3 | import { PageLayout } from "../components/page-layout"; 4 | import { getAdminResource } from "../services/message.service"; 5 | 6 | export const AdminPage = () => { 7 | const [message, setMessage] = useState(""); 8 | 9 | useEffect(() => { 10 | let isMounted = true; 11 | 12 | const getMessage = async () => { 13 | const { data, error } = await getAdminResource(); 14 | 15 | if (!isMounted) { 16 | return; 17 | } 18 | 19 | if (data) { 20 | setMessage(JSON.stringify(data, null, 2)); 21 | } 22 | 23 | if (error) { 24 | setMessage(JSON.stringify(error, null, 2)); 25 | } 26 | }; 27 | 28 | getMessage(); 29 | 30 | return () => { 31 | isMounted = false; 32 | }; 33 | }, []); 34 | 35 | return ( 36 | 37 |
38 |

39 | Admin Page 40 |

41 |
42 |

43 | 44 | This page retrieves an admin message from an 45 | external API. 46 | 47 | 48 | 49 | Only authenticated users with the{" "} 50 | read:admin-messages permission should access this 51 | page. 52 | 53 | 54 |

55 | 56 |
57 |
58 |
59 | ); 60 | }; 61 | -------------------------------------------------------------------------------- /src/pages/callback-page.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { NavBar } from "../components/navigation/desktop/nav-bar"; 4 | import { MobileNavBar } from "../components/navigation/mobile/mobile-nav-bar"; 5 | import { PageLayout } from "../components/page-layout"; 6 | 7 | export const CallbackPage = () => { 8 | const { error } = useAuth0(); 9 | 10 | if (error) { 11 | return ( 12 | 13 |
14 |

15 | Error 16 |

17 |
18 |

19 | {error.message} 20 |

21 |
22 |
23 |
24 | ); 25 | } 26 | 27 | return ( 28 |
29 | 30 | 31 |
32 |
33 | ); 34 | }; 35 | -------------------------------------------------------------------------------- /src/pages/home-page.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Auth0Features } from "../components/auth0-features"; 3 | import { HeroBanner } from "../components/hero-banner"; 4 | import { PageLayout } from "../components/page-layout"; 5 | 6 | export const HomePage = () => ( 7 | 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /src/pages/not-found-page.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { PageLayout } from "../components/page-layout"; 3 | 4 | export const NotFoundPage = () => { 5 | return ( 6 | 7 |
8 |

9 | Not Found 10 |

11 |
12 |
13 | ); 14 | }; 15 | -------------------------------------------------------------------------------- /src/pages/profile-page.js: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import React from "react"; 3 | import { CodeSnippet } from "../components/code-snippet"; 4 | import { PageLayout } from "../components/page-layout"; 5 | 6 | export const ProfilePage = () => { 7 | const { user } = useAuth0(); 8 | 9 | if (!user) { 10 | return null; 11 | } 12 | 13 | return ( 14 | 15 |
16 |

17 | Profile Page 18 |

19 |
20 |

21 | 22 | You can use the ID Token to get the profile 23 | information of an authenticated user. 24 | 25 | 26 | Only authenticated users can access this page. 27 | 28 |

29 |
30 |
31 | Profile 36 |
37 |

{user.name}

38 | {user.email} 39 |
40 |
41 |
42 | 46 |
47 |
48 |
49 |
50 |
51 | ); 52 | }; 53 | -------------------------------------------------------------------------------- /src/pages/protected-page.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import { CodeSnippet } from "../components/code-snippet"; 3 | import { PageLayout } from "../components/page-layout"; 4 | import { getProtectedResource } from "../services/message.service"; 5 | 6 | export const ProtectedPage = () => { 7 | const [message, setMessage] = useState(""); 8 | 9 | useEffect(() => { 10 | let isMounted = true; 11 | 12 | const getMessage = async () => { 13 | const { data, error } = await getProtectedResource(); 14 | 15 | if (!isMounted) { 16 | return; 17 | } 18 | 19 | if (data) { 20 | setMessage(JSON.stringify(data, null, 2)); 21 | } 22 | 23 | if (error) { 24 | setMessage(JSON.stringify(error, null, 2)); 25 | } 26 | }; 27 | 28 | getMessage(); 29 | 30 | return () => { 31 | isMounted = false; 32 | }; 33 | }, []); 34 | 35 | return ( 36 | 37 |
38 |

39 | Protected Page 40 |

41 |
42 |

43 | 44 | This page retrieves a protected message from an 45 | external API. 46 | 47 | 48 | Only authenticated users can access this page. 49 | 50 |

51 | 52 |
53 |
54 |
55 | ); 56 | }; 57 | -------------------------------------------------------------------------------- /src/pages/public-page.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import { CodeSnippet } from "../components/code-snippet"; 3 | import { PageLayout } from "../components/page-layout"; 4 | import { getPublicResource } from "../services/message.service"; 5 | 6 | export const PublicPage = () => { 7 | const [message, setMessage] = useState(""); 8 | 9 | useEffect(() => { 10 | let isMounted = true; 11 | 12 | const getMessage = async () => { 13 | const { data, error } = await getPublicResource(); 14 | 15 | if (!isMounted) { 16 | return; 17 | } 18 | 19 | if (data) { 20 | setMessage(JSON.stringify(data, null, 2)); 21 | } 22 | 23 | if (error) { 24 | setMessage(JSON.stringify(error, null, 2)); 25 | } 26 | }; 27 | 28 | getMessage(); 29 | 30 | return () => { 31 | isMounted = false; 32 | }; 33 | }, []); 34 | 35 | return ( 36 | 37 |
38 |

39 | Public Page 40 |

41 |
42 |

43 | 44 | This page retrieves a public message from an 45 | external API. 46 | 47 | 48 | Any visitor can access this page. 49 | 50 |

51 | 52 |
53 |
54 |
55 | ); 56 | }; 57 | -------------------------------------------------------------------------------- /src/services/external-api.service.js: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export const callExternalApi = async (options) => { 4 | try { 5 | const response = await axios(options.config); 6 | const { data } = response; 7 | 8 | return { 9 | data, 10 | error: null, 11 | }; 12 | } catch (error) { 13 | if (axios.isAxiosError(error)) { 14 | const axiosError = error; 15 | 16 | const { response } = axiosError; 17 | 18 | let message = "http request failed"; 19 | 20 | if (response && response.statusText) { 21 | message = response.statusText; 22 | } 23 | 24 | if (axiosError.message) { 25 | message = axiosError.message; 26 | } 27 | 28 | if (response && response.data && response.data.message) { 29 | message = response.data.message; 30 | } 31 | 32 | return { 33 | data: null, 34 | error: { 35 | message, 36 | }, 37 | }; 38 | } 39 | 40 | return { 41 | data: null, 42 | error: { 43 | message: error.message, 44 | }, 45 | }; 46 | } 47 | }; 48 | -------------------------------------------------------------------------------- /src/services/message.service.js: -------------------------------------------------------------------------------- 1 | import { callExternalApi } from "./external-api.service"; 2 | 3 | const apiServerUrl = process.env.REACT_APP_API_SERVER_URL; 4 | 5 | export const getPublicResource = async () => { 6 | const config = { 7 | url: `${apiServerUrl}/api/messages/public`, 8 | method: "GET", 9 | headers: { 10 | "content-type": "application/json", 11 | }, 12 | }; 13 | 14 | const { data, error } = await callExternalApi({ config }); 15 | 16 | return { 17 | data: data || null, 18 | error, 19 | }; 20 | }; 21 | 22 | export const getProtectedResource = async () => { 23 | const config = { 24 | url: `${apiServerUrl}/api/messages/protected`, 25 | method: "GET", 26 | headers: { 27 | "content-type": "application/json", 28 | }, 29 | }; 30 | 31 | const { data, error } = await callExternalApi({ config }); 32 | 33 | return { 34 | data: data || null, 35 | error, 36 | }; 37 | }; 38 | 39 | export const getAdminResource = async () => { 40 | const config = { 41 | url: `${apiServerUrl}/api/messages/admin`, 42 | method: "GET", 43 | headers: { 44 | "content-type": "application/json", 45 | }, 46 | }; 47 | 48 | const { data, error } = await callExternalApi({ config }); 49 | 50 | return { 51 | data: data || null, 52 | error, 53 | }; 54 | }; 55 | -------------------------------------------------------------------------------- /src/styles/components/angular.css: -------------------------------------------------------------------------------- 1 | app-nav-bar { 2 | width: 100%; 3 | } 4 | 5 | app-nav-bar-tabs { 6 | flex: 1; 7 | } 8 | 9 | app-nav-bar-tab { 10 | margin-right: 24px; 11 | } 12 | 13 | app-nav-bar-tab:last-child { 14 | margin-right: 0; 15 | } 16 | 17 | app-login-button, 18 | app-signup-button, 19 | app-logout-button { 20 | margin-right: 1.6rem; 21 | } 22 | 23 | app-login-button:last-child, 24 | app-signup-button:last-child, 25 | app-logout-button:last-child { 26 | margin-right: 0; 27 | } 28 | 29 | app-page-loader { 30 | display: flex; 31 | height: 100%; 32 | width: 100%; 33 | } 34 | 35 | app-mobile-nav-bar { 36 | width: 100%; 37 | } 38 | 39 | app-mobile-nav-bar-tab { 40 | width: 100%; 41 | } 42 | 43 | app-mobile-nav-bar-brand { 44 | flex: 1; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/styles/components/auth0-features.css: -------------------------------------------------------------------------------- 1 | .auth0-features { 2 | /* responsive */ 3 | 4 | padding: 3.2rem 6.4rem; 5 | } 6 | 7 | .auth0-features__title { 8 | color: var(--white); 9 | font-weight: 600; 10 | text-align: center; 11 | 12 | /* responsive */ 13 | 14 | margin-top: 0; 15 | margin-bottom: 4.8rem; 16 | 17 | font-size: 3.2rem; 18 | line-height: 3.2rem; 19 | } 20 | 21 | .auth0-features__grid { 22 | display: grid; 23 | 24 | /* responsive */ 25 | 26 | grid-template-columns: 1fr 1fr; 27 | column-gap: 6.4rem; 28 | row-gap: 6.4rem; 29 | } 30 | 31 | .auth0-feature { 32 | display: block; 33 | 34 | background-color: var(--white); 35 | 36 | color: var(--black); 37 | 38 | cursor: pointer; 39 | 40 | transition: all 0.3s ease-in-out 0s; 41 | 42 | /* responsive */ 43 | 44 | padding: 4.8rem; 45 | 46 | border-radius: 1.6rem; 47 | } 48 | 49 | .auth0-feature:hover { 50 | transform: scale(1.03); 51 | } 52 | 53 | .auth0-feature__headline { 54 | display: flex; 55 | align-items: center; 56 | 57 | margin-top: 0; 58 | 59 | color: var(--black); 60 | font-weight: 600; 61 | letter-spacing: -0.05rem; 62 | 63 | /* responsive */ 64 | 65 | font-size: 2.4rem; 66 | line-height: 3.2rem; 67 | } 68 | 69 | .auth0-feature__icon { 70 | /* responsive */ 71 | 72 | margin-right: 1.6rem; 73 | } 74 | 75 | .auth0-feature:hover .auth0-feature__headline { 76 | text-decoration: underline solid 2px var(--black); 77 | text-underline-offset: 2px; 78 | 79 | transition: all 0.3s ease-in-out 0s; 80 | } 81 | 82 | .auth0-feature__description { 83 | margin: 0; 84 | 85 | color: rgb(36, 36, 36); 86 | font-weight: 500; 87 | 88 | opacity: 0.7; 89 | 90 | /* responsive */ 91 | 92 | font-size: 1.6rem; 93 | line-height: 2.4rem; 94 | } 95 | 96 | @media only screen and (max-width: 900px) { 97 | .auth0-features__grid { 98 | grid-template-columns: 1fr; 99 | row-gap: 3.2rem; 100 | } 101 | 102 | .auth0-feature { 103 | padding: 3.2rem; 104 | border-radius: 0.8rem; 105 | } 106 | 107 | .auth0-feature__headline { 108 | font-size: 2rem; 109 | line-height: 2.4rem; 110 | } 111 | 112 | .auth0-feature__icon { 113 | height: 3.6rem; 114 | 115 | margin-right: 1.6rem; 116 | } 117 | 118 | .auth0-feature__description { 119 | font-size: 1.4rem; 120 | line-height: 2.2rem; 121 | } 122 | } 123 | 124 | @media only screen and (max-width: 480px) { 125 | .auth0-features { 126 | padding: 1.6rem; 127 | } 128 | 129 | .auth0-features__title { 130 | font-size: 2rem; 131 | line-height: 2.8rem; 132 | margin-bottom: 2.4rem; 133 | } 134 | 135 | .auth0-features__grid { 136 | grid-template-columns: 1fr; 137 | row-gap: 1.6rem; 138 | } 139 | 140 | .auth0-feature { 141 | padding: 3.2rem; 142 | border-radius: 0.8rem; 143 | } 144 | 145 | .auth0-feature__headline { 146 | font-size: 2rem; 147 | line-height: 2.4rem; 148 | } 149 | 150 | .auth0-feature__icon { 151 | height: 3.6rem; 152 | 153 | margin-right: 1.6rem; 154 | } 155 | 156 | .auth0-feature__description { 157 | font-size: 1.4rem; 158 | line-height: 2.2rem; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/styles/components/button.css: -------------------------------------------------------------------------------- 1 | .button { 2 | border: 0; 3 | border-radius: 0.8rem; 4 | 5 | font-family: var(--font-primary); 6 | font-weight: 600; 7 | color: var(--white); 8 | 9 | cursor: pointer; 10 | user-select: none; 11 | 12 | transition: background 0.3s ease-out, color 0.3s ease-out; 13 | 14 | /* responsive */ 15 | 16 | min-width: 10rem; 17 | padding: 1.6rem 1.6rem; 18 | 19 | font-size: 1.6rem; 20 | line-height: 2.4rem; 21 | } 22 | 23 | .button--compact { 24 | /* responsive */ 25 | 26 | padding: 1rem 1.6rem; 27 | 28 | font-size: 1.6rem; 29 | line-height: 1.6rem; 30 | } 31 | 32 | .button--primary { 33 | background-color: var(--indigo); 34 | } 35 | 36 | .button--primary:hover { 37 | background: rgba(99, 93, 255, 0.85); 38 | } 39 | 40 | .button--secondary { 41 | background-color: var(--white); 42 | color: var(--black); 43 | } 44 | 45 | .button--secondary:hover { 46 | background: rgba(255, 255, 255, 0.85); 47 | } 48 | 49 | @media only screen and (max-width: 480px) { 50 | .button { 51 | /* responsive */ 52 | 53 | min-width: 0.8rem; 54 | padding: 1rem 1.2rem; 55 | 56 | font-size: 1.3rem; 57 | line-height: 2.2rem; 58 | } 59 | 60 | .button--compact { 61 | /* responsive */ 62 | 63 | padding: 0.6rem 1rem; 64 | 65 | font-size: 1.3rem; 66 | line-height: 2rem; 67 | } 68 | } 69 | 70 | .button__login, 71 | .button__logout { 72 | min-width: 8.4rem; 73 | 74 | border: 0.1rem solid var(--indigo); 75 | color: var(--white); 76 | background: var(--indigo); 77 | width: 50%; 78 | font-size: 1.6rem; 79 | 80 | margin-right: 1.6rem; 81 | 82 | font-family: var(--font-primary); 83 | font-style: normal; 84 | font-weight: 600; 85 | line-height: 3.2rem; 86 | padding: 0.8rem 0; 87 | border-radius: 0.8rem; 88 | text-align: center; 89 | 90 | cursor: pointer; 91 | user-select: none; 92 | 93 | transition: background 0.3s ease-out, color 0.3s ease-out; 94 | } 95 | 96 | .button__sign-up { 97 | min-width: 8.4rem; 98 | 99 | border: 0.1rem solid var(--white); 100 | color: var(--white); 101 | background-color: transparent; 102 | width: 50%; 103 | font-size: 1.6rem; 104 | 105 | margin-right: 1.6rem; 106 | 107 | font-style: normal; 108 | font-weight: 500; 109 | line-height: 3.2rem; 110 | padding: 0.8rem 0; 111 | border-radius: 0.8rem; 112 | text-align: center; 113 | 114 | cursor: pointer; 115 | user-select: none; 116 | } 117 | 118 | .button__login:last-child, 119 | .button__logout:last-child, 120 | .button__sign-up:last-child { 121 | margin-right: 0; 122 | } 123 | 124 | @media only screen and (min-width: 641px) { 125 | .button__login, 126 | .button__logout, 127 | .button__sign-up { 128 | padding: 0.8rem 1.2rem; 129 | 130 | font-size: 1.4rem; 131 | line-height: 1.6rem; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/styles/components/code-snippet.css: -------------------------------------------------------------------------------- 1 | .code-snippet { 2 | display: flex; 3 | flex-direction: column; 4 | width: 100%; 5 | border-radius: 0.8rem; 6 | margin-top: 3.2rem; 7 | overflow: hidden; 8 | } 9 | 10 | .code-snippet__title { 11 | height: 4.8rem; 12 | width: 100%; 13 | 14 | background-color: var(--aluminium); 15 | color: var(--black); 16 | 17 | font-family: "Fira Code", source-code-pro, Menlo, Monaco, Consolas, 18 | "Courier New", monospace; 19 | font-weight: 600; 20 | 21 | /* responsive */ 22 | 23 | font-size: 1.6rem; 24 | line-height: 2.4rem; 25 | padding: 1.2rem 1.6rem; 26 | } 27 | 28 | .code-snippet__container { 29 | min-height: 32.4rem; 30 | background-color: var(--dark-aluminium); 31 | overflow-x: auto; 32 | } 33 | 34 | .code-snippet__wrapper { 35 | display: inline-block; 36 | padding: 32px; 37 | } 38 | 39 | .code-snippet__body { 40 | margin: 0; 41 | 42 | color: var(--white); 43 | font-size: 16px; 44 | line-height: 32px; 45 | word-wrap: break-word; 46 | white-space: pre-wrap; 47 | } 48 | 49 | @media only screen and (max-width: 480px) { 50 | .code-snippet__title { 51 | /* responsive */ 52 | 53 | height: 4.4rem; 54 | 55 | font-size: 1.4rem; 56 | line-height: 2.2rem; 57 | padding: 1.2rem 1.6rem; 58 | } 59 | 60 | .code-snippet__wrapper { 61 | padding: 1.6rem; 62 | } 63 | 64 | .code-snippet__body { 65 | font-size: 1.4rem; 66 | line-height: 2.4rem; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/styles/components/grids/index.css: -------------------------------------------------------------------------------- 1 | @import "messages-grid.css"; 2 | @import "profile-grid.css"; 3 | -------------------------------------------------------------------------------- /src/styles/components/grids/messages-grid.css: -------------------------------------------------------------------------------- 1 | .messages-grid { 2 | display: flex; 3 | flex-direction: column; 4 | } 5 | 6 | .messages-grid__header { 7 | margin: 48px 0 0 0; 8 | 9 | color: var(--white); 10 | font-weight: 500; 11 | text-align: center; 12 | 13 | /* responsive */ 14 | 15 | font-size: 24px; 16 | line-height: 32px; 17 | } 18 | 19 | .messages-grid__options { 20 | display: flex; 21 | 22 | /* responsive */ 23 | 24 | border-radius: 16px; 25 | margin: 32px auto; 26 | } 27 | 28 | .messages-grid__option { 29 | border: 2px solid rgb(96, 96, 96); 30 | border-right: 0; 31 | background-color: var(--black); 32 | 33 | color: var(--white); 34 | font-weight: 600; 35 | text-transform: uppercase; 36 | text-align: center; 37 | 38 | cursor: pointer; 39 | user-select: none; 40 | outline: none; 41 | 42 | transition: background 0.3s ease-out, color 0.3s ease-out; 43 | 44 | /* responsive */ 45 | 46 | padding: 8px 24px; 47 | margin: 0; 48 | 49 | font-size: 16px; 50 | line-height: 24px; 51 | } 52 | 53 | .messages-grid__option:first-child { 54 | border-radius: 8px 0 0 8px; 55 | } 56 | 57 | .messages-grid__option:last-child { 58 | border-radius: 0 8px 8px 0; 59 | border-right: 2px solid rgb(96, 96, 96); 60 | } 61 | 62 | .messages-grid__option--active, 63 | .messages-grid__option--active:hover { 64 | background-color: var(--white); 65 | color: var(--black); 66 | } 67 | 68 | @media only screen and (max-width: 540px) { 69 | .messages-grid__header { 70 | margin: 1.6rem 0 1.6rem 0; 71 | 72 | font-size: 2rem; 73 | line-height: 2.8rem; 74 | } 75 | 76 | .messages-grid__options { 77 | max-width: 24rem; 78 | flex-wrap: wrap; 79 | border-radius: 0.8rem; 80 | margin: 0.8rem auto 1.6rem; 81 | } 82 | 83 | .messages-grid__option { 84 | width: 12rem; 85 | padding: 0.4rem 1.6rem; 86 | 87 | border: 0.2rem solid rgb(96, 96, 96); 88 | 89 | font-size: 1.4rem; 90 | } 91 | 92 | .messages-grid__option:nth-child(1) { 93 | border-bottom-left-radius: 0; 94 | border-right: 0; 95 | border-bottom: 0; 96 | } 97 | 98 | .messages-grid__option:nth-child(2) { 99 | border-top-right-radius: 0.8rem; 100 | border-bottom: 0; 101 | } 102 | 103 | .messages-grid__option:nth-child(3) { 104 | border-bottom-left-radius: 0.8rem; 105 | border-right: 0; 106 | } 107 | 108 | .messages-grid__option:nth-child(4) { 109 | border-top-right-radius: 0; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/styles/components/grids/profile-grid.css: -------------------------------------------------------------------------------- 1 | .profile-grid { 2 | display: flex; 3 | flex-direction: column; 4 | 5 | /* responsive */ 6 | 7 | margin-top: 48px; 8 | } 9 | 10 | .profile__header { 11 | display: grid; 12 | grid-template-columns: auto 1fr; 13 | column-gap: 16px; 14 | } 15 | 16 | .profile__avatar { 17 | border: solid 2px var(--aqua); 18 | border-radius: 50%; 19 | 20 | /* responsive */ 21 | 22 | height: 80px; 23 | width: 80px; 24 | } 25 | 26 | .profile__headline { 27 | display: flex; 28 | flex-direction: column; 29 | justify-content: space-around; 30 | } 31 | 32 | .profile__title { 33 | margin-top: 0; 34 | margin-bottom: 0; 35 | 36 | color: var(--white); 37 | } 38 | 39 | .profile__details { 40 | /* responsive */ 41 | 42 | margin-top: 32px; 43 | } 44 | 45 | @media only screen and (max-width: 480px) { 46 | .profile-grid { 47 | margin-top: 2.4rem; 48 | } 49 | 50 | .profile__avatar { 51 | height: 5.6rem; 52 | width: 5.6rem; 53 | 54 | border-radius: 50%; 55 | 56 | border: solid 0.13rem var(--aqua); 57 | } 58 | 59 | .profile__title { 60 | font-size: 1.6rem; 61 | } 62 | 63 | .profile__description { 64 | font-size: 1.3rem; 65 | } 66 | 67 | .profile__details { 68 | margin-top: 1.6rem; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/styles/components/hero-banner.css: -------------------------------------------------------------------------------- 1 | .hero-banner { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | 6 | width: 100%; 7 | 8 | background: var(--yellow-mandarine-gradient); 9 | 10 | color: var(--black); 11 | 12 | /* responsive */ 13 | 14 | margin: 0 auto; 15 | padding: 3.2rem 6.4rem; 16 | } 17 | 18 | .hero-banner--yellow-mandarine { 19 | background: var(--yellow-mandarine-gradient); 20 | } 21 | .hero-banner--pink-yellow { 22 | background: var(--pink-yellow-gradient); 23 | } 24 | 25 | .hero-banner--blue-aqua { 26 | background: var(--blue-aqua-gradient); 27 | } 28 | 29 | .hero-banner--aqua-emerald { 30 | background: var(--aqua-emerald-gradient); 31 | } 32 | 33 | .hero-banner--emerald-yellow { 34 | background: var(--emerald-yellow-gradient); 35 | } 36 | 37 | .hero-banner__logo { 38 | display: flex; 39 | justify-content: center; 40 | align-items: center; 41 | 42 | background-color: var(--white); 43 | border-radius: 50%; 44 | 45 | box-shadow: 0 2px 4px rgb(0 0 0 / 12%); 46 | 47 | /* responsive */ 48 | 49 | width: 12.8rem; 50 | height: 12.8rem; 51 | } 52 | 53 | .hero-banner__image { 54 | width: 10.8rem; 55 | height: 10.8rem; 56 | } 57 | 58 | .hero-banner__image--small { 59 | width: 7.6rem; 60 | height: 7.6rem; 61 | } 62 | 63 | .hero-banner__headline { 64 | letter-spacing: -1.5px; 65 | 66 | /* responsive */ 67 | 68 | margin: 2.4rem 0 8px 0; 69 | 70 | font-size: 4.8rem; 71 | } 72 | 73 | .hero-banner__description { 74 | max-width: 58rem; 75 | 76 | text-align: center; 77 | 78 | /* responsive */ 79 | 80 | margin-bottom: 3.2rem; 81 | 82 | font-size: 20px; 83 | line-height: 3.2rem; 84 | } 85 | 86 | @media only screen and (max-width: 540px) { 87 | .hero-banner { 88 | padding: 3.2rem 1.6rem; 89 | } 90 | 91 | .hero-banner__logo { 92 | width: 9.6rem; 93 | height: 9.6rem; 94 | } 95 | 96 | .hero-banner__image { 97 | width: 7.2rem; 98 | height: 7.2rem; 99 | } 100 | 101 | .hero-banner__image--small { 102 | width: 6rem; 103 | height: 6rem; 104 | } 105 | 106 | .hero-banner__headline { 107 | font-size: 3.2rem; 108 | } 109 | 110 | .hero-banner__description { 111 | font-size: 1.6rem; 112 | line-height: 2.4rem; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/styles/components/index.css: -------------------------------------------------------------------------------- 1 | @import "auth0-features.css"; 2 | @import "button.css"; 3 | @import "code-snippet.css"; 4 | @import "page-footer.css"; 5 | @import "hero-banner.css"; 6 | @import "page-loader.css"; 7 | @import "nav-bar.css"; 8 | @import "mobile-nav-bar.css"; 9 | @import "grids/index.css"; 10 | @import "layouts/index.css"; 11 | @import "angular.css"; 12 | -------------------------------------------------------------------------------- /src/styles/components/layouts/content-layout.css: -------------------------------------------------------------------------------- 1 | .content-layout { 2 | flex: 1; 3 | display: flex; 4 | flex-direction: column; 5 | flex-shrink: 0; 6 | 7 | width: 100%; 8 | min-height: 640px; 9 | 10 | /* responsive */ 11 | 12 | padding: 48px; 13 | } 14 | 15 | .content__title { 16 | margin-top: 0; 17 | 18 | color: var(--white); 19 | } 20 | 21 | .content__body { 22 | /* responsive */ 23 | 24 | font-size: 1.6rem; 25 | line-height: 2.4rem; 26 | } 27 | 28 | #page-description { 29 | display: flex; 30 | flex-direction: column; 31 | } 32 | 33 | #page-description span { 34 | margin-bottom: 1.6rem; 35 | } 36 | 37 | #page-description span:last-child { 38 | margin-bottom: 0; 39 | } 40 | 41 | @media only screen and (max-width: 480px) { 42 | .content-layout { 43 | padding: 1.6rem; 44 | } 45 | 46 | .content__title { 47 | font-size: 2.4rem; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/styles/components/layouts/index.css: -------------------------------------------------------------------------------- 1 | @import "page-layout.css"; 2 | @import "content-layout.css"; 3 | -------------------------------------------------------------------------------- /src/styles/components/layouts/page-layout.css: -------------------------------------------------------------------------------- 1 | .page-layout { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | 6 | height: 100%; 7 | width: 100%; 8 | } 9 | 10 | .page-layout__content { 11 | flex: 1; 12 | flex-basis: auto; 13 | flex-shrink: 0; 14 | display: flex; 15 | flex-direction: column; 16 | 17 | margin-top: 8rem; 18 | max-width: 120rem; 19 | width: 100%; 20 | } 21 | 22 | @media only screen and (max-width: 640px) { 23 | .page-layout__content { 24 | margin-top: 6.4rem; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/styles/components/mobile-nav-bar.css: -------------------------------------------------------------------------------- 1 | .mobile-nav-bar__container { 2 | position: fixed; 3 | display: none; 4 | 5 | justify-content: center; 6 | flex-shrink: 0; 7 | width: 100%; 8 | 9 | box-shadow: rgb(90 95 102) 0-1.5px 0 inset; 10 | 11 | z-index: 300; 12 | 13 | background-color: var(--black); 14 | } 15 | 16 | .mobile-nav-bar { 17 | flex: 1; 18 | display: flex; 19 | align-items: center; 20 | flex-shrink: 0; 21 | 22 | /* responsive */ 23 | 24 | height: 6.4rem; 25 | max-width: 1200px; 26 | 27 | padding: 0.8rem 1.6rem; 28 | margin: 0; 29 | } 30 | 31 | .mobile-nav-bar__brand { 32 | flex: 1; 33 | display: flex; 34 | align-items: center; 35 | 36 | height: 100%; 37 | 38 | /* responsive */ 39 | 40 | margin-right: 1.6rem; 41 | } 42 | 43 | .mobile-nav-bar__link { 44 | display: flex; 45 | align-items: center; 46 | 47 | height: 100%; 48 | } 49 | 50 | .mobile-nav-bar__logo { 51 | height: 2.4rem; 52 | } 53 | 54 | .mobile-nav-bar__menu { 55 | width: 100%; 56 | height: calc(100% - 6.4rem); 57 | position: fixed; 58 | left: 0; 59 | top: 6.4rem; 60 | background-color: var(--black); 61 | 62 | z-index: 300; 63 | } 64 | 65 | .mobile-nav-bar__toggle { 66 | margin-left: 2.4rem; 67 | font-size: 3.6rem; 68 | cursor: pointer; 69 | } 70 | 71 | .mobile-nav-bar__tabs { 72 | flex: 1; 73 | display: flex; 74 | align-items: center; 75 | justify-content: flex-end; 76 | flex-direction: column; 77 | width: 100%; 78 | } 79 | 80 | .mobile-nav-bar__tab { 81 | display: flex; 82 | flex-direction: row; 83 | /*justify-content: center;*/ 84 | 85 | font-weight: 500; 86 | font-size: 2rem; 87 | line-height: 16px; 88 | 89 | padding: 3.2rem 2.4rem; 90 | background-color: var(--black); 91 | color: var(--white); 92 | width: 100%; 93 | box-shadow: rgb(90 95 102) 0-1.5px 0 inset; 94 | } 95 | 96 | .mobile-nav-bar__tab:last-child { 97 | margin-right: 0; 98 | } 99 | 100 | .mobile-nav-bar__tab--active { 101 | text-decoration-line: underline; 102 | text-decoration-style: solid; 103 | text-decoration-color: var(--indigo); 104 | 105 | /* responsive */ 106 | 107 | text-decoration-thickness: 4px; 108 | text-underline-offset: 8px; 109 | } 110 | 111 | .mobile-nav-bar__tab:hover { 112 | color: var(--white); 113 | } 114 | 115 | .mobile-nav-bar__icon { 116 | display: none; 117 | } 118 | 119 | .mobile-nav-bar__buttons { 120 | display: flex; 121 | justify-content: center; 122 | padding: 3.2rem; 123 | background-color: var(--black); 124 | } 125 | 126 | @media only screen and (max-width: 640px) and (hover: none) { 127 | .mobile-nav-bar__tab:hover { 128 | color: var(--white); 129 | } 130 | 131 | .mobile-nav-bar__tab--active:hover { 132 | color: var(--white); 133 | } 134 | } 135 | 136 | @media only screen and (max-width: 640px) { 137 | .mobile-nav-bar__container { 138 | display: flex; 139 | } 140 | 141 | .mobile-nav-bar__menu--closed { 142 | display: none; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/styles/components/nav-bar.css: -------------------------------------------------------------------------------- 1 | .nav-bar__container { 2 | position: fixed; 3 | display: flex; 4 | justify-content: center; 5 | flex-shrink: 0; 6 | width: 100%; 7 | 8 | box-shadow: rgb(90 95 102) 0-1.5px 0 inset; 9 | 10 | z-index: 300; 11 | background-color: var(--black); 12 | } 13 | 14 | .nav-bar { 15 | flex: 1; 16 | display: flex; 17 | align-items: center; 18 | flex-shrink: 0; 19 | 20 | /* responsive */ 21 | 22 | height: 80px; 23 | max-width: 1200px; 24 | 25 | padding: 0 24px; 26 | margin: 0; 27 | } 28 | 29 | .nav-bar__brand { 30 | display: flex; 31 | align-items: center; 32 | 33 | height: 100%; 34 | 35 | /* responsive */ 36 | 37 | margin-right: 64px; 38 | } 39 | 40 | .nav-bar__link { 41 | display: flex; 42 | align-items: center; 43 | 44 | height: 100%; 45 | } 46 | 47 | .nav-bar__logo { 48 | height: 3.2rem; 49 | } 50 | 51 | .nav-bar__tabs { 52 | flex: 1; 53 | display: flex; 54 | align-items: center; 55 | justify-content: flex-end; 56 | } 57 | 58 | .nav-bar__tab { 59 | display: flex; 60 | flex-direction: row; 61 | justify-content: center; 62 | 63 | margin-right: 24px; 64 | 65 | font-weight: 500; 66 | font-size: 16px; 67 | line-height: 16px; 68 | } 69 | 70 | .nav-bar__tab:last-child { 71 | margin-right: 0; 72 | } 73 | 74 | .nav-bar__tab--active { 75 | text-decoration-line: underline; 76 | text-decoration-style: solid; 77 | text-decoration-color: var(--indigo); 78 | 79 | /* responsive */ 80 | 81 | text-decoration-thickness: 4px; 82 | text-underline-offset: 8px; 83 | } 84 | 85 | .nav-bar__tab:hover { 86 | color: var(--white); 87 | } 88 | 89 | .nav-bar__icon { 90 | display: none; 91 | } 92 | 93 | .nav-bar__buttons { 94 | display: flex; 95 | margin-left: 24px; 96 | } 97 | 98 | @media only screen and (max-width: 640px) and (hover: none) { 99 | .mobile-nav-bar__tab:hover { 100 | color: var(--white); 101 | } 102 | 103 | .mobile-nav-bar__tab--active:hover { 104 | color: var(--white); 105 | } 106 | } 107 | 108 | @media only screen and (max-width: 640px) { 109 | .nav-bar__container { 110 | display: none; 111 | } 112 | 113 | .nav-bar__tab { 114 | font-size: 1.5rem; 115 | } 116 | 117 | .nav-bar { 118 | height: 6.4rem; 119 | 120 | padding: 0.8rem 1.6rem; 121 | } 122 | 123 | .nav-bar__brand { 124 | display: flex; 125 | align-items: center; 126 | 127 | margin-right: 1.6rem; 128 | } 129 | 130 | .nav-bar__logo { 131 | height: 3.2rem; 132 | } 133 | 134 | .nav-bar__tab--active { 135 | text-decoration-line: none; 136 | color: var(--pink); 137 | } 138 | 139 | .nav-bar__label { 140 | display: none; 141 | } 142 | 143 | .nav-bar__icon { 144 | display: block; 145 | font-size: 3.2rem; 146 | } 147 | 148 | .nav-bar__buttons { 149 | margin-left: 24px; 150 | } 151 | } 152 | 153 | @media only screen and (max-width: 340px) { 154 | .nav-bar__tab { 155 | font-size: 1.3rem; 156 | } 157 | 158 | .nav-bar { 159 | height: 6.4rem; 160 | 161 | padding: 0.8rem 1.6rem; 162 | } 163 | 164 | .nav-bar__brand { 165 | display: flex; 166 | align-items: center; 167 | 168 | margin-right: 1.6rem; 169 | } 170 | 171 | .nav-bar__logo { 172 | height: 2.8rem; 173 | } 174 | 175 | .nav-bar__tab--active { 176 | text-decoration-line: none; 177 | color: var(--pink); 178 | } 179 | 180 | .nav-bar__buttons { 181 | margin-left: 24px; 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /src/styles/components/page-footer.css: -------------------------------------------------------------------------------- 1 | .page-footer { 2 | display: flex; 3 | justify-content: center; 4 | flex-shrink: 0; 5 | 6 | width: 100%; 7 | 8 | margin-top: 2.4rem; 9 | 10 | background-color: var(--dark-aluminium); 11 | 12 | color: var(--light-aluminium); 13 | font-weight: 500; 14 | text-align: center; 15 | 16 | /* responsive */ 17 | 18 | font-size: 1.6rem; 19 | line-height: 2.4rem; 20 | } 21 | 22 | .page-footer-grid { 23 | display: grid; 24 | grid-template-rows: auto auto; 25 | 26 | width: 100%; 27 | max-width: 120rem; 28 | 29 | /* responsive */ 30 | 31 | padding: 3.2rem; 32 | } 33 | 34 | .page-footer-grid__info { 35 | display: grid; 36 | 37 | /* responsive */ 38 | 39 | grid-template-columns: 1.5fr 1fr auto; 40 | column-gap: 2.4rem; 41 | } 42 | 43 | .page-footer-grid__brand { 44 | display: grid; 45 | 46 | justify-items: center; 47 | 48 | grid-template-columns: 1fr; 49 | margin-top: 3.2rem; 50 | } 51 | 52 | .page-footer-info__message { 53 | /* responsive */ 54 | 55 | text-align: left; 56 | } 57 | 58 | .page-footer-message__headline { 59 | margin: 0 0 1.4rem; 60 | 61 | font-weight: 500; 62 | } 63 | 64 | .page-footer-message__description { 65 | margin-bottom: 0; 66 | 67 | letter-spacing: 0.016rem; 68 | } 69 | 70 | .page-footer-info__button { 71 | display: flex; 72 | justify-content: center; 73 | align-items: center; 74 | } 75 | 76 | .page-footer-info__resource-list { 77 | display: grid; 78 | 79 | /* responsive */ 80 | 81 | row-gap: 0.8rem; 82 | } 83 | 84 | .page-footer-info__resource-list-item { 85 | text-align: right; 86 | } 87 | 88 | .page-footer-brand { 89 | display: flex; 90 | justify-content: center; 91 | align-items: center; 92 | 93 | width: 100%; 94 | } 95 | 96 | .page-footer-brand__logo { 97 | width: 20px; 98 | margin-right: 12px; 99 | } 100 | 101 | .page-footer__hyperlink { 102 | letter-spacing: 0.001rem; 103 | } 104 | 105 | .page-footer__hyperlink, 106 | .page-footer__hyperlink:active, 107 | .page-footer__hyperlink:visited { 108 | color: var(--white); 109 | } 110 | 111 | .page-footer__hyperlink:hover { 112 | color: var(--aluminium); 113 | } 114 | 115 | @media only screen and (max-width: 960px) { 116 | .page-footer { 117 | /* responsive */ 118 | 119 | font-size: 1.4rem; 120 | line-height: 2.2rem; 121 | } 122 | 123 | .page-footer-grid { 124 | /* responsive */ 125 | 126 | padding: 3.2rem; 127 | } 128 | 129 | .page-footer-grid__info { 130 | /* responsive */ 131 | 132 | grid-template-columns: 1fr; 133 | row-gap: 3.2rem; 134 | } 135 | 136 | .page-footer-info__message { 137 | /* responsive */ 138 | 139 | text-align: center; 140 | } 141 | 142 | .page-footer-info__resource-list { 143 | /* responsive */ 144 | 145 | grid-template-columns: 1fr 1fr; 146 | row-gap: 3.2rem; 147 | column-gap: 3.2rem; 148 | } 149 | 150 | .page-footer-info__resource-list-item:nth-child(odd) { 151 | text-align: right; 152 | } 153 | 154 | .page-footer-info__resource-list-item:nth-child(even) { 155 | text-align: left; 156 | } 157 | } 158 | 159 | @media only screen and (max-width: 480px) { 160 | .page-footer { 161 | /* responsive */ 162 | 163 | font-size: 1.4rem; 164 | line-height: 2.2rem; 165 | } 166 | 167 | .page-footer-grid { 168 | /* responsive */ 169 | 170 | padding: 3.2rem 1.6rem; 171 | } 172 | 173 | .page-footer-grid__info { 174 | /* responsive */ 175 | 176 | grid-template-columns: 1fr; 177 | row-gap: 3.2rem; 178 | } 179 | 180 | .page-footer-info__message { 181 | /* responsive */ 182 | 183 | text-align: center; 184 | } 185 | 186 | .page-footer-info__resource-list { 187 | /* responsive */ 188 | 189 | grid-template-columns: 1fr 1fr; 190 | row-gap: 3.2rem; 191 | column-gap: 3.2rem; 192 | } 193 | 194 | .page-footer-info__resource-list-item:nth-child(odd) { 195 | text-align: right; 196 | } 197 | 198 | .page-footer-info__resource-list-item:nth-child(even) { 199 | text-align: left; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/styles/components/page-loader.css: -------------------------------------------------------------------------------- 1 | .loader { 2 | height: 5rem; 3 | width: 5rem; 4 | 5 | margin: auto; 6 | 7 | animation: spin 2s infinite linear; 8 | } 9 | 10 | @keyframes spin { 11 | from { 12 | transform: rotate(0deg); 13 | } 14 | to { 15 | transform: rotate(360deg); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/styles/general.css: -------------------------------------------------------------------------------- 1 | /* General */ 2 | 3 | * { 4 | box-sizing: border-box; 5 | } 6 | 7 | html { 8 | font-size: 10px; 9 | text-rendering: geometricPrecision; 10 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 11 | } 12 | 13 | html, 14 | body { 15 | height: 100%; 16 | width: 100%; 17 | margin: 0; 18 | padding: 0; 19 | } 20 | 21 | body { 22 | background-color: var(--black); 23 | 24 | color: var(--white); 25 | font-family: var(--font-primary); 26 | 27 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 28 | -webkit-font-smoothing: antialiased; 29 | -moz-osx-font-smoothing: grayscale; 30 | 31 | overflow-y: scroll; 32 | } 33 | 34 | h1, 35 | h2, 36 | h3, 37 | h4, 38 | h5, 39 | h6 { 40 | font-family: var(--font-secondary); 41 | font-weight: 600; 42 | color: rgba(0, 0, 0, 0.86); 43 | } 44 | 45 | h1, 46 | h2, 47 | h3 { 48 | margin-top: 3.2rem; 49 | margin-bottom: 1.6rem; 50 | } 51 | 52 | h4, 53 | h5, 54 | h6 { 55 | margin-top: 1.6rem; 56 | margin-bottom: 1.6rem; 57 | } 58 | 59 | h1 { 60 | font-size: 3.2rem; 61 | } 62 | 63 | h2 { 64 | font-size: 2.8rem; 65 | } 66 | 67 | h3 { 68 | font-size: 2.4rem; 69 | } 70 | 71 | h4 { 72 | font-size: 2rem; 73 | } 74 | 75 | h5 { 76 | font-size: 1.6rem; 77 | } 78 | 79 | h6 { 80 | font-size: 1.4rem; 81 | } 82 | 83 | p { 84 | margin: 0 0 1.6rem; 85 | } 86 | 87 | strong { 88 | font-weight: 500; 89 | } 90 | 91 | small { 92 | font-size: 1.2rem; 93 | } 94 | 95 | blockquote { 96 | padding: 1.6rem 3.2rem; 97 | margin: 0 0 3.2rem; 98 | 99 | border-left: 8px solid #eee; 100 | 101 | font-size: 1.6rem; 102 | font-style: italic; 103 | } 104 | 105 | body, 106 | button, 107 | input, 108 | select, 109 | textarea { 110 | -webkit-font-smoothing: antialiased; 111 | -moz-osx-font-smoothing: grayscale; 112 | } 113 | button, 114 | input, 115 | select, 116 | textarea { 117 | font-family: inherit; 118 | font-size: inherit; 119 | line-height: inherit; 120 | } 121 | 122 | a { 123 | color: var(--white); 124 | text-decoration: none; 125 | } 126 | 127 | figure { 128 | margin: 0; 129 | } 130 | img { 131 | vertical-align: middle; 132 | } 133 | 134 | code, 135 | pre { 136 | font-family: "Fira Code", source-code-pro, Menlo, Monaco, Consolas, 137 | "Courier New", monospace; 138 | width: 100%; 139 | } 140 | 141 | code { 142 | color: var(--emerald); 143 | } 144 | 145 | #root { 146 | height: 100%; 147 | width: 100%; 148 | } 149 | 150 | @media only screen and (max-width: 640px) { 151 | .mobile-scroll-lock { 152 | overflow: hidden; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/styles/styles.css: -------------------------------------------------------------------------------- 1 | @import "theme.css"; 2 | @import "general.css"; 3 | @import "components/index.css"; 4 | -------------------------------------------------------------------------------- /src/styles/theme.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600&display=swap"); 2 | 3 | /* Theme */ 4 | 5 | :root { 6 | --orange: #ff4f40; 7 | --indigo: #635dff; 8 | --white: #fff; 9 | --light-aluminium: #eaecee; 10 | --aluminium: #bdc4cf; 11 | --dark-aluminium: #2a2e35; 12 | --black: #000000; 13 | --yellow: #ebca40; 14 | --mandarine: #ff7f38; 15 | --pink: #ff44dd; 16 | --blue: #3885ff; 17 | --aqua: #3ec6eb; 18 | --emerald: #1bc99f; 19 | 20 | --yellow-mandarine-gradient: linear-gradient( 21 | 153.07deg, 22 | var(--yellow) -2.47%, 23 | var(--mandarine) 102.78% 24 | ); 25 | 26 | --mandarine-orange-gradient: linear-gradient( 27 | 153.07deg, 28 | var(--mandarine) -2.47%, 29 | var(--orange) 102.78% 30 | ); 31 | 32 | --pink-yellow-gradient: linear-gradient( 33 | 153.07deg, 34 | var(--pink) -2.47%, 35 | var(--yellow) 102.78% 36 | ); 37 | 38 | --pink-indigo-gradient: linear-gradient( 39 | 153.07deg, 40 | var(--pink) -2.47%, 41 | var(--indigo) 102.78% 42 | ); 43 | 44 | --indigo-aqua-gradient: linear-gradient( 45 | 153.07deg, 46 | var(--indigo) -2.47%, 47 | var(--aqua) 102.78% 48 | ); 49 | 50 | --blue-aqua-gradient: linear-gradient( 51 | 153.07deg, 52 | var(--blue) -2.47%, 53 | var(--aqua) 102.78% 54 | ); 55 | 56 | --aqua-emerald-gradient: linear-gradient( 57 | 153.07deg, 58 | var(--aqua) -2.47%, 59 | var(--emerald) 102.78% 60 | ); 61 | 62 | --emerald-yellow-gradient: linear-gradient( 63 | 153.07deg, 64 | var(--emerald) -2.47%, 65 | var(--yellow) 102.78% 66 | ); 67 | 68 | --font-primary: "Inter", sans-serif; 69 | --font-secondary: "Space Grotesk", sans-serif; 70 | --font-mono: "Fira Code", monospace; 71 | } 72 | --------------------------------------------------------------------------------