├── .gitignore ├── Chapter01 ├── Custom Elements │ ├── Add Smiley │ │ └── index.html │ ├── Hello World │ │ └── index.html │ └── Smiley Emoji │ │ └── index.html ├── Modules │ ├── Add Number with Random Number Generator and export │ │ ├── addNumber.js │ │ └── index.html │ ├── Add Number with Random Number Generator │ │ ├── addNumber.js │ │ └── index.html │ ├── Add Number │ │ └── index.html │ ├── Calc and export │ │ ├── calc.js │ │ └── index.html │ ├── RevampedParagraph │ │ ├── index.html │ │ └── revampedParagraph.js │ └── StudentPage │ │ ├── InformationBanner.js │ │ ├── StudentAttendanceTable.js │ │ ├── TimeSlot.js │ │ ├── index.html │ │ └── student.json ├── Shadow DOM │ ├── Hello World with Shadow DOM │ │ └── index.html │ ├── Simple Shadow DOM 2 │ │ └── index.html │ └── Simple Shadow DOM │ │ └── index.html └── Templates │ ├── Hello World Custom Element with Shadow DOM and Template │ └── index.html │ ├── Small Template Example With Shadow DOM │ └── index.html │ └── Small Template Example │ └── index.html ├── Chapter02 ├── attributeChangedCallback │ ├── MyName.js │ └── index.html ├── connectedCallbackButtonExample │ ├── CustomButton.js │ └── index.html ├── connectedCallbackStudentExample │ ├── StudentAttendanceTable.js │ ├── index.html │ └── student.json └── disconnectedCallbackButtonExample │ ├── CustomButton.js │ └── index.html ├── Chapter03 ├── Accessibility for web components │ └── Header Image component │ │ ├── HeaderImage.js │ │ └── index.html └── Styling Web Component │ ├── company header component with shadow dom │ ├── CompanyHeader.js │ ├── icon.png │ ├── index.html │ └── newicon.jpeg │ ├── company header component │ ├── CompanyHeader.js │ ├── icon.png │ ├── index.html │ └── newicon.jpeg │ └── company-login │ ├── CompanyLogin.js │ └── index.html ├── Chapter04 ├── company-header │ ├── CompanyHeader.js │ ├── icon.png │ ├── index.html │ └── newicon.jpeg ├── my-article │ ├── MyArticle.js │ ├── icon.png │ ├── index.html │ └── newicon.jpeg └── profile-info │ ├── Demo │ ├── index.html │ └── john-doe.png │ ├── LICENSE │ ├── ProfileInfo.js │ ├── README.md │ └── package.json ├── Chapter05 ├── attributes and props │ ├── StudentList.js │ └── index.html ├── event handling │ ├── CustomClicker.js │ └── index.html └── online-checker │ ├── OnlineChecker.js │ └── index.html ├── Chapter06 ├── Game Information App │ ├── README.md │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── components │ │ │ ├── custom-header │ │ │ │ └── index.js │ │ │ ├── gif-cover │ │ │ │ └── index.js │ │ │ ├── my-app │ │ │ │ └── index.js │ │ │ ├── search-bar │ │ │ │ └── index.js │ │ │ ├── search-container │ │ │ │ └── index.js │ │ │ ├── show-random │ │ │ │ └── index.js │ │ │ └── show-trending │ │ │ │ └── index.js │ │ ├── index.js │ │ └── styles.scss │ ├── webpack.config.js │ └── webpack.dev.server.js └── Starter Project │ ├── README.md │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── src │ ├── components │ │ └── my-app │ │ │ └── index.js │ ├── index.js │ └── styles.scss │ ├── webpack.config.js │ └── webpack.dev.server.js ├── Chapter07 ├── Polymer │ ├── hello-string.js │ ├── hello-world.js │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── second-element.js │ └── student-name.js └── Stencil │ ├── hello-world │ ├── .editorconfig │ ├── .gitignore │ ├── LICENSE │ ├── package-lock.json │ ├── package.json │ ├── readme.md │ ├── src │ │ ├── components.d.ts │ │ ├── components │ │ │ ├── hello-world │ │ │ │ ├── hello-world.css │ │ │ │ └── hello-world.tsx │ │ │ └── my-component │ │ │ │ ├── my-component.css │ │ │ │ ├── my-component.e2e.ts │ │ │ │ ├── my-component.tsx │ │ │ │ └── readme.md │ │ ├── index.html │ │ ├── index.ts │ │ └── utils │ │ │ ├── utils.spec.ts │ │ │ └── utils.ts │ ├── stencil.config.ts │ └── tsconfig.json │ └── student-list │ ├── .editorconfig │ ├── .gitignore │ ├── LICENSE │ ├── package-lock.json │ ├── package.json │ ├── readme.md │ ├── src │ ├── components.d.ts │ ├── components │ │ ├── student-list │ │ │ ├── student-list.css │ │ │ └── student-list.tsx │ │ └── student-name │ │ │ ├── student-name.css │ │ │ └── student-name.tsx │ ├── index.html │ ├── index.ts │ └── utils │ │ ├── utils.spec.ts │ │ └── utils.ts │ ├── stencil.config.ts │ └── tsconfig.json ├── Chapter08 ├── Angular │ └── my-app │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── README.md │ │ ├── angular.json │ │ ├── e2e │ │ ├── protractor.conf.js │ │ ├── src │ │ │ ├── app.e2e-spec.ts │ │ │ └── app.po.ts │ │ └── tsconfig.e2e.json │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ ├── app │ │ │ ├── app.component.css │ │ │ ├── app.component.html │ │ │ ├── app.component.spec.ts │ │ │ ├── app.component.ts │ │ │ ├── app.module.ts │ │ │ ├── main-body │ │ │ │ ├── main-body.component.css │ │ │ │ ├── main-body.component.html │ │ │ │ ├── main-body.component.spec.ts │ │ │ │ └── main-body.component.ts │ │ │ └── web-components │ │ │ │ └── header-image │ │ │ │ ├── header-image.js │ │ │ │ └── index.html │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── browserslist │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── karma.conf.js │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── styles.css │ │ ├── test.ts │ │ ├── tsconfig.app.json │ │ ├── tsconfig.spec.json │ │ └── tslint.json │ │ ├── tsconfig.json │ │ └── tslint.json ├── React │ └── my-app │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ └── manifest.json │ │ └── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ ├── main-body │ │ └── main-body.js │ │ ├── serviceWorker.js │ │ └── web-components │ │ └── header-image │ │ ├── header-image.js │ │ └── index.html ├── Vue │ ├── app.js │ ├── index.html │ ├── main-body.js │ └── web-components │ │ └── header-image │ │ ├── header-image.js │ │ └── index.html └── header-image │ ├── header-image.js │ └── index.html ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | 24 | # nyc test coverage 25 | .nyc_output 26 | 27 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 28 | .grunt 29 | 30 | # Bower dependency directory (https://bower.io/) 31 | bower_components 32 | 33 | # node-waf configuration 34 | .lock-wscript 35 | 36 | # Compiled binary addons (https://nodejs.org/api/addons.html) 37 | build/Release 38 | 39 | # Dependency directories 40 | node_modules/ 41 | jspm_packages/ 42 | 43 | # TypeScript v1 declaration files 44 | typings/ 45 | 46 | # Optional npm cache directory 47 | .npm 48 | 49 | # Optional eslint cache 50 | .eslintcache 51 | 52 | # Optional REPL history 53 | .node_repl_history 54 | 55 | # Output of 'npm pack' 56 | *.tgz 57 | 58 | # Yarn Integrity file 59 | .yarn-integrity 60 | 61 | # dotenv environment variables file 62 | .env 63 | .env.test 64 | 65 | # parcel-bundler cache (https://parceljs.org/) 66 | .cache 67 | 68 | # next.js build output 69 | .next 70 | 71 | # nuxt.js build output 72 | .nuxt 73 | 74 | # vuepress build output 75 | .vuepress/dist 76 | 77 | # Serverless directories 78 | .serverless/ 79 | 80 | # FuseBox cache 81 | .fusebox/ 82 | 83 | # DynamoDB Local files 84 | .dynamodb/ 85 | 86 | # Mac OS Specific 87 | *.DS_Store 88 | 89 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 90 | 91 | # dependencies 92 | */node_modules 93 | */.pnp 94 | *.pnp.js 95 | 96 | # testing 97 | */coverage 98 | 99 | # production 100 | */build 101 | 102 | # misc 103 | *.DS_Store 104 | *.env.local 105 | *.env.development.local 106 | *.env.test.local 107 | *.env.production.local 108 | 109 | npm-debug.log* 110 | *yarn-debug.log* 111 | *yarn-error.log* 112 | -------------------------------------------------------------------------------- /Chapter01/Custom Elements/Add Smiley/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | Hello World 8 | 9 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Chapter01/Custom Elements/Hello World/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Placeholder for Random Number
7 | 8 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Chapter01/Modules/Add Number with Random Number Generator/addNumber.js: -------------------------------------------------------------------------------- 1 | class AddNumber { 2 | constructor() { 3 | // let's set the inner text of 4 | // this element to a smiley 5 | document.querySelector('p').innerText = randomNumberGenerator(); 6 | } 7 | } 8 | 9 | function randomNumberGenerator() { 10 | return Math.random(); 11 | } 12 | 13 | new AddNumber(); 14 | -------------------------------------------------------------------------------- /Chapter01/Modules/Add Number with Random Number Generator/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |Placeholder for Random Number
7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Chapter01/Modules/Add Number/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |Placeholder for Random Number
7 | 8 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Chapter01/Modules/Calc and export/calc.js: -------------------------------------------------------------------------------- 1 | export function add(a, b) { 2 | return a + b; 3 | } 4 | 5 | export function subtract(a, b) { 6 | return a - b; 7 | } 8 | -------------------------------------------------------------------------------- /Chapter01/Modules/Calc and export/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |Placeholder for Random Number
7 | 8 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Chapter01/Modules/RevampedParagraph/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This is the default paragraph inside 33 | the revamped-paragraph element
34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Chapter01/Modules/RevampedParagraph/revampedParagraph.js: -------------------------------------------------------------------------------- 1 | export default class RevampedParagraph extends HTMLElement { 2 | constructor() { 3 | super(); 4 | 5 | // temaplte ref and content 6 | let templateReference = document.querySelector('#revamped-paragraph-template'); 7 | let template = templateReference.content; 8 | 9 | // adding html from template 10 | this.append(template.cloneNode(true)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Chapter01/Modules/StudentPage/InformationBanner.js: -------------------------------------------------------------------------------- 1 | export default class InformationBanner extends HTMLElement { 2 | constructor() { 3 | super(); 4 | 5 | // we simply called another method 6 | // inside the class 7 | this.render(); 8 | } 9 | 10 | render() { 11 | 12 | // Get the reference to the template 13 | let templateReference = document.querySelector('#information-banner-template'); 14 | 15 | // Get the content node 16 | let templateContent = templateReference.content; 17 | 18 | let shadowRoot = this.attachShadow({mode: 'open'}); 19 | 20 | // add the template text to the shadow root 21 | shadowRoot.append(templateContent.cloneNode(true)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Chapter01/Modules/StudentPage/StudentAttendanceTable.js: -------------------------------------------------------------------------------- 1 | export default class StudentAttendanceTable extends HTMLElement { 2 | constructor() { 3 | super(); 4 | 5 | // we simply called another method 6 | // inside the class 7 | this.render(); 8 | } 9 | 10 | render() { 11 | // let put our loading text first 12 | this.innerText = this.getLoadingText(); 13 | 14 | // let's start our fetch call 15 | this.getStudentList(); 16 | } 17 | 18 | getStudentList() { 19 | // lets use fetch api 20 | // https://developer.mozilla.org/en-US/docs/Web 21 | // /API/Fetch_API/Using_Fetch 22 | fetch('./student.json') 23 | .then(response => { 24 | 25 | // converts response to json 26 | return response.json(); 27 | 28 | }) 29 | .then(jsonData => { 30 | this.generateTable(jsonData); 31 | }) 32 | .catch(e => { 33 | 34 | // lets set the error message for 35 | // the user 36 | this.innerText = this.getErrorText(); 37 | 38 | // lets print out the error 39 | // message for the devs 40 | console.log(e); 41 | }); 42 | 43 | } 44 | 45 | generateTable(names) { 46 | // lets loop through names 47 | // with the help of map 48 | let rows = names.map((data, index) => { 49 | return this.getTableRow(index, data.name); 50 | }); 51 | 52 | // creating the table 53 | let table = document.createElement('table'); 54 | table.innerHTML = rows.join(''); 55 | 56 | // setting the table as html for this component 57 | this.appendHTMLToShadowDOM(table); 58 | } 59 | 60 | getTableRow(index, name) { 61 | let tableRow = `Just Some Random Street
41 |Town
42 |State - 123456
43 |Hello Templates
31 |This is a small template
32 |Hello Templates
41 |This is a small template
42 |Hello Templates
31 |This is a small template
32 |This is a demo paragraph
24 |This is another demo paragraph
25 |Try Searching for a tag in the search bar
56 |Hello, [[name]]
20 | `; 21 | } 22 | } 23 | 24 | customElements.define('hello-string', HelloString); 25 | -------------------------------------------------------------------------------- /Chapter07/Polymer/hello-world.js: -------------------------------------------------------------------------------- 1 | import { PolymerElement, html } from '@polymer/polymer/polymer-element.js'; 2 | import './second-element.js'; 3 | 4 | class HelloWorld extends PolymerElement { 5 | constructor() { 6 | super(); 7 | } 8 | static get template() { 9 | return html` 10 |Hello World
11 |This is the second element
15 | `; 16 | } 17 | } 18 | 19 | customElements.define('second-element', SecondElement); 20 | -------------------------------------------------------------------------------- /Chapter07/Polymer/student-name.js: -------------------------------------------------------------------------------- 1 | import { PolymerElement, html } from '@polymer/polymer/polymer-element.js'; 2 | import './hello-string.js'; 3 | 4 | class StudentName extends PolymerElement { 5 | constructor() { 6 | super(); 7 | } 8 | 9 | static get properties() { 10 | return { 11 | name: { 12 | type: String, 13 | value: 'John Doe' 14 | } 15 | }; 16 | } 17 | 18 | static get template() { 19 | return html` 20 |2 | main-body works! 3 |
4 |
12 | Edit src/App.js
and save to reload.
13 |
This is the main body
21 |This is the main body
7 |