
Welcome to the course! Let me introduce myself and give you a rough overview of this course, in this lecture.
What are "Web Components"? You understand them best, if you see them in action - so time for a quick web components + custom HTML elements demo.
We saw web components in action - what exactly are web components then? How did that demo work? Let's dive into the important theory in this lecture.
Learning alone is absolutely fine but finding learning partners might be a nice thing, too. Our learning community is a great place to learn and grow together - of course it's 100% free and optional!
We know what Web Components and Custom HTML Elements are - why would we use them? In this lecture, I'll give you some ideas!
Do web components replace Angular, React.js or Vue.js? Are custom HTML elements better than JavaScript frameworks? Let's explore that question in this lecture!
We got the theory out of the way - time to now understand what's in this course. Here's an overview of the course content and the order in which it is presented.
It's important to me to ensure that you're getting the most out of this course! So here are some tipps & tricks regarding how you should use the course content.
Refresh your knowledge of es6+ JavaScript features, including arrow functions, let and const, and array methods. See how we use modern JavaScript in this course, with a touch of TypeScript.
Discover let and const as modern JavaScript variables, replacing var and clarifying scope, with const used for values that never change and live jsbin examples.
Master arrow functions in JavaScript, including compact syntax, argument variations, and when to omit parentheses. Learn how they preserve this context at runtime and enable concise one-line returns.
Master modular javascript with exports and imports, using default and named exports, aliasing, and star imports, preparing code for browser compatibility.
learn the next generation JavaScript class syntax for web components, initializing properties directly in class, and defining methods as arrow functions to simplify this handling, with ES6 Babel.
Explore how the spread and rest operators, the three dots, copy arrays and objects, merge new properties, and collect function arguments into an array for processing.
Learn how array functions like map transform a numbers array into a doubleNum array by applying an arrow function to each element and returning the result.
Have a look at this lecture to get a good overview over the various next-gen JS features you'll encounter in this course.
Here's something we'll also use quite a bit in this course: Some JavaScript array functions.
Explore how to create custom HTML elements with vanilla JavaScript and understand the core web components concepts. Uncover the roles of shadow DOM, templates, and slots for encapsulated, reusable components.
Create your web component by defining a tooltip class that extends the HTML element, register it with customElements.define using a dash-separated tag name, and implement constructor logic with super.
Build and integrate custom web components by composing built-in HTML elements and tooltips, while understanding the lifecycle of custom elements as the browser renders them.
Learn to use the connectedCallback lifecycle method to safely access the DOM, move child-creation logic from the constructor, and render content for custom web components.
Add hover interactivity to a web component by listening to mouseenter and mouseleave to show and hide a tooltip, storing the tooltip in a class property like _tooltipContainer.
Style a web component by applying absolute positioning to the tooltip, making the host relative, adding a z-index, and using Shadow DOM and templates to prevent global style interference.
Attach an open shadow root to a custom component to isolate its DOM from the light DOM and render content through the shadow tree.
Use templates to define the base HTML structure of a custom element and bring back text between its tags. Clone template content into the shadow DOM with deep cloning.
Define a reusable web component by embedding the template in the JavaScript file, using shadow root innerHTML and template literals for a multi-line HTML string, preparing content for DOM mounting.
Learn how to define styles inside a web component's shadow DOM using style tags within the template or innerHTML, producing scoped CSS that does not affect the main DOM.
Master the basics of web components, including two creation approaches—extending a generic HTML element or a specific one like anchor—and the use of a constructor, shadow DOM, slots, and connectedCallback.
Dive into advanced basics of web components by exploring slots, reacting to attribute changes, and styling techniques to shape custom elements.
Explore how shadow DOM projection works with slots, showing how web components render light DOM content in the shadow DOM without moving the DOM node, clarified via Chrome DevTools.
Use the ::slotted selector inside the shadow DOM to style slotted content by a selector, such as the highlight class or a span, but only style the top-level slotted element.
Explore styling the host component with the :host-context selector and its function form to apply bold rules when the element sits inside a paragraph, under surrounding conditions.
Learn how to conditionally style web components with host selectors inStencil.js, using :host with conditions to apply a default background only when the custom element has the important class.
Apply host-context styling to custom elements with the host-context selector and its function form in parentheses to specify surrounding conditions like a paragraph, enabling bold font weight when inside.
Implement attributeChangedCallback in your tooltip web component to respond to text attribute changes; declare observedAttributes and log the attribute name, old value, and new value.
Listen to attribute changes and adjust the tooltip content by comparing old and new values and updating TooltipText when the text attribute changes.
In this lecture, use disconnectedCallback to clean up event listeners when a web component is removed, and store a class property like _tooltipIcon to manage cleanup.
Introduce a central render method to manage DOM updates in a web component. Use tooltipVisible to toggle the tooltipContainer in the shadow DOM via showTooltip and hideTooltip.
Wrap up the module by moving styling to the host selector and reinforce concepts like host, host with condition, slotted selectors, and css variables for themes.
Learn to build a custom uc-modal web component using shadow DOM, with a backdrop and modal panel, defined in modal.js and used in index.html.
Position the modal above the backdrop inside the shadow DOM with fixed placement, a higher z-index, top 15vh, left 25%, width 50%, a white background, and a drop shadow.
Build a modal with a header title, a main slot for content, and an actions area with cancel and confirm buttons, styled with flexbox, borders, and padding.
Explore opening a modal by reacting to the opened attribute with attributeChangedCallback and observedAttributes, and contrast with a CSS only approach using :host([opened]).
Expose a public open method on the modal component to show it from outside. A public isOpen property reflects state and enables external control for safe, single openings.
Explore using named slots in web components with stencil.js, including naming slots, targeting content with slot attributes, and styling slotted content via the slotted selector.
Explore named slots in web components and learn to access projected content with the slotchange event, assignedNodes, and slot properties in shadow and light DOM.
Learn to wire up the modal’s shadow dom buttons, close it with a hide method, update isOpen, and prepare to dispatch custom confirm and cancel events for the host app.
Learn how to create and dispatch a custom event in JavaScript using dispatchEvent with a new Event('cancel'), listen for it externally, and understand why it remains on the button.
Configure custom events by setting bubbles and composed to let events leave the shadow DOM, enabling outside listeners on the custom element or body.
Enable closing the modal by clicking the backdrop, adjust header styling with a bottom border and zero h1 margins, and implement a 0.3s CSS transition for slide-in and slide-out.
Build a complex web component using shadow DOM and slots, featuring a backdrop and a two-part modal. Explore attributes, custom events, and public properties and methods for external control.
Explore how to deploy your custom HTML elements, preview stencil.js as a helpful tool for building web components, and anticipate publishing libraries to npm later in the course.
Reuse the web component by importing its JavaScript file into HTML page in your app; Chrome, Firefox, and Safari support custom elements and shadow DOM, and Stencil.js helps with compatibility.
Explore browser support for web components, including custom elements and shadow DOM across Firefox, Chrome, Safari, Edge and Internet Explorer, and learn how polyfills and stencil.js ensure cross-browser compatibility.
Install NodeJS and npm to enable stencil, then initialize a new stencil project to build web components and run a development server with an index.html demo.
Stencil acts as a compiler for native web components, not a framework, turning TypeScript and JavaScript code into browser-ready components with automatic polyfills and older browser compatibility.
Introduces stencil.js workflow, showing how to author a tsx component in TypeScript with a render function and JSX, and build it to a dist web component that auto-updates the DOM.
Summarizes stencil advantages for building native web components with automatic polyfill loading, out-of-the-box browser compatibility, and an easier, condensed syntax that becomes clearer as you learn.
Dive into the basics of stencil.js, learning how to use its special syntax, JSX, and TypeScript to build web components.
Start a development server with npm start to preview components in memory, auto-reloading on changes and serving index.html at localhost:3333, while dist output remains unused.
Build a stencil web component named side drawer with side-drawer.tsx, using @component, a uc-side-drawer tag, and a render method returning jsx.
Configure the prop decorator to communicate with the component from outside via attributes or properties, and enable reflect to attr so the attribute updates as the property changes.
Explore slots in web components with stencil.js, including named slots, and learn to style slotted content from the light dom while configuring a side drawer header.
Learn how props combine with attributes in Stencil.js to control a side drawer, syncing the open property to the open attribute and reflecting changes for programmatic control via a button.
Add an x button to the side drawer and wire onCloseDrawer to close it, noting that props are immutable by default and can be mutable with reflect to attribute.
This lecture demonstrates building a two-tab toggle in a side drawer with navigation and contact tabs, styled with flexbox, equal button widths, and an active state for content switching.
Expose public methods in stencil web components by applying the method decorator, enabling outside calls to open a side drawer via the opened property and the public API.
Add a clickable backdrop to side drawer in stencil web components by returning an array of JSX elements and styling it with fixed positioning, opacity transition, and an opened attribute.
Wrap up stencil fundamentals by highlighting decorators, declarative templates, and dynamic rendering that auto-updates props and state. See how external methods and JSX-driven conditional content enable clean web components.
Explore advanced features of stencil.js, including the lifecycle of stencil components, emitting and listening to custom events, and writing more reactive components that adapt to changing circumstances.
Create a standalone Stencil stock price component that fetches the latest stock price from an open API, reacts to input changes, and displays the result using shadow dom.
Register for a free Alphavantage API key to fetch stock data. Render a symbol input and a price output, and handle form submit to fetch the latest price.
Implement a form submission in a stock price component by wiring an onFetchStockPrice method to the form's submit event, preventing default behavior and displaying 'submitted' before styling and API hookup.
Fetch stock data in stencil components using the fetch API, handle promises with then and catch, parse JSON, update state with the global quote price, and ensure correct this context.
Centralize the alphavantage API key in a global module and use it with template literals and the fetch API to fetch user data in stencil.js web components.
Learn how to fetch user-entered stock symbols using query selector or references, focusing on stencil's ref feature to access an input element directly, and comparing when to use each approach.
Use two-way binding to store user input in a stateful stock user input, update on each keystroke, and enable live validation that disables the button when input is empty.
Explore all lifecycle hooks in stencil, from componentWillLoad to componentDidUnload, and learn how each hook runs in a guaranteed order around loading, updating, and removing a web component.
Explore update lifecycle hooks to react to external stock symbol changes, fetch prices after render, and avoid extra network calls by comparing new and initial symbols.
Use stencil's watch decorator to react to stockSymbol changes and run fetchStockPrice when values change. Make stockSymbol mutable and reflect it to the attribute to keep the input in sync.
Create a new stock finder component in stencil.js, wire a search form to fetch stock symbols from alphavantage, and prepare to render results in the dom.
Reuse form styling from another component by applying the host selector, creating cohesive visuals, and set up shared styles before adding logic to display results below the input and button.
Learn to output a list of search results by mapping parsed data to objects with symbol and name, binding them to state, and rendering as an unordered list using TSX.
Emit a custom event when a list item is clicked using a Stencil.js event emitter named ucSymbolSelected, with a string symbol payload.
Learn to use the host data method in stencil to add a conditional error class on the host element when the input is invalid, enabling dynamic border color styling.
Manage a loading state in a web component to show a css spinner while fetching api data and disable actions during loading, reusing spinner across stock price and stock finder.
Create a reusable spinner web component withStencil.js, styling via spinner.css, and embed it into the stock finder component's loading state, using ucSpinner as a custom HTML element in TSX/JSX.
Apply CSS properties and custom CSS variables to style web components from outside the shadow DOM. Use tokens like color-primary, color-primary inverse, and color-primary highlight to unify the look.
Explore how to deploy, publish, and share web components across projects, and learn how to generate native web components and integrate them into different projects using stencil.js.
Configure stencil with a namespace and output targets, and apply bundles for automatic code splitting; learn how stencil loads only the required components, like spinner with stock price or finder.
Build and bundle web components with Stencil.js by running npm run build to generate dist files, then deploy and use them in web pages or React, Vue, or Angular projects.
Learn how to render web components in a Node.js project by serving a public/scripts folder with express.static, linking scripts, and running npm start to load the component on the server.
Publish your stencil project to npm by configuring package.json, creating an npm account, logging in, and running npm publish; add --access public to publish as a public package.
Install the component from npm with npm install --save, using a name like uc-components. Consider unpublished packages to protect sensitive code, and load front-end dependencies bundled by a build tool.
Integrate custom web components into an Angular app by enabling the custom elements schema and registering Stencil elements, then use lazy loading for on-demand components like uc-stock-price and uc-stock-finder.
Learn how to use web components in a React app by importing uc-components, registering custom elements, and rendering with lowercase tags like us-stock-price, while exploring lazy loading and code splitting.
Learn to integrate Stencil web components in a Vue app by installing and loading uc-components, defining custom elements, and enabling lazy loading with dynamic bundles in development.
Explore stencil.js web components across browsers with conditional polyfills, noting Edge and Internet Explorer 11 limitations, and patch shadow DOM and CSS variables via a custom polyfill in index.html.
Explore web components andStencil.js by building projects, exporting dist output, and publishing to npm, with integration in Angular, React, and Vue apps.
Encourage learners to apply what they learned in day-to-day projects by building demo projects, reinforcing the course foundation, and pursuing more courses to deepen proficiency.
Let's face it: You got hundreds of HTML tags to choose from but some really helpful ones (<tabs>, <side-drawer>, <modal>, ...) are missing.
What if you could build your own HTML tags?
Without frameworks like Angular, libraries like React or expert JavaScript knowledge in general. Just with a magic, native-JavaScript feature called "Web Components" (or "custom HTML elements").
Web Components are a combination of various specifications that are baked into the browser. Getting started with these features is a breeze and you'll quickly be able to build your own powerful and re-usable (even across projects!) custom HTML elements.
Such custom elements don't replace Angular, React or Vue though - instead you can easily use them in ANY web project, including projects using such frameworks and libraries.
In this course, you'll learn this from scratch.
But we won't stop there. Whilst getting started is fairly easy, more complex components will be more difficult to create. Stencil.js is a tool that makes the creation of such native web components much easier by using modern features like TypeScript and JSX (don't know that? No worries, you'll learn it in the course!).
In detail, in this course you will learn:
how to build re-usable, lightweight custom HTML elements with native browser features
how to build web components of all complexities - from a simple tooltip to modals or side drawers
how to pass data into your own web components and use it there
how to emit your own custom events which you can listen to in JavaScript
how to use the Shadow DOM to scope your CSS styles to your custom elements
how to use Stencil.js to get a much easier development workflow
how to use the many features Stencil.js provides to build native web components way more efficiently
how to deploy/ re-use your own web components in ANY project using ANY JavaScript framework like Angular, React or Vue (or none at all!)
Prerequisites:
Basic JavaScript knowledge is a must-have
ES6 JavaScript knowledge (const, let, classes, ...) is strongly recommended but not strictly required - a brief refresher is provided as part of the course
NO JavaScript framework knowledge (e.g. Angular, React, Vue) is required
NO TypeScript or JSX knowledge is required
Let's dive into this exciting technology together!