Schlagwort: web components

  • Web Komponenten – Die vergessene Revolution im Web

    Ich habe in den letzten Jahren unzählige Webseiten mit React, Vue oder anderen Frameworks gebaut. Was all diese Seiten gemeinsam haben? Sie mussten ständig aktualisiert werden, um mit den neuesten Trends und Updates Schritt zu halten.

    Und dann gibt es da die paar Seiten, die ich vor Jahren mit Web Komponenten testweise erstellt habe. Wisst ihr was? Sie funktionieren immer noch – und nicht nur das: Sie haben sogar an Funktionsumfang gewonnen! Dank der kontinuierlichen Unterstützung durch immer mehr Browser haben sie sich fast von selbst weiterentwickelt.

    Es gibt schlicht keinen Grund mehr, auf Web Komponenten zu verzichten. Vielleicht bist du skeptisch oder hast Angst vor „Neuem“? Aber mal ehrlich, so neu sind sie nicht. Schon 2019 habe ich in Blogposts dafür geworben, endlich Web Komponenten zu nutzen.

    Was meint ihr? Sollten wir die ganzen Frameworks mal für eine Weile in den Urlaub schicken und das Web so gestalten, wie es gedacht war?

  • A Continuous Experience Pipeline…

    …evolved

    Some months back I created for my current employer a blog post on Design System Managers, and this evolved over time. This is the natural continued post.

    In the subsequent sections, we present our comprehension of your requirements, outline our recommended strategy for this product, and describe the potential workflow based on our in-depth deliberations.

    1. Initiating the Journey

    Starting point & challenges

    A brand relaunch at our client prompted the development of an online Brand Style Guide. This guide encompassed all the necessary information for crafting a brand-compliant digital experience across their digital landscape.

    A Figma Master served as the definitive source for design elements. In the past, each design team developed its components based on their needs, building on the existing library.

    This resulted in design inconsistencies. Developers established code libraries derived from these designs. However, the output varied significantly, leading to inconsistencies across digital touch-points and hindering the achievement of a cohesive look and feel.

    Our approach involves employing Publicis Sapient’s best practices to develop a distinct and user-friendly toolkit for both designers and developers.

    Team up and let‘s go

    Initially, we assembled a dedicated team focused on constructing a Continuous Experience Pipeline in both design and code. This pipeline supports the brand design guidelines and functions as a reliable source of truth. All stakeholders involved in developing projects for the brand must adhere to this framework.

    Subsequently, we shifted into problem-solving mode to assess the current situation, identify gaps, and address existing issues. We devised the workflow for a reusable product that can be easily implemented in various projects.

    2. Defining Our Mission  

    Establish a unified comprehension and a definitive source for UI assets and code to ensure a cohesive and streamlined user experience across all digital interactions.

    Upon consolidating the insights, we formulated a mission statement to guide our efforts towards our overarching objective.

    To achieve this, we went beyond merely developing a library with reusable code.

    Through a distinctive toolkit, a specialized workflow, and a structured process, we crafted a supportive solution for both designers and developers. This approach simplifies communication and effortlessly ensures consistency with the brand’s look and feel.

    3. Crafting Our Strategy

    Let‘s do this!

    Considering the participants‘ requirements, we have established quality benchmarks and optimized the process and workflow across all actions. Key features include a centralized system that integrates cutting-edge design with efficient code and an easy-to-understand, streamlined process. You will be able to contribute design and code components while utilizing the assets from the Continuous Experience Pipeline.

    4. Developing Our Process

    How we make it happen

    The procedure involves a collaborative effort from all contributors and disciplines, including designers and technical personnel. In adherence to brand design principles, we examine, enhance, and develop UI (User Interface) components to address the challenge of inconsistent design across touch-points.

    Flow Chart showing Brand Design, UI Components in Design and UI Components in Code in the middle and Design of touch-points on the right

    5. Establishing Workflow Fundamentals

    The How

    We have established ‚workflow fundamentals‘ for our product, supporting the continuous experience pipeline:

    Foundation: Initially, we examined various code and design outputs from different teams. The most effective elements from both domains form the basis of our work.

    Standards: Our focus is on four key aspects: information should be Perceivable, interfaces should be Operable, content should be Understandable, and the significance of the content should be Robust to accommodate changes in the way it is accessed.

    Design Tokens: We define all fundamental components of the design system in a structured and user-friendly manner. Design Tokens enable us to implement and modify these basic rules as needed.

    Single Source of Truth: In accordance with brand design, we maintain a master file for all components and apply design tokens to it. Developers can utilize these token definitions to generate code that adheres to user experience and accessibility standards.

    6. Implementing Tools & Streamlining Workflow

    Good alignment between Experience and Engineering

    Tools in design

    Figma and Figma Token Studio Relation
    • Figma Design System in design
    • Token Studio  A design token is a design decision

    Tools in design

    Tools in code

    Webcomponents, Bitbucket, NPM and Storybook to Docusaurus Relations
    • Web Components Stencil Library
    • Bitbucket Git code management
    • Storybook UI development, testing
    • Docusaurus – documentation
    • npm JavaScript package provider

    Tool setup and workflow

    Integrated working between Experience and Engineering

    We integrate tools to create a robust and efficient Continuous Experience Pipeline.

    To ensure the highest quality across all disciplines, we have implemented approval processes overseen by gatekeepers.

    If you have an alternate tool-set or environment, adjustments should be made to accommodate your specific requirements.

    Full flow of the described tools above with some Gatekeepers in between

    7. Fostering Collaboration

    Team up

    We collaborate to contribute and utilize design and code elements effectively.

    As product owners, we actively engage with consumers, partners, and stakeholders, constantly enhancing the quality of our deliverables. The Continuous Experience Pipeline is accessible to any team interested in adopting the same process.

    We provide guidance and support through team chats, issue tracking, and regular feedback sessions conducted by our specialists.

    8. Realizing the Benefits

    What comes with it…

    Optimized Component Toolkit / Unified Source of Truth in UX, Design, and Code / Time and Cost Efficiency / Seamless Integration and Contribution / Simplified On-boarding / Rigorous Quality Standards / Regular Updates

    9. Achieving the Results

    Satisfied Customers: Experience a consistent brand design across all touch-points, ensuring a cohesive user experience.

    Content Clients: Streamlined on-boarding and workflow reduce time and costs, making project execution more efficient.

    Delighted Designers: Rely on a single source and process with ready-to-use components to accelerate your workflow.

    Pleased Developers: Comprehensive documentation and efficient code ensure rapid, high-quality results.

    10. Gaining Insights & Knowledge

    We learned a lot

    Avoid Shortcuts: Often, the quickest solution isn’t the best one. We prioritize thorough approaches over shortcuts to address challenges effectively.

    Make Decisions and Commit: Effective solutions are based on clear reasoning. Our decisions are driven by well-founded rationale.

    Build Alliances: In large organizations with global business units, communication can be complex. To gain momentum for your project, forge partnerships with supportive allies.

    Implement Design Tokens: Streamline your design system’s foundation to improve the handover process between designers and developers, making it more efficient and faster.

    Value Feedback: As the Continuous Experience Pipeline is a product, feedback is invaluable. Embrace it and strive for immediate improvements.

    Promote Collaboration: A dynamic library requires a collective effort. We continually encourage participation and teamwork among all stakeholders.

    Get in touch in case of any question.
    We’d love to work with you.

    The people behind: A dedicated team of Developers and Designers lead by Holger Hellinger (Director Technology) and Michael Brandt (Design Lead) at Publicis Sapient, Cologne.

  • Should I use Web components?

    At my current employer we do all kind of Web Applications. We call it Experience Technology. These customer user experiences have different needs. Sometimes we do static content deliverables like temporary marketing campaign pages, or knowledge bases that never get touched again. More often we do enterprise shopping experiences, catalogue maintenance, and other e-commerce platforms.

    Asking someone of my team how to build their next customer user experience I get named: React, VUE, Svelte or at last, Angular. Normally no one tells me yet: Let’s do it native, let’s use Web Components.

    Do I know why?

    Maybe

    Why the frameworks are so common and preferred is having some reasons:

    • They offer a community
    • Searching for an issue or supporting library for sure returns an Stackoverflow entry or an NPM library
    • There is great support by someone that has „already done this“
    • For Business: It is good to have something to sell that everyone knows

    A quick poll

    Doing a quick poll with our experience technologists hardens the opinion.

    Showing React 58%, Angular 3%, VUE 15%, Native Web Components 7%. Other 13%

    Observing the obvious

    Using frameworks and libraries for everything, causes problems that could be prevented. Average weight of a page is increasing. Complexity of generated code too. Views of common frameworks and libraries are often ridiculous complicated and deep nested and adding libraries and grid systems is done with a click. Importing without seeing the direct deeper effect. On top of that, Designers create complex animations and placeholders and forget that we still have low-end devices to support and not an ideal-world fast internet. Accessibility and search, like find-ability is getting worse. When useless containers are nested and semantics are getting lost.

    On top of all, GDPR compliance is bad to achieve as of often third parties are used in a way that makes it hard to know where your customers details are getting shared.

    This directly leads me to the this ask: Do we at all need to use a framework or library? Can’t we use Web components?

    Webcomponents.org tells a clear use case, but why does still no one considers it first place to use it as base in their projects?

    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 behaviour.

    Webcomponents.org

    Would there be any advantage when using them instead of a framework? Long-term for sure. Imagine a situation where Facebook stops support for React, or Google for Angular. Sooner or later libraries might get outdated. The community for sure support it for some years, but it can stop. There is no guarantee that it works long. There are also new Libraries popping out every day.

    As we started writing decoupled user experiences, using micro-services and micro-frontends, we forgot to enable us to create long lasting frontend code, that is maintainable. Instead of using native functionalities, write proper markup and getting accessible and search engine friendly.

    We now create a dependency to a framework that is maybe out-dating soon. Any reason to do so?

    Not really!

    Frameworks and libraries should help us organizing and writing our code and deliverables, but not overtaking our thinking and tooling. It is not reasonable that we deliver whole applications to clients browsers, when the contents never or only every view months change. We should instead build more meaningful smaller applications. We even need to render server side, using JavaScript.

    A quick excursion on what Web Components are

    Using Web components would allow us to get back to standards, using browser supported simple tooling.

    So why should you consider Web components as complement for frameworks and libraries?

    • They are already a standard!
    • They work cross browser (Can I use it?)
    • They are simple and stand-alone
    • They are already used
    • They are future proof!

    The details

    Web components are the wrapper name for a set of techniques that create browser rendered interfaces. They are created through custom elements, shadow DOM, HTML templates and HTML modules. The latter is yet not widely adopted by browsers.

    Custom Element

    Setup a JavaScript file that contains the code for your custom element.

    class MyCustomElement extends HTMLElement {    
      connectedCallback() {
        this.innerHTML = `<p>Some Text</p>`;
      }
    }
    window.customElements.define('my-custom-element',  MyCustomElement)Code-Sprache: JavaScript (javascript)

    You need a DOM node that can initialise it.

    <my-custom-element></my-custom-element>Code-Sprache: HTML, XML (xml)

    Shadow DOM

    With your custom element you can add coloured text in the context of other text paragraphs. You can capsule your styles that only belonging to the needed node.

    const shadowRoot = document.getElementById('fetched').attachShadow({ mode: 'open' });
    shadowRoot.innerHTML = `<style>
    p {
      border: 1px solid red;
      padding: 5px;
    }
    </style>
    <p id="paragraph">Paragraph using <slot></slot></p>`;Code-Sprache: HTML, XML (xml)

    Create some HTML to connect your code with it.

    <span id="fetched">Slot</span>
    <p id="paragraph">Normal Text</p>Code-Sprache: HTML, XML (xml)

    Shadow DOM like shown below will be generated.

    <body>
      <span id="fetched">    
        <#shadow-root>
          <style>
          p {
            border: 1px solid red;
            padding: 5px;
          }
          </style>
          <p id="paragraph">Paragraph using Slot</p>
        </#shadow-root>
      </span>
      <p id="paragraph">Normal Text</p>
    </body>Code-Sprache: HTML, XML (xml)

    Use HTML Templates

    Stay DRY. Use HTML templates. Look at the the above example. If you want to render more paragraphs, you can repeat your <p> or just use a <template>. It is obvious what is wet and what is dry.

    You can use them together with custom elements and shadow root, or alone.

    <template id="template">
      <p></p>
    </template>
    <section id="paragraphs"></section>Code-Sprache: HTML, XML (xml)

    How to render a HTML template.

    const paragraphs = document.getElementById('template');
    const text = [
      { node: 'Text 1' },
      { node: 'Text 2' },
      { node: 'Text 3' }
    ];
    text.forEach(text => {
      const domNode = document.importNode(paragraphs.content, true);
      domNode.querySelector('p').innerHTML = text.node;
      document.getElementById('paragraphs').appendChild(domNode);
    });Code-Sprache: JavaScript (javascript)

    Did I missed HTML Modules?

    Nope. But they are currently considered. So let’s see.

    What else to consider

    Take also into account that all is maintained in a component library. Handled in a DSM provided by InVision, Figma, or Design Kits like Sketch. We need to ensure to reuse our code and Styles. Design Tokens help here. Amazon has Style Dictionary, but there are others. And ideally, have a direct connect to your repository. (More would be subject of a full own post)

    But my client has IE11 as standard browser!

    Ask them why! Seriously!

    If they still insist, and maybe even have a dated soon to be replaced Edge: there are Polyfills available, they render the components as HTML for you.

    Any other input?

    More and more Frameworks and libraries arise that help generating your applications with Web components. They offer build in test ability, design libraries, pattern libraries and more. There are well established ones like Polymer or Stencil. You can find more on the web component page list. So if you do not want to do it manually. Use provided tools. 

    What to do

    There is no golden hammer that makes all your problems a nail. But you should consider re-usability, need of the current implementation, and how long it will exists. Then it can help you making a decision.

    Static rendering for interims campaign pages, knowledge bases, and so on can improve SEO, size, and customer experience. Full blown SPA with a checkout or profile management, and a healthy mixture for catalogue can do their part on this.

    But the base of all should be a Web component. Just do it.

    Resources mentioned and used

    Fun fact

    Yes, you can also make Web components complicated.