A complete VanillaJS shot at building a full fledged coffee ordering app for users.
We created an usual web page and running it using Live Server VS code extension. We used “type”: “module”
to the script tag for us to enable imports in app.js
. This has led us to do:
- In the
app.js
, the logic will define global scope for the app. We do that bywindow.app={}
- Create
/services
folder and createAPI.js
andRouter.js
API.js
will use fetch to interact with internet to fetch data or so something.Router.js
will usehistory
API to change the path in URL. The changes can be observed to replace HTML ultimately to act like a single page application.
- Create
/components
folder and get get to definecustomElements
. These need to be imported intoapp.js
so that JS engine can invoke thecustomElements.define(..)
line and make it an understandable component to the user. - Now the idea is to use the
Router
to render these components like an Single Page App. - We use
Proxy()
to observe changes happening to the data and automatically update the UI HTML Elements. - The Shadow DOM is used to show CSS seperation from web components.
- This project is primarily to combination of different techniques combined and driven in vanillajs way.
- Clone this project and open in vscode and run with Live Server