<?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: Dagim G. Astatkie</title>
    <description>The latest articles on DEV Community by Dagim G. Astatkie (@dagimgdot).</description>
    <link>https://dev.to/dagimgdot</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%2F934467%2F0daff483-6587-4979-b217-16cf2f8e4d60.jpeg</url>
      <title>DEV Community: Dagim G. Astatkie</title>
      <link>https://dev.to/dagimgdot</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dagimgdot"/>
    <language>en</language>
    <item>
      <title>How do you setup your gnome extension development environment?</title>
      <dc:creator>Dagim G. Astatkie</dc:creator>
      <pubDate>Fri, 19 Jul 2024 20:47:21 +0000</pubDate>
      <link>https://dev.to/dagimgdot/how-do-you-setup-your-gnome-extension-development-environment-1l5</link>
      <guid>https://dev.to/dagimgdot/how-do-you-setup-your-gnome-extension-development-environment-1l5</guid>
      <description>&lt;p&gt;When I first thought of developing a gnome extension I thought it would be as simple as all the other web projects I did before. Start the project with vite then develop using visual studio code and see changes in real time when you change your code. But it was more complicated than that. &lt;/p&gt;

&lt;p&gt;I faced two difficult problems (as a beginner for this kind of development) during this journey.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding a good starter template with typescript&lt;/li&gt;
&lt;li&gt;Hot reloading the extension when I change the source code in my IDE&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After some digging I got an active forum in &lt;a href="https://matrix.org/" rel="noopener noreferrer"&gt;matrix&lt;/a&gt; called &lt;a href="https://app.element.io/#/room/#extensions:gnome.org" rel="noopener noreferrer"&gt;extensions-gnome&lt;/a&gt;. I relentlessly asked so many questions to the members until I get what I need and finally I was able to have a good dev environment.&lt;/p&gt;

&lt;p&gt;Today I want to take you on that journey where I went to have a good development environment when developing extensions for gnome. However, bear in mind that I am just a beginner in this topic and there may be better ways to do what I wanted to do. I wrote this for beginners like me who want to go from 0 to gnome-extension hero 🙂🙂 with simple reproducible steps.&lt;/p&gt;

&lt;p&gt;So, for the first problem, I got a simple solution when I was bombarding the matrix room with questions. It was a CLI tool that you can use without installing anything. Here it is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Scaffolding the Extension&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create gnome-extension@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzcs3lo95hz4xerxc959i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzcs3lo95hz4xerxc959i.png" alt="create-gnome-extension cli tool in action" width="673" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will ask you some questions and finally create the extension for you. This is the GitHub repository for the project, if you want to check it out for yourself. &lt;a href="https://github.com/Leleat/create-gnome-extension" rel="noopener noreferrer"&gt;create-gnome-extension&lt;/a&gt;. This tool gives you a basic extension that you can build and install in your system. But hang in there don't build it yet, there is more configuration.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Hot Reloading&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This one was a lot more challenging and took me a couple of days to figure out. The main reason that makes it difficult was that when you change something in you extension and try to apply the latest changes to the running extension for testing, you are actually changing the gnome-shell. Changing the gnome-shell means it has to be restarted so that the changes can take effect and this is only possible by logging out and logging in again to the system. Imagine doing this every time you change something in your code. That would be a total waste of time and disruption of your workflow. The Solution involves virtual machines for testing the running extensions and debugging.&lt;/p&gt;

&lt;p&gt;Let's split it the solution into two sub sections.&lt;/p&gt;

&lt;p&gt;2.1 &lt;strong&gt;Setting Up a Virtual Machine&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This one is pretty straight forward. Download an OS of your choice and set it up as a Virtual Machine. For instance I used Gnome Boxes to setup a &lt;strong&gt;Fedora 40 Guest OS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Guest OS should be configured the following way.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make the default display server x11/Xorg. In the login screen head to the right bottom corner and click the settings button. This is because gnome-shell restart without logging out and logging in is not possible in wayland.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff26kdbw661vy7lfdh7wx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff26kdbw661vy7lfdh7wx.png" alt="Changing default display server in gnome" width="448" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="https://github.com/linushdot/unsafe-mode-menu" rel="noopener noreferrer"&gt;Unsafe Mode Menu&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is because the gnome-shell restart needs gnome unsafe mode to be enabled to work correctly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="https://flathub.org/apps/com.mattjakeman.ExtensionManager" rel="noopener noreferrer"&gt;Extension Manager&lt;/a&gt; or using the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is to check your extensions, debug them and more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Ubuntu
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;gnome-shell-extension-manager 

Fedora
&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf instlal gnome-shell-extension-manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finally, install node because you gonna need it for the extension development. (yeah I know, but you need node in the Guest OS too !!)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Ubuntu
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nodejs

Fedora
&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.2 &lt;strong&gt;Sharing the extension dev folder between the Host and Guest OS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that you have your VM setup, you need to be able to install the extension in this Guest OS for debugging purposes. And also change something in your code in the host machine and see the changes in the extension installed on the guest os right away. For this to work we need these packages&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/libfuse/sshfs" rel="noopener noreferrer"&gt;sshfs&lt;/a&gt; - allows us mount a remote filesystem using SFTP&lt;/li&gt;
&lt;li&gt;ssh - allows us to have remote access to a computer
Install these packages for your distro both in the host machine and the guest os. And also check whether ssh service is running in both the host machine and the guest os.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, what we are going to do is, mount a folder from the host machine to the guest os using sshfs. But before this check whether you can ssh into the guest os from the host machine and vice versa. You can use the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh username@ipaddress

&lt;span class="c"&gt;# For example I use&lt;/span&gt;

ssh lix@192.168.124.167 -&amp;gt; from host to guest-os
ssh jd@192.168.124.1 -&amp;gt; from guest-os to host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you make sure the above commands work correctly you can continue to mount you extension directory to the guest os using the following command which uses sshfs. (You run this command in the Guest OS Terminal)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sshfs username@host_ipaddress:/path/to/the/extension/dev/folder /mount/directory/in/the/guestos

&lt;span class="c"&gt;# For example I use&lt;/span&gt;

sshfs jd@192.168.124.1:/home/jd/JDrive/Projects/TYPESCRIPT/gnome-extensions /mnt/host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will mount your extension development folder into the directory you choose in the guest os. After that you can execute commands like rebuild and reload gnome-shell while you are editing the source code in the host machine.&lt;/p&gt;

&lt;p&gt;That's it. You are done 🙂🙂. Now all you need is one magical command to run everytime you change something in the source code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build:dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to run this command in the guest os inside the shared folder (which we mount earlier) and it will rebuild the extension, install it in the guest os and also reload the gnome-shell withing 2–3 seconds. What a relief !!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lq1ggje3m3isdiy0giu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5lq1ggje3m3isdiy0giu.png" alt="My Dev Environment - Host" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fux9usxsy4wr5i9zfq9ql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fux9usxsy4wr5i9zfq9ql.png" alt="Guest OS" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see I am in the host machine (My main machine) and in the second terminal I ssh into the guest os. So, while I am inside visual studio code I can rebuild the extension installed in the guest os and also reload the gnome-shell of the guest os.&lt;/p&gt;

&lt;p&gt;If you happen to know anyway to persist mount during reboots, I will be happy to listen and learn.&lt;/p&gt;

&lt;p&gt;Finally, If this helps you setup your environment don't forget to clap and also if you have any feedback don't hesitate to put it in the comment section.&lt;/p&gt;

</description>
      <category>gnome</category>
      <category>extensions</category>
      <category>virtualmachine</category>
      <category>ssh</category>
    </item>
    <item>
      <title>The power button</title>
      <dc:creator>Dagim G. Astatkie</dc:creator>
      <pubDate>Thu, 13 Jul 2023 08:02:29 +0000</pubDate>
      <link>https://dev.to/dagimgdot/the-power-button-2hh8</link>
      <guid>https://dev.to/dagimgdot/the-power-button-2hh8</guid>
      <description>&lt;p&gt;Have you wondered what happens when we press the power button on our computer ? How does a computer begins in an off state and then be in an active state in 15 seconds ? It would be amazing  to know every step a computer takes to be turned on and be fully functional.&lt;/p&gt;

&lt;p&gt;That’s what I am going to be researching today. &lt;/p&gt;

&lt;p&gt;💡 What exactly happens when you press the power button on your PC ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To understand the whole process let’s divide it into subtopics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Power&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Every component of our computer needs electricity to operate. So, for this purpose there is a component called Power Supply that handles this process. It receives power from a DC, AC or if we have a laptop our battery will do the same thing. They distribute the power among the components of the PC. Here the power that is being distributed is going to be checked whether its the right amount or not. After everything got power the CPU tries to load a program called BIOS which is found in ROM.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;ROM, POST and BIOS&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;let’s see each of them separately&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I. ROM&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ROM is an abbreviation of Read Only Memory, when we were learning about it I didn’t get what its used for until now. When I am learning I like to relate new things with the things I know before. But for this one I couldn’t relate it at all.&lt;/p&gt;

&lt;p&gt;So related to our topic, what ROM is used for is to store this program we called BIOS earlier. Since its read only memory its contents will be there anytime and cant be overwritten. &lt;/p&gt;

&lt;p&gt;Additionally it is hardwired in the motherboard and it comes loaded with the BIOS which the manufacturers of the motherboard will be responsible for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;II. BIOS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;BIOS stands for &lt;strong&gt;Basic Input Output System.&lt;/strong&gt; So, this piece of software is stored on a small memory chip (the ROM as I mentioned before).&lt;/p&gt;

&lt;p&gt;We can say BIOS is the first software to run after we press that power button. But what is its use in the process that we are talking now ? &lt;/p&gt;

&lt;p&gt;It contains a set of instructions waiting to be executed once we press that power button. The first instruction to be executed is called POST. And it loads configuration settings from a special place called CMOS battery ( It is here that your clock is ticking by the way).  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;III. POST&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;POST stands for &lt;strong&gt;Power On Self Test.&lt;/strong&gt; What this thing basically do is check all the components(RAM, Hard drive and other Input Output devices ) in the motherboard ****whether they are working correctly or not. This is because its at this point we have to know if something is not working among the components. Here if there is a failure, it will tell us using different kinds of beep sounds. And like the morse code these beep sounds have their own meaning, maybe you encounter them before.&lt;/p&gt;

&lt;p&gt;It achieves this checking stage by sending signals using the System Bus to the components. So, if all the components are functioning normally the next step begins. Here let’s talk about BIOS a little bit. &lt;/p&gt;

&lt;p&gt;The BIOS is currently in control of everything at this point, so after the POST is over it grants the CPU to have access to all the hardware components that are connected to the motherboard. Hence, the CPU tries to access a startup code which is usually (There is a reason I said usually but that is for another article.) found in the &lt;strong&gt;hard drive.&lt;/strong&gt; This startup code is called &lt;strong&gt;The Boot Code.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Now that all the hardware are operating in our motherboard, the next step will be booting up the software.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;The Boot Code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;So, before we talk about the &lt;strong&gt;Boot Code&lt;/strong&gt; we have to have a base knowledge about the &lt;strong&gt;MBR&lt;/strong&gt;. What is MBR ??&lt;/p&gt;

&lt;p&gt;First &lt;strong&gt;MBR&lt;/strong&gt; stands for &lt;strong&gt;Master Boot Record&lt;/strong&gt;. It is a small piece of code responsible for loading the OS on your computer. It also contains information about the partitions on your hard drive and how they lay out.&lt;/p&gt;

&lt;p&gt;We said BIOS is found in a ROM chip which is hardwired in the motherboard if you remember,  so where ****is the MBR located ?? &lt;/p&gt;

&lt;p&gt;The MBR is located in the &lt;strong&gt;first sector of your hard drive&lt;/strong&gt; which is S*&lt;em&gt;ector 0&lt;/em&gt;*. (If you are wondering what sector is, I got you. Sector is the smallest physical storage unit of a hard drive and it is fixed to store 512 bytes of data.) &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnw2yejwbmhaaaado4wv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnw2yejwbmhaaaado4wv.png" alt="The disk anatomy" width="435" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s continue where we left off. We stopped when the CPU tries to access this Boot Code which is found in the hard drive. Actually this Boot Code is not found alone. That’s why I tried to explain what MBR is. It turns out &lt;strong&gt;Boot Code ( 446 bytes )&lt;/strong&gt; is one of the three main parts of the MBR. The other two parts are &lt;strong&gt;The partition table ( 64 bytes )&lt;/strong&gt; and &lt;strong&gt;The MBR signature ( 2 bytes)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We now know what a Boot Code and MBR are, so we can proceed to the next step. The next step will be the CPU loading this MBR to the memory ( RAM ) to run it. Here, after the CPU runs the Boot Code it will try to find where the installed OS is found in the partitions of our hard drive. &lt;/p&gt;

&lt;p&gt;Once it find the OS files it will load them to RAM to run them. And then the OS will take control of the system starting from now. At this point the OS will tell the CPU to run a bunch of background services and device drivers which will run in the background these background services include: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows services (If you are using windows)&lt;/li&gt;
&lt;li&gt;Different processes&lt;/li&gt;
&lt;li&gt;Desktop environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, you will be asked to enter your password. Voila your PC booted up successfully !!&lt;/p&gt;

&lt;p&gt;If you are still here it means you are curios enough to continue . . . These are the resources I used to write this. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://youtu.be/C_xxra5HMz0" rel="noopener noreferrer"&gt;What happens when I turn my computer on?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=B8_oQ3cU5FI&amp;amp;t=728s" rel="noopener noreferrer"&gt;What happens when you turn on a computer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=HzbpT67S1jo" rel="noopener noreferrer"&gt;WHAT HAPPENS WHEN YOU PRESS COMPUTERS POWER BUTTON!!!!!!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@Ayushverma8/what-exactly-happens-when-you-press-the-power-button-on-pc-7c781050b83e" rel="noopener noreferrer"&gt;What Exactly happens when you press the power button on PC ?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.howtogeek.com/398493/what-exactly-happens-when-you-turn-on-your-computer/" rel="noopener noreferrer"&gt;What Exactly Happens When You Turn On Your Computer?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ami.com/blog/2018/02/05/what-happens-when-you-press-the-power-button/" rel="noopener noreferrer"&gt;What Happens When You Press the Power Button? - AMI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/3KcpWxbhzr8" rel="noopener noreferrer"&gt;What happens when you turn on the computer |Computer Fundamentals |Computer course |computer science&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.easeus.com/diskmanager/master-boot-record.html" rel="noopener noreferrer"&gt;An Ultimate Guide to the Master Boot Record (MBR)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hardware</category>
      <category>os</category>
      <category>curiosity</category>
    </item>
    <item>
      <title>💪🏿Let's flex . . .</title>
      <dc:creator>Dagim G. Astatkie</dc:creator>
      <pubDate>Tue, 04 Jul 2023 18:48:24 +0000</pubDate>
      <link>https://dev.to/dagimgdot/lets-flex--49fg</link>
      <guid>https://dev.to/dagimgdot/lets-flex--49fg</guid>
      <description>&lt;p&gt;Have you ever wondered about the difference between the display values &lt;code&gt;block&lt;/code&gt;, &lt;code&gt;flex&lt;/code&gt;, &lt;code&gt;inline-flex&lt;/code&gt;  and &lt;code&gt;inline-block&lt;/code&gt; ?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;block&lt;/code&gt; and &lt;code&gt;inline-block&lt;/code&gt; are used to create block-level and inline-level elements respectively. &lt;code&gt;block&lt;/code&gt; elements take up the full width available and create a new line, while &lt;code&gt;inline-block&lt;/code&gt; elements only take up as much width as needed and allow other elements to sit next to them on the same line.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flex&lt;/code&gt; and &lt;code&gt;inline-flex&lt;/code&gt; are used to create flexible containers that can adjust the size and position of their child elements. &lt;code&gt;flex&lt;/code&gt; containers are block-level elements, while &lt;code&gt;inline-flex&lt;/code&gt; containers are inline-level elements that can be placed inline with other elements. The main difference between &lt;code&gt;flex&lt;/code&gt; and &lt;code&gt;inline-flex&lt;/code&gt; is the direction in which the items are laid out. By default, &lt;code&gt;flex&lt;/code&gt; lays items out in a row, while &lt;code&gt;inline-flex&lt;/code&gt; lays items out in a line along the inline axis.&lt;/p&gt;

&lt;p&gt;What do all the above sentences mean ? I don’t know NotionAi said that. Now let me tell you mine 😊.&lt;/p&gt;

&lt;p&gt;Let’s see what their difference is with an example to make it more clear. So, here is what we start the example with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="wrap"&amp;gt;
    &amp;lt;div class="child"&amp;gt;1&amp;lt;/div&amp;gt;
    &amp;lt;div class="child"&amp;gt;2&amp;lt;/div&amp;gt;
    &amp;lt;div class="child"&amp;gt;3&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class="wrap"&amp;gt;
    &amp;lt;div class="child"&amp;gt;1&amp;lt;/div&amp;gt;
    &amp;lt;div class="child"&amp;gt;2&amp;lt;/div&amp;gt;
    &amp;lt;div class="child"&amp;gt;3&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s add some css to spice it up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrap {
        /* display: flex; */ 
        /* display: inline-flex; */
                /* display: inline-block; */
        border: 3px solid blue;
        padding: 5px;
        margin: 30px;
    }

    .child {
        border: 2px solid green; 
        margin: 5px 2px;
        padding: 3px;
        text-align: center;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see from the above &lt;strong&gt;html&lt;/strong&gt; and &lt;strong&gt;css&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;we have two sets of three child &lt;code&gt;div&lt;/code&gt; elements wrapped in parent &lt;code&gt;div&lt;/code&gt; elements with the class &lt;code&gt;wrap&lt;/code&gt;. Now let's apply different display values to the parent &lt;code&gt;div&lt;/code&gt; elements and see how it affects the layout of the child &lt;code&gt;div&lt;/code&gt; elements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;block&lt;/code&gt;: The &lt;code&gt;wrap&lt;/code&gt; elements will take up the full available width and the child elements will be displayed in a block layout, with each child element taking up the full width of the parent element and appearing on a new line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 Remember: block is the default value for div tag&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fur77snyptoy2hgpuy28c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fur77snyptoy2hgpuy28c.png" alt="Image description" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;inline-block&lt;/code&gt;: The &lt;code&gt;wrap&lt;/code&gt; elements will only take up as much width as necessary and also will be displayed in inline layout, but the child elements will be displayed in an block layout, with each child element taking up only as much width as necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F068grcub9qmq066v9j2v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F068grcub9qmq066v9j2v.png" alt="Image description" width="221" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;flex&lt;/code&gt;: The &lt;code&gt;wrap&lt;/code&gt; elements will become flexible containers that can adjust the size and position of their child elements. By default, the child elements will be laid out in a row, but the &lt;code&gt;wrap&lt;/code&gt;  element is still in block layout.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fotdvloygxhht1ctmqbrz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fotdvloygxhht1ctmqbrz.png" alt="Image description" width="800" height="141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;inline-flex&lt;/code&gt;: The &lt;code&gt;wrap&lt;/code&gt; elements will become flexible containers that can adjust the size and position of their child elements, and they will be displayed inline with other elements. By default and also the child elements will be displayed in inline layout too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhd54vqd85pxhm4tml9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhd54vqd85pxhm4tml9a.png" alt="Image description" width="273" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the basic difference between them. feel free to comment what you think !!&lt;/p&gt;

&lt;p&gt;And here is a codepen link for you to play with if you are curious&lt;br&gt;
&lt;a href="https://codepen.io/dagimg-dot/pen/poQrvaO" rel="noopener noreferrer"&gt;https://codepen.io/dagimg-dot/pen/poQrvaO&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>flex</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
