Skip to content

Commit 0e65c07

Browse files
committed
squash: adding the notes from our previous meetings on web components
1 parent daa5245 commit 0e65c07

File tree

1 file changed

+46
-13
lines changed

1 file changed

+46
-13
lines changed

docs/front-end/web-components.md

+46-13
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,60 @@ Broadly speaking, every web component is a custom element - a specific, globally
2424

2525
## Guidance
2626

27+
### Our Experiences Using Web Components at Red Hat
28+
29+
The team at Red Hat has been involved in several Web Component projects and have learned a good amount about Web Components and how to write them
30+
31+
Two Web Component "Systems" at Red Hat are
32+
33+
* [PatternFly Elements](https://patternflyelements.org/) (aka PFE) (“upstream”)
34+
* [Red Hat Design System](https://ux.redhat.com/) (aka RHDS) (“downstream”)
35+
2736
### Advantages and Ideal Use Cases
2837

29-
- mix and matching components
30-
- a la carte / low impact development
31-
- cross-team collaboration
32-
- design systems
33-
- migrating piecemeal from older frameworks
38+
Through the teams experience with Web Components, we've identified a few different pros and cons when using Web Components and what type of applications you might want to use them with.
39+
40+
#### Accessibility
41+
42+
a single implementation of complex ui patterns can help teams to ship accessible experiences with less fuss
43+
44+
#### Work Across frameworks / Cross Team Collaboration
45+
46+
the same `<rh-card>` which works in drupal can work the same way in react, or in an ejs template, and the teams working with those components can transfer that knowledge to other projects, instead of reimplementing design specs for each new framework.
47+
48+
49+
#### Design Systems
3450

35-
### Potential Gotchas When Using Web Components
51+
The case for web component-based design systems is strong because of encapsulation / knowledge transfer / future proofing as described above. These can also include a certain amount of business logic like analytics code, personalization, etc (ymmv)
52+
53+
#### Microfrontends
54+
55+
This is another case where web components and shadow dom shine, as the encapsulation guarantees and framework interoperability aspects lend themselves naturally to enabling teams to cooperate while maintaining boundaries.
56+
57+
#### Greenfield SPA
58+
59+
There’s an argument to be made from a loading / rendering perf and future-proofing perspective to start new projects with a web component framework (like lit, stencil, hybrids, FAST, etc) in place of traditional / legacy framework (angular, react, vue)
60+
61+
docs.redhat.com (a greenfield project) leaned heavily on RHDS web components, and that helped ship the project faster
62+
63+
#### Piecemeal migration
64+
65+
The framework interoperability aspect enables upgrading complex projects on a component-by-component basis. Rather than break the entire app when bumping the underlying frontend-framework from vX to vY, replace components one by one with interoperable web components.
66+
67+
### Common Gripes
68+
69+
As with all programming models, there are some gotchas that the team has encountered:
3670

3771
- cross-root aria
72+
- To prevent a11y failures, signifacant expertise might be needed
73+
3874
- double-registration errors
3975
- server-side tooling / ssr limitations
4076
- shadow dom can be a double edged sword
4177

42-
### Our Experiences Using Web Components at Red Hat
78+
- Unit Testing
79+
- JSDOM/Jest may not work with your customer elements
4380

44-
- Design Systems
45-
- PFE
46-
- RHDS
47-
- HTML-first / MPAs
48-
- SPA usage (high javascript, state-management)
81+
### General Concensus
4982

50-
## Further Reading
83+
If you have a team with web platform experience, that always have an MDN tab open, and you’re hopeful to leverage current and future web standards like PWA, then you’re likely to succeed. If on the other hand you don’t have much senior experience or depth of knowledge on web platform features, you may run into issues. However, your teams that overcome those issues will gain platform knowledge and not just framework knowledge.

0 commit comments

Comments
 (0)