<?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: Harry Tom</title>
    <description>The latest articles on DEV Community by Harry Tom (@harrify).</description>
    <link>https://dev.to/harrify</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%2F513591%2F2307b7d3-69a1-40ef-b4e3-7acf7813842f.png</url>
      <title>DEV Community: Harry Tom</title>
      <link>https://dev.to/harrify</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harrify"/>
    <language>en</language>
    <item>
      <title>Create a On-This-Day project with html, css and javascirpt!</title>
      <dc:creator>Harry Tom</dc:creator>
      <pubDate>Wed, 16 Jun 2021 11:11:53 +0000</pubDate>
      <link>https://dev.to/harrify/create-a-on-this-day-project-with-html-css-and-javascirpt-46de</link>
      <guid>https://dev.to/harrify/create-a-on-this-day-project-with-html-css-and-javascirpt-46de</guid>
      <description>&lt;p&gt;Hello coders! This is my first post and with a simple project you can do easily. So what we are gonna make is a today in history project with a &lt;em&gt;WikiPedia&lt;/em&gt; based API. This will be the thing you will get afterwards!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHarry260%2Fharry260.github.io%2Fmain%2Fpersonal-files%2Fimages%2Foutput.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHarry260%2Fharry260.github.io%2Fmain%2Fpersonal-files%2Fimages%2Foutput.PNG" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  You need
&lt;/h2&gt;

&lt;p&gt;We are going to use an simple light weight rest API. This is an API made with WikiPedia and sure its verified content! And nothing else, so we can start coding.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://github.com/harrify-apis/historyjs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;First, we have to create the files for the project.&lt;br&gt;
Create a files with the name &lt;code&gt;index.html&lt;/code&gt;, &lt;code&gt;app.js&lt;/code&gt;, and &lt;code&gt;style.css&lt;/code&gt;;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHarry260%2Fharry260.github.io%2Fmain%2Fpersonal-files%2Fimages%2Fdevto_historyjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FHarry260%2Fharry260.github.io%2Fmain%2Fpersonal-files%2Fimages%2Fdevto_historyjs.png" alt="Files Screenshot"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;Now lets start the real coding! As usual we start with index.html. Now, open the index.html file in notepad or any preferred text editors. Here I am using &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;Visual Studio Code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is the code you want to write&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;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;My wiki-project&amp;lt;/title&amp;gt;
        &amp;lt;link rel="stylesheet" href="style.css" type="text/css"&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;div class="title-bar"&amp;gt;
             &amp;lt;h1&amp;gt;Today In History&amp;lt;/h1&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="root-div"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/body&amp;gt;
    &amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;!--APP.js file linked!--&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Step 3
&lt;/h1&gt;

&lt;p&gt;Next, we are going to write some css script, which you can do according to your need, the code goes here! I have made a basic minimal User Interface.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    transition: 0.4s;
}

body{
    padding-top: 120px;
    background-color: burlywood;
}

.wrap{
    display: flex;
    justify-content: center;
    width: 100%;
}

.title-bar{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.534);
    backdrop-filter: blur(10px); /*Less Browser Suppor*/
}

.root-div{
    width: 700px;
    padding: 30px;
    min-height: 100vh;
    margin-top: 20px;
}
.item{
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 4px 12px 40px 6px rgb(0 0 0 / 9%);
    margin-bottom: 20px;
    cursor: pointer;
}

.item:hover{
    transform: scale(1.1) rotate(5deg);
}

.item h1{
    font-size: 20px;
    line-height: 25px;
    color: #333333;
}

.item h4{
    font-size: 15px;
    margin-bottom: 15px;
    color: #2575fc;

}

a{
    text-decoration: none;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Step 4
&lt;/h1&gt;

&lt;p&gt;Now we are getting into the important but easiest part! Yes the &lt;code&gt;javascirpt&lt;/code&gt; part. So , I have used __ &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API" rel="noopener noreferrer"&gt;Javascript Fetch Api&lt;/a&gt; __ to fetch content from our Today in History API&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var api_type = "events"; //events | deaths | births

var today = new Date();//New date class
var year = today.getFullYear(); //Get fill year
var month = today.getMonth() + 1; //Get the month
var date = today.getDate();// Get the date
var root_div = document.querySelector(".root-div"); //Selecting the DOM
//Api url construction
var api = "https://cdn.jsdelivr.net/gh/harrify-apis/historyjs/" + api_type + "/" + month + "_" + date + ".json";

//Javascript fetch from json api
fetch(api).then(
    function(response){

        response.json().then(function(json) {

            json = json[api_type];
            const list = Object.values(json).map(post =&amp;gt; `


            &amp;lt;a href="${post.wikipedia[0].wikipedia}" target="_blank"&amp;gt;
                &amp;lt;div class="item"&amp;gt;
                    &amp;lt;h4&amp;gt;${post.year} - ${year - post.year} years ago&amp;lt;/h4&amp;gt;
                    &amp;lt;h1&amp;gt;${post.description}&amp;lt;/h1&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/a&amp;gt;
            `);

            var html = list.join("");
            root_div.innerHTML = html;
        });
        //Mapping Json Response


    }
);

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

&lt;/div&gt;

&lt;h1&gt;
  
  
  Lets break down the code
&lt;/h1&gt;

&lt;p&gt;So, lemme break down the code, so that you can understand way better than just reading this box full text 🤣&lt;/p&gt;
&lt;h2&gt;
  
  
  Variable
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;today&lt;/strong&gt; : We created a new instance of JavaScript Date Class&lt;br&gt;
&lt;strong&gt;year&lt;/strong&gt; : We've set it to the current year&lt;br&gt;
&lt;strong&gt;month&lt;/strong&gt; : We've set it to the current mont&lt;br&gt;
&lt;strong&gt;date&lt;/strong&gt; : We've set it to the current date&lt;br&gt;
&lt;strong&gt;root_div&lt;/strong&gt; : We've set it to the div in which we have to insert the html &lt;/p&gt;
&lt;h3&gt;
  
  
  api
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"https://cdn.jsdelivr.net/gh/harrify-apis/historyjs/{type}/{month}_{date}.json";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, we replace &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 &lt;code&gt;{type}&lt;/code&gt; with &lt;code&gt;events&lt;/code&gt; or &lt;code&gt;birsth&lt;/code&gt; or &lt;code&gt;deaths&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;2 &lt;code&gt;{date}&lt;/code&gt; with todays data&lt;/li&gt;
&lt;li&gt;3 &lt;code&gt;{month}&lt;/code&gt; with current month&lt;/li&gt;
&lt;li&gt;4 &lt;code&gt;{year}&lt;/code&gt; with current year&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  api_type
&lt;/h3&gt;

&lt;p&gt;You can set the api type according to your needs. You can choose from three catagories.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;events&lt;/code&gt; : Which will get you the &lt;strong&gt;events&lt;/strong&gt; happened on this day&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;deaths&lt;/code&gt; : Which will get you the &lt;strong&gt;deaths&lt;/strong&gt; happened on this day&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;births&lt;/code&gt; : Which will get you the &lt;strong&gt;births&lt;/strong&gt; happened on this day&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  fetch() function
&lt;/h2&gt;

&lt;p&gt;We are using this javascript api here to get &lt;code&gt;json&lt;/code&gt; data from the api. After the &lt;code&gt;json&lt;/code&gt; data is downloaded, we render the json to html and we insert the html to the &lt;code&gt;.root-div&lt;/code&gt; element. And that's all happening inside this three simple files! If you want, see this pen, maybe this will be helpful! &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/harrify/embed/qBrgOwN?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;h1&gt;
  
  
  Full Source Code here!
&lt;/h1&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I just made this post because, I was searching for this for many days. One day I made it and I want to share this hoping it will be helpful for someone. This is my first post in dev.to, and sorry for the formatting in this page :)&lt;/p&gt;

&lt;p&gt;You can find me and ask anything to me&lt;br&gt;
&lt;a href="//mailto:harrytom2606@gmail.com"&gt;email&lt;/a&gt;, &lt;a href="https://github.com/harry260" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://harrytom.ml" rel="noopener noreferrer"&gt;my works&lt;/a&gt;, &lt;a href="https://twitter.com/@me_harrify" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;, &lt;a href="https://www.youtube.com/channel/UClUfC4LfzheWm-8qAg6Nq3g?sub_confirmation=1" rel="noopener noreferrer"&gt;youtube&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>css</category>
      <category>wikipedia</category>
    </item>
  </channel>
</rss>
