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

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
When it comes to building whimsical interfaces, React is a surprisingly capable ally. In this talk, I'll show you how I use React to orchestrate complex interactions by digging into some examples from my blog.
Domain Driven Design with Vue Applications
Vue.js London 2023Vue.js London 2023
14 min
Domain Driven Design with Vue Applications
Top Content
Introduction to Domain Driven Design- What is DDD?- Key principles of DDD- Benefits of using DDD in web application developmentDomain Modeling in Vue 3 Applications- How to design and implement domain models in Vue 3- Strategies for integrating domain logic with Vue's reactive data model and component-based architectureBest Practices for Implementing DDD in Vue 3- Strategies for organizing code in a way that follows DDD principles- Techniques for reducing coupling between domain and application logic- Tips for testing and debugging domain logic in Vue 3 applications
Proven Pinia Patterns
Vue.js London 2023Vue.js London 2023
20 min
Proven Pinia Patterns
Top Content
With Vue's new-and-improved state management library, Pinia, we gain a much more modular tool. While being more flexible, leaner, and lacking the Mutations of Vuex, Pinia presents us with more opportunities to be creative, for better or worse, with our app architecture and how state management is conducted and organized within it.This talk explores some @posva-approved best practices and architectural design patterns to consider when using Pinia in production.
Component Design Patterns
Vue.js London 2023Vue.js London 2023
18 min
Component Design Patterns
How do you write a good component? In this talk we’ll explore several different patterns for writing better components. We’ll look at techniques for simplifying our components, making them easier to understand, and getting more out of the components we’ve already got.
Building Figma’s Widget Code Generator
React Advanced Conference 2022React Advanced Conference 2022
19 min
Building Figma’s Widget Code Generator
Widgets are custom, interactive objects you place in a Figma or Figjam file to extend functionality and make everything a bit more fun. They are written in a declarative style similar to React components, which gets translated to become a node on the canvas. So can you go the other way, from canvas to code? Yes! We’ll discuss how we used the public Figma plugin API to generate widget code from a design file, and make a working widget together using this.
So You Want to be an Indie Game Developer?
JS GameDev Summit 2022JS GameDev Summit 2022
30 min
So You Want to be an Indie Game Developer?
So you want to be an indie game developer? You probably have an idea of what indie game development is like. My job is to assure you that you are wrong. I'm going to talk about misconceptions around indie game development and all you need to know before getting into it.