<?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: Ahab</title>
    <description>The latest articles on DEV Community by Ahab (@eyhab333).</description>
    <link>https://dev.to/eyhab333</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%2F1064522%2F4e446eb4-b57d-4e67-a268-4e192eea8a66.jpeg</url>
      <title>DEV Community: Ahab</title>
      <link>https://dev.to/eyhab333</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eyhab333"/>
    <language>en</language>
    <item>
      <title>How to use an icon library to create an animated battery icon</title>
      <dc:creator>Ahab</dc:creator>
      <pubDate>Sun, 07 May 2023 10:05:05 +0000</pubDate>
      <link>https://dev.to/eyhab333/how-to-use-an-icon-library-to-create-an-animated-battery-icon-3j7f</link>
      <guid>https://dev.to/eyhab333/how-to-use-an-icon-library-to-create-an-animated-battery-icon-3j7f</guid>
      <description>&lt;p&gt;First import the &lt;a href="https://fontawesome.com/"&gt;Font Awesome icon library&lt;/a&gt; and sets the font size of the battery icon to 48 pixels.&lt;/p&gt;

&lt;p&gt;Then use this JavaScript code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const batteryIcon = document.getElementById("battery-icon");
      const batteryLevels = ["&amp;amp;#xf244;", "&amp;amp;#xf243;", "&amp;amp;#xf242;", "&amp;amp;#xf241;", "&amp;amp;#xf240;"];
      let currentLevel = 0;

      function chargeBattery() {
        batteryIcon.innerHTML = batteryLevels[currentLevel];
        currentLevel = (currentLevel + 1) % batteryLevels.length;
      }

      chargeBattery();
      setInterval(chargeBattery, 1000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The JavaScript code creates an array &lt;code&gt;const batteryLevels&lt;/code&gt; of battery levels represented by Font Awesome icons.  &lt;/p&gt;

&lt;p&gt;It then defines a function called &lt;code&gt;chargeBattery()&lt;/code&gt; that updates the battery icon with the next level in the array and cycles back to the beginning of the array when it reaches the end.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;chargeBattery()&lt;/code&gt; function is called once to initialize the battery icon and then repeatedly every second using the &lt;code&gt;setInterval()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;currentLevel = (currentLevel + 1) % batteryLevels.length;&lt;/code&gt;&lt;br&gt;
This line of code updates the &lt;code&gt;currentLevel&lt;/code&gt; variable to the next index in the &lt;code&gt;batteryLevels&lt;/code&gt;array.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;%&lt;/code&gt; operator is the modulus operator, which returns the remainder of a division operation.&lt;/p&gt;

&lt;p&gt;In this case, the modulus operator is used to ensure that the &lt;br&gt;
&lt;code&gt;currentLevel&lt;/code&gt; variable always stays within the bounds of the &lt;br&gt;
&lt;code&gt;batteryLevels&lt;/code&gt;array.&lt;br&gt;
If &lt;code&gt;currentLevel&lt;/code&gt; is equal to the last index of the array, the modulus operator will return 0, which will set &lt;code&gt;currentLevel&lt;/code&gt; back to the first index of the array.&lt;/p&gt;

&lt;p&gt;So, this line of code ensures that the &lt;code&gt;chargeBattery()&lt;/code&gt; function cycles through the &lt;code&gt;batteryLevels&lt;/code&gt; array indefinitely, without ever going out of bounds.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const batteryLevels = ["&amp;amp;#xf244;", "&amp;amp;#xf243;", "&amp;amp;#xf242;", "&amp;amp;#xf241;", "&amp;amp;#xf240;"];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This array contains five string elements.&lt;br&gt;
Each string element represents a Font Awesome icon that corresponds to a different level of battery charge.&lt;/p&gt;

&lt;p&gt;The strings are written using HTML character entities, which represent special characters that cannot be typed directly on a keyboard. &lt;br&gt;
In this case, the character entities represent the Unicode values of the Font Awesome icons.&lt;/p&gt;

&lt;p&gt;The battery icons are represented by the following Unicode values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;#xf244;&lt;/code&gt;    Full battery icon&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;#xf243;&lt;/code&gt;    4/5 battery icon&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;#xf242;&lt;/code&gt;    3/5 battery icon&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;#xf241;&lt;/code&gt;    2/5 battery icon&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;#xf240;&lt;/code&gt;    1/5 battery icon&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the first element of the array is &lt;br&gt;
&lt;code&gt;&amp;amp;#xf244;&lt;/code&gt;, which represents the full battery icon. &lt;br&gt;
The &lt;code&gt;&amp;amp;#x&lt;/code&gt; prefix indicates that the following characters represent a hexadecimal value, and &lt;code&gt;f244&lt;/code&gt; is the hexadecimal value of the full battery icon in the Font Awesome icon set.&lt;/p&gt;

&lt;p&gt;Similarly, the other elements of the array represent the 4/5, 3/5, 2/5, and 1/5 battery icons, respectively.&lt;br&gt;
The &lt;code&gt;chargeBattery()&lt;/code&gt; function uses these string elements to update the battery icon with the appropriate level of charge. The function sets the &lt;code&gt;innerHTML&lt;/code&gt; property of the &lt;code&gt;batteryIcon&lt;/code&gt;&lt;br&gt;
element to the string element at the current index of the &lt;br&gt;
&lt;code&gt;batteryLevels&lt;/code&gt;array.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;currentLevel&lt;/code&gt; variable is used to keep track of the current index in the &lt;code&gt;batteryLevels&lt;/code&gt; array. The line of code &lt;br&gt;
&lt;code&gt;currentLevel = (currentLevel + 1) % batteryLevels.length;&lt;/code&gt;&lt;br&gt;
increments the &lt;code&gt;currentLevel&lt;/code&gt; variable by 1 and uses the modulus operator &lt;code&gt;%&lt;/code&gt;&lt;br&gt;
to ensure that the variable stays within the bounds of the &lt;br&gt;
&lt;code&gt;batteryLevels&lt;/code&gt; array.&lt;/p&gt;

&lt;p&gt;This allows the &lt;code&gt;chargeBattery()&lt;/code&gt; function to cycle through the &lt;br&gt;
&lt;code&gt;batteryLevels&lt;/code&gt; array indefinitely, updating the battery icon with the appropriate level of charge every second.&lt;/p&gt;

&lt;p&gt;Thats it, I hope you enjoyed&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to make your profile on github looks good</title>
      <dc:creator>Ahab</dc:creator>
      <pubDate>Fri, 28 Apr 2023 14:22:40 +0000</pubDate>
      <link>https://dev.to/eyhab333/how-to-make-your-profile-on-github-looks-good-2kca</link>
      <guid>https://dev.to/eyhab333/how-to-make-your-profile-on-github-looks-good-2kca</guid>
      <description>&lt;p&gt;visit this &lt;a href="https://github.com/abhisheknaiidu/awesome-github-profile-readme"&gt;link&lt;/a&gt;, choose your favourite, copy, paste and modify&lt;/p&gt;

</description>
      <category>github</category>
    </item>
  </channel>
</rss>
