<?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: David Frempong</title>
    <description>The latest articles on DEV Community by David Frempong (@davidfrempong).</description>
    <link>https://dev.to/davidfrempong</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%2F779576%2Fdf8fb7d1-8c78-4a58-b191-a65281c267b4.jpeg</url>
      <title>DEV Community: David Frempong</title>
      <link>https://dev.to/davidfrempong</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/davidfrempong"/>
    <language>en</language>
    <item>
      <title>How I built a megamenu feature with Vanilla JavaScript</title>
      <dc:creator>David Frempong</dc:creator>
      <pubDate>Fri, 04 Feb 2022 22:17:29 +0000</pubDate>
      <link>https://dev.to/davidfrempong/how-i-built-a-megamenu-feature-with-vanilla-javascript-i59</link>
      <guid>https://dev.to/davidfrempong/how-i-built-a-megamenu-feature-with-vanilla-javascript-i59</guid>
      <description>&lt;p&gt;On one of the projects I'm working on, I want the visitor to be able to hover on a nav menu item, and a megamenu will appear. &lt;strong&gt;Here's how I built it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After styling everything in CSS, I gave the original class in CSS a display: none. Then, I created another duplicate class with an ending (-visible) &lt;code&gt;(example: .thisdiv and .thisdiv-visible)&lt;/code&gt; and gave it a display: block.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .navmenucontent{
  display: none;
  }

 .navmenucontent-visible{
  display: block;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, I went to JavaScript and created my variables. I then targeted the menu item itself (let's say "shop"), and gave it an EventListener of click. This lets the browser listen for a click, and then do something. &lt;/p&gt;

&lt;p&gt;I then created another EventListener that said that if the mouse left that div, to remove the div. This event is 'mouseleave'.&lt;/p&gt;

&lt;p&gt;From there I created a function that basically said: &lt;strong&gt;"When this menu item is clicked, show this menu-content, and if the mouse leaves, hide it."&lt;/strong&gt; Here's how I built this feature.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; let navhover = 
 document.getElementsByClassName('navhover') 
 [0]



 let newselections = 
 document.getElementsByClassName('navhover', 
 'new', 'selections')[1]

 let menuitemnew = 
 document.getElementsByClassName('nav- 
 hover', 'new')[0]




 let showitemnew = function () {
 {
    newselections.classList.add('navhover', 
       'new', 'selections-visible')
    navhover.classList.add('navhover- 
       visible')
       console.log('showing')
     }
 }

 let hideitemnew = function () {
   {
 newselections.classList.remove('navhover', 
      'new', 'selections-visible')
    navhover.classList.remove('navhover- 
      visible')
    console.log('removed')
    }
  }



 menuitemnew.addEventListener('mouseover', 
    function () {
    showitemnew();
 })


newselections.addEventListener('mouseleave', 
   function () {
   hideitemnew();
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;One thing I learned from this:&lt;/strong&gt;  Organize both your CSS and your JavaScript, because it's very easy to get things confused.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>css</category>
    </item>
    <item>
      <title>Installing Node Js. Ubuntu, and Gulp - Tips</title>
      <dc:creator>David Frempong</dc:creator>
      <pubDate>Fri, 21 Jan 2022 15:15:15 +0000</pubDate>
      <link>https://dev.to/davidfrempong/installing-node-js-ubuntu-and-gulp-tips-1317</link>
      <guid>https://dev.to/davidfrempong/installing-node-js-ubuntu-and-gulp-tips-1317</guid>
      <description>&lt;p&gt;I recently spent four days in the terminal trying to start a jQuery application. &lt;strong&gt;Here are some mistakes I made so you don't have to.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One, follow the documentation step by step. Even when I had one space or letter off, I had trouble installing the packages. &lt;/p&gt;

&lt;p&gt;Two, when typing in your Sudo password, Windows will keep it invisible for confidentiality, so commit it to memory if possible, and don't worry if you can't see it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's a very helpful tip.&lt;/strong&gt; You know how in JS, you can use &lt;code&gt;console.log&lt;/code&gt; to debug? Here's a easy way to debug in Ubuntu to make sure that everything is working correctly. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   gulp --version
   npm --version
   node --version
   npx --version 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You should get four sets of numbers like this: &lt;code&gt;6.14.4&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also,&lt;/strong&gt; if running an application, and you're using &lt;code&gt;npm run watch&lt;/code&gt;, make sure you have both a &lt;strong&gt;local and external access URL&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;And of course, don't give up. The problem will be solved, and hopefully with these tips you won't be in the terminal as long as I was.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>ubuntu</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How I target an Element By Class Name in JavaScript</title>
      <dc:creator>David Frempong</dc:creator>
      <pubDate>Thu, 13 Jan 2022 21:58:39 +0000</pubDate>
      <link>https://dev.to/davidfrempong/how-i-target-an-element-by-class-name-in-javascript-p6</link>
      <guid>https://dev.to/davidfrempong/how-i-target-an-element-by-class-name-in-javascript-p6</guid>
      <description>&lt;p&gt;This concept deals with the classes you create in HTML.&lt;/p&gt;

&lt;p&gt;IF I want to target a specific class in JavaScript, I'll do something like this first in HTML:&lt;br&gt;
   &lt;code&gt;&amp;lt;div class="next"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That is my HTML class. And in JavaScript, &lt;/p&gt;

&lt;p&gt;&lt;code&gt;document.getElementsByClassName('next')[0]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You want the document, or DOM, to "get" the element by it's class name in HTML. But why did I add that 0 with the brackets like this [0]?&lt;/p&gt;

&lt;p&gt;Each class is listed as an array, or group of items. So to choose the one I want, I simply choose the specific "index" in the array which is equal to the class I'm trying to target.&lt;/p&gt;

&lt;p&gt;This is one way you can target an HTML class in JavaScript.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>How I built a dropdown cart modal in JavaScript</title>
      <dc:creator>David Frempong</dc:creator>
      <pubDate>Wed, 05 Jan 2022 19:55:23 +0000</pubDate>
      <link>https://dev.to/davidfrempong/how-i-built-a-dropdown-cart-modal-in-javascript-1i22</link>
      <guid>https://dev.to/davidfrempong/how-i-built-a-dropdown-cart-modal-in-javascript-1i22</guid>
      <description>&lt;p&gt;Here's how I built a feature which allows a cart modal to fade in when it's clicked.&lt;/p&gt;

&lt;p&gt;First, I want to create a class with all my styles, and then to trigger in JS, give the first class a display: none. I then create a second class named (-visible) and give it a display: flex;.&lt;/p&gt;

&lt;p&gt;It looks like this: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .dropdown-cart{
background: #fafafa;
height: 57vh;
width: 25%;
top: 91px;
right: 0px;
position: fixed;
display: none; (Here's where I hide the cart)
padding-left: 4%;
z-index: 1;
animation-duration: 1s;
animation-name: fadein;  (Here is where the effect will come in)
}

.dropdown-cart-visible{
display: flex; (Here's where the cart is visible)
padding-left: 4%;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In JS, I made sure to create variables that would help me target the index I was looking for. &lt;/p&gt;

&lt;p&gt;Basically, I created a variable for the cart icon and the modal itself, so when you click on the icon, it will fade in, and if you click again, it will fade out. Here's what it looks like.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let dropdowncart = 
document.getElementsByClassName('dropdown-cart')[0]

let carticon = 
document.getElementsByClassName('cart')[0]


let showdropdown = function () {
    dropdowncart.classList.add('dropdown-cart-visible')
    pagefade.classList.add('fadecart-fadein')
    console.log('hello')
}

let hidedropdown = function () {
    dropdowncart.classList.remove('dropdown-cart-visible')
    pagefade.classList.remove('fadecart-fadein')
    console.log('goodbye')
}



carticon.addEventListener('click', function () {
    showdropdown();
})

closeicon.addEventListener('click', function () {
    hidedropdown();
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To sum it up,&lt;br&gt;
1) Create your classes in CSS, and hide the original class, since you don't want it shown until clicked.&lt;/p&gt;

&lt;p&gt;2) Create a second class of -visible, and that's what you'll use to create variables in JS.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>How I center a div</title>
      <dc:creator>David Frempong</dc:creator>
      <pubDate>Fri, 31 Dec 2021 14:45:06 +0000</pubDate>
      <link>https://dev.to/davidfrempong/how-i-center-a-div-2ijb</link>
      <guid>https://dev.to/davidfrempong/how-i-center-a-div-2ijb</guid>
      <description>&lt;p&gt;This is one of the most commonly asked questions, so here's how I do it.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; HTML: 
 &amp;lt;div class='circle'&amp;gt;&amp;lt;/div&amp;gt;

 CSS:
 .circle{
 height: 24px;
 width: 24px;
 border-radius: 50%;
 background: #618ed6;
 justify-content: center; 
      (justify's content in center of page)
 text-align: center;
      (any text will be aligned to center of page)
 margin: 0 auto;
      (creates an equal amount of margin on each side, centering the object)
 padding: 0;
      (I do this if necessary to help center the object)
     }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>html</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Design tip from Apple's Website</title>
      <dc:creator>David Frempong</dc:creator>
      <pubDate>Fri, 31 Dec 2021 14:40:06 +0000</pubDate>
      <link>https://dev.to/davidfrempong/design-tip-from-apples-website-3524</link>
      <guid>https://dev.to/davidfrempong/design-tip-from-apples-website-3524</guid>
      <description>&lt;p&gt;Designing pages can be tricky, but here's some things I've learned from Apple's website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1: Use Contrast.&lt;/strong&gt; If you look at their product description, you'll notice they'll have an initial sentence in one color, and a secondary sentence in other. To me, using this slight contrast in color helps to give more information to the user, while also creating a clean layout. Because everything is not in one color, it's easier for someone to take in the information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1: Use Cards.&lt;/strong&gt; When you go to their store page, do you notice how they have information on individual "cards", and you can swipe left and right to learn more? Why didn't they just put everything on one page? To me, they did this to reduce the cognitive load, or in other words, make it easier for the visitor to understand what's going on. &lt;/p&gt;

&lt;p&gt;One thing I've learned about Apple is that they make it easy for people to buy things from their website. Using &lt;strong&gt;contrast&lt;/strong&gt; and &lt;strong&gt;cards&lt;/strong&gt; are just two ways I've seen that they've used to create a good user experience and clean web page.&lt;/p&gt;

</description>
      <category>ux</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What I've learned about good UX</title>
      <dc:creator>David Frempong</dc:creator>
      <pubDate>Thu, 23 Dec 2021 15:36:51 +0000</pubDate>
      <link>https://dev.to/davidfrempong/what-ive-learned-about-good-ux-31m9</link>
      <guid>https://dev.to/davidfrempong/what-ive-learned-about-good-ux-31m9</guid>
      <description>&lt;p&gt;There are a lot of websites, apps, and softwares out there. But, what makes them easy to use? Here's what I've seen.&lt;/p&gt;

&lt;p&gt;For one, most people go on the web on their cell phone, so creating a product that's mobile friendly seems like a good start.&lt;/p&gt;

&lt;p&gt;Also, many of us use our phones with just one hand, so making sure that a website can be accessed and used with one hand is also helpful. &lt;/p&gt;

&lt;p&gt;Another helpful idea is including tooltips in HTML. Many times, a website visitor may want more information on what is shown, so a tooltip where they can hover for more information is helpful.&lt;/p&gt;

&lt;p&gt;These are just a few things I've noticed that help make websites and apps easy to use.&lt;/p&gt;

</description>
      <category>ux</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
