Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web Components

Web Components

Avatar for Abdalla Nayer

Abdalla Nayer

April 05, 2018

Other Decks in Programming

Transcript

  1. About Me Full Stack Developer Cross platform mobile developer Vezeeta

    eme international Cross platform mobile developer Intellisc VIS Sr. Frontend Developer Sr. Frontend Developer Sr. Frontend Developer https://www.linkedin.com/in/abdalla-nayer-24b65175/
  2. AGENDA •What are Components? •Component Based Architecture •Web components •Demo

    •Web components VS the world •Live Examples •Web components Libraries •Questions
  3. What are Components? •Definition A component is an independent software

    unit that has a clear function, it can be used to create a software system through communication with other components •Characteristics 1- Independent 2- Composable 3- Small 4- Reusable 5- Encapsulated 6- Testable
  4. Component based architecture • Component based architecture is the process

    for building a system based on components • Let’s try to divide this website into components
  5. Component based architecture cont’d •Benefits •Accelerates development •Increases productivity •Ensures

    maintainability •Ensures Extendibility •Ensures reusability •Ensures replaceability
  6. Web Components • Web components are a set of web

    platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps. Custom components and widgets build on the Web Component standards, will work across modern browsers, and can be used with any JavaScript library or framework that works with HTML. • Web components are based on existing web standards. Features to support web components are currently being added to the HTML and DOM specs, letting web developers easily extend HTML with new elements with encapsulated styling and custom behavior.
  7. Web Components Cont’d • The 4 main pillars of Web

    components 1.Custom Elements 2.Shadow DOM 3.HTML <template>/<slot> 4.HTML Imports (abandoned feature) <link rel="import" href="foo.html"> • Attributes and Properties • Lifecycles • Custom Events
  8. 1. Custom Elements Web Components Cont’d • tag name must

    contain - • same tag cannot be registered more than once. • custom elements cannot be self-closing
  9. Web Components Cont’d • What we have achieved till now

    is the below Flattened DOM tree Shadow DOM and Light DOM
  10. Web Components Cont’d • Lifecycles • constructor • connectedCallback •

    disconnectedCallback • attributeChangedCallback • adoptedCallback
  11. Web Components Cont’d • Custom Events • Events donot propagate

    out of the shadow DOM by default unless used the composed: true
  12. Web components VS the world Web components are not here

    to replace frameworks or libraries (angular, react, vue…), they are here to work with them to enrich the web experience. Web components VS and the world
  13. Live Examples • EA Sports • https://www.ea.com/games/library/sports • https://www.youtube.com/watch?v=FJ2KEvzlyo4 •

    Youtube • https://www.youtube.com • https://www.youtube.com/watch?v=tNulrEbTQf8
  14. Web Components Libraries • Bosonic https://bosonic.github.io/ • Polymer https://www.polymer-project.org/ •

    X-Tag https://x-tag.github.io/ • Stencil https://stenciljs.com/ • Pollyfills https://www.npmjs.com/package/@webcomponents/webco mponentsjs