<?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: Harshit Prasad</title>
    <description>The latest articles on DEV Community by Harshit Prasad (@harshitpd).</description>
    <link>https://dev.to/harshitpd</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%2F1135469%2F6c802c2d-e01c-4bbd-8884-e69bdecec51c.png</url>
      <title>DEV Community: Harshit Prasad</title>
      <link>https://dev.to/harshitpd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshitpd"/>
    <language>en</language>
    <item>
      <title>Tailwind CSS basic usage</title>
      <dc:creator>Harshit Prasad</dc:creator>
      <pubDate>Wed, 16 Aug 2023 10:21:57 +0000</pubDate>
      <link>https://dev.to/harshitpd/tailwind-css-basic-usage-1odk</link>
      <guid>https://dev.to/harshitpd/tailwind-css-basic-usage-1odk</guid>
      <description>&lt;p&gt;*&lt;em&gt;Tailwind CSS *&lt;/em&gt; is an open source CSS framework. It enables us to implement CSS in our application in a much simpler way. The way it does this is by giving us utility-classes(meaning you just have to name a class accordingly to implement a specific style in a component or element and does not have to define the style completely write the style for that component or element). This will be cleared by seeing the examples below.&lt;br&gt;
      Tailwind CSS differs from different frameworks like Bootstrap in the way that in Tailwind, utility classes are build upon style elements unlike in Bootstrap where utility-classes are build upon components. Like 'bg-blue-400' gives style blue background style when applied on an element like button where as in bootstrap, we write 'Primary' which gives an already defined button with specific style. So, this enables us to more specifically design our component while writing our html in our own way.&lt;br&gt;
     Here are some basic utility classes which are used to implement CSS property in our project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Margin and padding -&lt;/strong&gt; &lt;br&gt;
Tailwind CSS Classes: m-{size}, p-{size}&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="m-4 p-6 "&amp;gt;Lorem ipsum dolor sit amet&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Width and Height -&lt;/strong&gt;&lt;br&gt;
Tailwind CSS Classes: w-{size}, h-{size}&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="w-64 h-32 "&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Background and Text Color -&lt;/strong&gt; &lt;br&gt;
Tailwind CSS Classes: bg-{color}-{strength}, text-{color}&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="bg-green-300 text-white"&amp;gt;Colored Content&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Font size and font weight -&lt;/strong&gt;&lt;br&gt;
Tailwind CSS Classes: text-{size}, font-{weight}&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;p class="text-lg font-semibold"&amp;gt;Large Bold Text&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Borders and Border Radius -&lt;/strong&gt;&lt;br&gt;
Tailwind CSS Classes: border, border-{size}, rounded, rounded-{size}&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="border border-gray-400 rounded-lg "&amp;gt;
  Bordered and Rounded
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Positioning -&lt;/strong&gt;&lt;br&gt;
Tailwind CSS Classes: top-{size}, right-{size}, bottom-{size}, left-{size}&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="absolute top-0 left-0 "&amp;gt;Top Left&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. Flexbox -&lt;/strong&gt;&lt;br&gt;
Tailwind CSS Classes: flex, inline-flex, flex-{direction}, flex-wrap, justify-{content}, items-{alignment}&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="flex justify-center items-center "&amp;gt;
  Centered Content
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are some of the basic CSS properties. If you want to know about more properties, go to tailwindcss.com and search for the property you need to implement. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Tailwind CSS setup</title>
      <dc:creator>Harshit Prasad</dc:creator>
      <pubDate>Tue, 15 Aug 2023 13:18:13 +0000</pubDate>
      <link>https://dev.to/harshitpd/tailwind-css-setup-4e1n</link>
      <guid>https://dev.to/harshitpd/tailwind-css-setup-4e1n</guid>
      <description>&lt;p&gt;*&lt;em&gt;Tailwind CSS *&lt;/em&gt; is an open source CSS framework. It gives us low-level utility-classes to implement CSS in our projects. By low level we mean that the utility classes gives us style elements instead of style components. E.g.- 'bg-red-200' in Tailwind gives red background colour to our element where as in frameworks like bootstrap or materialize we get fully styled components like buttons, forms etc.&lt;br&gt;
       Here are the basic steps to include Tailwind CSS in our javaScript project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Get node.js installed in your computer. You can get it by going the nodejs.org and selecting the right version for your computer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Go to your project folder in the terminal and write&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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will include package.json file to your project folder. you can check this to know your project dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; On the terminal on the same address of your project folder, write&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This will include Tailwind CSS to your project. You can check this as a dependency in your package.json file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Now go to your package.json file and in the script tag and replace build tag with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"build-css": "tailwindcss build src/style.css -o public/style.css --watch"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Now in your terminal, write:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This will compile all your tailwind file in your public CSS file.&lt;/p&gt;

&lt;p&gt;Now you can use tailwind CSS utility classes in your project.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Socket.io basic setup</title>
      <dc:creator>Harshit Prasad</dc:creator>
      <pubDate>Tue, 08 Aug 2023 18:16:59 +0000</pubDate>
      <link>https://dev.to/harshitpd/socketio-basic-setup-8a2</link>
      <guid>https://dev.to/harshitpd/socketio-basic-setup-8a2</guid>
      <description>&lt;p&gt;Socket.io is a library which is used to establish bidirectional communication between different components of a web application(e.g.- (client ,server), (two different web pages) etc. ). It gives us a simple way to establish such communication in Real-time. This library has a low-latency which makes it real time and ensures almost zero data loss. Following is the basic process of how to establish communication between a client and a server using socket.io in javaScript.&lt;/p&gt;

&lt;h5&gt;
  
  
  1. Setting up client server address
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const io = require('socket.io')(4500);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  2. Creating IO communication
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
io.on('connection', socket =&amp;gt;{
    socket.on('new-user-joined', names =&amp;gt; {
        console.log("JOINED THE CHAT",names );
        users[socket.id] = names;
        socket.broadcast.emit('user-joined',names);

    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;socket.emit('new-user-joined',names);

socket.on('user-joined',names =&amp;gt;{
append(`${names} joined the chat`,'right')
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These two code blocks , server side and client side respectively , gives us a full circuit of communication between client and server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;io.on('connection', socket =&amp;gt;{
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;io.on creates and maintains the circuit for communication and listens for requests. &lt;/p&gt;

&lt;h5&gt;
  
  
  2. socket.emit
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;socket.emit('new-user-joined',names);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;socket.emit emits an event to the opposite party (here - new-user-joined) where the opposite party is waiting to listen to the event to take action. Here, &lt;strong&gt;names&lt;/strong&gt; is a variable passed with the event.&lt;/p&gt;

&lt;h5&gt;
  
  
  3. socket.on
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; socket.on('new-user-joined', names =&amp;gt; {

});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;socket.on listens to the event emitted by socket.emit with the same name and takes action accordingly.&lt;/p&gt;

&lt;h5&gt;
  
  
  4. socket.broadcast.emit
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; socket.broadcast.emit('user-joined',names);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;socket.broadcast.emit emits event as well as data (here - names) to all the clients connected to the server except the user itself. socket.on also listens to the request made be socket.broadcast.emit.&lt;/p&gt;

&lt;p&gt;So, here was a simple description and demonstration of how to establish a connection and communication between client and server using &lt;strong&gt;socket.io&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>react</category>
      <category>chatapp</category>
    </item>
  </channel>
</rss>
