<?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: joostm020</title>
    <description>The latest articles on DEV Community by joostm020 (@joostm020).</description>
    <link>https://dev.to/joostm020</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F316275%2F5f8a9b8d-2fe6-4870-9f9c-564456cad2eb.png</url>
      <title>DEV Community: joostm020</title>
      <link>https://dev.to/joostm020</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joostm020"/>
    <language>en</language>
    <item>
      <title>Animated content placeholders</title>
      <dc:creator>joostm020</dc:creator>
      <pubDate>Thu, 09 Mar 2023 13:34:56 +0000</pubDate>
      <link>https://dev.to/joostm020/animated-content-placeholders-1o2c</link>
      <guid>https://dev.to/joostm020/animated-content-placeholders-1o2c</guid>
      <description>&lt;p&gt;Most modern (web)apps use content placeholders, it's a trend that has spread across platforms in the last half a decade. But what exactly are they, and why are they used? I'm going to tell you in this short article.&lt;/p&gt;

&lt;p&gt;At the end of this article I will also provide a code example, for anyone interested in building content placeholders using HTML and CSS.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What are content placeholders?&lt;/strong&gt;&lt;br&gt;
Content placeholders are elements that provide the user with visual information of what to expect after content has loaded. See an example below!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Content placeholders in the Twitter app&lt;/strong&gt;&lt;br&gt;
In this example you can clearly see how Twitter is trying to give the user the most accurate representation of the expected content.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--17b8JdOX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hsl67oqtl3p8pobbo92l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--17b8JdOX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hsl67oqtl3p8pobbo92l.png" alt="Content placeholders in the Twitter app" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Why are content placeholders used?&lt;/strong&gt;&lt;br&gt;
The main reason for content placeholders to be used instead of traditional loading spinners is to improve the user-experience, doing so by amongst others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preparing the user for the content that will be displayed&lt;/li&gt;
&lt;li&gt;Preventing content jumping and minimising &lt;a href="https://web.dev/cls/"&gt;Cumulative Layout Shift&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Retaining user attention with an animation (ripple effect)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;How to build content placeholders&lt;/strong&gt;&lt;br&gt;
Good content placeholders have a few simple requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Represent the (to be loaded) content accurately by using the same shape &amp;amp; size, if possible 1:1.&lt;/li&gt;
&lt;li&gt;Use one neutral colour across the whole placeholder to make it uniform&lt;/li&gt;
&lt;li&gt;Make use of an animation like the ripple effect to indicate that content is being loaded&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KeOCpfq_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb0z4qvmurucenwrsgbm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KeOCpfq_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb0z4qvmurucenwrsgbm.png" alt="Image description" width="506" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/joostm020/pen/GRXMzzz"&gt;Check code example on Codepen.io&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Thank you for your read!
&lt;/h2&gt;

&lt;p&gt;I hope you enjoyed reading my post and have learned something, feel free to give a like, and comment below to give some feedback.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A solution to scoped styling of components</title>
      <dc:creator>joostm020</dc:creator>
      <pubDate>Sat, 18 Dec 2021 19:29:20 +0000</pubDate>
      <link>https://dev.to/joostm020/the-solution-to-scoped-styling-of-components-436c</link>
      <guid>https://dev.to/joostm020/the-solution-to-scoped-styling-of-components-436c</guid>
      <description>&lt;p&gt;Most modern web applications built with React.js or other libraries, consist of many components that have their own functionality and styles. Styling all these components can quickly turn into a disorganised situation if not done the right way, so how exactly should you style your components?&lt;br&gt;
Fortunately, a methodology by the name of Block Element Modifier or BEM exists, to make it easier for you.&lt;/p&gt;


&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What are some common styling problems?&lt;/li&gt;
&lt;li&gt;How to solve these problems?&lt;/li&gt;
&lt;li&gt;Advantages of using BEM&lt;/li&gt;
&lt;li&gt;BEM explained&lt;/li&gt;
&lt;li&gt;Generate class names using a library&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  What are some common styling problems?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Styling out of component scope&lt;/li&gt;
&lt;li&gt;Over-qualifying selectors and use of !important&lt;/li&gt;
&lt;li&gt;Unclear what styles are exactly doing&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  How to solve these problems?
&lt;/h2&gt;

&lt;p&gt;We are going to apply the BEM methodology to solve these problems, but first you need to understand what exactly BEM is. Shortly said, BEM is a naming convention for writing cleaner and more readable CSS classes using unique class names for each component (block).&lt;/p&gt;


&lt;h2&gt;
  
  
  Advantages of using BEM
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Creating modular and independent blocks&lt;/li&gt;
&lt;li&gt;Blocks are re-usable and thus reduce CSS&lt;/li&gt;
&lt;li&gt;Block styles remain simple and are easy to understand&lt;/li&gt;
&lt;li&gt;Developers spend less time styling components&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  BEM explained
&lt;/h2&gt;

&lt;p&gt;The BEM naming convention for class names is as following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;block__element--modifier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;block&lt;/code&gt; represents the wrapping element of your component, there is only one per component.&lt;br&gt;
An &lt;code&gt;element&lt;/code&gt; is any element within your block.&lt;br&gt;
A &lt;code&gt;modifier&lt;/code&gt; is used to change appearance, behaviour or state.&lt;/p&gt;

&lt;p&gt;I strongly encourage you to read through the naming conventions rules on the original &lt;a href="http://getbem.com/naming/"&gt;BEM website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's take a look at an example.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Bf0DI67--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9gi070t3tjs6ekth1gz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Bf0DI67--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9gi070t3tjs6ekth1gz.png" alt="Example of BEM" width="718" height="632"&gt;&lt;/a&gt; &lt;br&gt;
&lt;a href="https://codepen.io/joostm020/pen/vYeZEXd"&gt;View on Codepen&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Generate class names using a library
&lt;/h2&gt;

&lt;p&gt;You can use the BEM methodology in your project without installing any libraries, however, to efficiently generate the class names you can use a library like &lt;code&gt;rebem-classname&lt;/code&gt; that does the job for you.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install the ‘rebem-classname’ package&lt;br&gt;
&lt;code&gt;npm install rebem-classname&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use stringify to generate BEM class names in your component:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;stringify&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="s1"&gt;rebem-classname&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Component.style.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Component&lt;/span&gt;&lt;span class="p"&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;bem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;block&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;block&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;elem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;mods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;mod&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&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;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;bem&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I'm using BEM!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Render result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"block__elem block__elem_mod"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;I'm using BEM!&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Thank you for your read!
&lt;/h2&gt;

&lt;p&gt;I hope you enjoyed reading my post and have learned something, feel free to give a like, and comment below to give some feedback.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
