GithubHelp home page GithubHelp logo

raamir / myportfoliopwa Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 263 KB

This portfolio is a pwa app created using reactjs framework. It can be accessed at: https://nosy-flower.surge.sh/

HTML 10.41% JavaScript 80.54% CSS 9.05%

myportfoliopwa's Introduction

VanillaJs

Portfolio App PWA Support Documentation

App can be accessed and installed from: https://nosy-flower.surge.sh/

***NOTE: Make sure to check Offline in Developer Tools for it to work***

Application

๐Ÿš Guide

  1. Tutorials/Resources Used

    Follow these links to create your portfolio https://www.youtube.com/watch?v=9AboneIxeM8&list=PL3KAvm6JMiowqFTXj3oPQkhP7aCgRHFTm https://appdividend.com/2018/03/14/how-to-build-progressive-web-application-using-react-js/ https://medium.com/front-end-weekly/build-a-realtime-pwa-with-react-99e7b0fd3270

  2. Create App

    In the project directory, you can run:

    npm create react-app myportfoliosite

    then

    npm start

    Runs the app in the development mode.
    Open http://localhost:3000 to view it in the browser.

    The page will reload if you make edits.
    You will also see any lint errors in the console.

    npm test

    Launches the test runner in the interactive watch mode.
    See the section about running tests for more information.

    npm run build

    Builds the app for production to the build folder.
    It correctly bundles React in production mode and optimizes the build for the best performance.

    The build is minified and the filenames include the hashes.
    Your app is ready to be deployed!

  3. Create a service-worker.js file and modify manifest.json file in public folder

    Enter the following contents to service-worker.js:

    `

       // Flag for enabling cache in production
    
           var doCache = false;
           var CACHE_NAME = 'myportfoliosite-cache';
           
         // Code to handle install prompt on desktop
    
         let deferredPrompt;
         const addBtn = document.querySelector('.add-button');
         addBtn.style.display = 'none';
    
         // Delete old caches
         self.addEventListener('activate', event => {
           const currentCachelist = [CACHE_NAME];
           event.waitUntil(
             caches.keys()
               .then(keyList =>
                 Promise.all(keyList.map(key => {
                   if (!currentCachelist.includes(key)) {
                     return caches.delete(key);
                   }
                 }))
               )
           );
         });
         // This triggers when user starts the app
         self.addEventListener('install', function(event) {
           if (doCache) {
             event.waitUntil(
               caches.open(CACHE_NAME)
                 .then(function(cache) {
                   fetch('asset-manifest.json')
                     .then(response => {
                       response.json();
                     })
                     .then(assets => {
                       // We will cache initial page and the main.js
                       // We could also cache assets like CSS and images
                       const urlsToCache = [
                         '/',
                         assets['main.js']
                       ];
                       cache.addAll(urlsToCache);
                     })
                 })
             );
           }
         });
         // Here we intercept request and serve up the matching files
         self.addEventListener('fetch', function(event) {
           if (doCache) {
             event.respondWith(
               caches.match(event.request).then(function(response) {
                 return response || fetch(event.request);
               })
             );
           }
         })
         `
    
  4. Add the following script in index.html file in public folder `<script>

         if ('serviceWorker' in navigator) {
           window.addEventListener('load', function() {
             navigator.serviceWorker.register('service-worker.js').then(function(registration) {
               console.log('Worker registration successful', registration.scope);
             }, function(err) {
               console.log('Worker registration failed', err);
             }).catch(function(err) {
               console.log(err);
             });
           });
         } else {
           console.log('Service Worker is not supported by browser.');
         }
       </script>
       `
    
  5. File Structure

    `

     my-app/
     README.md
     node_modules/
     package.json
     public/
       index.html
       favicon.ico
     src/
       App.css
       App.js
       App.test.js
       index.css
       index.js
       logo.svg 
     `
    
  6. Edit your app by adding componenents in src folder

  7. Install Http-server to run the pwa app

    npm install http-server -g

    http-server ./build -p 3000

  8. Deploy to Surge `

     npm install --global surge
     surge
     npm run build`
     ls build
     surge build/ 
    

    `

  9. Learn More

    You can learn more in the Create React App documentation.

    To learn React, check out the React documentation.

    Code Splitting

    This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

    Analyzing the Bundle Size

    This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

    Making a Progressive Web App

    This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

    Advanced Configuration

    This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

    Deployment

    This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

    npm run build fails to minify

    This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

myportfoliopwa's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.