Measuring Coverage of React Design System

Rate this content
Bookmark

Design systems are becoming increasingly popular in modern front-end development. However, measuring the usage and coverage of these design systems is often challenging. In this lightning talk, I'll discuss about a tool that we're working on which uses react-scanner and Abstract Syntax Tree (AST) with custom scripts to generate component usage data for a React design system.

The talk will cover how we generate this data and how it is rendered in a dashboard to provide valuable insights on the coverage of the design system.

- Introduction to react-scanner
- Measuring Component Usage
- Identifying Native HTML elements and Styled Components
- Showing Tree structure of Page in terms of Components
- Highlighting Anti Patterns
- Benefits / Use Cases for this tool

This talk has been presented at React Summit US 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

Karan's talk at the React Summit focuses on the majoring coverage of the Reduzon system and the migration from design-system-3.0 to design-system-4.0.

Karan is currently working as an ST2 front-end developer at Fabric Agency, a US-based e-commerce startup.

The older design system (design-system-3.0) at Fabric was built using JavaScript and was very flexible, which led to a lot of customization and variations of the same component, resulting in a lack of consistency across applications.

Fabric decided to build design-system-4.0 using TypeScript to resolve the issues of inconsistency present in design-system-3.0. The new system offers design constraints, consistency, support for the latest features, and flexibility.

React Scanner is a tool that statically analyzes code to extract React component and prop usage. It supports various configurations and helps in generating data to show component usage, which assists in the migration process from design-system-3.0 to design-system-4.0.

React Scanner provides custom functions like getComponent, getProperValue, and processors such as countComponents, countComponent and props, and raw report to generate consolidated information from the scanned code.

React Scanner differentiates between JSX elements and HTML elements by checking if the element is lowercase and does not contain any dots. HTML elements are always lowercase and lack dot syntax, which is used for sub-components in JSX.

Anti-patterns describe practices that should be avoided. In Karan's talk, anti-patterns refer to the use of hard-coded colors instead of design system tokens and using HTML elements instead of design system components. Identifying anti-patterns helps improve code quality.

The purpose of creating a component tree structure is to visualize how different components are used together on a page. This helps in identifying optimization opportunities and making data-driven decisions to improve design consistency.

Karan mentioned Omelet.dev as an alternative tool for component analytics. Developed by Zeppelin, it provides a comprehensive solution, including CLI tools and a dashboard for data visualization, and supports both React and React Native.

Karan Kiri
Karan Kiri
19 min
15 Nov, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Talk discusses the majoring coverage of the Reduzon system and the journey of migrating from design-system-3.0 to design-system-4.0. It introduces React scanner, a tool that statically analyzes code and extracts React component and prop usage. The Talk explores the options and custom functions in React scanner, as well as the processors and AST used by the tool. It also discusses exploring AST using astexplorer.net and showcases the usage of react-scanner. Finally, it mentions the importance of component restructure and introduces Omelet, a tool for component analytics.

1. Introduction to React Summit

Short description:

Hello everyone, my name is Karan. Today I am going to talk about majoring coverage of Reduzon system. I am currently working as a ST2 front-end at Fabric Agency. We have our own dashboard where retailers can manage their products, inventories, customers, coupons, and subscriptions. We were in a journey of building our design system in Typescript, which was design-system-4.0. Let's define the problem statement where we're on the journey of migrating from design-system-3.0 to design-system-4.0. We as a platform team wanted to measure our component usage and to get some data to take data-driven decisions around our component strategies. Let's get started. First thing first, if you are an engineer, you get assigned any task and you try to google the hell out of it. But if you are a developer, you go to chatgpd type your question and hope it produces the output, but it didn't. But after struggling for a few days, asking for people help on Twitter, various platforms, I was able to find this NPM package called a React scanner. So what does React scanner? React scanner is basically a tool which statically analyzes your given code and it extracts the React component and prop usage.

Hello everyone, my name is Karan, welcome all to the React Summit. Today I am going to talk about majoring coverage of Reduzon system.

To give you an introduction about myself, I am currently working as a ST2 front-end at Fabric Agency, which is a US-based e-commerce startup. I have previously worked with startups like Razorpay and Google Foods in India.

Let's have some context before defining the problem statement. I will talk about what I usually deal with at Fabric in my day to day work. We have our own dashboard, a SAS dashboard, where retailers can manage their products, inventories, customers, coupons, and subscriptions. It is a micro-front-end-based architecture. We use single-SPA, REACT, Typescript, and Style components. We were in a journey of building our design system in Typescript, which was design-system-4.0. We had our older design system, which was in Vs3. It was built using JavaScript. It was very flexible, not a design system, but a component library or UI kit. It was very flexible. So people ended up creating a lot of customization and a lot of variations of the same component in turn, which lacked consistency across our applications. So all our applications started to look like it belonged to a different platform altogether.

To resolve all the issues that we had with design-system-3.0, we decided to build our design-system-4.0 using TypeScript. It was flexible, but it had design constraints with respect to our design system. It's very consistent, it has all the support, all the latest features like tokens, spacing, color, theme, that you can use.

Let's define the problem statement where we're on the journey of migrating from design-system-3.0 to design-system-4.0. We as a platform team wanted to measure our component usage and to get some data to take data-driven decisions around our component strategies. So a few data points that we wanted to capture was design-system-3.0 usage, design-system-4.0 usage, any native HTML elements that the domain teams were using, any style components they were using built on top of native HTML elements, or any existing design-system-3.0 components. We also wanted to have a tree structure of any page or any layout so we can visualize how our different components are getting used in combination with other components. And we also wanted to highlight some anti-patterns that we can gather using the data.

So let's get started. First thing first, if you are an engineer, you get assigned any task and you try to google the hell out of it. You see if there are any existing solutions that you can use readily. But if you are a developer, you go to chatgpd type your question and hope it produces the output, but it didn't. But after struggling for a few days, asking for people help on Twitter, various platforms, I was able to find this NPM package called a React scanner. So what does React scanner? React scanner is basically a tool which statically analyzes your given code and it extracts the React component and prop usage.

2. Options and Custom Functions in React Scanner

Short description:

React scanner supports various options such as defining the root directory, crawling starting point, excluding specific files, and including subcomponents. It also allows generating data for specific libraries and provides custom functions and processors for consolidated information.

So React scanner supports the following options that you can give. So basically when you run this React scanner on a given codebase, you have a few options. So first one is root directory. You can define from where your root directory is so it will start scanning from that root directory. You can also define where you want to start crawling from. You can exclude any of the files that you don't want to run a scan on. You can define the block pattern as well to include specific or exclude specific files.

You can also include sub components like if you don't want to report all the components, then you can also define using components. Similarly, for sub components as well. If you want to generate the data for only specific libraries, let's say you want to get the information from a library, like let's say what all components are using from Material.ai, then you can define your particular libraries as well. So it will generate only the data for that particular library that you've defined. Also, there are some custom functions that you can pass on. So few of them are like getComponent, getProperValue, and processors. So processors are basically functions that runs on top of raw data and it will generate consolidated information for you.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

The Whimsical Potential of JavaScript Frameworks
React Summit US 2023React Summit US 2023
28 min
The Whimsical Potential of JavaScript Frameworks
Top Content
Watch video: The Whimsical Potential of JavaScript Frameworks
The speaker discusses the whimsical and detailed work of Stripe, particularly their interactive and dynamic pages. They explain the use of React for building whimsical details and tracking mouse position. The speaker introduces React Spring for smooth animation and React3 Fiber for creating a 3D egg model. They also mention the use of Framer Motion and React server components for animating CSS properties.
AI + UX: Product Design for Intelligent Experiences
C3 Dev Festival 2024C3 Dev Festival 2024
28 min
AI + UX: Product Design for Intelligent Experiences
AI design challenges include bias, safety, and security. Trust and transparency are important in AI. Design principles for AI include user control, fighting bias, and promoting good decision-making. AI can enable the design process and investors expect to see it included in products. AI empowers individuals to create and share ideas, but managing expectations is crucial.
Domain Driven Design with Vue Applications
Vue.js London 2023Vue.js London 2023
14 min
Domain Driven Design with Vue Applications
Top Content
Welcome to this talk on domain-driven design in Vue.js application. Today we are going to look into domain-driven design, its benefits and how it works with Vue.js domain-driven design versus the MVVM model. Vue.js thrives in domain-driven design, a design approach that models software to match a domain. DDD emphasizes understanding business logic and creating a domain that reflects the language and concepts. Integrating DDD in Vue.js offers benefits such as effective modeling of complex business domains, structured code reflecting domain logic, and easier onboarding and ownership.
Proven Pinia Patterns
Vue.js London 2023Vue.js London 2023
20 min
Proven Pinia Patterns
Top Content
Pinnia is a lighter, more modular state management solution for Vue apps, offering consistent patterns, TypeScript support, and an intuitive developer experience. PINIA encourages splitting state into manageable domains, improving code splitting, type inferences, team collaboration, and debugging clarity. Pinia provides flexibility in accessing and mutating state, with different approaches for option and setup stores. It also offers features like patch, reset, and onAction methods. Vue Mastery offers comprehensive Pinnia courses and resources for fast learning.
Component Design Patterns
Vue.js London 2023Vue.js London 2023
18 min
Component Design Patterns
The Talk covers clean components and when to create new components, as well as patterns for writing cleaner components and the benefits of VIP patterns. Refactoring and separating code into separate components can make it shorter and easier to read, reducing complexity. The importance of not repeating oneself and the benefits of using smaller components for performance and developer experience are discussed. Composables can help extract logic in large and complex components, and patterns can be incorporated into component libraries and design systems.
Building Figma’s Widget Code Generator
React Advanced Conference 2022React Advanced Conference 2022
19 min
Building Figma’s Widget Code Generator
This Talk introduces Figma's Widget Code Generator and demonstrates how to build a FigJam widget using it. The speaker discusses the implementation of voting functionality, avatar functionality, and remove vote functionality. They also explain how the Widget Code Generator plugin works and how to access properties and modify names using the Figma plugin API.