<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhi Masri</title>
    <description>The latest articles on DEV Community by Muhi Masri (@muhimasri).</description>
    <link>https://dev.to/muhimasri</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F409026%2F461f3dc7-9725-4a44-9392-cf5529104215.jpeg</url>
      <title>DEV Community: Muhi Masri</title>
      <link>https://dev.to/muhimasri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muhimasri"/>
    <language>en</language>
    <item>
      <title>4 Effective Tools for Building a React Design System</title>
      <dc:creator>Muhi Masri</dc:creator>
      <pubDate>Fri, 06 Aug 2021 23:30:36 +0000</pubDate>
      <link>https://dev.to/muhimasri/4-effective-tools-for-building-a-react-design-system-564j</link>
      <guid>https://dev.to/muhimasri/4-effective-tools-for-building-a-react-design-system-564j</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;NOTE:&lt;/em&gt;&lt;/strong&gt; A newer and updated version of this article is available on my site &lt;a href="https://muhimasri.com/blogs/4-effective-tools-for-building-a-react-design-system/" rel="noopener noreferrer"&gt;https://muhimasri.com/blogs/4-effective-tools-for-building-a-react-design-system/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Introduction:
&lt;/h3&gt;

&lt;p&gt;Building a design system is a progressive and abstractive approach to maintaining a consistent and cost-efficient components library that follows a specific styling guide and is sharable across multiple products. A design system has always been associated with designers but now it’s becoming critical for frontend developers to understand it from the technology perspective.&lt;/p&gt;

&lt;p&gt;In this article, I will share some of the tools I used to successfully build a design system in React. Of course, before building the library, we require the designer’s expertise to develop the brand’s look and feel, user experience, style guide, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  create-react-library:
&lt;/h3&gt;

&lt;p&gt;One of the essential parts of providing a design system library is to be able to have an independent React components solution that can be published and used by other projects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/create-react-library" rel="noopener noreferrer"&gt;create-react-library&lt;/a&gt; is a CLI for creating reusable React libraries using Rollup and &lt;a href="https://reactjs.org/docs/create-a-new-react-app.html" rel="noopener noreferrer"&gt;create-react-app&lt;/a&gt;. All you need to do is a simple global installation &lt;code&gt;npm install -g create-react-library&lt;/code&gt;, then &lt;code&gt;create-react-library&lt;/code&gt;, followed by few questions about your package and you have it all! A Boilerplate project for publishing React components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmuhimasri.com%2Fwp-content%2Fuploads%2F2021%2F06%2Fimage-7-1024x928.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmuhimasri.com%2Fwp-content%2Fuploads%2F2021%2F06%2Fimage-7-1024x928.png" alt="React design system"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;src&lt;/code&gt; folder is where you develop and export components.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;example&lt;/code&gt; folder is for testing your components.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Material-UI:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://material-ui.com/" rel="noopener noreferrer"&gt;Material-UI&lt;/a&gt; can serve as a powerful base layer for your design system and can be easily customized to meet your component’s requirements.&lt;/p&gt;

&lt;p&gt;Advantages of using Material UI over building components from scratch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Built-in functionalities that will take a while to build from scratch, e.g. Dialogs, Autocomplete, Trees, Tables…&lt;/li&gt;
&lt;li&gt;Material is not only a library but a design system guide that helps you follow best design practices&lt;/li&gt;
&lt;li&gt;Responsive components that work on different devices&lt;/li&gt;
&lt;li&gt;Supported by Google&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Material uses JSS at its core – a high-performance JavaScript to CSS compiler which works at runtime and server-side. This works great for isolating components and creating dynamic CSS. If you’d like to learn more, I wrote an article on &lt;a href="https://muhimasri.com/blogs/how-to-customize-a-button-with-react-material-and-jss/" rel="noopener noreferrer"&gt;how to create custom dynamic styling for a Material Button using JSS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmuhimasri.com%2Fwp-content%2Fuploads%2F2021%2F06%2Fimage-9-1024x654.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmuhimasri.com%2Fwp-content%2Fuploads%2F2021%2F06%2Fimage-9-1024x654.png" alt="React design system"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Storybook:
&lt;/h3&gt;

&lt;p&gt;Storybook is a great tool for documenting, showcasing, and testing components with designers, managers, and developers. It allows you to create a story for each component that showcases different variants, behaviors, and features of your component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fstorybook.js.org%2Fff519d6518900d4be0ce86bbf3655913%2Fexample-button-args.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fstorybook.js.org%2Fff519d6518900d4be0ce86bbf3655913%2Fexample-button-args.png" alt="Button story with args"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Designers can provide feedback and updates while developers can test and learn how to work with your components.&lt;/p&gt;

&lt;p&gt;Besides documentation, it has plenty of other useful features and plugins such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unit test functionality&lt;/li&gt;
&lt;li&gt;Accessibility testing&lt;/li&gt;
&lt;li&gt;Visual test appearance&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Style Dictionary and Design Tokens:
&lt;/h3&gt;

&lt;p&gt;Design tokens are defined as all the values needed to construct and maintain a design system — spacing, color, typography, border, shadow, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.github.io/style-dictionary/#/README" rel="noopener noreferrer"&gt;Style Dictionary&lt;/a&gt; enables you to create and organize all Design Tokens as variables in a JSON format and automatically transform it into any format like JS, SASS, XML (for Android), etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmuhimasri.com%2Fwp-content%2Fuploads%2F2021%2F06%2Fimage-10-1024x308.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmuhimasri.com%2Fwp-content%2Fuploads%2F2021%2F06%2Fimage-10-1024x308.png" alt="React design system"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is a powerful tool for both designers and developers. As a designer, you control all the design system values to ensure consistency, and as a developer, you don’t need to create and structure style variables for every project that follows the same style guide. As soon as there is a design update, the designer will change the value and it will reflect on all platforms. Awesome!&lt;/p&gt;

&lt;h3&gt;
  
  
  Takeaway:
&lt;/h3&gt;

&lt;p&gt;A design system is a hot topic and an integral part of many companies. Following the best practices to building a design system will ensure scalable and cost-efficient products.&lt;/p&gt;

&lt;p&gt;I hope this article was helpful and if you have any questions, please leave a comment below.&lt;/p&gt;

&lt;p&gt;Bye for now!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For more related articles, you can visit my &lt;a href="https://muhimasri.com" rel="noopener noreferrer"&gt;site&lt;/a&gt; or &lt;a href="https://muhimasri.com/signup" rel="noopener noreferrer"&gt;subscribe here&lt;/a&gt; to receive the latest Frontend Development articles.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>designsystem</category>
      <category>javascript</category>
      <category>jss</category>
    </item>
    <item>
      <title>Why I Chose Preact for my Latest Project</title>
      <dc:creator>Muhi Masri</dc:creator>
      <pubDate>Mon, 03 May 2021 22:03:04 +0000</pubDate>
      <link>https://dev.to/muhimasri/why-i-chose-preact-for-my-latest-projectsharing-my-experience-working-with-preact-on-my-latest-javascript-project-48h</link>
      <guid>https://dev.to/muhimasri/why-i-chose-preact-for-my-latest-projectsharing-my-experience-working-with-preact-on-my-latest-javascript-project-48h</guid>
      <description>&lt;p&gt;As part of my ongoing consultation, architecture, and development work with JavaScript applications, I’ve recently started a new project that required me to re-evaluate the typical options that I usually go for (Angular, React, or Vue).&lt;/p&gt;

&lt;p&gt;Here are some of the project’s requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web Components support&lt;/li&gt;
&lt;li&gt;Progressive Web App&lt;/li&gt;
&lt;li&gt;Server-Side rendering &lt;/li&gt;
&lt;li&gt;JSX-like syntax and functional components&lt;/li&gt;
&lt;li&gt;Size and performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While, to some extent, this is all achievable by most of the popular JavaScript frameworks, Preact fully met the criteria without any hurdles and workarounds.&lt;/p&gt;

&lt;p&gt;Let’s dig a bit deeper into some of Preact’s features that I put together from research and hands-on experience:&lt;/p&gt;

&lt;h3&gt;
  
  
  Web Components Support:
&lt;/h3&gt;

&lt;p&gt;Unlike React, Preact uses the browser’s native addEventListener for handling events internally so it can listen to native DOM events dispatched from Custom Elements. Also, it has a special approach to know when to pass data to Custom Elements as either properties or attributes.&lt;/p&gt;

&lt;p&gt;Here is an example from &lt;a href="https://preactjs.com/guide/v10/web-components"&gt;Preact official site&lt;/a&gt;:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
 

&lt;p&gt;If you prefer using the same library for both your Web Components and Preact components, then you can use &lt;a href="https://github.com/preactjs/preact-custom-element"&gt;preact-custom-element&lt;/a&gt; to turn any Preact component into a Web Component!&lt;/p&gt;

&lt;h3&gt;
  
  
  JSX and HTM:
&lt;/h3&gt;

&lt;p&gt;JSX allows us to write HTML elements in JavaScript. This is very useful if you want to leverage JavaScript syntax within your templates.&lt;/p&gt;

&lt;p&gt;Preact supports JSX out of the box but also encourages to use HTM as an alternative. HTM is a JSX-like syntax but does not require an extra build step because it uses JavaScript’s Tagged Templates Literals to bind data and properties to the template. Awesome!&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
 

&lt;h3&gt;
  
  
  React compatibility:
&lt;/h3&gt;

&lt;p&gt;One of the biggest advantages of using React is its vast community, support, and libraries. Preact’s syntax is nearly identical to React and by adding a simple &lt;code&gt;preact/compact&lt;/code&gt; layer, it allows you to use any React library and fully leverage its ecosystem. Also, it supports Hooks API using &lt;code&gt;preact/hooks&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Progressive Web Apps (PWA):
&lt;/h3&gt;

&lt;p&gt;PWS is a design pattern that is typically used to provide a native like-app user experience.&lt;/p&gt;

&lt;p&gt;Preact CLI bundles your code into a highly optimized Progressive Web App with a 100 &lt;a href="https://developers.google.com/web/tools/lighthouse/"&gt;Lighthouse&lt;/a&gt; score. Here are some of the features that Preact CLI provides out of the box:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code-splitting for your URL routes&lt;/li&gt;
&lt;li&gt;Automatically generates and installs a ServiceWorker&lt;/li&gt;
&lt;li&gt;Generates HTTP2/Push headers based on the URL&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Server-Side Rendering:
&lt;/h3&gt;

&lt;p&gt;Server-Side Rendering (SSR) allows you to render your application on the server as HTML string which then can be sent to the client-side. This design pattern usually improves performance and SEO.&lt;/p&gt;

&lt;p&gt;SSR is automatically enabled with &lt;code&gt;preact-cli&lt;/code&gt;. Here is an example from &lt;a href="https://preactjs.com/guide/v10/server-side-rendering/"&gt;Preact official site&lt;/a&gt;:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
 

&lt;h3&gt;
  
  
  Size and performance:
&lt;/h3&gt;

&lt;p&gt;Although most modern JavaScript libraries and frameworks focus on performance, size, efficiency, etc. It’s worth mentioning that Preact had the smallest bundle size and fastest loading time compared to React, Vue, and Angular.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; this comparison was not conducted on a large-scale enterprise application. If performance and size is the main requirement for your next JavaScript project, please make sure to do enough research and testing and don’t just rely on this article.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Other cool features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Native support for ES Modules&lt;/li&gt;
&lt;li&gt;Helpful warnings and errors by importing &lt;code&gt;preact/debug&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Powerful and easy to use &lt;a href="https://github.com/preactjs/preact-cli"&gt;CLI&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final Thoughts:
&lt;/h3&gt;

&lt;p&gt;Working with Preact surpassed the expectations and was very satisfying but as usual, each project has its requirements and Preact might not be the optimum solution for you and your team.&lt;/p&gt;

&lt;p&gt;I hope this article was helpful and if you have any questions, please leave a comment below.&lt;/p&gt;

&lt;p&gt;Bye for now!&lt;/p&gt;

&lt;p&gt;For more related articles, you can &lt;a href="https://muhimasri.com/"&gt;visit my site&lt;/a&gt; or &lt;a href="https://muhimasri.com/signup/"&gt;signup for the latest articles and updates&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://muhimasri.com/blogs/why-i-chose-preact-for-my-latest-project/"&gt;Why I Chose Preact for my Latest Project&lt;/a&gt; appeared first on &lt;a href="https://muhimasri.com"&gt;Muhi Masri&lt;/a&gt;.(&lt;a href="https://muhimasri.com"&gt;https://muhimasri.com&lt;/a&gt;).&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>preact</category>
      <category>webcomponents</category>
    </item>
  </channel>
</rss>
