<?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: Juan Carlos Valerio Barreto</title>
    <description>The latest articles on DEV Community by Juan Carlos Valerio Barreto (@jcvb).</description>
    <link>https://dev.to/jcvb</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%2F969123%2Ffa3f3f24-ad11-49e9-9a78-fa786f03bc5e.png</url>
      <title>DEV Community: Juan Carlos Valerio Barreto</title>
      <link>https://dev.to/jcvb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jcvb"/>
    <language>en</language>
    <item>
      <title>Moving a Square with CSS Grid and Minimal JavaScript</title>
      <dc:creator>Juan Carlos Valerio Barreto</dc:creator>
      <pubDate>Sat, 07 Oct 2023 01:00:36 +0000</pubDate>
      <link>https://dev.to/jcvb/moving-a-square-with-css-grid-and-minimal-javascript-2lal</link>
      <guid>https://dev.to/jcvb/moving-a-square-with-css-grid-and-minimal-javascript-2lal</guid>
      <description>&lt;p&gt;In a recent technical interview, I was tasked with a problem where a square had to be moved within a grid using buttons. The solution I initially thought of required more complex logic and JavaScript, but I realized I could use CSS Grid to handle most of the heavy lifting. In this post, I'll explain how I used grid properties to solve the problem with minimal JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HYuTt-36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mss3vf1ssa9m7pw14fil.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HYuTt-36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mss3vf1ssa9m7pw14fil.gif" alt="example" width="300" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;I had to move a square within a grid with the help of four buttons: up, down, left, and right. The grid and buttons are defined as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.square&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;grid-column-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-row-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn-up&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;grid-column-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-column-end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn-down&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;grid-column-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-column-end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-row-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn-right&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;grid-column-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-row-end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-row-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn-left&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;grid-column-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-row-end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-row-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The JavaScript Solution with React
&lt;/h2&gt;

&lt;p&gt;Instead of manually moving the square's position in the DOM, I used CSS grid properties combined with React's state to determine the square's position on the grid.&lt;/p&gt;

&lt;p&gt;Here's the JavaScript code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Board&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;axisX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setAxisX&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;axisY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setAxisY&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleMoveSquare&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;up&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;axisY&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;setAxisY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevY&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevY&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;down&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;axisY&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;setAxisY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevY&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevY&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;right&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;axisX&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;setAxisX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevX&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;axisX&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;setAxisX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevX&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevX&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;grid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;btn btn-up&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;handleMoveSquare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;up&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* ...other buttons... */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;square&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;gridColumnStart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;axisX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;gridRowStart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;axisY&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/square-direction-pv28wm"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;CSS Grid properties combined with React's state management provide a powerful way to create dynamic interfaces without much manipulation of the DOM. By setting the grid properties dynamically based on React's state, we can create fluid interfaces that react to user interactions.&lt;/p&gt;

&lt;p&gt;Would love to hear your thoughts on other creative uses of CSS Grid!&lt;/p&gt;

</description>
      <category>react</category>
      <category>css</category>
      <category>grid</category>
      <category>javascript</category>
    </item>
    <item>
      <title>The 2MB Tailwind CSS Dilemma: Performance Snag or Not? Explore Alternatives with BundlePhobia &amp; Moiva</title>
      <dc:creator>Juan Carlos Valerio Barreto</dc:creator>
      <pubDate>Fri, 22 Sep 2023 21:45:12 +0000</pubDate>
      <link>https://dev.to/jcvb/the-2mb-tailwind-css-dilemma-performance-snag-or-not-explore-alternatives-with-bundlephobia-moiva-dl6</link>
      <guid>https://dev.to/jcvb/the-2mb-tailwind-css-dilemma-performance-snag-or-not-explore-alternatives-with-bundlephobia-moiva-dl6</guid>
      <description>&lt;p&gt;In a world that is steadily marching towards 5G, significant areas still rely on 3G connections. This digital disparity necessitates a prudent choice in packages and libraries while developing applications intended for use in such regions. A case in point is the recent update of Tailwind CSS, which now tips the scales at over 2MB. This size uptick can pose concerns, particularly in 3G-dominated scenarios.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Importance of Lightness:
&lt;/h2&gt;

&lt;p&gt;The gravitas of lightweight libraries cannot be overstated. They are pivotal in ensuring optimal performance, faster load times, and superior UX/UI—particularly crucial in areas where 3G is the norm. A lighter library translates to quicker loading times, which, in turn, plays a vital role in SEO and user retention. In a slow internet scenario, every byte saved contributes to a smoother and more enjoyable user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Analyzing Alternatives:
&lt;/h2&gt;

&lt;p&gt;In our journey to explore lightweight and efficient alternatives to Tailwind CSS, especially suited for 3G prevalent areas, let’s delve into a comparative analysis of some widely recognized libraries and frameworks: Chakra UI, @mui/material, antd (Ant Design), React Bootstrap, Semantic UI React, and Tailwind CSS itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chakra UI:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Summary&lt;/strong&gt;: Chakra UI is a simple, modular and accessible component library that provides a set of high-quality components out of the box.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Highly accessible and easy to use with strong community support.&lt;/li&gt;
&lt;li&gt;Customizable to align with your design requirements.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Less comprehensive compared to some other libraries.&lt;/li&gt;
&lt;li&gt;Might require additional configurations for more advanced design systems.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bundlephobia Report
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RkCDYzjn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cc9itm9dvmabf3yp9qp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RkCDYzjn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cc9itm9dvmabf3yp9qp.jpg" alt="Bundlephobia Report" width="800" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source:&lt;/strong&gt; &lt;a href="https://bundlephobia.com/package/@chakra-ui/react@2.8.1"&gt;https://bundlephobia.com/package/@chakra-ui/react@2.8.1&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  @mui/material (formerly Material-UI):
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Summary&lt;/strong&gt;: This is a popular React UI framework that follows Google's Material Design guidelines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Rich set of components and strong community support.&lt;/li&gt;
&lt;li&gt;Built-in theming and customization capabilities.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;The design is very specific to Material Design, which may not suit all projects.&lt;/li&gt;
&lt;li&gt;Could be heavyweight depending on the usage and configurations.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bundlephobia Report
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G_834wYd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hyxw7taxrzzqiylm0nkl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G_834wYd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hyxw7taxrzzqiylm0nkl.jpg" alt="Bundlephobia Report" width="800" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source&lt;/strong&gt; &lt;a href="https://bundlephobia.com/package/@mui/material@5.14.10"&gt;https://bundlephobia.com/package/@mui/material@5.14.10&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  antd (Ant Design):
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Summary&lt;/strong&gt;: A design system for enterprise-level products, creating an enhanced user interface experience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Provides a robust set of high-quality components.&lt;/li&gt;
&lt;li&gt;Ideal for building enterprise-level applications with a modern design.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;The library size can be on the larger side which might impact load times.&lt;/li&gt;
&lt;li&gt;May require more configurations for customization outside the default design.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bundlephobia Report
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ys8u35Kh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mgl5g2ajohawxbkc8yax.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ys8u35Kh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mgl5g2ajohawxbkc8yax.jpg" alt="Bundlephobia Report" width="800" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source:&lt;/strong&gt; &lt;a href="https://bundlephobia.com/package/antd@5.9.2"&gt;https://bundlephobia.com/package/antd@5.9.2&lt;/a&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Summary&lt;/strong&gt;: Combines Bootstrap with React, delivering the Bootstrap's frontend elements through React components.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Leveraging Bootstrap’s robustness with React’s flexibility.&lt;/li&gt;
&lt;li&gt;Great documentation and community support.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;If Bootstrap's design doesn't align with your project, customization can be tedious.&lt;/li&gt;
&lt;li&gt;Sometimes can feel bloated with unnecessary features.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bundlephobia Report
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mxac3FbA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdit1efbd51xjemfvuct.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mxac3FbA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdit1efbd51xjemfvuct.jpg" alt="Bundlephobia Report" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source&lt;/strong&gt; &lt;a href="https://bundlephobia.com/package/react-bootstrap@2.8.0"&gt;https://bundlephobia.com/package/react-bootstrap@2.8.0&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Semantic UI React:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Summary&lt;/strong&gt;: A development framework that helps create beautiful, responsive layouts using human-friendly HTML.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;User-friendly and intuitive to use.&lt;/li&gt;
&lt;li&gt;Provides a more semantic, human-readable syntax.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Might not have as many built-in components or utilities compared to other libraries.&lt;/li&gt;
&lt;li&gt;Some developers find the customization to be less intuitive compared to other frameworks.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bundlephobia Report
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dQjO38M8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7pwarsie2y2gy8ymw11r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dQjO38M8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7pwarsie2y2gy8ymw11r.jpg" alt="Bundlephobia Report" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source&lt;/strong&gt; &lt;a href="https://bundlephobia.com/package/semantic-ui-react@2.1.4"&gt;https://bundlephobia.com/package/semantic-ui-react@2.1.4&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Tailwind CSS:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Summary&lt;/strong&gt;: A utility-first CSS framework for rapidly building custom designs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pros&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;High level of customization and utility-based design approach.&lt;/li&gt;
&lt;li&gt;Encourages component reuse and maintainability.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cons&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;The recent size increase crossing 2MB could impact performance, especially in 3G scenarios.&lt;/li&gt;
&lt;li&gt;Initial learning curve can be steep if coming from a traditional CSS background.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Bundlephobia Report
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tpm0ju-q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbwe4s8cqzta8kefpafp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tpm0ju-q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbwe4s8cqzta8kefpafp.jpg" alt="Bundlephobia Report" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source&lt;/strong&gt; &lt;a href="https://bundlephobia.com/package/tailwindcss@3.3.3"&gt;https://bundlephobia.com/package/tailwindcss@3.3.3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each of these libraries and frameworks comes with its own set of advantages and drawbacks. The choice among them would largely depend on the specific requirements of your project, your team’s familiarity with the library, and of course, the network conditions under which your application will predominantly operate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Utilizing BundlePhobia and Moiva for Intelligent Selections:
&lt;/h2&gt;

&lt;p&gt;Tools like BundlePhobia and Moiva are indispensable for developers keen on making informed decisions. BundlePhobia allows one to analyze the size and performance impact of different packages before making a choice, while Moiva assists in comparing the alternatives. &lt;/p&gt;

&lt;h2&gt;
  
  
  Head-to-Head: Chakra UI vs @mui/material vs antd vs React Bootstrap vs Semantic UI React vs Tailwind CSS Analysis by Moiva
&lt;/h2&gt;

&lt;h3&gt;
  
  
  By Popularity
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Tailwind CSS with 26.6M of downloads&lt;/li&gt;
&lt;li&gt;@mui/material with 12.5M of downloads&lt;/li&gt;
&lt;li&gt;React Bootstrap 9.8M of downloads&lt;/li&gt;
&lt;li&gt;Ant Design 5.4M of downloads&lt;/li&gt;
&lt;li&gt;Chakra UI 2.1M of downloads&lt;/li&gt;
&lt;li&gt;Semantic UI React 1.1M of downloads&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VwB-ABTv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvw18v1l3jr120872bpv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VwB-ABTv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvw18v1l3jr120872bpv.png" alt="By Popularity" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;The realm of front-end development is rich with choices when it comes to CSS frameworks and libraries. While Tailwind CSS stands tall in terms of popularity and community support, its recent size increase rings alarm bells for developers building applications for regions predominantly relying on 3G connectivity. It's vital to remember that popularity does not always equate to suitability. The key lies in understanding the unique requirements of your project and the network conditions under which your application will function.&lt;/p&gt;

&lt;p&gt;In environments where network speed is a limiting factor, opting for more lightweight libraries could spell the difference between a snappy user experience and a sluggish, frustrating interface. The comparative analysis of different libraries like Chakra UI, @mui/material, antd, React Bootstrap, and Semantic UI React sheds light on how each has its own set of pros and cons, and how some may offer a more performance-optimized solution over Tailwind CSS in 3G conditions.&lt;/p&gt;

&lt;p&gt;In conclusion, the quest for optimal performance especially in lower network speed scenarios, demands a well-considered, informed choice of libraries and frameworks. Tools like BundlePhobia and Moiva further empower developers in making these crucial decisions. Hence, despite the allure of popular libraries, a discerning examination of alternatives against the backdrop of network conditions and project requirements is indispensable in crafting applications that are not only functional and aesthetically pleasing but also performance-optimized for a broader user base.&lt;/p&gt;




&lt;p&gt;Share your thoughts and experiences in the comments below on how you navigated the library and package selection landscape to optimize your projects for different network conditions!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://moiva.io/?npm=@chakra-ui/react+@mui/material+antd+react-bootstrap+semantic-ui-react+tailwindcss"&gt;Full Moiva Source&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>tailwindcss</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>The Power of Pure Functions: Why Every JavaScript Dev Should Care!</title>
      <dc:creator>Juan Carlos Valerio Barreto</dc:creator>
      <pubDate>Tue, 05 Sep 2023 18:28:53 +0000</pubDate>
      <link>https://dev.to/jcvb/the-power-of-pure-functions-why-every-javascript-dev-should-care-58f5</link>
      <guid>https://dev.to/jcvb/the-power-of-pure-functions-why-every-javascript-dev-should-care-58f5</guid>
      <description>&lt;p&gt;If you're on a quest to write cleaner, more maintainable, and bug-resistant code, pure functions should definitely be in your toolbox. Let's deep dive into this topic and understand why it's such a game-changer for JavaScript developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Pure Functions? 🧐
&lt;/h2&gt;

&lt;p&gt;In a nutshell:&lt;/p&gt;

&lt;p&gt;They always return the same output for the same input.&lt;br&gt;
They have no side-effects; they don't change anything in the outer world.&lt;/p&gt;
&lt;h2&gt;
  
  
  A Real-world Example 🛍️: Online Shopping Cart
&lt;/h2&gt;

&lt;p&gt;Let's understand this with a juicy example - calculating the total of an online shopping cart, including discounts and taxes.&lt;/p&gt;
&lt;h3&gt;
  
  
  Without Pure Functions:
&lt;/h3&gt;

&lt;p&gt;Imagine using a function relying on global variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;discount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// default 10% discount&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// 5% tax&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;product&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;discount&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;strong&gt;calculateTotal&lt;/strong&gt; isn't pure since it leans on global variables &lt;strong&gt;discount&lt;/strong&gt; and &lt;strong&gt;tax&lt;/strong&gt;. If &lt;strong&gt;discount&lt;/strong&gt; or &lt;strong&gt;tax&lt;/strong&gt; accidentally changes somewhere in your code, it can lead to incorrect calculations.&lt;/p&gt;

&lt;h2&gt;
  
  
  With Pure Functions:
&lt;/h2&gt;

&lt;p&gt;The better approach? Make &lt;strong&gt;calculateTotal&lt;/strong&gt; pure by taking all its needed values as arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;discount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;product&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;discount&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why You Should Care! 🌟
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Predictability&lt;/strong&gt;: With pure functions, you know that given the same arguments, they'll always return the same result. No more unexpected surprises!&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testability&lt;/strong&gt;: Pure functions are a breeze to test. You can easily mock inputs and verify outputs without setting up and tearing down external states.&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reusability&lt;/strong&gt;: They tend to be more reusable since they're not tied to any specific state or context.&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimization and Parallelism&lt;/strong&gt;: Certain platforms/libraries can make specific optimizations when they know a function is pure. Think about memoization or parallel processing. Neat, right?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Wrap Up 🎁
&lt;/h2&gt;

&lt;p&gt;Pure functions are not just a "nice-to-have"; they can significantly improve the quality of your codebase. So, the next time you're about to write a function, ask yourself: "Can I make this pure?"&lt;/p&gt;

&lt;p&gt;And hey, if you found this useful, don't forget to smash that ❤️ button and share with your friends! Let's keep the conversation going. How have pure functions made a difference in your coding journey? Drop your thoughts below! 👇&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discuss</category>
      <category>learning</category>
      <category>web</category>
    </item>
    <item>
      <title>🎨 Diving Deep into the Colorful World of 'State of CSS' 2023: Trends, Tools, and More! 🚀</title>
      <dc:creator>Juan Carlos Valerio Barreto</dc:creator>
      <pubDate>Mon, 04 Sep 2023 20:52:40 +0000</pubDate>
      <link>https://dev.to/jcvb/diving-deep-into-the-colorful-world-of-state-of-css-2023-trends-tools-and-more-36i9</link>
      <guid>https://dev.to/jcvb/diving-deep-into-the-colorful-world-of-state-of-css-2023-trends-tools-and-more-36i9</guid>
      <description>&lt;h2&gt;
  
  
  Hello dev.to community! ✨
&lt;/h2&gt;

&lt;p&gt;Today, I want to share with you something about the "State of CSS" 🎨, an annual survey I've been closely following for some time. For those unfamiliar, State of CSS collects data on trends, technologies, and techniques we web developers use, focusing specifically on our beloved CSS.&lt;/p&gt;

&lt;p&gt;Ever heard of "State of JS"? 📊 Well, "State of CSS" is its counterpart, zooming in on the world of stylesheets. I find these surveys incredibly helpful for pinpointing emerging trends within our community 🌐. They help me grasp which tools are gaining traction and which might be fading away.&lt;/p&gt;

&lt;p&gt;In the "State of CSS" reports, I've discovered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSS features my fellow developers are using or wanting to learn 📚.&lt;/li&gt;
&lt;li&gt;Info on preprocessing tools I adore, like Sass and LESS ❤️.&lt;/li&gt;
&lt;li&gt;Insights on trending CSS frameworks and libraries 🛠️.&lt;/li&gt;
&lt;li&gt;And about CSS writing methodologies, such as BEM and OOCSS 🔍.&lt;/li&gt;
&lt;li&gt;Plus, there's always a segment on opinions (sometimes controversial ones!) around trends like CSS in JS 💬.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're someone keen on staying updated with the best practices and most popular tools in web design and development, I'd definitely recommend giving it a look 🔥.&lt;/p&gt;

&lt;p&gt;Catch you next time, devs! 🚀👩‍💻👨‍💻&lt;/p&gt;

&lt;p&gt;&lt;a href="https://2023.stateofcss.com/en-US/"&gt;https://2023.stateofcss.com/en-US/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>programming</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Unveiling AnalogJS: Crafting Angular Applications with a Fullstack Meta-Framework</title>
      <dc:creator>Juan Carlos Valerio Barreto</dc:creator>
      <pubDate>Wed, 23 Aug 2023 04:18:17 +0000</pubDate>
      <link>https://dev.to/jcvb/unveiling-analogjs-crafting-angular-applications-with-a-fullstack-meta-framework-3ghc</link>
      <guid>https://dev.to/jcvb/unveiling-analogjs-crafting-angular-applications-with-a-fullstack-meta-framework-3ghc</guid>
      <description>&lt;h2&gt;
  
  
  Analog is a meta-framework for building applications and websites with Angular.
&lt;/h2&gt;

&lt;p&gt;Similar to other meta-frameworks such as Next.JS, Nuxt, SvelteKit and others, Analog provides a similar experience, building on top of Angular created by &lt;a href="https://twitter.com/brandontroberts"&gt;brandontroberts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Are you an Angular enthusiast who's always on the lookout for cutting-edge tools to enhance your development process? Look no further! We're excited to introduce you to AnalogJS, a groundbreaking fullstack meta-framework designed to transform your Angular app-building journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why AnalogJS?
&lt;/h2&gt;

&lt;p&gt;Picture a world where you can seamlessly combine the power of Angular with the ease of use provided by meta-frameworks like Next.js and Nuxt.js. AnalogJS does just that - it marries the versatility of Angular with the efficiency of a meta-framework, creating a developer-friendly ecosystem that accelerates your project development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Documentation
&lt;/h2&gt;

&lt;p&gt;Visit the docs at &lt;a href="https://analogjs.org"&gt;https://analogjs.org&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Supports Vite/Vitest/Playwright&lt;/li&gt;
&lt;li&gt;File-based routing&lt;/li&gt;
&lt;li&gt;Support for using markdown as content routes&lt;/li&gt;
&lt;li&gt;Support for API/server routes&lt;/li&gt;
&lt;li&gt;Hybrid SSR/SSG support&lt;/li&gt;
&lt;li&gt;Supports Angular CLI or Nx workspaces&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Use your package manager of choice to create a new project&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With yarn:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn create analog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;With npm:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init analog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the prompts to scaffold the project and start the development server.&lt;/p&gt;

&lt;p&gt;Elevate your Angular experience with AnalogJS - where Angular meets meta-framework magic!&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Creator: *&lt;/em&gt;&lt;br&gt;
&lt;a href="https://dev.to/brandontroberts"&gt;https://dev.to/brandontroberts&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discuss</category>
      <category>frontend</category>
      <category>angular</category>
    </item>
    <item>
      <title>Unlocking Your #dev.to Portfolio: Elevate Your Web Presence with Integrated Article Showcase</title>
      <dc:creator>Juan Carlos Valerio Barreto</dc:creator>
      <pubDate>Tue, 22 Aug 2023 00:01:45 +0000</pubDate>
      <link>https://dev.to/jcvb/unlocking-your-devto-portfolio-elevate-your-web-presence-with-integrated-article-showcase-2akh</link>
      <guid>https://dev.to/jcvb/unlocking-your-devto-portfolio-elevate-your-web-presence-with-integrated-article-showcase-2akh</guid>
      <description>&lt;p&gt;In today's fast-paced tech world, showcasing your expertise is paramount. You've penned insightful articles on #dev.to, and now it's time to amplify your reach. &lt;/p&gt;

&lt;p&gt;Imagine seamlessly merging your dev.to articles into your personal portfolio website, creating a comprehensive showcase of your accomplishments. &lt;/p&gt;

&lt;p&gt;In this tutorial, we'll embark on an exciting journey to integrate the dev.to API with your portfolio section built in React. Get ready to empower your web presence and captivate your audience with a harmonious blend of technology and content.&lt;/p&gt;




&lt;h3&gt;
  
  
  Installing React
&lt;/h3&gt;

&lt;p&gt;These are the initial steps to create your application in react.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Environment Setup
&lt;/h4&gt;

&lt;p&gt;Before you start, make sure you have Node.js installed on your computer, as React requires Node.js to run. You can download it from &lt;a href="https://nodejs.org/"&gt;https://nodejs.org/&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2: Create a new React application
&lt;/h4&gt;

&lt;p&gt;To create a new application in React, you can use the official command line tool called "Create React App". Open your terminal and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-personal-site
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 3: Navigate to the Application Directory
&lt;/h4&gt;

&lt;p&gt;After creating the application, navigate to the directory where it was generated using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd my-personal-site
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 4: Run the Application
&lt;/h4&gt;

&lt;p&gt;Once you are in the application directory, you can start a development server to see how your application looks in the browser. Run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 5: Declaring Variables
&lt;/h4&gt;

&lt;p&gt;To save the list posts, the username that you have on dev.to and last the URL path for the API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPosts&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;USERNAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jcvb&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;DEV_TO_API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="s2"&gt;`https://dev.to/api/articles?username=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;USERNAME&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 6: Get the posts
&lt;/h4&gt;

&lt;p&gt;Used the useEffect hook to fetch the data after the component mounts. The empty dependency array ([]) ensures that the effect runs only once, similar to the behavior of componentDidMount in class components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;fetchPosts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DEV_TO_API&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;postsData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="nx"&gt;setPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;postsData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error fetching posts:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;fetchPosts&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt; &lt;span class="c1"&gt;// Empty dependency array means this effect runs once after mount&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 7: Render the results
&lt;/h4&gt;

&lt;p&gt;Added a key prop to each &lt;/p&gt;
&lt;li&gt; element to provide a unique identifier for React to efficiently update the list.

&lt;pre class="highlight html"&gt;&lt;code&gt;return (
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Post Lists&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    {posts.length &amp;gt; 0 ? (
      &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
        {posts.map((post) =&amp;gt; (
          &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;key=&lt;/span&gt;&lt;span class="s"&gt;{post.id}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{post.title}&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
        ))}
      &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
    ) : (
      &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;No posts available.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    )}
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;
  
  
  Final result
&lt;/h4&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/stackblitz-starters-srpfb8?file=src%2FApp.tsx" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;


&lt;/li&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>react</category>
      <category>meta</category>
    </item>
  </channel>
</rss>
