<?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: Kemi Owoyele</title>
    <description>The latest articles on DEV Community by Kemi Owoyele (@kemiowoyele1).</description>
    <link>https://dev.to/kemiowoyele1</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%2F438567%2F6122b62f-d08e-42f0-8bd6-e0e0ec2b89b3.jpg</url>
      <title>DEV Community: Kemi Owoyele</title>
      <link>https://dev.to/kemiowoyele1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kemiowoyele1"/>
    <language>en</language>
    <item>
      <title>Overcoming Obstacles: Proven Strategies for Learning to Code</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Mon, 15 Jul 2024 23:03:49 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/overcoming-obstacles-proven-strategies-for-learning-to-code-4a2n</link>
      <guid>https://dev.to/kemiowoyele1/overcoming-obstacles-proven-strategies-for-learning-to-code-4a2n</guid>
      <description>&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%2Fp5y92uz3otn85b97owmp.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%2Fp5y92uz3otn85b97owmp.png" alt="Image description" width="800" height="653"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The journey of learning to code can be a bit daunting. It is very easy to start feeling like you are not smart enough for this career path or that coding is just too hard for you. Or maybe you started with a lot of enthusiasm, but a few weeks in, you start feeling stuck and find yourself lacking motivation to carry on. &lt;br&gt;
For some, it is getting stuck in tutorial hell, watching several tutorials and feeling good but still unable to implement what was learned on their own. It can feel like being stuck in a wilderness with no way back or forth. These experiences are very common among coders, especially at the early stages of learning. In this article, we are going to explore some of the steps you can take to make the journey less turbulent. &lt;/p&gt;

&lt;h2&gt;
  
  
  1.   Start with a clear goal in mind:
&lt;/h2&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%2F536dgl4je9ktncdpovmt.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%2F536dgl4je9ktncdpovmt.png" alt="Image description" width="800" height="683"&gt;&lt;/a&gt;&lt;br&gt;
It is important to set goals and plan towards any important move you want to make in life. As with programming, you should have a plan. This could be to get a job within a reasonable specified time, build a project, a SAAS product, freelance or venture into some tech related entrepreneurship. &lt;br&gt;
You should also decide on what aspect of programing you intend to learn. If you are not sure yet, you should do some research on the various coding related career paths and figure out which one is fitting for your goal.&lt;br&gt;
You also need to set a learning plan. Are you going to take an online course, attend a boot camp, get a personal tutor, or learn on your own? How do you make out time for learning? How much time can you afford to spare, or what are you willing to give up?&lt;br&gt;
You need the plan, so it can be a guide for you as you embark on the journey. Your goal might be needed as a motivation for when you face difficulty. Reminding yourself, why you started learning might help keep you on track.&lt;br&gt;
It will also help to set daily/weekly goals. You should also review the goals against the results at the end of the period. &lt;br&gt;
While setting goals though, try as much as possible to be realistic. If your initial goal turns out to be too unrealistic, it wouldn’t hurt to readjust the goals. Unrealistic goals could overwhelm you, and cause you to feel like a failure even if you are doing way better than most people are doing. &lt;br&gt;
“Goals are the fuel for the engine of achievement”-Brian Tracy&lt;/p&gt;

&lt;h2&gt;
  
  
  2.   Pick one programming language and stick to it.
&lt;/h2&gt;

&lt;p&gt;The programming language you choose will be determined by your goal, or what you intend to achieve by learning to program. The language you need for game development, for instance, is different from the one you will need for web development or data analysis. &lt;br&gt;
After deciding on the programming language, get a relevant roadmap and let it guide you as you progress. If you are learning on your own, it is very important to work with a roadmap to avoid unnecessary distractions. Do not move on to the next topic until you are comfortable with the current topic.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.   Experiment with different resources or approaches to find out which is most suitable for you.
&lt;/h2&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%2Frasu7qxslgc25lookj4p.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%2Frasu7qxslgc25lookj4p.png" alt="Image description" width="800" height="921"&gt;&lt;/a&gt;&lt;br&gt;
Seek out online resources, Read documentation, watch video tutorials, read articles and books. Find out which combination is more suitable for you. If you are reading or watching videos, code along and take notes. Unless you find the material unhelpful, try not to move on to the next video or material until you are comfortable with the codes you learned from that material.&lt;/p&gt;

&lt;h2&gt;
  
  
  4.   Learn the basics
&lt;/h2&gt;

&lt;p&gt;Don’t jump this step. Get yourself well-grounded in the fundamentals of the programming language you are learning.&lt;br&gt;
Learn how the programming language you are learning works behind the scenes. Don’t ignore the theoretical aspect of programming, learn the theory and practice what you learned.&lt;/p&gt;

&lt;h2&gt;
  
  
  5.   Always Be Coding
&lt;/h2&gt;

&lt;p&gt;Code like your life depends on it. It is important to code. You learn to code by coding. Every other step is hinged upon this step. In all your learning, if you do not practice by writing your own codes, you will not be able to make visible progress. After watching tutorials or reading an article or documentation, fiddle with the codes; try them out with different scenarios. Find out for yourself what will work and what will not.&lt;br&gt;
It may also help to code by hand. Coding by hand might seem old school, but it will help you to strengthen your mental muscles, especially with writing syntax precisely. Coding by hand is also helpful during job interviews.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Learn by doing
&lt;/h2&gt;

&lt;p&gt;Make a small project from each topic or concept you learn. Own the codes. Practice the code samples until they are fully imbibed in you. Break down complex concepts into smaller, manageable chunks. Write a lot of small projects, and work your way up to more complex ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  7.    Don’t do it alone
&lt;/h2&gt;

&lt;p&gt;Find a community of learners to engage with. If you are in a boot camp or doing an online course, don’t take pair programming for granted. Seek help whenever you need one. Don’t hesitate to ask for help, sometimes a bug you’ve been struggling with for hours will be easier to spot for someone else with a different perspective, or who has encountered the same bug before.&lt;br&gt;
     Collaborate with someone more experienced. Seek out a mentor if you can find one. Mentors are more likely to make your journey easier. They will help you figure out where you may be going wrong and help you avoid the mistakes they made while they were learning. They may even give you projects to do or materials that they found most helpful. Mentors can also help get jobs or land first sets of freelance projects.&lt;br&gt;
    Be open to feedback. Do not take criticisms as a blow to your ego. Rather, consider it as an opportunity to learn different perspectives, and as a challenge to get better. Feedback may also help you identify your areas of weakness, areas you may need to pay some more attention to.&lt;br&gt;
Don’t hoard knowledge; share what you have learned with other learners. You can do this with your peers at a boot camp or an online course platform, or by answering questions on Quora, StackOverflow, Reddit, Discord, WhatsApp groups etc. Get involved in communities attend meet-ups (both online and physically), and be an active participant.&lt;/p&gt;

&lt;h2&gt;
  
  
  8.   Endeavor to stay motivated
&lt;/h2&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%2Fsv03ek62fmws8e1ieryc.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%2Fsv03ek62fmws8e1ieryc.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
Make coding a habit. Motivation is very important in learning to code, but way more important than motivation is personal discipline. There are times when you will find it hard to be motivated, especially when you are stuck on a problem for a while. This is where discipline comes in. You have to decide that irrespective of how you feel, you will stick to the plan you set for your learning. Focus on the end goal. Always remind yourself of the reason you got started in the first place. &lt;br&gt;
Learn to fall in love with the process. Find a project that you are passionate about. Building a personal project on something that particularly interests you can be very good for your morale.&lt;br&gt;
It may also help to celebrate your small wins. For each milestone you cross, throw yourself a mini party. Be happy for yourself. Evaluate your progress based on the things you could not do previously that you can now do with minimal effort.&lt;/p&gt;

&lt;h2&gt;
  
  
  9.   Be a problem solver
&lt;/h2&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%2Fo5emoa57bnn3ukgstp1q.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%2Fo5emoa57bnn3ukgstp1q.png" alt="Image description" width="800" height="182"&gt;&lt;/a&gt;&lt;br&gt;
The core purpose of programming is problem-solving. Try to solve as many problems as possible, of varying difficulty, &lt;br&gt;
Also, when you choose to do a project, try as much as possible to complete that project. Especially if you find it difficult. Most of the time, these difficult situations are your best opportunities for growing. Expect to fail repeatedly, but make sure you learn from every mistake, bug or error.&lt;/p&gt;

&lt;h2&gt;
  
  
  10.  Don’t be too anxious about your learning speed.
&lt;/h2&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%2Fpblgkvbri67cm15tjldu.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%2Fpblgkvbri67cm15tjldu.png" alt="Image description" width="447" height="448"&gt;&lt;/a&gt;&lt;br&gt;
The anxiety could be crippling at times. Although it is also important not to be stagnant, the most important thing is not how fast you learn, but how consistently you are improving. You may have intended to learn a particular topic for two days. Don’t jump to the next topic before you are comfortable enough with the current topic just because of deadline. Be patient with yourself. You are not dull. Learning to code takes time and can be hard. Don't get discouraged if progress is slow.&lt;br&gt;
It is also important to take breaks. This is more important when trying to debug an error. If after a couple of minutes the error is being persistent, take a short break and come back to it.&lt;br&gt;
The entire learning process can easily become overwhelming sometimes that you might forget to take proper rest or eat well. It is important to know when to rest, and take care of yourself. Your physical and mental health is also imperative to achieving your learning goals.&lt;/p&gt;

&lt;h2&gt;
  
  
  11.  Avoid distraction
&lt;/h2&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%2Fpqk16agjvub4m4yadz71.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%2Fpqk16agjvub4m4yadz71.png" alt="Image description" width="734" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don’t pay attention to noise and unhealthy hot takes on the internet. This can be very confusing. Sometimes, you are just beginning your learning journey, then someone on the internet is posting something like “websites will soon be obsolete”, “AI will soon take all our jobs”, “apps are dead”, “a particular programming language is dead” etc. This could discourage you from persisting with what you are learning. The best thing is to recognize these takes for what they are. Most times, they are just click baits. People have been saying these things for years, and programming has remained a promising career path nonetheless.&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%2Fxxekl9zsq1pkj2ilyd58.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%2Fxxekl9zsq1pkj2ilyd58.png" alt="Image description" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also be careful with new technologies and frameworks. Sometimes, while you are learning something, something new may pop up, and everyone is talking about it. Do not allow that to distract you, especially if you are not yet well-grounded with the fundamentals. Focus on your roadmap.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You will need a lot of dedication, passion, commitment, grit.&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%2Fa1b5m3sxhb84w4c99ecy.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%2Fa1b5m3sxhb84w4c99ecy.png" alt="Image description" width="718" height="648"&gt;&lt;/a&gt;&lt;br&gt;
“It doesn’t matter how many times you fail, remember you only have to succeed once.”&lt;br&gt;
Mark Cuban.&lt;br&gt;
That once will definitely make up for all the failures you’ve experienced.&lt;/p&gt;

&lt;h2&gt;
  
  
  13.  You need to be consistent in learning.
&lt;/h2&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%2Ffgfrny1wfliw4eiugb12.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%2Ffgfrny1wfliw4eiugb12.png" alt="Image description" width="800" height="665"&gt;&lt;/a&gt;&lt;br&gt;
One or two hours daily are better than six hours binge once in a week. It may help to participate in the #100dayofcode. Try coding every day for at least an hour. You may get more comfortable with coding that you can start coding for longer hours.&lt;br&gt;
    Also, set aside a particular time of the day, or learning environment to help get you in the zone. Try as much as possible to put away distraction. If for example you code by 4pm daily, try as much as possible to make the environment conducive for that time. And when learning, try not to multi-task. Just focus on learning one thing at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  14.  Believe in yourself, be confident
&lt;/h2&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%2Fpq30p9vcorp90oywpf60.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%2Fpq30p9vcorp90oywpf60.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
You just have to believe in yourself. Others have done it, you can do it too. No matter how difficult it feels, convince yourself that you can do it. Practice positive self-talk, overcome self-doubt and imposter syndrome. Be your own cheer leader/ hype man.&lt;/p&gt;

&lt;p&gt;Surround yourself with positivity; listen to podcasts that can help strengthen your mental resilience. Expect to fail several times, they are opportunities to grow and learn. &lt;br&gt;
Self-confidence, like every other skill can be learned. You can start small and grow in confidence as you proceed in your journey. Challenge every negative thought, take calculated risks. Whenever that voice tells you that it can’t be done, prove it wrong by getting it done. With each challenge you overcome, your confidence gets better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Embarking on the journey of learning to code demands a willingness to make sacrifices. It requires surrendering your comfort zone, dedicating countless hours, and persevering through obstacles. By following the steps outlined in this article, you'll be forced to confront your limits and push past them. Embrace the sacrifice, stay committed to your goals, and don't hesitate to seek guidance when needed. In return, you'll unlock your full potential and reap the rewards of success in the world of programming.&lt;br&gt;
What are the strategies that have worked for you? Please, share with us in the comment section. You may also share what obstacles you may have faced, and how you are tackling those challenges.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>learning</category>
      <category>beginners</category>
      <category>coding</category>
    </item>
    <item>
      <title>Build a digital clock with React JS; A step-by-step guide</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Mon, 15 Jul 2024 15:05:34 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/build-a-digital-clock-with-react-js-a-step-by-step-guide-4n7b</link>
      <guid>https://dev.to/kemiowoyele1/build-a-digital-clock-with-react-js-a-step-by-step-guide-4n7b</guid>
      <description>&lt;p&gt;In this series of building simple projects with react, we are at the digital clock bus stop. Our final project will 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%2F4to4ybowrewxg9w31w5c.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%2F4to4ybowrewxg9w31w5c.png" alt="Image description" width="616" height="519"&gt;&lt;/a&gt;&lt;br&gt;
Simply cool right?&lt;br&gt;
So let’s get started by creating a react app. If you are not sure if you have the modern version of node in your computer, confirm by typing &lt;code&gt;node –v&lt;/code&gt; in your terminal. If a version number does not show up, or the version is less than version 5.2, visit nodejs.org and download the latest version of node.&lt;br&gt;
If you’ve done this, still in your terminal, navigate to the location you would like to create your app in and type in&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  npx create-react-app digital-clock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This may take a while, as npx runs the code on the internet and downloads a new app for you along with all the needed dependencies for a starter project. After the app is created, navigate into the app and type &lt;code&gt;code.&lt;/code&gt; To open the code in vscode(if that is your default code editor). If your default code editor is not vscode, open up your editor to the newly created folder. To run the app on the browser, type &lt;code&gt;npm start&lt;/code&gt; in the terminal. Ensure that the terminal is addressed to the root folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the DigitalClock component
&lt;/h2&gt;

&lt;p&gt;In the src folder of the app created for you, create a new file and name it DigitalClock.js. In the file, create a basic react component and export it at the bottom.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const DigitalClock = () =&amp;gt; {
  return &amp;lt;&amp;gt;&amp;lt;/&amp;gt;;
};
export default DigitalClock;

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

&lt;/div&gt;



&lt;p&gt;Now, go to the root component of your app and replace the content with the codes below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import DigitalClock from "./DigitalClock";
function App() {
  return (
    &amp;lt;&amp;gt;
  &amp;lt;DigitalClock /&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt;This is to import the DigitalClock component into the App component and render the DigitalClock.&lt;/p&gt;

&lt;h2&gt;
  
  
  Write the relevant jsx and CSS
&lt;/h2&gt;

&lt;p&gt;In our DigitalClock component, we will render our jsx codes for displaying the time in hours, minutes and seconds. We will also display the date in another section of the clock.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const DigitalClock =() =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="clock-container"&amp;gt;
        &amp;lt;div className="cover"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;p className="date"&amp;gt;sun 1 Jan 2020&amp;lt;/p&amp;gt;
        &amp;lt;div className="time"&amp;gt;
          &amp;lt;span className="clock"&amp;gt;00:&amp;lt;/span&amp;gt;
          &amp;lt;span className="clock"&amp;gt;00:&amp;lt;/span&amp;gt;
          &amp;lt;span className="secs"&amp;gt;00&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;p className="date"&amp;gt;00:00:00 am&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}
export default DigitalClock;


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

&lt;/div&gt;



&lt;p&gt;Paste the following CSS style in your index.css file to replace the former content of the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Segoe UI", "Roboto", sans-serif;
  background: black;
  background: linear-gradient(
      45deg,
      rgb(184, 183, 185),
      rgb(90, 89, 133),
      rgb(158, 158, 161)
    ),
    conic-gradient(
      rgba(148, 195, 240, 0.4),
      rgba(107, 111, 131, 0.4),
      rgba(225, 192, 255, 0.4),
      rgba(82, 105, 184, 0.4)
    );
  background-size: 20px 50px, 100px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: rgb(18, 17, 68);
  text-shadow: 1px 1px 2px rgb(255, 255, 255);
  -webkit-text-stroke: 1px rgb(0, 0, 0);
  font-family: monospace;
  background-blend-mode: color-burn;
}
.clock-container {
  padding: 20px;
  border-radius: 50%;
  background-color: rgb(125, 130, 148);
  background-size: 3px 5px;
  box-shadow: inset 5px 5px 5px rgb(0, 0, 0), inset -5px -5px 5px rgb(0, 0, 0);
  height: 250px;
  width: 250px;
  position: relative;
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  align-items: center;
  text-align: center;
}
.cover {
  position: absolute;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  box-shadow: inset 5px 5px rgb(5, 5, 5), inset -5px -5px rgb(5, 5, 5);
  background-color: rgba(0, 2, 10, 0.363);
  background: conic-gradient(
    rgb(185, 185, 199),
    rgb(205, 205, 243),
    rgb(139, 147, 177),
    rgb(139, 141, 175)
  );
  opacity: 0.3;
  border-radius: 50%;
}
.date {
  font-size: 1rem;
  font-weight: 900;
}

.time {
  padding: 10px 0;
  border-radius: 30px;
  background: rgb(0, 0, 69);
  color: #fff;
  font-size: 2rem;
  font-weight: 900;
  text-shadow: 1px 1px 2px rgb(91, 109, 161);
  -webkit-text-stroke: 1px rgb(0, 0, 0);
  box-shadow: 3px 5px 5px rgb(5, 5, 5);
}
.secs {
  font-size: 1rem;
}

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

&lt;/div&gt;



&lt;p&gt;Outcome so far&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%2Fw01wivg2ibn2ssqe1t3q.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%2Fw01wivg2ibn2ssqe1t3q.png" alt="Image description" width="509" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Write the code for getting the time
&lt;/h2&gt;

&lt;p&gt;So now we have a clock, but it’s not yet working. To make the clock work we will need to import two hooks. These are the useState hook and the useEffect hook.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;_The useState hook is used render variable updates, or variable state changes to the DOM. While useEffect hook is used to handle function side effects. _&lt;/p&gt;

&lt;p&gt;To use the useState hook, we assign useState to a variable and a function for setting the value of the time variable. And give it an initial value of the new date object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const [time, setTime] = useState(new Date());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  get the time to start running
&lt;/h2&gt;

&lt;p&gt;To get the time to update every second, we will have to run the update every second with the JavaScript setInterval method. And in react, actions like setting timers, fetching API, localstorage and other side effect producing functions are usually taken care of with the useEffect hook. This is also useful for cleaning up resources that are no longer in use with the cleanup function. Hence, inside the useEffect function, we will run the setInterval function, and return the cleanup function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  useEffect(() =&amp;gt; {
    const timeInterval = setInterval(() =&amp;gt; {
      setTime(new Date());
    }, 1000);

    return () =&amp;gt; clearInterval(timeInterval);
  }, []);

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Display the time on the clock
&lt;/h2&gt;

&lt;p&gt;Now we have the clock and the running time. But the time is yet to be displayed on the clock. So to display the time, we use curly braces to embed time. But we want to output date in one div, output the time in 12 hour format in another div and output the hours, minutes and seconds in another div. we will attach to the time variable the different relevant functions to extract the particular version of the time we need.&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 className="date"&amp;gt;{time.toDateString()}&amp;lt;/p&amp;gt;
        &amp;lt;div className="time"&amp;gt;
          &amp;lt;span className="clock"&amp;gt;{time.getHours()}:&amp;lt;/span&amp;gt;
          &amp;lt;span className="clock"&amp;gt;{time.getMinutes()}:&amp;lt;/span&amp;gt;
          &amp;lt;span className="secs"&amp;gt;{time.getSeconds()}&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;p className="date"&amp;gt;{time.toLocaleTimeString()}&amp;lt;/p&amp;gt;


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

&lt;/div&gt;



&lt;p&gt;The overall code for the DigitalClock component will be as below.&lt;br&gt;
&lt;/p&gt;

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

function DigitalClock() {
  const [time, setTime] = useState(new Date());

  useEffect(() =&amp;gt; {
    const timeInterval = setInterval(() =&amp;gt; {
      setTime(new Date());
    }, 1000);

    return () =&amp;gt; clearInterval(timeInterval);
  }, []);
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="clock-container"&amp;gt;
        &amp;lt;div className="cover"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;p className="date"&amp;gt;{time.toDateString()}&amp;lt;/p&amp;gt;
        &amp;lt;div className="time"&amp;gt;
          &amp;lt;span className="clock"&amp;gt;{time.getHours()}:&amp;lt;/span&amp;gt;
          &amp;lt;span className="clock"&amp;gt;{time.getMinutes()}:&amp;lt;/span&amp;gt;
          &amp;lt;span className="secs"&amp;gt;{time.getSeconds()}&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;p className="date"&amp;gt;{time.toLocaleTimeString()}&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}
export default DigitalClock;


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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Result
&lt;/h2&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%2Fg00wegvy0rebzovyldyx.gif" 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%2Fg00wegvy0rebzovyldyx.gif" alt="Image description" width="456" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We now have a functional digital clock that we built together with React. I will recommend that you try to build this app again on your own. You can make adjustments to the app if you deem fit. Also, try to build other simple projects to help you get more comfortable with React JS.&lt;br&gt;
    Let me know your outcomes, and whatever challenges you may face in the comment section. Also, if you want to read more front-end web development content, follow this account. Thank you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Build a weight converter app with React js</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Mon, 15 Jul 2024 12:37:39 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/build-a-weight-converter-app-with-react-js-2da4</link>
      <guid>https://dev.to/kemiowoyele1/build-a-weight-converter-app-with-react-js-2da4</guid>
      <description>&lt;p&gt;As you are learning React js, it is always advised to try building projects. This will help make your learning journey easier and help you get acquainted with the practical utilization of the tool.&lt;br&gt;
In this tutorial, we will build a simple weight converter app using React JS. This will allow us to explore a couple of introductions to react js concepts. We will explore how to create a component in react, how to dynamically display values, how to handle state change with the useState hook and how to access user inputs.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;• Knowledge of HTML &amp;amp; CSS&lt;br&gt;
• Knowledge of basic JavaScript&lt;br&gt;
• Introduction to react (not compulsory)&lt;/p&gt;
&lt;h2&gt;
  
  
  Create react app
&lt;/h2&gt;

&lt;p&gt;Verify that a modern version of node.js is installed in the computer you are using. In your terminal, navigate to the folder/location you want to create the app in and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app weight-converter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It may take a couple of minutes, while React sets up your app for you.&lt;br&gt;
Once the app is created, navigate into the created folder and type&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The localhost address will be provided for you, and your default page will open up in your default browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Set up the components
&lt;/h2&gt;

&lt;p&gt;In your src folder, create a new file and name it WeightConverter.js. In the WeightConverter.js app, set up a basic react component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const WeightConverter = () =&amp;gt; {
  return &amp;lt;&amp;gt;
        &amp;lt;/&amp;gt;;
};
export default WeightConverter;

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

&lt;/div&gt;



&lt;p&gt;In the App.js file, stripe the content of the file to the bare component and render the WeightConverter component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import WeightConverter from "./WeightConverter";
function App() {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;WeightConverter /&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt;The rest of the code we will write will be in our WeightConverter.js file. Our weight converter app will accept input in pounds and display real-time conversion into grams, kilograms, and ounces. Thus, our jsx/html will require an input tag for accepting user input, and a couple of divs for displaying the results. And some wrapping divs for styling purposes.&lt;br&gt;
*&lt;em&gt;jsx code *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "./weight-converter.css";
const WeightConverter = () =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="container"&amp;gt;
        &amp;lt;h1&amp;gt;Weight Converter&amp;lt;/h1&amp;gt;
        &amp;lt;div className="wrapper"&amp;gt;
          &amp;lt;input type="number" placeholder="enter pounds"&amp;gt;&amp;lt;/input&amp;gt;
          &amp;lt;div className="weight grams"&amp;gt;
            &amp;lt;div&amp;gt;0&amp;lt;/div&amp;gt;

            &amp;lt;label&amp;gt;Grams&amp;lt;/label&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="weight kg"&amp;gt;
            &amp;lt;div&amp;gt;0&amp;lt;/div&amp;gt;

            &amp;lt;label&amp;gt;Kilograms&amp;lt;/label&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="weight ounces"&amp;gt;
            &amp;lt;div&amp;gt;0&amp;lt;/div&amp;gt;
            &amp;lt;label&amp;gt;Ounces&amp;lt;/label&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};
export default WeightConverter;


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

&lt;/div&gt;



&lt;p&gt;** CSS code**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Segoe UI", "Roboto", sans-serif;
  background: black;
  background: radial-gradient(
    /* 45deg, */ rgb(11, 0, 47) 20%,
    rgb(6, 0, 28) 50%,
    rgb(0, 0, 0) 60%
  );
  background-size: 30px 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: rgb(255, 255, 255);
  font-size: 1.2rem;
  text-shadow: 1px 1px 3px black;
}
.container {
  padding: 50px;
  background-color: rgba(36, 35, 46, 0.317);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: 10px 10px 20px rgb(0, 4, 53);
}
input {
  padding: 10px;
  width: 100%;
  border-radius: 10px;
  font-size: 1.2rem;
  color: rgb(8, 8, 64);
  box-shadow: inset 0 0 5px rgb(8, 8, 64);
}
h1,
h3 {
  margin: 10px auto;
  text-align: center;
  font-size: 2rem;
  -webkit-text-stroke: 2px rgb(213, 44, 47);
}
h1 {
  letter-spacing: 10px;
}
.weight {
  width: 100%;
  padding: 10px;
  border-radius: 10%;
  margin: 10px auto;
  background-color: rgb(213, 44, 47);
  box-shadow: inset 2px 2px 15px rgb(0, 0, 0);
}
.kg {
  background-color: rgb(41, 86, 169);
}
.ounces {
  background-color: rgb(31, 160, 87);
}


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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output&lt;/strong&gt;&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%2Fei8jajqcetkpfxjswf4j.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%2Fei8jajqcetkpfxjswf4j.png" alt="Image description" width="800" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Get user input
&lt;/h2&gt;

&lt;p&gt;The next code we will write is for accessing the user’s input. We want to access the number of pounds that the user wants to convert to other weights. To do this, we will create a function inside the WeightConverter component, but above the return statement to handle the input value. Inside that function, we will set the value for pounds&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const handleInput = (e) =&amp;gt; {
    const pounds = e.target.value;
  };

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

&lt;/div&gt;



&lt;p&gt;However, react will be unable to render this value unless we use the useState hook. Therefore, we will import useState hook at the top of the page.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then above the handle input function, we assign useState to a variable and a function for setting the value of the weight variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const [weight, setWeight] = useState("");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our handleInput function, we use the useState.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const handleInput = (e) =&amp;gt; {
    const pounds = e.target.value;
    setWeight(pounds);
  };

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

&lt;/div&gt;



&lt;p&gt;We can now reference the handleInput function in our input tag&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;input
            type="number"
            onChange={handleInput}
            placeholder="enter pounds"
          &amp;gt;&amp;lt;/input&amp;gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Converting the values
&lt;/h2&gt;

&lt;p&gt;The next thing we will do is to convert the value in pounds to grams, kilograms and ounces. We will be dividing and multiplying as appropriate to get these values. We will also round our outcome up to two decimal places.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
  const changeWeight = () =&amp;gt; {
    const grams = (weight / 0.0022046).toFixed(2);
    const kgs = (weight / 2.2046).toFixed(2);
    const ounces = (weight * 16).toFixed(2);
    return { grams, kgs, ounces };
  };


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

&lt;/div&gt;



&lt;p&gt;This function returned a detructured object with the three needed values. These values will then be dynamically displayed in the weight divs.&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 className="weight grams"&amp;gt;
            &amp;lt;div&amp;gt;{changeWeight().grams}&amp;lt;/div&amp;gt;
            Grams
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="weight kg"&amp;gt;
            &amp;lt;div&amp;gt;{changeWeight().kgs}&amp;lt;/div&amp;gt;
            Kilograms
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="weight ounces"&amp;gt;
            &amp;lt;div&amp;gt;{changeWeight().ounces}&amp;lt;/div&amp;gt;
            Ounces
          &amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "./weight-converter.css";
import { useState } from "react";

const WeightConverter = () =&amp;gt; {
  const [weight, setWeight] = useState("");

  const handleInput = (e) =&amp;gt; {
    const pounds = e.target.value;
    setWeight(pounds);
  };

  const changeWeight = () =&amp;gt; {
    const grams = (weight / 0.0022046).toFixed(2);
    const kgs = (weight / 2.2046).toFixed(2);
    const ounces = (weight * 16).toFixed(2);
    return { grams, kgs, ounces };
  };
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="container"&amp;gt;
        &amp;lt;h1&amp;gt;Weight Converter&amp;lt;/h1&amp;gt;
        &amp;lt;div className="wrapper"&amp;gt;
          &amp;lt;input
            type="number"
            onChange={handleInput}
            placeholder="enter pounds"
          &amp;gt;&amp;lt;/input&amp;gt;
          &amp;lt;div className="weight grams"&amp;gt;
            &amp;lt;div&amp;gt;{changeWeight().grams}&amp;lt;/div&amp;gt;
            Grams
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="weight kg"&amp;gt;
            &amp;lt;div&amp;gt;{changeWeight().kgs}&amp;lt;/div&amp;gt;
            Kilograms
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="weight ounces"&amp;gt;
            &amp;lt;div&amp;gt;{changeWeight().ounces}&amp;lt;/div&amp;gt;
            Ounces
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};
export default WeightConverter;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final output
&lt;/h2&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%2Fg19kw32uvx76qb5jw2bw.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%2Fg19kw32uvx76qb5jw2bw.png" alt="Image description" width="800" height="704"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Now that we have successfully built a weight converter app together, I will need you to do us a favor. Create another React app, and try recreating this app on your own. Be sure that you can;&lt;br&gt;
• Create components&lt;br&gt;
•  render the component in your root component&lt;br&gt;
• Access the value of user inputs&lt;br&gt;
•  dynamically display values in your app&lt;br&gt;
• Manage state change with the useState hook&lt;br&gt;
• Make a functional weight converter app with react. &lt;br&gt;
It may also help to try making another simple project on your own. &lt;br&gt;
Let me know if you can achieve this on your own. You can also share your challenges or outcomes in the comment section.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Coloring Your Web World: A Guide to CSS Colors</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Sat, 13 Jul 2024 11:03:36 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/coloring-your-web-world-a-guide-to-css-colors-4b2a</link>
      <guid>https://dev.to/kemiowoyele1/coloring-your-web-world-a-guide-to-css-colors-4b2a</guid>
      <description>&lt;p&gt;Color is a form of electromagnetic radiation that is visible to the human eye. It is the way we perceive and experience different wavelengths of light. Colors can evoke emotions, convey meanings, and add depth and complexity to our experiences.&lt;br&gt;
Color plays a significant role in many aspects of our day-to-day life. It helps to convey messages, express identity, influence mood, stimulate appetite, influence fashion trends, enhance artistic expression, etc. &lt;br&gt;
For web developers, colors help to enhance user experiences, affect legibility, create appealing effects and aesthetics, indicate interactive elements, and evoke emotions. Web developers and designers must be very careful in choosing colors for their projects as it significantly affects how users interact with the page. Other reasons why developers must pay attention include;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;  Accessibility: some users may have visual impairment or color blindness. The colors should be used in such a way that there is enough contrast between the background and text. Also, different modes like light and dark modes or different color themes could be made available for the sake of users with color sensitivity.&lt;/li&gt;
&lt;li&gt; Brand identity: colors are usually used to represent brand identity. When building for an organization, it is important to reflect the colors of the organization’s brand for consistency, and for reinforcing the brand's identity and recognition.&lt;/li&gt;
&lt;li&gt;  Also, take note of the cultural implications of colors and how to use colors to evoke the desired emotions.&lt;/li&gt;
&lt;li&gt; Colors can also determine if the website/app will be visually appealing or repulsive to the users. It is important to ensure that beauty and aesthetics are taken into consideration.&lt;/li&gt;
&lt;li&gt; Colors can also be used to direct the users on how to interact with the websites. Call-to-action buttons are usually made to stand out. Also, color red is usually used to warn users against deleting important data.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  how to indicate colors in CSS
&lt;/h2&gt;

&lt;p&gt;There are several color systems available in CSS. However, in this course, we shall discuss;&lt;br&gt;
• Color keywords &lt;br&gt;
• Hex color&lt;br&gt;
• Hexa colors&lt;br&gt;
• Rgb() &lt;br&gt;
• Rgba()&lt;br&gt;
• Hsl()&lt;br&gt;
• Hsla()&lt;/p&gt;

&lt;h2&gt;
  
  
  Color keywords
&lt;/h2&gt;

&lt;p&gt;One way of representing colors in CSS is obviously by their known names. Names like red, purple, green, blue, etc. are easily identifiable. There are also variations of those colors, like darkblue, cornflowerblue, darkgreen, darkorange, darkcyan, slateblue, slategrey, seagreen, hotpink etc. &lt;br&gt;
    Besides the fact that not all colors and shades have names, it is also a lot of work to memorize the colors by their various names. You may also know the name of the color you intend to use, but that name may not be a valid CSS color keyword or may look slightly different in CSS from what you know the color to look like.&lt;br&gt;
    Besides that, color keywords are only available for just 147 colors. Whereas, the human eye is said to see and distinguish approximately between 1 million to 1.5 million colors. And arguments are disputing this figure with claims that the eyes can see way more than that.&lt;br&gt;
    Also, the color keywords do not have alpha support, thereby making it difficult to add transparency to the colors.&lt;br&gt;
In other to limit some of these challenges, CSS allows us to create colors, or mix colors with a couple of color systems. Some of them require mixing colors; others involve manipulating the lightness, transparency, and saturation of existing colors and hues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hexadecimal (hex) colors
&lt;/h2&gt;

&lt;p&gt;The hexadecimal color system allows for a lot more flexibility with creating colors, and gives a lot more options to the designers/developers with colors to choose from. With the hex system, colors are created by mixing red, blue, and green.&lt;br&gt;
    The hexadecimal system starts with the # symbol and then followed by six digits. These digits range from 0-f. So, rather than have the numbers like&lt;br&gt;
0    1    2    3    4    5    6    7    8    9,&lt;br&gt;
 as in decimal numbers, making up ten, &lt;br&gt;
We have numbers&lt;br&gt;&lt;br&gt;
0   1    2    3    4    5    6    7    8    9    a    b    c    d    e    f &lt;br&gt;
Making up 16.&lt;/p&gt;

&lt;p&gt;So to combine a hex color, you’ll have;&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%2Fde130877jslo4nl9byy6.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%2Fde130877jslo4nl9byy6.png" alt="Image description" width="231" height="478"&gt;&lt;/a&gt;&lt;br&gt;
In decimal notation, each of these values corresponds to an integer between 00 and FF, or 0 and 255. The hexadecimal notation allows for the representation of 256 ^ 3 or 16,777,216 colors in total. Black represents the absence of all three colors; while white represents the full capacity of all three colors. To get various shades of grey, have all three colors in equal proportions.&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%2F01jemvtkkvddyo1ya48b.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%2F01jemvtkkvddyo1ya48b.png" alt="Image description" width="348" height="464"&gt;&lt;/a&gt;&lt;br&gt;
You can also have as many shades of the same colors as you can imagine. A couple of blue shades for example.&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%2Fqydbolv25uutz5de7p6l.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%2Fqydbolv25uutz5de7p6l.png" alt="Image description" width="756" height="749"&gt;&lt;/a&gt;&lt;br&gt;
We can make thousands of shades from blue alone, by ensuring that the value for blue is higher than that of red and green. You can also do the same with red and green. In most cases, a color picker will help with choosing colors.&lt;br&gt;
&lt;strong&gt;Applying transparency&lt;/strong&gt;&lt;br&gt;
You can apply transparency to hexadecimal by adding an extra alpha value to the hex color. The closer the number is to zero, the higher the transparency while a higher number will be more opaque. For example,&lt;/p&gt;

&lt;p&gt;(#000d or #fefe56dd will add a little transparency to the colors, and a color of say #0004 0r #fefe5644 will be much more transparent.)&lt;br&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%2Ftx878rjid5nv3m6rsy2g.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%2Ftx878rjid5nv3m6rsy2g.png" alt="Image description" width="753" height="753"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rgb() colors
&lt;/h2&gt;

&lt;p&gt;rgb() colors are quite similar to the hexadecimal color system. They both represent a mixture of red, blue, and green with 255 possible values for each color. The difference here however is the syntax. The rgb() colors use decimal numbers of 0-255, separated by comma to represent each color.&lt;br&gt;
Syntax;&lt;br&gt;
rgb(red, green, blue);&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%2Ffthoxz0bpa0w7cjtv1md.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%2Ffthoxz0bpa0w7cjtv1md.png" alt="Image description" width="382" height="756"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rgba()
&lt;/h2&gt;

&lt;p&gt;Rgba() gives the opportunity to add opacity/transparency to the colors. The extra a there is called the alpha value and is a number between 0 and 1. The closer the number is to zero, the more transparent the color will be.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hsl() colors
&lt;/h2&gt;

&lt;p&gt;Hsl stand for &lt;br&gt;
Hue: specifies the color. Represented by the degree along the color wheel. 0° is red, &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%2F7u3eza1vi0g0jlg59sfg.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%2F7u3eza1vi0g0jlg59sfg.png" alt="Image description" width="361" height="363"&gt;&lt;/a&gt;&lt;br&gt;
Saturation: indicating the level of vividness of the color. 0 will give a gray color, whereas 100% will give the most vivid version of the color.&lt;br&gt;
Lightness: in percentage indicating how light or dark the color would be;&lt;br&gt;
&lt;strong&gt;Illustration&lt;/strong&gt;&lt;br&gt;
The image below illustrates the HSL hue. The saturation has been set to 100%, and lightness 50% for all cases. &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%2Fur9yod8xbhmle40ep2tr.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%2Fur9yod8xbhmle40ep2tr.png" alt="Image description" width="753" height="756"&gt;&lt;/a&gt;&lt;br&gt;
2.&lt;br&gt;
Now let’s take a hue of 0deg, and 50% lightness and see how different saturations look like&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%2Fzt57pi3miaq7rkwouz0f.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%2Fzt57pi3miaq7rkwouz0f.png" alt="Image description" width="739" height="747"&gt;&lt;/a&gt;&lt;br&gt;
Now, let’s maintain the hue of 0deg, and saturation of 100% and see how the lightness plays out.&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%2Fa265c0uy31c60ba8hqdi.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%2Fa265c0uy31c60ba8hqdi.png" alt="Image description" width="745" height="753"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This text provides a comprehensive overview of colors in web development, including their importance, cultural implications, and how to represent them in CSS using various color systems.&lt;br&gt;
Here is a summary of the color systems mentioned:&lt;br&gt;
• Color Keywords: 147 predefined color names, e.g. "red", "blue", and "green".&lt;br&gt;
• Hexadecimal (Hex): Six-digit code starting with #, e.g. #FF0000 for red.&lt;br&gt;
• RGB: Decimal values for red, green, and blue, e.g. rgb(255, 0, 0) for red.&lt;br&gt;
• RGBA: Adds alpha value for transparency, e.g. rgba(255, 0, 0, 0.5) for semi-transparent red.&lt;br&gt;
• HSL: Hue, saturation, and lightness values, e.g. hsl(0, 100%, 50%) for red.&lt;br&gt;
• HSLA: Adds alpha value for transparency, e.g. hsla(0, 100%, 50%, 0.5) for semi-transparent red.&lt;br&gt;
The text also provides examples and illustrations to help understand how to work with colors in CSS.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>BASIC CSS SELECTORS</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Fri, 12 Jul 2024 21:53:37 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/basic-css-selectors-4182</link>
      <guid>https://dev.to/kemiowoyele1/basic-css-selectors-4182</guid>
      <description>&lt;p&gt;CSS selectors are used to target specific HTML elements and apply styles to them. There are a couple of ways we can be specific about the element we intend to select. In this chapter, we are going to focus on four basic selection methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  1.   Universal selector (*)
&lt;/h2&gt;

&lt;p&gt;Universal selector is used to target all elements in the page at once. This selector is usually useful in cases of some basic formatting. Most common use of the universal selector is to remove default margins and paddings.&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  2.   Selecting by element name
&lt;/h2&gt;

&lt;p&gt;With this approach, all elements of the one named by the selector will be styled accordingly. This will only exclude those selected differently as we will see in future examples.&lt;br&gt;
Code sample:&lt;br&gt;
HTML&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;h3&amp;gt;this is heading 1&amp;lt;/h3&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 1&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 2&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 3&amp;lt;/p&amp;gt;
    &amp;lt;h3&amp;gt;this is heading 2&amp;lt;/h3&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 4&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 5&amp;lt;/p&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body{
    background: lightgray;
}
h3{
    color: blue;
}
p{
    color: red;

}

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

&lt;/div&gt;



&lt;p&gt;Result&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%2Fc5sze0vmgpde3psj6llx.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%2Fc5sze0vmgpde3psj6llx.png" alt="Image description" width="519" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3.   Selecting by id
&lt;/h2&gt;

&lt;p&gt;An id is a unique identifier that sets apart an element from the other elements. Ideally, there should be only one element with the same id on a page. There could be many elements with the id attribute, but not more than one should bear the same name. Otherwise there will be nothing unique about the id. So to style an element with an id, use the id attribute to give it a name in HTML, then use the # symbol before that name, when selecting in CSS.&lt;/p&gt;

&lt;p&gt;HTML&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;body&amp;gt;
   &amp;lt;h3 &amp;gt;this is heading 1&amp;lt;/h3&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 1&amp;lt;/p&amp;gt;
    &amp;lt;p &amp;gt;this is paragraph 2&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 3&amp;lt;/p&amp;gt;
    &amp;lt;h3&amp;gt;this is heading 2&amp;lt;/h3&amp;gt;
    &amp;lt;p id="unique"&amp;gt;this is paragraph 4&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 5&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#unique{
    color: green;
}
body{
    background: lightgray;
}
h3{
    color: blue;
}
p{
    color: red;

}


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

&lt;/div&gt;



&lt;p&gt;Result &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%2Fzhfeel7b1j61yl16rk50.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%2Fzhfeel7b1j61yl16rk50.png" alt="Image description" width="339" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4.   Selecting by class
&lt;/h2&gt;

&lt;p&gt;Class works kind of similar to id, but in the case of class, there could be more than one element with the same class name. To style an element with a class name, use the class attribute to give it a name in HTML, then use the . symbol before that name, when selecting in CSS.&lt;/p&gt;

&lt;p&gt;Code sample&lt;br&gt;
HTML&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;h3 &amp;gt;this is heading 1&amp;lt;/h3&amp;gt;
    &amp;lt;p class="pink"&amp;gt;this is paragraph 1&amp;lt;/p&amp;gt;
    &amp;lt;p class="pink" &amp;gt;this is paragraph 2&amp;lt;/p&amp;gt;
    &amp;lt;p class="pink"&amp;gt;this is paragraph 3&amp;lt;/p&amp;gt;
    &amp;lt;h3&amp;gt;this is heading 2&amp;lt;/h3&amp;gt;
    &amp;lt;p id="unique"&amp;gt;this is paragraph 4&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;this is paragraph 5&amp;lt;/p&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.pink{
    background: pink;
}
body{
    background: lightgray;
}
h3{
    color: blue;
}
p{
    color: red;

}

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

&lt;/div&gt;



&lt;p&gt;Result&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%2Fr3nbn1bcz0nts4fo3skd.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%2Fr3nbn1bcz0nts4fo3skd.png" alt="Image description" width="359" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Each selector type has its own purpose and usage. Understanding how to use each selector is crucial for effective HTML styling and layout control. Proper use of selectors can help create visually appealing and well-structured web pages, making it easier for users to interact with and understand the content presented.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Learn react js by building a countdown timer</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Wed, 10 Jul 2024 15:08:23 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/learn-react-js-by-building-a-countdown-timer-kej</link>
      <guid>https://dev.to/kemiowoyele1/learn-react-js-by-building-a-countdown-timer-kej</guid>
      <description>&lt;p&gt;In this article, we are going to learn react js from scratch by building a countdown timer. We will learn &lt;br&gt;
• how to create new react app, &lt;br&gt;
• to create a react component, &lt;br&gt;
• to dynamically display content,&lt;br&gt;
• to listen to and handle events&lt;br&gt;
• to use the useState hook for state management and &lt;br&gt;
• to manage function side effects with the useEffect hook&lt;br&gt;
Our countdown time will &lt;br&gt;
• accept input from the user to set time, &lt;br&gt;
• validate if the time is in the future or the past;&lt;br&gt;
•  start counting down if the time is valid or alert the user to set the correct time if not &lt;br&gt;
• When the counter counts to zero seconds, the user will be alerted that the time is up.&lt;br&gt;
Before we start building the countdown timer with react.js, I’d like to let you know some of the assumptions I’ll be working with. &lt;br&gt;
• I assume that you are proficient with HTML and CSS. I will not explain the HTML/CSS codes.&lt;br&gt;
• I assume that you know JavaScript, and can probably build this project in vanilla JavaScript without much trouble. But I will try as much as possible to explain the JavaScript codes.&lt;br&gt;
• I assume you are relatively new to react. I’ll explain all the react concepts as though you are completely new to react js.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create react app
&lt;/h2&gt;

&lt;p&gt;The first thing you will need to do is to set up a react development environment. To do that, we will open our terminal and navigate to the location where we want to create the app and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app countdown-timer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;npx will run the code on the internet and create a basic react app for us with the name “countdown-timer” or whatever name you used as an alternative.&lt;br&gt;
    After the app is created, navigate into the folder and open it with a text editor. In the folder, you are going to find a couple of folders and files. Some of the folders include; &lt;br&gt;
• node_modules folder: stores installed packages and dependencies. This folder is to be untouched.&lt;br&gt;
• public folder: this folder serves as the directory for publicly accessible assets. Initial assets in this folder include index.html, favicon.ico, index.css, logo images, manifest.json, etc. Files in the public folder do not require imports, and can be accessed directly from the root folder. Files in this folder may be deleted or tampered with, except the index.html file.&lt;br&gt;
• src folder: src is short for source. It is where the source codes are kept. All your styles, logic, components, etc. are going into the src folder.&lt;br&gt;
*&lt;em&gt;files&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
The files include .gitignore, package.json, package-lock.json, README.md. These files are not to be tampered with. Except for the git ignore, in case you added some assets that you want git to ignore.&lt;br&gt;
• index.html is the entry point to your react application. This is the file that will be returned from the server. The root component is then mounted on the index.html and the rest of the app's logic and interface will handled from there on.&lt;br&gt;
• Index.js file is where the root component is mounted to reactDOM.&lt;br&gt;
• App.js is the root component. A component is an autonomous segment of content, usually containing its logic and its HTML-like template. A react app is made up of a component tree with the root component at the origin point of the other components&lt;br&gt;
To run the app, open your terminal, ensure it is navigated to your app folder, and type&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;A localhost address will be made available to you for viewing your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the CountDown component
&lt;/h2&gt;

&lt;p&gt;In the src folder, create a CountDown.js file. Remember that the name of the file should start with an upper case, as this is the standard for component file naming. In the CountDown.js file, create a basic CountDown component and export the component.&lt;br&gt;
&lt;strong&gt;Countdown.js file&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const CountDown = () =&amp;gt; {
 return 
 (&amp;lt;&amp;gt;&amp;lt;/&amp;gt;);
};

export default CountDown;


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

&lt;/div&gt;



&lt;p&gt;In your App.js file, delete the already existing content of the page, and create a basic App component.  Then import the CountDown component and render it in your App component.&lt;br&gt;
*&lt;em&gt;App.js file&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import CountDown from "./CountDown";
function App() {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;CountDown /&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Build The Interface Of The Countdown Timer
&lt;/h2&gt;

&lt;p&gt;Go back to your CountDown.js file, in the return statement of your component, you will render jsx content. jsx is HTML like but is actually javascript. You may also create an app.css file and import the file at the top of your page;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "./app.css";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will create a section for selecting and displaying the target time. In this section, we will use the date time picker of the input-type date to allow the user to select the date and time for the target time. The time selected will be displayed in a div inside this section.&lt;br&gt;
Another section will be used to display the time remaining in days, hours, minutes and seconds to the target time. For these figures, we will use 0 as the placeholders for now. When we get to the functionality part, we will dynamically output the figures. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML/jsx code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "./app.css";
const CountDown = () =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="container"&amp;gt;
        &amp;lt;h1&amp;gt;Countdown Timer&amp;lt;/h1&amp;gt;

        &amp;lt;section className="select-time"&amp;gt;
          &amp;lt;div&amp;gt;Set Countdown Target Time&amp;lt;/div&amp;gt;
          &amp;lt;input type="datetime-local"&amp;gt;&amp;lt;/input&amp;gt;
          &amp;lt;div&amp;gt;Countdown Target Time&amp;lt;/div&amp;gt;
          &amp;lt;div className="time-set"&amp;gt;0&amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
        &amp;lt;section className="display-time"&amp;gt;
          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;0&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Days&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;0&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Hours&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;0&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Minutes&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;0&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Seconds&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default CountDown;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can style this page as you please. &lt;br&gt;
&lt;strong&gt;CSS code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Segoe UI", "Roboto", sans-serif;
  background: radial-gradient(
    circle,
    rgb(190, 190, 190),
    rgb(117, 117, 123),
    rgb(95, 126, 228)
  );
  background-size: 10px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: aliceblue;
}

.container {
  color: rgb(255, 255, 255);
  box-shadow: 2px 2px 10px black;
  padding: 20px;
  background: linear-gradient(
    90deg,
    rgb(64, 60, 82),
    rgb(97, 97, 110),
    rgb(126, 130, 220)
  );
  border-radius: 15px;
  text-align: center;
}
h1 {
  font-size: 3rem;
  text-shadow: 1px 1px rgb(36, 32, 61), 2px 2px 4px rgb(36, 32, 61);
}
.select-time {
  background: rgba(36, 38, 51, 0.645);
  padding: 10px;
  margin: 10px 0;
  border-radius: 10px;
  box-shadow: 0 0 5px black;
  font-size: 1.5em;
  font-weight: bold;
}
.select-time input {
  padding: 5px;
  font-size: 1em;
  color: rgb(8, 2, 79);
  background-color: rgb(199, 199, 255);
 -webkit-text-stroke: 1px rgb(198, 106, 156);
}
.time-set {
  color: rgb(143, 198, 202);
  -webkit-text-stroke: 1px rgb(198, 106, 156);
}
.wrapper {
  margin: 10px 0;
  padding: 5px 0;
  box-shadow: 0 0 5px black;
}
.time {
  font-size: 2rem;
  font-weight: 900;
  -webkit-text-stroke: 2px rgb(36, 32, 61);
  text-shadow: 1px 1px rgb(36, 32, 61), 2px 2px rgb(36, 32, 61);
}


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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Appearance so far&lt;/strong&gt;&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%2Fuovndqaetmw1jnv0vk9n.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%2Fuovndqaetmw1jnv0vk9n.png" alt="Image description" width="800" height="627"&gt;&lt;/a&gt;&lt;br&gt;
Now that we have set up what our app will look like, we will work on the logic/ functionality of the app.&lt;/p&gt;
&lt;h2&gt;
  
  
  Adding functionality to the app
&lt;/h2&gt;

&lt;p&gt;Before we go further into the JavaScript aspect, there are two dependencies that we have to import and briefly explain. We will import the useState hook and the useEffect hook from the react library.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Place the code at the top of your component file.&lt;/p&gt;

&lt;h2&gt;
  
  
  useState hook
&lt;/h2&gt;

&lt;p&gt;When you change the value of a variable either in reaction to some event or over time, react will not re-render the new value. The useState hook is used to inform react that the value of a variable has changed. This will trigger a re-render of the component, and the changes can therefore be reflected in the new render.&lt;br&gt;
    To use the useState hook, you will declare a variable with two values (the name of the variable we want to make reactive, and the function for changing/setting the value of the variable.), and set it equal to the useState.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [targetTime, setTargetTime] = useState();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code should be written in your component function, but above the jsx template.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get user input from the date picker
&lt;/h2&gt;

&lt;p&gt;The next thing we would do now is to use the useState hook to render the date and time that the user picks with the date picker or enters in the input tag. To do this, we will create a function and name it handleTimeSelected, this function will be an event listener to listen for changes in the value of the input tag. To make that value reactive and trigger a re-render, we will use the useState hook values. We will use setTargetTime to set the value changes for targetTime.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const handleTimeChange = (event) =&amp;gt; {
      setTargetTime(event.target.value);
  };

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

&lt;/div&gt;



&lt;p&gt;In our jsx, we will reference the handleTimeChange function in an onChange event handler. Also, we will set the value of the input tag to be equal to targetTime.&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;input
            type="datetime-local"
            value={targetTime}
            onChange={handleTimeChange}
       &amp;gt;
&amp;lt;/input&amp;gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dynamically output the value of the user-selected time
&lt;/h2&gt;

&lt;p&gt;All we need to do here is to wrap the name of the variable we intend to dynamically output in curly braces, and place it in the jsx location we want it outputted in.&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 className="time-set"&amp;gt; 
{targetTime}
&amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;This can also be used to dynamically set HTML attributes, as we did above to set the value attribute to targetTime.&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%2Fcj0a1xtse4mcn5afjl8a.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%2Fcj0a1xtse4mcn5afjl8a.png" alt="Image description" width="717" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see, the time selected with the date and time picker is showing in another div tag below it.&lt;br&gt;
&lt;strong&gt;Check For Time Validity&lt;/strong&gt;&lt;br&gt;
Another thing we would like to check for is to verify that the time chosen by the user is a future date and time. If the time selected is already in the past, we would trigger an alert to notify the user that the time selected is invalid and set targetTime to “invalid”.&lt;br&gt;
Back into the handleTimeChange function. &lt;br&gt;
First we need to get the current time, then compare the current time with the selected time. To get current time, we will use the JavaScript date method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const currentTime = new Date();
    const selectedTime = new Date(event.target.value);


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

&lt;/div&gt;



&lt;p&gt;Next, we will use a conditional statement to compare the values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const handleTimeChange = (event) =&amp;gt; {
    const currentTime = new Date();
    const selectedTime = new Date(event.target.value);
    if (selectedTime &amp;gt;= currentTime) {
      setTargetTime(event.target.value);
    } else {
      setTargetTime("Invalid Time");
      alert("invalid time; please select a future date and time");
    }
  };


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

&lt;/div&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%2Fw0tialllhlkkqawy6syu.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%2Fw0tialllhlkkqawy6syu.png" alt="Image description" width="800" height="279"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Get the time remaining to the target time?&lt;/strong&gt;&lt;br&gt;
Now we are going to get the number of days, hours, minutes and seconds between the target time and the current time. This can be derived by deducting the current time from the target time. The number we are going to get will be the total milliseconds between those two periods. To get the other time durations, we will h divide the number appropriately.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const getTargetTime = new Date(targetTime);
  const getCountDownTime = () =&amp;gt; {
    const totalTimeLeft = getTargetTime - new Date();
    const daysLeft = Math.floor(totalTimeLeft / (1000 * 60 * 60 * 24));
    const hoursLeft = Math.floor((totalTimeLeft / (1000 * 60 * 60)) % 24);
    const minutesLeft = Math.floor((totalTimeLeft / (1000 * 60)) % 60);
    const secondsLeft = Math.floor((totalTimeLeft / 1000) % 60);
    return [daysLeft, hoursLeft, minutesLeft, secondsLeft];
  };

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

&lt;/div&gt;



&lt;p&gt;To get the total number of days left, we find the total milliseconds remaining, and divided the answer by 24 hours, multiplied by 60 minutes, 60 seconds and 1000 milliseconds. Then the function returned an array of the needed values.&lt;br&gt;
&lt;strong&gt;Dynamically display the remaining time&lt;/strong&gt;&lt;br&gt;
Now we want to take the returned values from the getCountDownTime() function and display them appropriately in the jsx render. getCountDownTime() returns an array, in our jsx, we will display the corresponding index of the getCountDownTime() array.&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 className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[0]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Days&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[1]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Hours&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[2]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Minutes&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[3]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Seconds&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;


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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&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%2Fuy94obrih6ol4r2w3eg4.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%2Fuy94obrih6ol4r2w3eg4.png" alt="Image description" width="800" height="665"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Set the countdown&lt;/strong&gt;&lt;br&gt;
The next thing we are going to do is to use setInterval to decrease the remaining time every second. We also want to ensure that the timer stops counting as soon as the time left is 0 seconds and the user is notified that time is up.&lt;br&gt;
    If you are familiar with JavaScript you probably know how to use the setInterval method. It is used the same way in react, but before setting up the setInterval, I want us to briefly explain the useEffect hook.&lt;/p&gt;
&lt;h2&gt;
  
  
  useEffect hook
&lt;/h2&gt;

&lt;p&gt;The useEfect hook is used to handle function side effect in react. Function side effect in JavaScript is any effect outside the function’s local scope. If the function produces a result that is not part of the functions return value. Examples of function side effect include;&lt;br&gt;
• Changing a global variable&lt;br&gt;
• Interacting with the DOM&lt;br&gt;
• Mutating external arrays, objects etc.&lt;br&gt;
• Fetching data from external API’s&lt;br&gt;
• Javascript animations&lt;br&gt;
• Set timers&lt;br&gt;
• Using web storage&lt;br&gt;
• Etc.&lt;br&gt;
React js is built on the concept of pure functions. Pure functions are functions that have no side effects. They always produce the same results if given the same inputs. This is because functions with side effects are quite unpredictable in behavior, harder to debug, test and maintain. There are also performance issues and memory leaks with regards to unnecessary re-renders or computation.&lt;br&gt;
    To handle functions with side effects, such as timers, api requests, updating UI etc we make use of useEffect hook.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to use useEffect hook
&lt;/h2&gt;

&lt;p&gt;First of all, we need to;&lt;br&gt;
• Import useEffect from react&lt;br&gt;
• Somewhere in your component, before the return statement, call the useEffect hook with two arguments. &lt;/p&gt;

&lt;p&gt;• The first argument is a callback function containing instructions we want to execute whenever the useEffect is triggered. &lt;/p&gt;

&lt;p&gt;• The second optional argument is an array of dependencies that will determine when the useEffect will run. If the array is empty, the useEffect will run only once after the initial render. If the dependency argument is omitted, the useEffect will trigger whenever there is a state change. If values are provided inside the dependency array, the useEffect will be triggered only when there is a state change in any of those values.&lt;br&gt;
• To avoid memory leaks and other performance issues, it is important to clean-up resources when they are no longer needed. This is usually implemented with a cleanup function.&lt;br&gt;
• Syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; useEffect(()=&amp;gt;{
    // excecute side effect
//cleanup function
  }, [an array of values that the effect depends on]);

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Back to our countdown timer&lt;/strong&gt;&lt;br&gt;
First set up the useState for the timer that we intend to update&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const [timer, setTimer] = useState();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the useEffect hook to execute the setIntervals&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
    const total = getTargetTime - new Date();

    const countDownInterval = setInterval(() =&amp;gt; {
      if (total &amp;gt;= 0) {
        setTimer(getCountDownTime());
      } else {
        clearInterval(countDownInterval);
        alert(`Time up
           Set New Time`);
      }
    }, 1000);


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

&lt;/div&gt;



&lt;p&gt;At the stage the entire code in the countdown.js page will be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "./app.css";
import { useState, useEffect } from "react";

const CountDown = () =&amp;gt; {
  const [targetTime, setTargetTime] = useState();
  const [timer, setTimer] = useState();

  const handleTimeChange = (event) =&amp;gt; {
    const currentTime = new Date();
    const selectedTime = new Date(event.target.value);
    if (selectedTime &amp;gt;= currentTime) {
      setTargetTime(event.target.value);
    } else {
      setTargetTime("Invalid Time");
      alert("invalid time; please select a future date and time");
    }
  };
  const getTargetTime = new Date(targetTime);
  const getCountDownTime = () =&amp;gt; {
    const totalTimeLeft = getTargetTime - new Date();
    const daysLeft = Math.floor(totalTimeLeft / (1000 * 60 * 60 * 24));
    const hoursLeft = Math.floor((totalTimeLeft / (1000 * 60 * 60)) % 24);
    const minutesLeft = Math.floor((totalTimeLeft / (1000 * 60)) % 60);
    const secondsLeft = Math.floor((totalTimeLeft / 1000) % 60);
    return [daysLeft, hoursLeft, minutesLeft, secondsLeft];
  };
  useEffect(() =&amp;gt; {
    const total = getTargetTime - new Date();

    const countDownInterval = setInterval(() =&amp;gt; {
      console.log(total);
      if (total &amp;gt;= 0) {
        setTimer(getCountDownTime());
      } else {
        clearInterval(countDownInterval);
        alert(`Time up
           Set New Time`);
      }
    }, 1000);

    return () =&amp;gt; {
      clearInterval(countDownInterval);
    };
  }, [timer, getTargetTime]);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="container"&amp;gt;
        &amp;lt;h1&amp;gt;Countdown Timer&amp;lt;/h1&amp;gt;

        &amp;lt;section className="select-time"&amp;gt;
          &amp;lt;div&amp;gt;Set Countdown Target Time&amp;lt;/div&amp;gt;
          &amp;lt;input
            type="datetime-local"
            value={targetTime}
            onChange={handleTimeChange}
          &amp;gt;&amp;lt;/input&amp;gt;
          &amp;lt;div&amp;gt;Countdown Target Time&amp;lt;/div&amp;gt;
          &amp;lt;div className="time-set"&amp;gt;{targetTime}&amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
        &amp;lt;section className="display-time"&amp;gt;
          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[0]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Days&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[1]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Hours&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[2]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Minutes&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;div className="wrapper"&amp;gt;
            &amp;lt;div className="time"&amp;gt;{getCountDownTime()[3]}&amp;lt;/div&amp;gt;
            &amp;lt;div className="label"&amp;gt;Seconds&amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/section&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default CountDown;


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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&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%2Forpwjholpygih9hjpcsw.gif" 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%2Forpwjholpygih9hjpcsw.gif" alt="Image description" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we have explored the fundamentals of React JS by building a practical application - a countdown timer. We have covered key concepts such as component creation, state management, event handling, and side effect management using the useState and useEffect hooks. Our countdown timer is now fully functional, and we have gained hands-on experience by building a React application from scratch.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Bringing Web Pages to Life with CSS Animations: A Step-by-Step Guide</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Sun, 30 Jun 2024 17:22:11 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/bringing-web-pages-to-life-with-css-animations-a-step-by-step-guide-3o8o</link>
      <guid>https://dev.to/kemiowoyele1/bringing-web-pages-to-life-with-css-animations-a-step-by-step-guide-3o8o</guid>
      <description>&lt;p&gt;Animation is an art of creating an illusion of movement from still characters. It is a process that causes still characters to be rendered in such a way that they change form gradually. The term animation is derived from the word “anime”. Anime is a Japanese word that means “to move”, “or to give live”. &lt;br&gt;
Animations are very important in any field that requires visual presentation of results. They have become more prevalent in creating educational materials, advertising, marketing, simulation training, data visualization, game development and of course, in entertainment.&lt;br&gt;
In web development, animations are used to add life our web pages. Animated elements can be more attention grabbing, interactive and can create better user experience than still characters. &lt;br&gt;
For instance;&lt;br&gt;
• Animations can be helpful in guiding users on how to navigate through the website. &lt;br&gt;
• It may help them to know when to be a little patient (like the loading animation).&lt;br&gt;
• Can be helpful with providing feedback like letting them know that a message has been sent.&lt;br&gt;
• It can also make the page more beautiful and captivating, thereby ensuring that users spend more time on the page.&lt;br&gt;
In CSS, animation is the gradual change in style or set of styles applied to an HTML element. To animate an element with CSS, you have to write the codes to define the animation properties, and define the keyframes for the steps to the implementation of the animations and the properties to be animated.&lt;/p&gt;
&lt;h2&gt;
  
  
  CSS keyframes
&lt;/h2&gt;

&lt;p&gt;Keyframes signifies start points, and end points for the specific animations/ transitions. &lt;br&gt;
Syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframes animation-name {
        from {
            property: initial value;
            property2: initial value;
            etc.       
 }

        to {
            property: final value;
            property2: final value;
            etc.
        }
    }

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

&lt;/div&gt;



&lt;p&gt;This is to say that the styles applied in the “from” block, should gradually morph into the styles applied in the “to” block. The “from” and “to” keywords are not so commonly used. What you are most likely to come across or use will be percentage values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    @keyframes animation-name {
        0% {
            property: value;
            property2: value;
            etc.
        }

        100% {
            property: value;
            property2: value;
            etc.
        }
    }

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

&lt;/div&gt;



&lt;p&gt;Percentage values allow you to have as many transitional points as you may be required to have. &lt;/p&gt;

&lt;h2&gt;
  
  
  CSS animation properties
&lt;/h2&gt;

&lt;h2&gt;
  
  
  animation-name
&lt;/h2&gt;

&lt;p&gt;This is the name of the animation. You can give your animation any name you like. This name will serve as the identifier when applying the keyframes and styles to the animated element.&lt;br&gt;
Syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        animation: animate;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then use the name as the identifier for the keyframes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    @keyframes animate {
        0% {
            border-radius: 0;
        }

        100% {
            border-radius: 50%;
        }
    }

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

&lt;/div&gt;



&lt;p&gt;Using animation-name property alone, you will not see any animation. To effect animation, you will have to at least set duration for the animation.&lt;/p&gt;

&lt;h2&gt;
  
  
  animation-duration
&lt;/h2&gt;

&lt;p&gt;This is used to determine how long the animation should run. It is usually measured in seconds(s) or milliseconds(ms). 1000 milliseconds is equal to 1second.&lt;br&gt;
syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        animation-duration: 10000ms;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        animation-duration: 10s;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;example&lt;/strong&gt;&lt;br&gt;
HTML&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="box"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    .box {
        height: 300px;
        width: 300px;
        background-color: red;
        border-radius: 50%;
        animation: animate;
        animation-duration: 2s;
    }

    @keyframes animate {
        0% {
            border-radius: 0;
        }

        100% {
            border-radius: 50%;
        }
    }

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

&lt;/div&gt;



&lt;p&gt;The div will gradually change shape from a square to a circle in 2 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  animation-delay
&lt;/h2&gt;

&lt;p&gt;If animation-delay is set to an animation, the animation will wait for the set time before it starts. If the animation is set to repeat, only the first instance will be delayed, the subsequent animations will not be delayed. The animation-delay property accepts negative values. Hence, delay of 2s will cause the animation to wait for 2 seconds, while animation-delay of -2s will cause the animation to start as though the animation has started 2 seconds ago.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Animation-delay: &amp;lt;time&amp;gt;;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   animation: animate;
        animation-duration: 2s;
        animation-delay: 0.5s;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  animation-play-state
&lt;/h2&gt;

&lt;p&gt;animation-play-state enables you to pause or play animation as you may need to. When you pause an animation, the animation will remain at the point it was when pause was activated, and resume from the same place as soon as the state is switched to running. The two major values for this property is “paused” and running.&lt;br&gt;
For example, you could set the animation-play-state of an animated element to pause when hovered on, or you can use JavaScript to dynamically change the animation state based on interaction&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box {
        height: 300px;
        width: 300px;
        background-color: red;
        border-radius: 50%;
        animation: animate;
        animation-duration: 2s;
        animation-play-state: running;
    }

    .box:hover {
        animation-play-state: paused;
    }

    @keyframes animate {
        0% {
            border-radius: 0;
        }

        100% {
            border-radius: 50%;
        }
    }

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  animation-iteration-count
&lt;/h2&gt;

&lt;p&gt;This property is used to set the number of times that the animation will run. The values for this property must be a positive integer or infinite. The value of infinite will cause the animation to continue running till infinity.&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  .box {
        height: 300px;
        width: 300px;
        background-color: red;
        animation: animate;
        animation-duration: 2s;
        animation-iteration-count: 6;
    }



    @keyframes animate {
        0% {
            border-radius: 0;
        }

        100% {
            border-radius: 50%;
        }
    }

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

&lt;/div&gt;



&lt;p&gt;In this example, the animation will run for 2 seconds each, six times.&lt;/p&gt;

&lt;h2&gt;
  
  
  animation-timing-function:
&lt;/h2&gt;

&lt;p&gt;animation-timing-function is used to set the rate of change of speed over the duration of the animation. Values to this property include;&lt;br&gt;
ease: speed increases towards the middle of the animation, then slows down towards the end. This is the default value;&lt;br&gt;
ease-in: starts slows, then becomes fast to the end&lt;br&gt;
ease-out: starts quickly, then slows down&lt;br&gt;
ease-in-out: starts slowly, seeds up then slows down again&lt;br&gt;
linear: this will ensure that the speed is even all through.&lt;br&gt;
steps(): makes stops according to the number of steps set&lt;br&gt;
cubic-bezier(): used to set custom speed rates.&lt;/p&gt;
&lt;h2&gt;
  
  
  animation-direction
&lt;/h2&gt;

&lt;p&gt;animation-direction is used to set whether the animation should play forward, backward, or alternate between the two. Values to this property include;&lt;br&gt;
normal: The animation will play forward.&lt;br&gt;
reverse: The animation will play backward.&lt;br&gt;
alternate: The animation will play forward on the first cycle, then backward on the second cycle, and so on.&lt;br&gt;
alternate-reverse: The animation will play backward on the first cycle, then forward on the second cycle, and so on.&lt;/p&gt;
&lt;h2&gt;
  
  
  animation-fill-mode
&lt;/h2&gt;

&lt;p&gt;animation-fill-mode sets the style of the element after the animation is completed. It determines if the element will go back to its original style before the animation, or take up one of the styles specified in the animation keyframes. Values for the animation-fill-mode property include;&lt;br&gt;
&lt;strong&gt;forwards:&lt;/strong&gt; The animation will apply the styles from the last keyframe to the element after the animation executes.&lt;br&gt;
&lt;strong&gt;backwards:&lt;/strong&gt; The animation will apply the styles from the first keyframe to the element before the animation executes.&lt;br&gt;
&lt;strong&gt;both:&lt;/strong&gt; The animation will apply the styles from the first keyframe to the element before the animation executes and the styles from the last keyframe to the element after the animation executes.&lt;/p&gt;
&lt;h2&gt;
  
  
  animation shorthand property
&lt;/h2&gt;

&lt;p&gt;The animation shorthand property is a CSS property that allows you to define multiple animation properties in a single declaration. It is a concise way to define animations, making it easier to write and maintain code.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        animation: &amp;lt;name&amp;gt; &amp;lt;duration&amp;gt; &amp;lt;timing-function&amp;gt; &amp;lt;delay&amp;gt; &amp;lt;iteration-count&amp;gt; &amp;lt;direction&amp;gt; &amp;lt;fill-mode&amp;gt; &amp;lt;play-state&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        animation: animate 2s linear 1s 3 alternate forwards running;   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is not compulsory to use all the values. Default values will be applied in place of the omitted values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiple CSS animations on the same element:
&lt;/h2&gt;

&lt;p&gt;You can apply multiple animations to the same element. All you have to do is separate the values with a comma.&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;animation: animate-one 2s linear 1s 3 alternate forwards running, 
         animate-Two 4s steps(5) 4s 3 reverse forwards running;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Illustration
&lt;/h2&gt;

&lt;p&gt;To illustrate all we have been learning so far, we are going to make a simple text typing animation example.&lt;br&gt;
To start with, we create an html page with a simple short text.&lt;br&gt;
&lt;strong&gt;HTML&lt;/strong&gt;&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;h1&amp;gt;CSS ANI&amp;lt;span&amp;gt;MA&amp;lt;/span&amp;gt;TION.&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then to add styles, we add some styles to the body tag to remove margins and add background color.&lt;br&gt;
&lt;strong&gt;CSS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  body {
        margin: 0;
        padding: 0;
        color: tan;
        background-color: rgb(2, 2, 33);

    }

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

&lt;/div&gt;



&lt;p&gt;Add basic styles to the h1 tag;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    h1 {
        overflow: hidden;
        white-space: nowrap;
        font-family: consolas;
        border-right: 4px solid tan;
        width: 14ch;
        margin-left: 50px;
        font-size: 6rem;    
    }

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

&lt;/div&gt;



&lt;p&gt;The hidden overflow will ensure we are unable to see what text venture outside the width of the h1. We set the white-space to no-wrap, so that all our text will be on a single line, and the width we set to 14 characters because that is the total number of characters we want to implement the typing animation on. Next, we add out animation styles to the h1 styles.&lt;br&gt;
&lt;strong&gt;CSS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    h1 {
        animation-name: type;
        animation-duration: 3s;
        animation-timing-function: steps(14);
        animation-fill-mode: forwards;
        animation-iteration-count: 5;
        animation-direction: alternate;
        overflow: hidden;
        white-space: nowrap;
        font-family: consolas;
        border-right: 4px solid tan;
        width: 14ch;
        margin-left: 50px;
        font-size: 6rem;
    }


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

&lt;/div&gt;



&lt;p&gt;Here, the animation name is type, the name is used as identifier for the keyframes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

    @keyframes type {
        0% {
            width: 0ch;
            border-right: 4px solid tan;

        }

        99% {
            width: 15ch;
            border-right: 4px solid tan;

        }

        100% {
            width: 15ch;
            border-right: none;

        }
    }


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

&lt;/div&gt;



&lt;p&gt;The animation will last for 3 seconds, and it will make 15 moves, one move per character within a time frame of three seconds. This will happen 5 times as we have set the iteration count to 5. The animation will also go as though the typed text is erased and rewritten a couple of times because we have set the direction to alternate. To illustrate animation play state, we will add a hover effect that will cause the animation to pause when we hover on the animation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1:hover {
        animation-play-state: paused;
        filter: hue-rotate(60deg);

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

&lt;/div&gt;



&lt;p&gt;We can also add another animation with a few styles to the span tag with the animation shorthand property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; h1 span {
        animation: rotate-hue 1s linear 2s infinite normal forwards;
        text-shadow: 0 5px 15px rgb(114, 255, 6);
        -webkit-text-stroke: 1px rgb(250, 0, 79);

    }

    @keyframes rotate-hue {
        0% {
            filter: hue-rotate(0deg);

        }

        100% {
            filter: hue-rotate(360deg);

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&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%2Fayemelg9vl9yyrflpj57.gif" 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%2Fayemelg9vl9yyrflpj57.gif" alt="Image description" width="600" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of CSS animations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; Flexibility : CSS animations can be used to animate a wide range of properties, including transforms, colors, and more.&lt;/li&gt;
&lt;li&gt; Customizable : CSS animations can be customized using various timing functions, delays, and iteration counts.&lt;/li&gt;
&lt;li&gt; Interactive : CSS animations can be interactive, responding to user input and hover states.&lt;/li&gt;
&lt;li&gt; No JavaScript required : CSS animations can be created without any JavaScript code.&lt;/li&gt;
&lt;li&gt; Improved user experience : CSS animations can enhance the user experience by providing visual feedback and smooth transitions.&lt;/li&gt;
&lt;li&gt; Cross-browser support : CSS animations are widely supported by modern browsers, including Chrome, Firefox, Safari, and Edge.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Disadvantages of CSS animation
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; Browser compatibility issues: While CSS animations are widely supported, there may be compatibility issues with older browsers.&lt;/li&gt;
&lt;li&gt; Performance issues with complex animations: Complex CSS animations can lead to performance issues, such as slow frame rates or lag.&lt;/li&gt;
&lt;li&gt; Limited support for conditional animations: CSS animations have limited support for conditional animations, making it difficult to animate elements based on specific conditions.&lt;/li&gt;
&lt;li&gt; Limited support for complex animations: CSS animations are best suited for simple animations, and complex animations may require JavaScript.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cautions to take when animating elements:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; Consider accessibility: Ensure animations don't cause accessibility issues, such as seizure triggers or distracting visuals.&lt;/li&gt;
&lt;li&gt; Avoid over-animating: Too many animations can cause visual overload and slow performance.&lt;/li&gt;
&lt;li&gt; Be cautious with animation durations: Long animation durations can lead to slow performance and visual lag.&lt;/li&gt;
&lt;li&gt; Be mindful of browser support: Ensure animations work across different browsers and versions.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Note that not all CSS properties can be animated. Some CSS properties that cannot be animated are;&lt;br&gt;
1)  display&lt;br&gt;
2)  overflow&lt;br&gt;
3)  position (except for position: fixed which can be animated)&lt;br&gt;
4)  z-index&lt;br&gt;
5)  visibility (except for toggling between visible and hidden)&lt;br&gt;
6)  cursor&lt;br&gt;
7)  pointer-events &lt;br&gt;
8)  box-sizing&lt;br&gt;
9)  caret-color (except in Firefox)&lt;br&gt;
10) unicode-bidi (except in Firefox)&lt;br&gt;
11) writing-mode (except in Firefox)&lt;br&gt;
12) direction&lt;br&gt;
13) user-select&lt;br&gt;
14) nav-index&lt;br&gt;
15) tab-size&lt;br&gt;
16) shape-image-threshold (except in Firefox)&lt;br&gt;
17) shape-margin (except in Firefox)&lt;br&gt;
18) clip-path (except in Firefox)&lt;br&gt;
19) filter (except in Firefox)&lt;br&gt;
20) backdrop-filter (except in Firefox)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check the MDN documentation or other resources for the most up-to-date information on animatable properties, as browser support and specifications can change over time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, CSS animations are a versatile tool that can be used to create a wide range of effects, from subtle interactions to complex animations. By leveraging the techniques and properties discussed in this article, developers can create web pages that are not only visually stunning but also provide a rich and engaging user experience.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CSS and js standing fan</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Sat, 29 Jun 2024 23:23:19 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/css-and-js-standing-fan-1nmh</link>
      <guid>https://dev.to/kemiowoyele1/css-and-js-standing-fan-1nmh</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontend-magic/embed/PovrWBo?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>Mastering Gradients in CSS: A Beginner's Guide</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Sat, 22 Jun 2024 07:30:25 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/mastering-gradients-in-css-a-beginners-guide-4gak</link>
      <guid>https://dev.to/kemiowoyele1/mastering-gradients-in-css-a-beginners-guide-4gak</guid>
      <description>&lt;p&gt;Gradients are gradual transition between two or more colors. They are used to create a smooth continuous change from one color to another. Gradients are used to add colored stripes and blends to backgrounds. They are usually treated as value to background-image property or to the background property. &lt;br&gt;
    Background gradients were introduced to CSS in 2008. The introduction of background gradients enabled developers to create appealing and dynamic backgrounds with better performance and faster load times. &lt;br&gt;
There are three major types of gradients.&lt;br&gt;
• Linear-gradient,&lt;br&gt;
• Radial-gradient,&lt;br&gt;
• Conic-gradient,&lt;br&gt;
• And a repeating version of each.&lt;/p&gt;
&lt;h2&gt;
  
  
  Linear-gradient
&lt;/h2&gt;

&lt;p&gt;linear-gradient is a kind of gradient that flows in a line. The line could be in any direction, and the direction could be specified either as an angle or as a named direction (to top, to bottom, to left or to right). If the direction is omitted, gradient will flow from top to bottom. &lt;br&gt;
    It is also required to have at least two colors for the gradient to work. You can also add start and stop points for each color. This is optional as by default, the gradient colors are evenly distributed. The points could be written in percentages or specific lengths.&lt;br&gt;
Syntax&lt;br&gt;
Background: linear-gradient( direction, color  start-point stop-point, another color ….)&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; background: linear-gradient(red, green, blue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fxwtj3t6ko1l7bycstl2e.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%2Fxwtj3t6ko1l7bycstl2e.png" alt="Image description" width="392" height="179"&gt;&lt;/a&gt;&lt;br&gt;
In this example, direction and color points were not given. Therefore, the colors flowed from top to bottom and were evenly blended into each other as it went.&lt;br&gt;
Example 2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; background: linear-gradient(to right, green, white, green);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F6etjtksi48n8lys5i04s.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%2F6etjtksi48n8lys5i04s.png" alt="Image description" width="437" height="202"&gt;&lt;/a&gt;&lt;br&gt;
0r we could use angles to specify the direction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: linear-gradient(45deg, red, blue, green);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fucy3k9qcsqzl1lwk1rum.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%2Fucy3k9qcsqzl1lwk1rum.png" alt="Image description" width="597" height="268"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Start points&lt;/strong&gt;&lt;br&gt;
Start points are used to specify where the color should start with no blend of the previous color. If only one value is added, it is taken as the start point. Start point for the first color is 0.&lt;br&gt;
To illustrate start and stop points, I will add ten equal elements in the body, and give each a border-top of 2px. Each of these border-tops will help us with the demarcation for each ten%.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: linear-gradient(to bottom, red, blue 40%, green 70%);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fxaxulx398alnwqs7ofox.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%2Fxaxulx398alnwqs7ofox.png" alt="Image description" width="720" height="516"&gt;&lt;/a&gt;&lt;br&gt;
From the illustration above, the start point for color red is zero by default. Then color blue stars to blend into color red up until 40% where it becomes a hard blue. But color green creeps in soon, but at 70% it becomes fully green with no more traces of blue. &lt;/p&gt;
&lt;h2&gt;
  
  
  Stop point
&lt;/h2&gt;

&lt;p&gt;You can also specify stop points, which will be the point the color can start blending into the next color.&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: linear-gradient(to bottom, red 30%, blue 40% 60%, green 70%);

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

&lt;/div&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%2Fkfr226nwa94fna8mil07.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%2Fkfr226nwa94fna8mil07.png" alt="Image description" width="756" height="539"&gt;&lt;/a&gt;&lt;br&gt;
With a stop point of 30% for color red, blue is not allowed to blend into red until it gets to 30%. Then since blue also has a start point of 40%, blending of red and blue is only allowed between 30% and 40%. So we have a hard blue from 40% to 60% before the next color (green) starts blending in. then at 70%, which is the start point for hard green, the blue stops. The stop point of the last color is 100% by default.&lt;br&gt;
 To create complete hard colors without blending into each other, the stop point of the previous color should be the same with the start point of the next color. &lt;br&gt;
Example 2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: linear-gradient(to right, green 0 33%, white 33% 66%, green 66%);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fm1s9hw1gmtzy8ey8vfct.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%2Fm1s9hw1gmtzy8ey8vfct.png" alt="Image description" width="429" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Radial-gradient:
&lt;/h2&gt;

&lt;p&gt;Radial gradient presents colors in circular or oval form. The colors radiates out from the center, unless otherwise indicated.&lt;br&gt;
Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: radial-gradient(white, blue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fndxgbzup25mqgq2dommf.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%2Fndxgbzup25mqgq2dommf.png" alt="Image description" width="544" height="225"&gt;&lt;/a&gt;&lt;br&gt;
You can specify that instead of an eclipse-shaped gradient, you will have a circle irrespective of the aspect ratio of your device screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; background: radial-gradient(circle, white, blue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fv6zawsbdm5v126rr9enl.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%2Fv6zawsbdm5v126rr9enl.png" alt="Image description" width="545" height="229"&gt;&lt;/a&gt;&lt;br&gt;
You can specify where you want the colors to radiate from&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: radial-gradient(circle at top, white, blue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fo1zuqvhg965f5qusgcjm.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%2Fo1zuqvhg965f5qusgcjm.png" alt="Image description" width="500" height="208"&gt;&lt;/a&gt;&lt;br&gt;
You can also specify the direction with percentages or other measuring units.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: radial-gradient(circle at 15% 95%, white, blue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F2f86o94mnxhu37uh5lw2.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%2F2f86o94mnxhu37uh5lw2.png" alt="Image description" width="800" height="327"&gt;&lt;/a&gt;&lt;br&gt;
You may also add start/ stop points to the colors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: radial-gradient(white 35%, blue 35% 70%, white 70%);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Ffiqyiqkq99v1y112ekya.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%2Ffiqyiqkq99v1y112ekya.png" alt="Image description" width="604" height="250"&gt;&lt;/a&gt;&lt;br&gt;
You can create interesting patterns, by manipulating these features along with the background-size and background-position properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: radial-gradient(circle at 5% 50%, white 35%, blue 35% 70%, white 70%);
background-size: 50px 50px;

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

&lt;/div&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%2Ffkesaize2omx9t36vsg8.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%2Ffkesaize2omx9t36vsg8.png" alt="Image description" width="548" height="226"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: radial-gradient(at 0%, blue 50%, white 50%);
background-size: 50px 50px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fhs9xb3vumxe354ww4p19.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%2Fhs9xb3vumxe354ww4p19.png" alt="Image description" width="492" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conic-gradients
&lt;/h2&gt;

&lt;p&gt;Instead of radiating from the center, conic-gradients rotate around the center (or whatever center point is specified).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; background: conic-gradient(red, green, blue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F06gtzrfd7qkk4diuia20.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%2F06gtzrfd7qkk4diuia20.png" alt="Image description" width="614" height="268"&gt;&lt;/a&gt;&lt;br&gt;
The gradients rotates clockwise, usually from 0deg.You can specify the center point of the gradient so instead of 0deg, you may use 45deg for example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; background: conic-gradient(from 45deg, red, green, white);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fr3fioz5xd294xqjy3e1p.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%2Fr3fioz5xd294xqjy3e1p.png" alt="Image description" width="705" height="303"&gt;&lt;/a&gt;&lt;br&gt;
You may use phrases like from top, from left etc, or you may use percentages or other measuring units to set the beginning point of the conic gradient. This could be set horizontally and vertically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: conic-gradient(from 45deg at 30% 5%, red, green, white);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fqh35zl4ehzfpmtx2pvbv.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%2Fqh35zl4ehzfpmtx2pvbv.png" alt="Image description" width="599" height="259"&gt;&lt;/a&gt;&lt;br&gt;
You can also set the start point and end points for each color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: conic-gradient(from 45deg at 30% 5%, red 10%, green 10% 20%, white 20% 30%, yellow 30% 40%, pink 40% 60%, black 60%);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Flk4pkf1iiklrle2tloy0.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%2Flk4pkf1iiklrle2tloy0.png" alt="Image description" width="579" height="255"&gt;&lt;/a&gt;&lt;br&gt;
You can also use gradients to create interesting patterns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: conic-gradient(from 45deg at 0% 5%, black 10%, grey 30% 40%, black 60%);
background-size: 50px 50px;

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

&lt;/div&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%2F1nk44oyuu1xgmxeykdyz.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%2F1nk44oyuu1xgmxeykdyz.png" alt="Image description" width="652" height="281"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: conic-gradient(from 45deg at 50% 55%, black 10deg, grey 30deg 40deg, black 60deg 100deg, blue 180deg);
background-size: 50px 50px;

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

&lt;/div&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%2F6lvccnbli5c0jiq43qkc.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%2F6lvccnbli5c0jiq43qkc.png" alt="Image description" width="606" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiple background gradients
&lt;/h2&gt;

&lt;p&gt;You can also use multiple gradients with comma (,) separating each gradient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: conic-gradient(from 45deg at 0% 5%, black 10%, grey 30% 40%, black 60%),
linear-gradient(to bottom, rgb(109, 16, 16) 30%, rgb(12, 12, 95) 40% 60%, rgb(10, 70, 10) 70%);

background-size: 50px 50px;
background-blend-mode: screen;

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

&lt;/div&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%2Fms0xvb013jklu1rdryu0.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%2Fms0xvb013jklu1rdryu0.png" alt="Image description" width="564" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Gradients provide beautiful alternatives to using url() images as they are lightweight and can be easily scaled to look consistent across devices. They can also be used to create dynamic effect, such as hover states, transitions, and animations. People also use gradient backgrounds to create images or artistic effects with a single div.&lt;/p&gt;

</description>
      <category>css</category>
      <category>gradients</category>
      <category>webdev</category>
      <category>backgrounds</category>
    </item>
    <item>
      <title>Sallah greeting with ram</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Sun, 16 Jun 2024 14:34:10 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/sallah-greeting-with-ram-73c</link>
      <guid>https://dev.to/kemiowoyele1/sallah-greeting-with-ram-73c</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontend-magic/embed/JjqMMXN?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>Creative CSS Border</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Fri, 14 Jun 2024 17:34:21 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/creative-css-border-1cme</link>
      <guid>https://dev.to/kemiowoyele1/creative-css-border-1cme</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontend-magic/embed/MWdONMo?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>3d rotating octahedron</title>
      <dc:creator>Kemi Owoyele</dc:creator>
      <pubDate>Fri, 14 Jun 2024 16:31:46 +0000</pubDate>
      <link>https://dev.to/kemiowoyele1/3d-rotating-octahedron-hfd</link>
      <guid>https://dev.to/kemiowoyele1/3d-rotating-octahedron-hfd</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/frontend-magic/embed/eYaeqdd?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
  </channel>
</rss>
