<?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: Gideon Chimaroke</title>
    <description>The latest articles on DEV Community by Gideon Chimaroke (@gideon1999).</description>
    <link>https://dev.to/gideon1999</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%2F1196443%2F5d707779-2351-40c5-9d39-7de036a352f7.jpg</url>
      <title>DEV Community: Gideon Chimaroke</title>
      <link>https://dev.to/gideon1999</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gideon1999"/>
    <language>en</language>
    <item>
      <title>Mastering the useState Hook: Creating a GitHub profile catalog using an API</title>
      <dc:creator>Gideon Chimaroke</dc:creator>
      <pubDate>Tue, 31 Oct 2023 10:46:18 +0000</pubDate>
      <link>https://dev.to/gideon1999/mastering-the-usestate-hook-creating-a-github-profile-catalog-using-an-api-33ge</link>
      <guid>https://dev.to/gideon1999/mastering-the-usestate-hook-creating-a-github-profile-catalog-using-an-api-33ge</guid>
      <description>&lt;p&gt;What you should Know:&lt;/p&gt;

&lt;p&gt;Knowledge of Javascript&lt;br&gt;
Basic knowledge of React&lt;br&gt;
Basic knowledge of React Hooks, especially useState() &amp;amp; useEffect&lt;br&gt;
React hooks are the modern way to deal with application state and lifecycle events within components. Hooks have been introduced to make React code cleaner.&lt;/p&gt;

&lt;p&gt;React has multiple hooks to carry out different operations. We have majorly the useState and useEffect hooks. It’s necessary that every aspiring React developer should be knowledgeable in these hooks, especially these 2.&lt;/p&gt;

&lt;p&gt;useState and useEffect are destructured from react.&lt;/p&gt;

&lt;p&gt;import { useState, useEffect } from “react&lt;/p&gt;

&lt;p&gt;We initialize our state by calling useState in our function component.&lt;/p&gt;

&lt;p&gt;useState accepts an initial state and returns two values:&lt;/p&gt;

&lt;p&gt;The current state.&lt;br&gt;
A function that updates the state.&lt;br&gt;
import { useState } from "react";&lt;/p&gt;

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

&lt;p&gt;const [value, setValue] = useState(0);&lt;/p&gt;

&lt;p&gt;return (&lt;/p&gt;


&lt;h1&gt;{value}&lt;/h1&gt; //prints zero

&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;The useEffect hook allows us to respond to changes in the component lifecycle. The component lifecycle refers to a set of events that occur from the time a component is mounted to the DOM until it is removed. It uses a dependency array to determine how many times it renders.&lt;/p&gt;

&lt;p&gt;One of the benefits of useState is used to fetch data from an Api endpoint&lt;/p&gt;

&lt;p&gt;We will be using the Github Api to create collage of Github contributors. (This idea is extracted from CoddingAddict).&lt;/p&gt;

&lt;p&gt;If we open the link(&lt;a href="https://api.github.com/users"&gt;https://api.github.com/users&lt;/a&gt;) on the web browser, You would get this:&lt;/p&gt;

&lt;p&gt;[&lt;/p&gt;

&lt;p&gt;{&lt;/p&gt;

&lt;p&gt;"login": "mojombo",&lt;/p&gt;

&lt;p&gt;"id": 1,&lt;/p&gt;

&lt;p&gt;"node_id": "MDQ6VXNlcjE=",&lt;/p&gt;

&lt;p&gt;"avatar_url": "&lt;a href="https://avatars.githubusercontent.com/u/1?v=4"&gt;https://avatars.githubusercontent.com/u/1?v=4&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"gravatar_id": "",&lt;/p&gt;

&lt;p&gt;"url": "&lt;a href="https://api.github.com/users/mojombo"&gt;https://api.github.com/users/mojombo&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"html_url": "&lt;a href="https://github.com/mojombo"&gt;https://github.com/mojombo&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"followers_url": "&lt;a href="https://api.github.com/users/mojombo/followers"&gt;https://api.github.com/users/mojombo/followers&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"following_url": "&lt;a href="https://api.github.com/users/mojombo/following%7B/other_user%7D"&gt;https://api.github.com/users/mojombo/following{/other_user}&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"gists_url": "&lt;a href="https://api.github.com/users/mojombo/gists%7B/gist_id%7D"&gt;https://api.github.com/users/mojombo/gists{/gist_id}&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"starred_url": "&lt;a href="https://api.github.com/users/mojombo/starred%7B/owner%7D%7B/repo%7D"&gt;https://api.github.com/users/mojombo/starred{/owner}{/repo}&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"subscriptions_url": "&lt;a href="https://api.github.com/users/mojombo/subscriptions"&gt;https://api.github.com/users/mojombo/subscriptions&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"organizations_url": "&lt;a href="https://api.github.com/users/mojombo/orgs"&gt;https://api.github.com/users/mojombo/orgs&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"repos_url": "&lt;a href="https://api.github.com/users/mojombo/repos"&gt;https://api.github.com/users/mojombo/repos&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"events_url": "&lt;a href="https://api.github.com/users/mojombo/events%7B/privacy%7D"&gt;https://api.github.com/users/mojombo/events{/privacy}&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"received_events_url": "&lt;a href="https://api.github.com/users/mojombo/received_events"&gt;https://api.github.com/users/mojombo/received_events&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"type": "User",&lt;/p&gt;

&lt;p&gt;"site_admin": false&lt;/p&gt;

&lt;p&gt;},&lt;/p&gt;

&lt;p&gt;{&lt;/p&gt;

&lt;p&gt;"login": "defunkt",&lt;/p&gt;

&lt;p&gt;"id": 2,&lt;/p&gt;

&lt;p&gt;"node_id": "MDQ6VXNlcjI=",&lt;/p&gt;

&lt;p&gt;"avatar_url": "&lt;a href="https://avatars.githubusercontent.com/u/2?v=4"&gt;https://avatars.githubusercontent.com/u/2?v=4&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"gravatar_id": "",&lt;/p&gt;

&lt;p&gt;"url": "&lt;a href="https://api.github.com/users/defunkt"&gt;https://api.github.com/users/defunkt&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"html_url": "&lt;a href="https://github.com/defunkt"&gt;https://github.com/defunkt&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"followers_url": "&lt;a href="https://api.github.com/users/defunkt/followers"&gt;https://api.github.com/users/defunkt/followers&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"following_url": "&lt;a href="https://api.github.com/users/defunkt/following%7B/other_user%7D"&gt;https://api.github.com/users/defunkt/following{/other_user}&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"gists_url": "&lt;a href="https://api.github.com/users/defunkt/gists%7B/gist_id%7D"&gt;https://api.github.com/users/defunkt/gists{/gist_id}&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"starred_url": "&lt;a href="https://api.github.com/users/defunkt/starred%7B/owner%7D%7B/repo%7D"&gt;https://api.github.com/users/defunkt/starred{/owner}{/repo}&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"subscriptions_url": "&lt;a href="https://api.github.com/users/defunkt/subscriptions"&gt;https://api.github.com/users/defunkt/subscriptions&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;"organizations_url": "&lt;a href="https://api.github.com/users/defunkt/orgs"&gt;https://api.github.com/users/defunkt/orgs&lt;/a&gt;",&lt;/p&gt;

&lt;p&gt;]&lt;/p&gt;

&lt;p&gt;An array of objects. We will to accessing each of these data and will be displaying it very soon.&lt;/p&gt;

&lt;p&gt;Declare your function components.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Exploring Variables in CSS (custom properties)</title>
      <dc:creator>Gideon Chimaroke</dc:creator>
      <pubDate>Mon, 30 Oct 2023 16:53:42 +0000</pubDate>
      <link>https://dev.to/gideon1999/exploring-variables-in-css-custom-properties-401g</link>
      <guid>https://dev.to/gideon1999/exploring-variables-in-css-custom-properties-401g</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2AUuRVpXO_DAQNKxQMZ0_ebw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2AUuRVpXO_DAQNKxQMZ0_ebw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Variables in CSS (custom properties)
&lt;/h2&gt;

&lt;p&gt;Like most programming languages, native CSS now has support for variables. If you have knowledge of programming languages, you will know variables are used to store values.&lt;/p&gt;

&lt;p&gt;CSS variables (officially known as custom properties) are entities defined by a user. They allow you to store values in your CSS files, which other parts of your stylesheet can then use. This makes it easier for teams working on large projects and allows developers to change values without repeating the change to every element style. They can be used as a value for any property, including, color margin and padding (eg., &lt;strong&gt;— primary-color: red;&lt;/strong&gt; ).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Basic knowledge of styling HTML documents using CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Usage — how to declare a custom property
&lt;/h2&gt;

&lt;p&gt;To declare a variable in CSS, come up with a name for the variable, then append double hyphens (-) as the prefix.&lt;/p&gt;

&lt;p&gt;It is best practice to define all of your variables at the top of your stylesheet. You could declare them in the :root element.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
--primary-color: #FF5733;
--mypadding: 2rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The custom property isn’t just for declaring color property. It could be used to house different CSS style properties.&lt;/p&gt;

&lt;p&gt;Here is a working example:&lt;/p&gt;

&lt;p&gt;Here’s an HTML boilerplate with a couple of HTML tags. We’ll be styling these tags with CSS variables.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta charset="UTF-8" /&amp;gt;
&amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
&amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;link rel="stylesheet" href="hello.css" /&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Welcome to Medium&amp;lt;/h1&amp;gt;
&amp;lt;h2&amp;gt;Using CSS custom properties&amp;lt;/h2&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I decided to center the text and change the background color with my predefined variable (--body-color). I defined five variables at the top of the stylesheet.&lt;/p&gt;

&lt;p&gt;Lastly, I applied those variables to my tags using the var() function.&lt;/p&gt;

&lt;p&gt;CSS part:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
  --body-color: rgb(33, 47, 108);
  --primary-color: #ff5733;
  --secondary-color: #ebb41f;
  --H1font-size: 4em;
  --H2font-size: 2em;
}
body {
  background-color: var(--body-color);
  text-align: center;
}
h1 {
  color: var(--primary-color);
  font-size: var(--H1font-size);
}
h2 {
  color: var(--secondary-color);
  font-size: var(--H2font-size);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3826%2F1%2AlEwgxT1IRdFIVaVRYMxckw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3826%2F1%2AlEwgxT1IRdFIVaVRYMxckw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Handling invalid variables with fallbacks:
&lt;/h2&gt;

&lt;p&gt;In some cases, you might reference a custom property that isn’t defined in the document. This is the case when you misspell a variable name. You can specify a fallback value to be used in place of that value. The syntax for providing a fallback value is still the var() notation. Add a comma and then give the values that come as a substitute. You could suggest multiple fallbacks.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
  --primary-color: #33ffd3;
}
h1 {
  color: var(--priary-color, #ff0000, #ffffff); /* if --priary-color doesn't work, then the next fallbac*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Did you notice that I misspelled the value — primary-colour? This should cause the value to be undefined, in which case the browser would use the first fallback value (red). If, for some reason, the first fallback doesn’t show, the next value would kick in(white), and so on. The browser will use the initial default color if it can’t find any of the provided values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a button variation — applying custom properties
&lt;/h2&gt;

&lt;p&gt;We’ll be applying the knowledge of custom properties to create different buttons. Buttons are an important part of a website. The appearance of a button is necessary for any website. I created three buttons and styled them with the predefined variables.&lt;/p&gt;

&lt;p&gt;Here is the Html:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta charset="UTF-8" /&amp;gt;
&amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
&amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;link rel="stylesheet" href="hello.css" /&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;section&amp;gt;
&amp;lt;h2&amp;gt;Button variation&amp;lt;/h2&amp;gt;
&amp;lt;button class="Success"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;button class="Cancel"&amp;gt;Cancel&amp;lt;/button&amp;gt;
&amp;lt;button class="Back"&amp;gt;Back&amp;lt;/button&amp;gt;
&amp;lt;/section&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
Here I gave each of the buttons different class names which I will style in the CSS section.
:root {
--back: #353434;
--cancel: #ce0606;
--success: #138b71;
--white: #ffffff;
}
.Back {
background: var(--back);
color: var(--white);
padding: 1rem 20px;
border-radius: 10px;
color: var(--white);
font-weight: 700;
cursor: pointer;
outline: none;
font-weight: 700;
}
.Success {
background: var(--success);
color: var(--white);
padding: 1rem 20px;
border-radius: 10px;
color: var(--white);
font-weight: 700;
cursor: pointer;
outline: none;
font-weight: 700;
}
.Cancel {
background: var(--cancel);
padding: 1rem 20px;
border-radius: 10px;
color: var(--white);
font-weight: 700;
cursor: pointer;
outline: none;
font-weight: 700;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The variables are defined in the :root element with various colors. These variables are then added to the various background and colors using their variable names.&lt;/p&gt;

&lt;p&gt;The output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2724%2F0%2AfxSYOlt98jkkgRmU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2724%2F0%2AfxSYOlt98jkkgRmU.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Variables are a great way to add flexibility to your CSS. They allow you to change the value of a property at runtime, and they’re also helpful for easily testing different values. Variables are an essential part of modern CSS development, but they can be hard to understand for beginners. This article is to walk you through how they work and how you can use them in your own projects.&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
