Instant download (Ebook) Fullstack Web Components: Complete Guide to Building UI Libraries with Web Components by Steve Belovarich; (edited by) Nate Murray ISBN B0BGYPWQVR pdf all chapter
Instant download (Ebook) Fullstack Web Components: Complete Guide to Building UI Libraries with Web Components by Steve Belovarich; (edited by) Nate Murray ISBN B0BGYPWQVR pdf all chapter
com
OR CLICK HERE
DOWLOAD EBOOK
ebooknice.com
ebooknice.com
ebooknice.com
ebooknice.com
(Ebook) Fullstack Node.js: The Complete Guide to Building
Production Apps with Node.js by Davit Guttman; Nate Murray
(ed) ISBN 08671X
https://ebooknice.com/product/fullstack-node-js-the-complete-guide-to-
building-production-apps-with-node-js-11798290
ebooknice.com
ebooknice.com
ebooknice.com
ebooknice.com
ebooknice.com
Fullstack Web Components
The Complete Guide to Building UI Libraries and Web Applications with
Web Components
© 2020 Fullstack.io
Published by \newline
Th
tt
Th
tt
Contents
Book Revision . . . . . . . . . . . . . . . . . . . . . . . . . 1
Join Our Discord . . . . . . . . . . . . . . . . . . . . . . . 1
Bug Reports . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Be notified of updates via Twitter . . . . . . . . . . . . . 1
We’d love to hear from you! . . . . . . . . . . . . . . . . . 1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
About the author . . . . . . . . . . . . . . . . . . . . . . . 3
Web Components . . . . . . . . . . . . . . . . . . . . . . . 4
About this book . . . . . . . . . . . . . . . . . . . . . . . . 5
Who is this book for . . . . . . . . . . . . . . . . . . . . . 5
Introduction to Web Components . . . . . . . . . . . . . 6
What are Web Components? . . . . . . . . . . . . . . . . 11
The many uses of Web Components . . . . . . . . . . . . 17
Implementing a design system with Web Components . 19
Conventions used in this Book . . . . . . . . . . . . . . . 20
Storybook . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Application . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Cypress . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Storyshots . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Monorepo . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Setting up the development environment . . . . . . . . . 25
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
CONTENTS
Part One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Part One . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Specification . . . . . . . . . . . . . . . . . . . . . . . . . 32
What you will learn . . . . . . . . . . . . . . . . . . . . . 33
Developing in Part One . . . . . . . . . . . . . . . . . . . 34
Micro-library . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Chapter Four . . . . . . . . . . . . . . . . . . . . . . . . . 186
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . 186
What is a micro-library? . . . . . . . . . . . . . . . . . . . 190
Coding in a monorepo . . . . . . . . . . . . . . . . . . . . 190
What you will build . . . . . . . . . . . . . . . . . . . . . 192
What you will learn . . . . . . . . . . . . . . . . . . . . . 192
Acceptance criteria . . . . . . . . . . . . . . . . . . . . . . 192
Getting started . . . . . . . . . . . . . . . . . . . . . . . . 193
CONTENTS
DialogStack . . . . . . . . . . . . . . . . . . . . . . . . . . 362
Testing Dialogs . . . . . . . . . . . . . . . . . . . . . . . . 372
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
Revision 1 (04-04-2022) . . . . . . . . . . . . . . . . . . . . 560
Revision 2 (12-06-2022) . . . . . . . . . . . . . . . . . . . . 560
CONTENTS 1
Book Revision
Revision 1 - Initial pre-release of the book - 04-04-2022
Revision 2 - Change book cover - 12-06-2022
Bug Reports
If you’d like to report any bugs, typos, or suggestions just email us
at: [email protected].
Foreword
This is a book about Web Components. UI components are a
common pattern in many front end web development frameworks
like Angular, React or Vue, but coding user interfaces in the context
of a framework usually makes sharing those components difficult.
Angular components can’t be easily loaded in the context of React,
for instance. The framework is a closed system.
If you can move past the framework, and possibly enjoy the
simplification and standardization offered by web specifications,
coding with Web Components can be quite rewarding. Working
directly with specifications opens up a world once obscured by
the framework. The web platform is yours to explore and find
interesting ways to utilize parts of HTML, CSS, and JavaScript. By
using web specifications to code UI components you can achieve
extraordinary results. When used responsibly, adopting Web Com-
ponents as your UI component pattern can lead to stellar perfor-
mance, compliance with accessibility standards, and reusability.
At enterprise corporations it can be rather costly to support several
development teams. One way to reduce operational overhead is
to standardize UI components and reuse them across a software
product. This cuts down on teams “reinventing the wheel”. I’ve
witnessed teams struggle with user interface development at sev-
eral companies. It can be quite difficult to coordinate the use
Introduction 3
Web Components
Before the set of technologies known as Web Components were
available engineers had to select an opinionated JavaScript frame-
work to abstract user interfaces into “components”. Web Com-
ponents are interoperable with virtually any JavaScript library
or framework because they are developed using only browser
specifications. The lifespan of a user interface component built with
Web Components can be much greater than a component built with
a library since browser specifications exist for a very long time.
Web Components can have dynamic templates, handle complex
form behaviors, even inherit characteristics of familiar HTML
elements like <button> or <table>. By coding a UI library with
Web Components, you can ensure the components have a farther
reach than components only compatible with a specific library
or framework. Depending on implementation, components coded
with Web Components specifications can out perform framework-
based components as well, due to the lack of dependencies and
overhead inherit in JavaScript frameworks.
Introduction 5
24 </section>
25 <footer>
26 <slot name="footer"></slot>
27 </footer>
28 `;
29 shadowRoot.appendChild(template.content.cloneNode(tru\
30 e));
31 }
32 }
33 customElements.define('in-card', CardComponent);
Custom elements
element attributes and manage content and styling for the new
element’s template. Custom elements behave like any other HTML
element, with some syntactical sugar that promotes standardization
across any custom element behavior.
There are three different types of custom elements: autonomous
custom elements, customized built-in elements, and form-associ-
ated custom elements.
hooks into form validation. This means you can still encapsulate a
form control’s template, while exposing the validity of the control
to the parent HTMLFormElement. Form-associated custom elements
open the door for the creation of truly customized user experiences
that participate in HTML forms. Instead of merely relying on
traditional form elements, it’s now possible to make your own.
In the first part of this book, we’ll investigate the similarities and
differences between the different types of custom elements and see
how they work together to provide complex, reusable components.
CustomElementRegistry
This interface on the window.customElements property provides
methods for registering custom elements and querying registered
elements. Every custom element must be registered with the
CustomElementRegistry through a declarative syntax.
Shadow DOM
Shadow DOM is a browser technology that provides encapsulation
for a HTML element, isolating the HTML element’s template from
the rest of DOM. When using Shadow DOM with custom elements,
you can isolate <style> and <script> within the ShadowRoot⁷:
the root node of a DOM substructure rendered outside the scope
of DOM. The top level element that employs Shadow DOM is
considered the host element. The ShadowRoot is attached to the
host element. In contrast to Shadow DOM, anything outside of the
shadow boundary in the global scope of the document is considered
Light DOM.
When you query for an element on the document using
document.querySelector or similar method, you are essentially
querying the entire document because the Document Object Model
⁷https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot
Introduction 15
HTML Template
Standalone widgets
Sometimes you need to code a standalone user interface that
shouldn’t interact with the rest of the page and needs to work on
several different sites. It doesn’t make sense to use a JavaScript
framework because you incur the cost of loading a dependency that
may be larger in filesize than your implementation.
⁸https://chromestatus.com/metrics/feature/popularity#CustomElementRegistryDefine
Introduction 18
Static websites
UI Library
Tokens
Components
Layouts
Figma
variable:
1 color: var(--color-red-300);
Similarly, CSS variables for sizing, border radius, font, icons and
box shadow are provided on the global stylesheet found in sr-
c/style/style.css. You may reference these CSS variables when
styling each UI component.
Storybook
The main development environment for a considerable portion of
this book is Storybook¹⁰, “an open source tool for building UI
components and pages in isolation.”
Application
In the third part of this book, you transition from developing user
interface components to developing with those components in the
context of a web application. When developing the application,
you’ll change up the local environment to a custom Webpack server
and only use Storybook when necessary.
The user can view or edit the contact list. User interfaces found in
the application are developed in Storybook first, exported from a
UI library package, then imported into the application source code.
Cypress
Cypress¹¹ is a test runner you’ll use to write end-to-end tests for
each UI component.
Storyshots
Storyshots¹² is a Storybook addon you’ll use to generate automatic
visual snapshots for each UI component.
Monorepo
When developing against the content in this book, you’ll be work-
ing in a monorepo built with lerna¹³. Lerna allows you to manage
multiple projects in the same repository. Those projects are defined
as:
Naming
• Class names are prefixed to avoid collisions with other UI
component libraries.
• File names are in kebab-case.
Prerequisites
The following tools should be installed prior to starting develop-
ment.
Terminal application
Which Terminal you use depends on your system. MacOS and
Linux systems come with the Terminal application. For Windows
Introduction 26
git
Changes to the codebase are tracked via git. git is a version control
system that allows projects like this one to track changes across the
codebase effectively. If you have little or no experience with git,
don’t worry. Each chapter clearly demonstrates the git commands
you’ll need to run to navigate between changes. git is installed
differently depending on your system.
• Mac¹⁶
• Windows¹⁷
• Linux¹⁸
NodeJS
JavaScript IDE
To actually code the various components and application in this
book you’ll need an IDE (integrated development environment).
There are many free IDE, so don’t feel like you need to spend a ton
of money on one. A few popular IDE are listed below. Download
and install your preferred application for JavaScript development.
Once you have all of the above tools installed on your system,
you’re ready to clone the git repository, install project dependen-
cies, and run the development server.
GitHub
The repository for this book is found on GitHub. If you don’t
already have a GitHub account, signup for a new account²⁷. If
you’ve never used GitHub before on your machine, you’ll need to
²¹https://github.com/nvm-sh/nvm
²²https://github.com/nvm-sh/nvm#installing-and-updating
²³https://code.visualstudio.com/
²⁴https://nova.app/
²⁵https://www.jetbrains.com/webstorm/
²⁶https://atom.io/
²⁷https://github.com/signup
Introduction 28
1 cd fullstack-web-components
There are times you may need to update your local repository from
the upstream repository, mainly to uptake dependency upgrades or
new content. Further instructions for maintaining your local fork
of the repository are found in the README.md³¹.
Yarn
²⁸https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-
in-git
²⁹https://docs.github.com/en/get-started/quickstart/set-up-git
³⁰https://github.com/readymade-ui/fullstack-web-components
³¹https://github.com/readymade-ui/fullstack-web-components
³²https://yarnpkg.com/
Introduction 29
Once yarn is installed you can install project dependencies with the
yarn command.
1 yarn
Storybook
After project dependencies are installed with yarn, run the
storybook script to start up the local Storybook development
environment.
1 yarn storybook
Summary
Through the practical exercises in this book, you’ll learn how to
code user interfaces that are interoperable, reusable, accessible,
portable and require zero dependencies. The goal is to mirror best
practices at enterprise corporations that you can bring into your
own professional development.
In the final chapter of this book, we’ll summarize what was learned
and look to the future of Web Component development.
In the next chapter Getting To Know Custom Elements, you will
learn the complete development lifecycle of an autonomous custom
element.
Part One
Part One
Specification
In Part One of this book we’ll explore several Web Components
specifications by developing the UI components that make up a
login form. This login user interface will be used in Part Three so
users can authenticate with the application.
Part One 33
Introduction
You can make completely customized HTML elements with au-
tonomous custom elements, so it can be daunting to know where to
start. In this exercise, autonomous custom elements are highlighted
for what they do best: provide a means to bind template encapsula-
tion provided by Shadow DOM with a unique HTML tag and then
reuse the custom element throughout DOM.
Autonomous custom elements are the most ubiquitous of the three
types of custom elements due to their compatibility in all major
evergreen browsers including Apple Safari, Google Chrome, Mi-
crosoft Edge, and Mozilla Firefox. When building out a UI library,
you’ll possibly find yourself coding with autonomous custom ele-
ments the most because of their utility.
In addition to autonomous custom elements and Shadow DOM,
we’ll make use of HTML templates and CSS variables in this
chapter.
Fig. 62.
Fig. 63.
Fig. 64.
Winklers Löschpapierprüfer.
Dr. K l e m m[67] hat für die Abstufung der Löschpapiere nach ihrer
Saugfähigkeit folgende Einteilung in Vorschlag gebracht:
Saughöhe nach 10
Saugfähigkeit.
Min.
ungenügen
weniger als 20 mm
d
20–40 mm schwach
41–60 „ mittel
61–90 „ groß
mehr als 90 mm s e h r g r o ß.
In Verbraucherkreisen zeigt sich vielfach eine besondere Vorliebe
für ausländische, namentlich englische Löschpapiere, die sachlich
nicht begründet ist. Zahlreiche Versuche[68] haben gezeigt, daß man
nicht nach ausländischen Erzeugnissen zu greifen braucht, um einer
großen Löschfähigkeit sicher zu sein; es gibt zur Genüge deutsche
Fabrikate, die den höchsten in dieser Hinsicht zu stellenden
Anforderungen genügen.
Versuchsausführung.
Aus dem zu prüfenden Papier werden zunächst kreisrunde Stücke
von etwa 5 cm Durchmesser, wenn möglich je eins aus 10
verschiedenen Bogen, entnommen. Man entfernt dann E von F, stellt
D so, daß durch R kein Wasser abfließen kann, öffnet H und gießt
durch T d e s t i l l i e r t e s , v o r d e m G e b r a u c h s t a r k
a u s g e k o c h t e s W a s s e r von etwa 20° C. in G; nach beendigter
Füllung wird H wieder geschlossen.
Dann wird D so gestellt, daß langsam Wasser in den unteren Teil
des Filtrierzylinders tritt; ist dieser gefüllt und zwar so weit, daß die
Wasserkuppe über den oberen Rand von F hervorragt, so stellt man
den Wasserzufluß bei D ab und legt eins der 10 Blätter auf den
abgeflachten Rand von F; hierauf wird E aufgesetzt, fest auf F
geschraubt und dann durch Drehen von D die Verbindung von G mit
F wieder hergestellt. Das Wasser dringt nun durch das Papier, füllt E
und läuft dann durch A in den Kolben K. Man kann nun bestimmen,
innerhalb welcher Zeit eine bestimmte Menge Wasser (z. B. 100
ccm) durch das Papier hindurch geht.
Fig. 65.
Herzbergs Filtrierpapierprüfer.
Der Druck, unter dem das Ausfließen erfolgt, wird bedingt durch
die Entfernung der unteren Öffnung des Trichters T von dem
Wasserspiegel in E; durch Verschieben von T kann man also den
Druck beliebig einstellen.
In der Versuchsanstalt wird bei Ausführung amtlicher Prüfungen
stets mit einer Druckhöhe von 50 mm gearbeitet; die Abmessungen
des Filtrierzylinders sind so gewählt, daß bei dem Filtrierpapier eine
wirksame Fläche von 10 qcm abgegrenzt wird. Die Durchlaufzeit von
100 ccm wird in Sekunden bestimmt; als Endergebnis wird diejenige
Wassermenge angegeben, die in einer Minute bei einem
Wasserdruck von 50 mm und einer Wasserwärme von 20° C. durch
100 qcm Papier läuft.
Mit Hilfe des Filtrierapparates kann man auch die Festigkeit des
Filtrierpapiers im nassen Zustande feststellen, indem man durch
Höherziehen des Trichterrohres T den Wasserdruck so lange steigert,
bis das eingespannte Papier durchreißt.
Um einen Überblick über die Filtriergeschwindigkeit der im
Handel vorkommenden Filtrierpapiersorten für analytische Zwecke zu
gewinnen, wurden 30 verschiedene Proben aufgekauft und in
geschilderter Weise geprüft. Die in der Minute durchlaufende
Wassermenge schwankte von 23 ccm bis zu 760 ccm; die Verteilung
innerhalb dieser Grenzen zeigt die nachfolgende Zusammenstellung.
§ 1.
Ta b e l l e I.
S t o f f k l a s s e I b i s I V.
Klasse I. Papiere, nur aus Hadern, mit nicht mehr als 3% Asche.
Klasse II. Papiere aus Hadern, mit Zusatz bis zu 25% von Cellulose, Strohstoff,
Esparto, aber frei von Holzschliff, mit nicht mehr als 5% Asche.
Klasse III. Papiere von beliebiger Stoffzusammensetzung, jedoch ohne Zusatz
von Holzschliff, mit nicht mehr als 15% Asche.
Klasse IV. Papiere von beliebiger Stoffzusammensetzung und mit beliebigem
Aschengehalt.
Ta b e l l e I I.
F e s t i g k e i t s k l a s s e 1–6.
Skala
Klasse 1 2 3 4 5 6 für den Widerstand
gegen Zerknittern
a Mittlere 0) außerordentlich
Reißlänge in gering,
Metern
mindestens 6000 5000 4000 3000 2000 1000
b Mittlere 1) sehr gering,
Dehnung in
Pro- 2) gering,
zenten der
ursprüng-
lichen Länge 3) mittelmäßig,
mindestens 4,5 4 3 2,5 2 1,5
c Widerstand 4) ziemlich groß,
gegen Zer-
5) sehr groß,
knittern 6 6 5 4 3 1
6) sehr groß,
7) außerordentlich
groß.
Ta b e l l e I I I.
Verwendungsklassen, B ogengrößen und Gewichte der
N o r m a l p a p i e r e.
Gewichte
Eigenschaften
Bogen- für
Klassen-
Verwendungsart Festig- größe 1000 1
zeichen Stoff-
keits cm Bogen qm
klasse
klasse kg g
A. S c h r e i b p a p i e r
1 Für besonders wichtige, auf lange
Aufbewahrungsdauer berechnete
Urkunden 33×42 15 –
Ordrepapier (Quart) I 1 26,5×42 12 –
Für Urkunden,
Standesamtsregister,
Geschäftsbücher u. s. w.:
2a für erste Sorte I 2 33×42 14 –
2b für zweite Sorte I 3 33×42 13 –
Für das zu dauernder
Aufbewahrung
bestimmte Aktenpapier:
3a für Kanzlei-, Mundir- u. s. w.
Papier 33×42 13 –
Briefpapier (Quart-) 26,5×42 10,4 –
II 3
desgl. (Oktav-) 26,5×21 5,2 –
3b für Konzeptpapier II 4 33×42 13 –
Für Papiere, welche für den
gewöhnlichen
Gebrauch bestimmt sind und nur
einige Jahre in Akten u. s. w.
aufbewahrt werden sollen:
4a für Kanzlei-, Mundir- usw. Reißlänge
Papier 3500 m,
Briefpapier (Quart-) Dehnung
desgl. (Oktav-) 2,75%, 33×42 12 –
III Widerstand 26,5×42 9,6 –
gegen Zer- 26,5×21 4,8 –
knittern
ziemlich
groß
4b für Konzeptpapier III 4 33×42 12 –
Bemerkung. Die unter A 1–4b
gegebenen
Vorschriften gelten auch für
solche
Schreibpapiere, welche
gleichzeitig
bedruckt werden
(Standesamtsregister,
Tabellenwerke u. s. w.).
Für Briefumschläge, Packpapier
etc.
und zwar:
5a für erste Sorte II 3 – – –
5b für zweite Sorte III 5 – – –
für Briefumschläge (für beide
Sorten):
1) bis zur Größe 13×19 cm – – – – 70
2) für größere und solche
Umschläge,
welche für Geld- und – – – – 115
Wertsendungen
bestimmt sind
für Packpapier:
für Klasse 5a – – – – 130
für Klasse 5b – – – – 115
6 Für Papiere, welche zu
untergeordneten
Zwecken im täglichen Verkehr
verwendet
werden sollen und an welche
Ansprüche
auf Dauerhaftigkeit nicht gestellt
werden, kann ohne besondere
Rücksicht
auf eine Festigkeitsklasse gewählt
werden IV – – – –
B. A k t e n d e c k e l.
7a Für Aktendeckel, welche Reißlänge
für häufigen Gebrauch und 2500 m,
I 36×47 81,2 480
längere Dehnung
Aufbewahrung bestimmt sind 3,5%
7b Für Aktendeckel, welche Reißlänge
2500 m,
für laufenden Gebrauch III 36×47 42,3 250
Dehnung
bestimmt sind
2,5%
C. D r u c k p a p i e r.
8a Für wichtigere, zu dauernder I
Aufbewahrung aber
bestimmte Drucksachen bis zu 4 – – –
10%
Asche
8b Für weniger wichtige Drucksachen III 4 – – –
8c Für Drucksachen, welche zu
untergeordneten
Zwecken im täglichen Verkehr
verwendet
werden sollen, kann ohne
Rücksicht auf
eine Festigkeitsklasse gewählt
werden IV – – – –
Gewichte für
Klassen- 1000
Verwendungsart 1 qm
zeichen Bogen
g
kg
nach oben oder unten abweichen, wobei die Riesumhüllung (das zum Verpacken
von 1000 Bogen verwendete Umschlagpapier) bei der Gewichtsfeststellung
mitgewogen wird.
§ 2.
§ 3.
§ 4.
§ 5.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com