<?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: Bakhita Otieno</title>
    <description>The latest articles on DEV Community by Bakhita Otieno (@bakhita87).</description>
    <link>https://dev.to/bakhita87</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%2F1290654%2Fded6fdb1-e6f7-4e2f-a905-98c56d7e8173.jpeg</url>
      <title>DEV Community: Bakhita Otieno</title>
      <link>https://dev.to/bakhita87</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bakhita87"/>
    <language>en</language>
    <item>
      <title>Creating a Note App</title>
      <dc:creator>Bakhita Otieno</dc:creator>
      <pubDate>Sun, 21 Apr 2024 12:52:51 +0000</pubDate>
      <link>https://dev.to/bakhita87/creating-a-note-app-1ma1</link>
      <guid>https://dev.to/bakhita87/creating-a-note-app-1ma1</guid>
      <description>&lt;p&gt;This Post shows one how to create a note app and the necessary steps to follow &lt;/p&gt;

&lt;p&gt;1.Create a react app first with npx create-react-app&lt;br&gt;
2.Then proceed to install dependencies &lt;br&gt;
3.Structure you folders and create a component folder called Notes.js that will Have the main code as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from "react";

const list1 = []



function Notes() {
  const[visibility, setVisibility] = useState(false);
  const[notes, setNotes] = useState([])
  const colors = ["lightpink", "lightgreen" ]
  const [miscellanous, setMiscellanous] = useState({
    title: "",
    body: "",
  });
  const popUp = ()=&amp;gt;{

    setVisibility(!visibility)
  }

   const addNote = (event) =&amp;gt; {

     const {name,value} = event.target

     setMiscellanous ({...miscellanous, [name]: value})

   }

   const appendNote = () =&amp;gt; {
     if(miscellanous .body.trim().length &amp;gt; 0){
      setNotes([ ...notes, miscellanous])
      setVisibility(!visibility) 
     }

   }

  return (
    &amp;lt;&amp;gt;




&amp;lt;div className="modal" style={{display: visibility  ? "block" : "none"}}&amp;gt;
  {visibility &amp;amp;&amp;amp;  &amp;lt;div className="modal-content" &amp;gt;

    &amp;lt;textarea type="text" id="note-body" name="body" value={miscellanous.body} onChange={addNote}&amp;gt;&amp;lt;/textarea&amp;gt;
    &amp;lt;div className="button-group"&amp;gt;
    &amp;lt;button onClick={appendNote}&amp;gt;Add note&amp;lt;/button&amp;gt;
    &amp;lt;button onClick={popUp} &amp;gt;Close&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;} 



&amp;lt;/div&amp;gt; 


    &amp;lt;div className="notes"&amp;gt;
      &amp;lt;div className="header"&amp;gt;
        &amp;lt;h1&amp;gt;Notes&amp;lt;/h1&amp;gt;
        &amp;lt;button onClick={popUp} className="btn"&amp;gt;+&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
       &amp;lt;div className="note-container" &amp;gt;
         {notes.map((nt,index)=&amp;gt;(
            &amp;lt;div  key= {notes.indexOf(nt)}className="note-card" style={{backgroundColor: colors[index % colors.length]}}&amp;gt;
              &amp;lt;p&amp;gt;{nt.body}&amp;lt;/p&amp;gt;

            &amp;lt;/div&amp;gt;
         ))}


       &amp;lt;/div&amp;gt;
       &amp;lt;/div&amp;gt;

    &amp;lt;/&amp;gt;
  );
}

export default Notes;

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Style the code in the Notes component in App.css as follows
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.notes {
  /* Add styles for the container if needed */
  background-color: white;
  width: 80%;

  margin: 0 auto;

}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  margin-right: 130px; /* Adjust spacing between h1 and button */
}

.btn {
  background-color: black;
  border-radius: 50%;
  color: white;
  padding: 7px 10px;
  border: none;
}
.note-container{
  display: flex;
  flex-wrap: wrap;

}
.note-card{
   width: 200px;
   height: 200px;
   border-radius: 10px;
   background-color: pink;
   margin-right: 15px;
   margin-bottom: 15px;
   padding: 10px;
   display: flex;
   flex-direction: column;
   justify-content: space-between;
   word-wrap: break-word;

}

.note-text{
  height: 70%;
  overflow: scroll;
}

/* Hide scrollbar for Chrome, Safari and Opera */.note-text::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.note-text {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.modal {

  position: absolute; /* Stay in place */
  z-index: 1; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0);
  background-color: rgba(0,0,0,0.4); 

}

/* Modal Content/Box */
.modal-content {
  background-color: #fefefe;
  margin: 15% auto; /* 15% from the top and centered */
  padding: 20px;
  border: 1px solid #888;
  width: 30%; /* Could be more or less, depending on screen size */
}

.button-group{
  display: flex;
  flex-direction: column;

}

textarea{
  width: 100%;
  height: 100px;
}

.button-group button{
  margin-top: 10px;
  width: 100%;
  background-color: rgb(110, 3, 3);
  color: white;
  border: 3px solid rgb(110, 3, 3);
  border-radius: 5px;
  font-size: 15px;
}
5. Call the notes component in the App.js folder to make it work as well as import the App.css in this folder

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

&lt;/div&gt;



&lt;p&gt;import './App.css';&lt;/p&gt;

&lt;p&gt;import Notes from './components/Notes';&lt;/p&gt;

&lt;p&gt;function App() {&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
      
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;export default App;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;6.Run npm start and it will open on the browser and look like this &lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;Click the plus button on the right to add a note &lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;Once you add the note you will see that they have been displayed on the screen&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;And Yep thats it :) :)&lt;/p&gt;

&lt;p&gt;If you would like to connect with me reach me on &lt;br&gt;
Linkedin: Bakhita Otieno&lt;/p&gt;

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