<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Prateek Jadhwani]]></title><description><![CDATA[// Frontend Developer// Gamer// !Nerd// Dreamer]]></description><link>https://prateekjadhwani.github.io</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 May 2019 12:27:56 GMT</lastBuildDate><atom:link href="https://prateekjadhwani.github.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Reduced Motion Media Query to Avoid Vestibular Disorders and Seizures]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>When I was doing my research in Accessibility, I came across the term Vestibular Disorder. I really didn’t know much about it at that time. It is basically a type of disability that a person viewing the screen might have. It is often grouped with seizures and symptoms may include dizziness, vertigo, nausea, etc.</p>
</div>
<div class="paragraph">
<p>In terms of browsing the web, this sort of motion sickness might be caused by weird animations, or parallax backgrounds[1], which a lot of might not like and thus causing a higher bounce rate[4].</p>
</div>
<div class="paragraph">
<p>In order to provide a solution for this accessibility issue, the web specifications now include a new media query called <code>prefers-reduced-motion</code>. What it does is, it lets the browser run a specific css stated under <code>prefers-reduced-motion</code> media query[3] which can contain fixes for Reduced Motion.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_enable_reduced_motion">Enable Reduced Motion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before we even start diving into code, let’s take a look at ways we can enable <strong>Reduced Motion</strong> option on a Mac.
<em>( Sorry windows users, I don’t have a windows machine with me. )</em></p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/reduced-motion.gif" alt="reduced motion">
</div>
</div>
<div class="paragraph">
<p>If you are unable to view the gif above, the steps are as follows:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Go to <strong>System Preferences</strong> &gt; <strong>Accessibility</strong> &gt; <strong>Display</strong></p>
</li>
<li>
<p>Click on <strong>Reduce Motion</strong> checkbox</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>And you can disable by unchecking the same checkbox.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prefers_reduced_motion_media_query">prefers-reduced-motion media query</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can use the media query <code>prefers-reduced-motion</code> to specifically hide the contents of the page that might cause motion sickness or nausea.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-css" data-lang="css">@media (prefers-reduced-motion) {
	// do magic here
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you want, you can take a look at the demo below. If you have <strong>Reduced Motion</strong> enabled, you will see a black overlay. Or else you see a gif.</p>
</div>
<div class="demo-message">Try Enabling or Disabling the Reduced Motion option under Accessibility</div>
<div class="reduced-motion-container">
  <blockquote class="imgur-embed-pub" lang="en" data-id="oPiNf7m"><a href="//imgur.com/oPiNf7m">Sex on acid</a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
  <div class="reduced-motion-overlay">
    Reduced Motion is ON, so this section is hidden.
  </div>
</div>
<style>
.demo-message {
  text-align: center;
  padding: 10px;
  border: 1px solid #cecece;
  border-radius: 5px;
  width: 400px;
  margin: 0 auto;
  margin-bottom: 35px;
}

.reduced-motion-container {
  margin: 0 auto;
  width: 550px;
  position: relative;
}

.reduced-motion-overlay {
  display: none;
}

@media (prefers-reduced-motion) {
  .reduced-motion-overlay {
    position: absolute;
    top: 0;
    left: 0;
    background: black;
    display: block;
    color: white;
    height: 100%;
    width: 100%;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
  }
}
</style>
<div class="paragraph">
<p>Demo Link : <a href="https://codepen.io/prateekjadhwani/pen/eajegp" class="bare">https://codepen.io/prateekjadhwani/pen/eajegp</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I hope you are now able to understand the main reason behind the implementation of this feature. And ways in which this media query can be used to provide a better user interface for you site.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="paragraph">
<p>[1] Accessibility For Everyone : <a href="https://abookapart.com/products/accessibility-for-everyone" class="bare">https://abookapart.com/products/accessibility-for-everyone</a></p>
</div>
<div class="paragraph">
<p>[2] CSS prefers-reduced-motion media query : <a href="https://chromestatus.com/feature/5597964353404928" class="bare">https://chromestatus.com/feature/5597964353404928</a></p>
</div>
<div class="paragraph">
<p>[3] prefers-reduced-motion media feature :  <a href="https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion" class="bare">https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion</a></p>
</div>
<div class="paragraph">
<p>[4] Bounce Rate <a href="https://en.wikipedia.org/wiki/Bounce_rate" class="bare">https://en.wikipedia.org/wiki/Bounce_rate</a></p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2019/05/28/Reduced-Motion-Media-Query-to-Avoid-Vestibular-Disorders-and-Seizures.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2019/05/28/Reduced-Motion-Media-Query-to-Avoid-Vestibular-Disorders-and-Seizures.html</guid><category><![CDATA[css3]]></category><category><![CDATA[accessibility]]></category><category><![CDATA[Reduced Motion]]></category><category><![CDATA[prefers-reduced-motion]]></category><category><![CDATA[media query]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Tue, 28 May 2019 00:00:00 GMT</pubDate></item><item><title><![CDATA[Picture In Picture API]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>If you are a software engineer, you must have heard of the term "No code is the best code". It simply means that if you can make a feature work without any code, it is a good way of implementing that feature. In my experience, I have tried to push towards features that can be done with just CSS and html rather than using JavaScript as well. One of the most common examples of this is the use of tabs in a web page. You can achieve a tabbed layout with just css and html without any javascript events and handlers. This way you can not only create a feature that uses less code, you are also creating a feature that needs zero to very less maintenance.</p>
</div>
<div class="paragraph">
<p>In this article, I would like to cover one of these no cost- low maintenance features that is available on Chrome. This feature is called Picture In Picture API.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_is_picture_in_picture_api">What is Picture in Picture API?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Picture in Picture api lets a developer create a floating video that can be placed on top of all the other content inside a web page.</p>
</div>
<div class="paragraph">
<p>Try looking at the demo below</p>
</div>
<p class="codepen" data-height="361" data-theme-id="3991" data-default-tab="result" data-user="prateekjadhwani" data-slug-hash="arVxry" style="height: 361px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Picture In Picture API">
  <span>See the Pen <a href="https://codepen.io/prateekjadhwani/pen/arVxry/">
  Picture In Picture API</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>)
  on <a href="https://codepen.io">CodePen</a>.</span>
</p>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>If you click on the button "Request Picture in Picture", you will be able to see the video move from its original location to the bottom right corner of the screen.</p>
</div>
<div class="paragraph">
<p>I am requesting Picture in Picture with the help of the following code:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('video').requestPictureInPicture();</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you want you can call this code on the scroll event to make something like how news site show their floating videos.</p>
</div>
<div class="paragraph">
<p>One thing to keep in mind is that I did not write any extra code to achieve this feature. I simply called an api and the browser did it for me.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_but_what_if_i_need_customization">But What If I Need Customization?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There are a lot of ways you can customize Picture in Picture feature.</p>
</div>
<div class="sect3">
<h4 id="_feature_support">Feature Support</h4>
<div class="paragraph">
<p>You can check if the browser supports Picture in Picture API by using the following code:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">if (!document.pictureInPictureElement) {
  // handle errors
}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_listening_for_events">Listening for events</h4>
<div class="paragraph">
<p>You can even listen to events triggered by the api. For example, you can listen for when the video enters Picture in Picture mode or when it leaves.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('video')
  .addEventListener('enterpictureinpicture', () =&gt; {
    // Do stuff when video enters Picture in Picture
  })</code></pre>
</div>
</div>
<div class="paragraph">
<p>or</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('video')
  .addEventListener('leavepictureinpicture', () =&gt; {
    // Do stuff when video leaves Picture in Picture
  })</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_look_and_feel">Look and Feel</h4>
<div class="paragraph">
<p>You can also change the css associated with the video using the <code>:picture-in-picture</code> pseudo class. Although this feature is available in chrome 76 and above.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-css" data-lang="css">video:picture-in-picture {
  border: 20px solid blue;
}</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>With the above description and code samples, you should be able to see the future aspect of Picture in Picture. If you are from a software / technology company who needs to show product or article videos, this might be a better route as it saves a lot of time in coding and maintenance.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="paragraph">
<p>[1] Picture-in-Picture (PiP) <a href="https://chromestatus.com/feature/5729206566649856" class="bare">https://chromestatus.com/feature/5729206566649856</a></p>
</div>
<div class="paragraph">
<p>[2] Picture-in-Picture <a href="https://wicg.github.io/picture-in-picture/" class="bare">https://wicg.github.io/picture-in-picture/</a></p>
</div>
<div class="paragraph">
<p>[3] CSS pseudo-class ":picture-in-picture" Sample <a href="https://googlechrome.github.io/samples/picture-in-picture/css-pseudo-class" class="bare">https://googlechrome.github.io/samples/picture-in-picture/css-pseudo-class</a></p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2019/05/22/Picture-In-Picture-API.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2019/05/22/Picture-In-Picture-API.html</guid><category><![CDATA[javascript]]></category><category><![CDATA[css3]]></category><category><![CDATA[pictureinpicture]]></category><category><![CDATA[picture]]></category><category><![CDATA[video]]></category><category><![CDATA[api]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 22 May 2019 00:00:00 GMT</pubDate></item><item><title><![CDATA[Where is Prateek + a Unity Game?]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>I know I have been missing in action and haven&#8217;t written anything at all in a  really long time. And I will be honest&#8230;&#8203; I gave up on the blog. In the past 10 years of me writing blogs, there have been times when I totally stop writing the blogs for a few months and then start writing again. And the last time this happened was when I moved my blog from Wordpress to Hubpress on Github.</p>
</div>
<div class="paragraph">
<p>But the good news is I am back. And here are the updates.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_unity_3d">Unity 3D</h2>
<div class="sectionbody">
<div class="paragraph">
<p>First and foremost news, I started learning Unity last year. And here is my first attempt to this technology:</p>
</div>
<div class="sect2">
<h3 id="_1_recycle_recycle">1. Recycle Recycle</h3>
<div class="paragraph">
<p>I created this game as a test project to see what can be done with Unity and basic / newbie Pixel art. The game is released on iOS and can be found <a href="https://itunes.apple.com/in/app/recycle-recycle/id1431570689?mt=8">here</a>.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/recycle-recycle.png" alt="screenshot" width="230" height="409">
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/recycle-recycle.png" alt="screenshot" width="230" height="409">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_2_chopper_to_hell">2. Chopper To Hell</h3>
<div class="paragraph">
<p>This is another interesting unity 3d project. My aim was to create a game using the asset store with $0 budget. The game involved killing spiders while controlling a chopper. This game needs its own blog, so I will try to write a totally new blog on it in the coming days, especially about the lessons learned.</p>
</div>
<div class="paragraph">
<p>The game was released on Steam and can be found  <a href="https://store.steampowered.com/app/1061790/Chopper_To_Hell/">here</a>.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/FlameThrower.png" alt="screenshot">
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_pixel_art">Pixel Art</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I have also been trying to play around with pixel art. I still have problems with Walk Cycles, but I am getting better at creating random artwork.</p>
</div>
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">How much would you rate it out of 10 ?<br><br>Also critique my art ¯\_(ツ)_/¯<a href="https://twitter.com/hashtag/Pixel_Dailies?src=hash&amp;ref_src=twsrc%5Etfw">#Pixel_Dailies</a> <a href="https://twitter.com/hashtag/pixelart?src=hash&amp;ref_src=twsrc%5Etfw">#pixelart</a> <a href="https://twitter.com/hashtag/%E3%83%89%E3%83%83%E3%83%88%E7%B5%B5?src=hash&amp;ref_src=twsrc%5Etfw">#ドット絵</a> <a href="https://twitter.com/hashtag/screenshotsaturday?src=hash&amp;ref_src=twsrc%5Etfw">#screenshotsaturday</a> <a href="https://twitter.com/hashtag/pixelartist?src=hash&amp;ref_src=twsrc%5Etfw">#pixelartist</a> <a href="https://twitter.com/hashtag/mood?src=hash&amp;ref_src=twsrc%5Etfw">#mood</a> <a href="https://twitter.com/hashtag/art?src=hash&amp;ref_src=twsrc%5Etfw">#art</a> <a href="https://twitter.com/hashtag/beautiful?src=hash&amp;ref_src=twsrc%5Etfw">#beautiful</a> <a href="https://twitter.com/hashtag/gameart?src=hash&amp;ref_src=twsrc%5Etfw">#gameart</a> <a href="https://twitter.com/hashtag/2d?src=hash&amp;ref_src=twsrc%5Etfw">#2d</a> <a href="https://twitter.com/hashtag/retro?src=hash&amp;ref_src=twsrc%5Etfw">#retro</a> <a href="https://twitter.com/hashtag/retroart?src=hash&amp;ref_src=twsrc%5Etfw">#retroart</a> <a href="https://t.co/8fl4VhM3OT">pic.twitter.com/8fl4VhM3OT</a></p>&mdash; Prateek Jadhwani 🎮 Chopper To Hell (@prateekjadhwani) <a href="https://twitter.com/prateekjadhwani/status/1122177892769603589?ref_src=twsrc%5Etfw">April 27, 2019</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</div>
<div class="sect1">
<h2 id="_writing_a_book">Writing a book</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In the past few months, I have also been writing a book. While I am trying to learn Unity3d, I am also keeping up with learning frontend technologies and keeping up with the market. And I know, I haven&#8217;t been writing blogs, but I am spending that energy on to writing a book.</p>
</div>
<div class="paragraph">
<p>I cannot say anything more about it. XD</p>
</div>
</div>
</div>
<h1 id="_summary" class="sect0">Summary</h1>
<div class="paragraph">
<p>There you go guys, all the updates. I will try not to disappear again for a long time.</p>
</div>]]></description><link>https://prateekjadhwani.github.io/2019/05/15/Where-is-Prateek-a-Unity-Game.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2019/05/15/Where-is-Prateek-a-Unity-Game.html</guid><category><![CDATA[Blog]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 15 May 2019 00:00:00 GMT</pubDate></item><item><title><![CDATA[Contextual Styling Demo]]></title><description><![CDATA[<div class="paragraph">
<p>After reading <a href="http://simurai.com/">Simurai</a>'s article on <a href="http://simurai.com/blog/2018/04/01/contextual-styling">Contextual Styling with Custom Properties</a>, I decided to create a small demo using the same tech.</p>
</div>
<p data-height="351" data-theme-id="3991" data-slug-hash="QmxKdd" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="CSS Variable theme using data-theme" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/QmxKdd/">CSS Variable theme using data-theme</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>Please do not forget to review <a href="http://simurai.com/blog/2018/04/01/contextual-styling">Contextual Styling with Custom Properties</a> article incase you are interested in this tech.</p>
</div>]]></description><link>https://prateekjadhwani.github.io/2018/04/02/Contextual-Styling-Demo.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2018/04/02/Contextual-Styling-Demo.html</guid><category><![CDATA[CSS3]]></category><category><![CDATA[checkbox]]></category><category><![CDATA[demo]]></category><category><![CDATA[css variables]]></category><category><![CDATA[css theme]]></category><category><![CDATA[theme]]></category><category><![CDATA[data-theme]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Mon, 02 Apr 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[Showing or Hiding Password]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Got bored while my PS4 was installing Monster Hunter World. And ended up making this concept <a href="https://dribbble.com/shots/4298963-Show-password">Show Password</a> by <a href="https://dribbble.com/prekesh">Prekesh</a></p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_dribbble_ui">Dribbble UI</h3>
<div class="paragraph">
<p>This is what the UI looks like.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cdn.dribbble.com/users/2138/screenshots/4298963/password.gif" alt="book">
</div>
</div>
<div class="paragraph">
<p>If only, the browsers had an attribute in <code>input[type=password]</code> to show and hide passwords.</p>
</div>
</div>
<div class="sect2">
<h3 id="_demo">Demo</h3>
<p data-height="420" data-theme-id="3991" data-slug-hash="QmwGmY" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="Show Password" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/QmwGmY/">Show Password</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
</div>]]></description><link>https://prateekjadhwani.github.io/2018/03/10/Showing-or-Hiding-Password.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2018/03/10/Showing-or-Hiding-Password.html</guid><category><![CDATA[CSS3]]></category><category><![CDATA[checkbox]]></category><category><![CDATA[demo]]></category><category><![CDATA[password]]></category><category><![CDATA[show]]></category><category><![CDATA[hide]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Sat, 10 Mar 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[Building WebComponent based Progressive WebApp in Stencil JS - Part 02]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>In <a href="https://prateekjadhwani.github.io/2018/03/03/Building-Web-Component-based-Progressive-Web-App-in-Stencil-JS-Part-01.html">Part 01</a>, we looked into the hello-world example. In this part, we will be working further on the <a href="https://dribbble.com/shots/2359374-Mail-client-app">Mail Client</a>.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/mail-client-app-Jakub-Antalik.png" alt="book">
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_observations">Observations</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Here are the various observations by looking at the <a href="https://dribbble.com/shots/2359374-Mail-client-app">Mail Client</a>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>We have three sections on the page.  The first section displays the folders and email labels, the second sections displays the mails in that folder and third section displays the actual mail content.</p>
</li>
<li>
<p>Each of these sections have a header. And then the content associated with it.</p>
</li>
<li>
<p>There is no mobile or tablet layout, so we wont be worrying about the responsive layouts.</p>
</li>
<li>
<p>To keep the demo simple, we will be using data from a json file instead of actual data for the email.</p>
</li>
<li>
<p>We will be able to see emails from different people, but to keep the demo not depend on any other backend services, all the other buttons wont have any functionality associated with it.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_components">Components</h2>
<div class="sectionbody">
<div class="paragraph">
<p>We are going to use the bottom up approach to component development. In my experience, using a bottom up approach, forces components to be reusable, which is a good thing.</p>
</div>
<div class="paragraph">
<p>For the Part 02 of this series, we are going to create three components. These are as follows:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The new mail button</p>
</li>
<li>
<p>The mail information card</p>
</li>
<li>
<p>Email labels</p>
</li>
</ol>
</div>
<div class="sect2">
<h3 id="_1_new_mail_button">1. New Mail Button</h3>
<div class="paragraph">
<p>In this we are simply going to create a component that acts like a button, which is green in color, and contains some text.</p>
</div>
<div class="paragraph">
<p>Why is this a component? Because if you see the layout again, you will see that there is a green button with text "New Message" at the top, as well as a button with the text "Send" at the bottom. I decided to name this component as <code>green-button</code>.</p>
</div>
<div class="paragraph">
<p>Just like we did with the <code>hello-world</code> component, we will create two files <code>green-button.tsx</code> and <code>green-button.css</code> and place them in the <code>/src/components/green-button</code> folder.</p>
</div>
<div>
<script src="https://gist.github.com/prateekjadhwani/7e87318e4904bd9d9be430e65f0ea879.js"></script>
</div>
</div>
<div class="sect2">
<h3 id="_2_mail_information_card">2. Mail Information Card</h3>
<div class="paragraph">
<p>The mail information card is the component which displays information about the sender, the subject, and the first line of the message.</p>
</div>
<div class="paragraph">
<p>Notice that there are a bunch of Mail Information Cards in the second column and you can only select one. This behaviour resembles that of a group of radio buttons, where you can select only one radio button at a time.</p>
</div>
<div class="paragraph">
<p>The Mail Information card has a label color associated with it as well. It also has a selected state which makes its background white. Keeping these things in mind, let&#8217;s create this component.</p>
</div>
<div class="paragraph">
<p>We will create two files <code>mail-information-card.tsx</code> and <code>mail-information-card.css</code>. And place them in <code>/src/components/mail-information-card</code> folder.</p>
</div>
<div>
<script src="https://gist.github.com/prateekjadhwani/ed7291cf9f097d27285f0b2924e9b749.js"></script>
</div>
</div>
<div class="sect2">
<h3 id="_3_email_labels">3. Email Labels</h3>
<div class="paragraph">
<p>This component simply tells you what color represents what label. We can break it down into multiple components. One component can be the label itself called <code>email-label</code> and the other one can be the mail container where all these labels are called <code>email-labels</code>. Just like above, we are going the put the files in their respective folders.</p>
</div>
<div class="sect3">
<h4 id="_email_label_the_label">email-label - the label</h4>
<div>
<script src="https://gist.github.com/prateekjadhwani/351fe687d1910a338cad5d488a8123f4.js"></script>
</div>
</div>
<div class="sect3">
<h4 id="_email_labels_the_container">email-labels - the container</h4>
<div>
<script src="https://gist.github.com/prateekjadhwani/aa0eadd919057e20da81b7dcf950e35c.js"></script>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>After making a bunch of changes to the <code>app-home.tsx</code> and <code>app-home.css</code> files, we can see it working on our demo. This is what it looks like with these three components:</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/stencil-js-poc-sceenshot-01.png" alt="book">
</div>
</div>
<div class="paragraph">
<p>If you are interested the full source code of the web app, here is the link to the github project: <a href="https://github.com/prateekjadhwani/my-pwa-02" class="bare">https://github.com/prateekjadhwani/my-pwa-02</a> or you can see a working demo of this project here: <a href="https://prateekjadhwani.github.io/my-pwa-02/" class="bare">https://prateekjadhwani.github.io/my-pwa-02/</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_upcoming_in_part_03">Upcoming in Part 03</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In part 03 of this series, we will try to implement the remaining components so that we can use them freely in our web app.</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2018/03/08/Building-Web-Component-based-Progressive-Web-App-in-Stencil-JS-Part-02.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2018/03/08/Building-Web-Component-based-Progressive-Web-App-in-Stencil-JS-Part-02.html</guid><category><![CDATA[webcomponents]]></category><category><![CDATA[stencil]]></category><category><![CDATA[stenciljs]]></category><category><![CDATA[helloworld]]></category><category><![CDATA[pwa]]></category><category><![CDATA[webapp]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Thu, 08 Mar 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[Building WebComponent based Progressive WebApp in Stencil JS - Part 01]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Stencil.js is a compiler for WebComponents. It lets you write Web Components in TypeScript and jsx. If you are new to Stencil.js please take a look at their site <a href="https://stenciljs.com/">https://stenciljs.com</a> for a brief introduction.</p>
</div>
<div class="paragraph">
<p>You can download the <a href="https://github.com/ionic-team/stencil-app-starter">starter project</a> by simply cloning it so that you can skip the configuration part which may take ages.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-shell" data-lang="shell">git clone https://github.com/ionic-team/stencil-app-starter my-pwa</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can then install the dependencies by using the following command inside the <code>my-pwa</code> folder</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-shell" data-lang="shell">npm install</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_hello_world">Hello World</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Let&#8217;s take a look at a small Hello World Example to get ourselves familiar with the starter template. Create a file <code>hello-world.tsx</code> inside the <code>my-pwa/src/components/hello-world/</code> folder.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-js" data-lang="js">// filename: hello-world.tsx

import { Component } from '@stencil/core';

@Component({
    tag: 'hello-world',
    styleUrl: 'hello-world.css'
})
export class HelloWorld {
    render() {
        return (
            &lt;h1&gt;Hello World&lt;/h1&gt;
        );
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The part <code>@Component</code> is a decorator which gives you information about the html tags used and the style sheet used. As you can see that we are trying to use a css file called <code>hello-world.css</code> for this stylesheet, let&#8217;s first create this file inside the same <code>hello-world</code> folder.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-css" data-lang="css">hello-world h1 {
    color: red;
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now, in order to load this component on to the page, we need to use it first. Let&#8217;s add the component <code>&lt;hello-world&gt;</code> in the <code>&lt;app-home&gt;</code> component.</p>
</div>
<div class="paragraph">
<p>In file <code>app-home.tsx</code> inside the ` my-pwa/src/components/app-home/` folder we will simply add the <code>hello-world</code> component.</p>
</div>
<div class="paragraph">
<p>Before:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-js" data-lang="js"> &lt;p&gt;
   Welcome to the Stencil App Starter.
   You can use this starter to build entire apps all with
   web components using Stencil!
   Check out our docs on
   &lt;a href='https://stenciljs.com'&gt;stenciljs.com&lt;/a&gt;
   to get started.
 &lt;/p&gt;

 &lt;stencil-route-link url='/profile/stencil'&gt;
   &lt;button&gt;
     Profile page</code></pre>
</div>
</div>
<div class="paragraph">
<p>After:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-js" data-lang="js"> &lt;p&gt;
   Welcome to the Stencil App Starter.
   You can use this starter to build entire apps all with
   web components using Stencil!
   Check out our docs on
   &lt;a href='https://stenciljs.com'&gt;stenciljs.com&lt;/a&gt;
   to get started.
 &lt;/p&gt;

 &lt;hello-world&gt;&lt;/hello-world&gt;

 &lt;stencil-route-link url='/profile/stencil'&gt;
   &lt;button&gt;
     Profile page</code></pre>
</div>
</div>
<div class="paragraph">
<p>Once this is done, we can now use the npm command to start the server and launch the page on to the browser with our hello world component.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-shell" data-lang="shell">npm run dev</code></pre>
</div>
</div>
<div class="paragraph">
<p>The output looks like this</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/stencil-js-hello-world.JPG" alt="book">
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_upcoming_in_part_02">Upcoming in Part 02</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This blog just gives you a basic introduction to Stencil.js and how we can use the startup template to have our own <code>hello-world</code> webcomponent in a PWA. In the next blog in this series, we will be looking at <a href="https://dribbble.com/shots/2359374-Mail-client-app">Mail Client App by Jakub Antalik</a> (refer screenshot below) and how we can create it in our demo.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/mail-client-app-Jakub-Antalik.png" alt="book">
</div>
</div>
<div class="paragraph">
<p>If you want to take a look at the source code for this <code>my-pwa</code> folder, feel free to refer this link <a href="https://github.com/prateekjadhwani/my-pwa-01" class="bare">https://github.com/prateekjadhwani/my-pwa-01</a> .</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2018/03/03/Building-Web-Component-based-Progressive-Web-App-in-Stencil-JS-Part-01.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2018/03/03/Building-Web-Component-based-Progressive-Web-App-in-Stencil-JS-Part-01.html</guid><category><![CDATA[webcomponents]]></category><category><![CDATA[stencil]]></category><category><![CDATA[stenciljs]]></category><category><![CDATA[helloworld]]></category><category><![CDATA[pwa]]></category><category><![CDATA[webapp]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Sat, 03 Mar 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[Universal Site is the new Accessible Site]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>When we talk about an accessible website, the first thing that comes to our mind is a user who is unable to see the screen. And I am sure 99% of the people reading this agree with me. This is the same case with an accessible area. The first thing that comes to the mind when someone talks about an accessible area is wheelchair access. But this is not the case all the time. It is simply our assumption that an accessible site is limited to just its availability on screen readers and an accessible area is limited to just wheelchair access.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s talk about the title of this blog, <em>Universal Site is the new Accessible Site</em>. A universal site, is a website that can be accessed by everyone. Not just people with a mouse or people with a screen readers, instead, it can be accessed via any hardware, any software and it can be accessed by any user, with or without disabilities, with ease.</p>
</div>
<div class="paragraph">
<p>The example of wheelchair access: If an area is accessible, it simply does not mean that it can only be accessed by wheelchairs. It means that it can also be accessed by baby strollers, or catering companies or movers to move their stuff. When we think of an accessible area that can be used my everyone, it becomes a universal area.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_welcome_to_the_book_accessibility_for_everyone">Welcome to the book "Accessibility for Everyone"</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I started reading the book "Accessibility for Everyone" by "Laura Kalbag" few days ago just for fun. If you are one of those people who are trying to understand various aspects of accessibility in a website, this is your to go book. It covers all the aspects of disabilities, hardware used, how various people perceive written text, and even animations.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/accessibility_for_everyone.JPG" alt="book">
</div>
</div>
<div class="paragraph">
<p>It covers how developers and designers are misusing html tags to make things look good by giving up on accessibility features. It also talks about content break down to logical sections for better readability, management of font styles and colors, and much more. These all lessons are taken by comparing live sites of various companies, and how they perceive the term accessibility for their users.</p>
</div>
<div class="paragraph">
<p>It also covers a set of solutions that are in place to take advantages of tags already available in the HTML5 specification sheet. And it discusses what a user is expecting in what scenarios and what steps can be taken to make the site more accessible in them.</p>
</div>
<div class="sect2">
<h3 id="_what_it_is_not">What it is not!</h3>
<div class="paragraph">
<p>It is not a book that can be used for learning how to code accessible web site using HTML. It discusses a bunch of good practices, but you cannot refer them for coding examples. I personally would rather go to MDN (Mozilla Developer Network) and look at the ARIA (Accessible Rich Internet Applications) example there.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This is not a book review by any means. I was trying to look into accessibility and I found this book pretty helpful. And I decided to share the book with other people so that they can use it as well.</p>
</div>
<div class="paragraph">
<p>I can already see a lot of improvements in the way I see sites. And I am making sure that I put accessibility before anything else when I write my code.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="paragraph">
<p>[1] Accessibility for Everyone <a href="https://abookapart.com/products/accessibility-for-everyone" class="bare">https://abookapart.com/products/accessibility-for-everyone</a></p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2018/03/01/Universal-Site-is-the-new-Accessible-Site.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2018/03/01/Universal-Site-is-the-new-Accessible-Site.html</guid><category><![CDATA[accessibility]]></category><category><![CDATA[book]]></category><category><![CDATA[universal]]></category><category><![CDATA[site]]></category><category><![CDATA[website]]></category><category><![CDATA[screen reader]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Thu, 01 Mar 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[<dialog> element: Modals for the future.]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>I recently came across a new spec with the name <code>&lt;dialog&gt;</code> element [1]. And decided to see if it works properly. This is what it looks like,</p>
</div>
<p data-height="198" data-theme-id="3991" data-slug-hash="MQEbKW" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="<dialog> element 001" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/MQEbKW/">&lt;dialog&rt; element 001</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>As you can see, it works right out of box, without any JavaScript or CSS. And&#8230;&#8203;. now we can finally stop worrying performance drops and extra events that stay on the site till the end of eternity.</p>
</div>
<div class="paragraph">
<p>So, what&#8217;s the catch? It is available only in chrome right now. It does not work on firefox nightly [3]. Which makes it harder to use in a site at the time of writing of this article. But if you still want to see it working, feel free to look at the demo in chrome.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="__backdrop_pseudo_class">::backdrop pseudo class</h3>
<div class="paragraph">
<p>As you can see it on the above demo, the background is semi opaque white colored. This can be customized with the help of <code>::backdrop</code> pseudo class. For example:</p>
</div>
<p data-height="300" data-theme-id="3991" data-slug-hash="NyabXZ" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="<dialog> element 002" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/NyabXZ/">&lt;dialog&rt; element 002</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
</div>
<div class="sect2">
<h3 id="_auto_focus">Auto focus</h3>
<div class="paragraph">
<p>The <code>&lt;dialog&gt;</code> element also makes the first focusable element inside it auto focussed by default. See the example below.</p>
</div>
<p data-height="332" data-theme-id="3991" data-slug-hash="jZGVKE" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="<dialog> element 003" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/jZGVKE/">&lt;dialog&rt; element 003</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The <code>&lt;dialog&gt;</code> element is one of those element that I am really excited about since css grid came out. I can see its potential in the web development world. But for now, we will have to code using the old methodologies for modals, since this element is not implemented in all the evergreen browsers yet.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="paragraph">
<p>[1] <a href="https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element" class="bare">https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element</a></p>
</div>
<div class="paragraph">
<p>[2] <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog" class="bare">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog</a></p>
</div>
<div class="paragraph">
<p>[3] <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement#Browser_compatibility" class="bare">https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement#Browser_compatibility</a></p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2018/02/14/dialog-element-Modals-for-the-future.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2018/02/14/dialog-element-Modals-for-the-future.html</guid><category><![CDATA[dialog]]></category><category><![CDATA[CSS3]]></category><category><![CDATA[focus]]></category><category><![CDATA[pseudo class]]></category><category><![CDATA[demo]]></category><category><![CDATA[backdrop]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 14 Feb 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[Accessibility in a modal]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>It is said that you learn a new thing every day, and so I did. Accessibility has been in the market for a very long time and even then, I did not have a chance to implement it in a modal.</p>
</div>
<div class="paragraph">
<p>But then few days ago, a new user story happened. <em>Make sure that the modal that shows blah blah blah information about blah blah blah thing needs to be accessible and should be read by blah blah blah screen reader.</em></p>
</div>
<div class="paragraph">
<p>Without the accessibility features, this is what the modal looks like. Click on the button to open the modal. You should be able to notice that if you keep on pressing the <code>tab</code> key, and it will still focus the buttons behind the modal. This case is the same if you are reading it with the help of a screen reader.</p>
</div>
<p data-height="609" data-theme-id="3991" data-slug-hash="VQPxYx" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="Modal" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/VQPxYx/">Modal</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>In order to make this accessible, we will need to follow a checklist.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_1_tell_the_accessibilty_devices_that_what_you_are_displaying_is_a_dialog">1. Tell the accessibilty devices that what you are displaying is a dialog.</h3>
<div class="paragraph">
<p>This is done with the help of <code>role="dialog"</code>. For Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;div class="modal-container" role="dialog" aria-label="Modal for Lorem Ipsum"&gt;
  ...
  ...
&lt;/div&gt;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_2_focus_the_modal_when_it_opens">2. Focus the modal when it opens.</h3>
<div class="paragraph">
<p>The modal html might be present at any section of the DOM. You do not want your users to keep on tabbing through the sections right after the button or link that opens up the modal. This is where you need to shift focus to the modal; because the screen reader needs to read the text inside the modal.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">function openModal() {
    ...
    ...
    ...
    document.querySelector(".modal").focus();
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_3_make_close_button_keyboard_accessible">3. Make close button keyboard accessible</h3>
<div class="paragraph">
<p>Your button should get triggered via Enter / Return key as well because you do need a way for the people reading on screen readers to close it.</p>
</div>
<div class="paragraph">
<p>If you code is not using the &lt;button&gt; tag and is instead using &lt;span&gt; tag or some other tags, you will need to make sure that it can be focussed with the help of tab keys. You can do that by adding <code>aria-label</code> and <code>tabindex</code> attributes. For Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-html" data-lang="html">&lt;span class="modal-close" aria-label="close" tabindex="0"&gt;X&lt;/span&gt;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_4_make_sure_that_esc_key_closes_the_modal">4. Make sure that Esc key closes the modal.</h3>
<div class="paragraph">
<p>This is really handy when a user is going through the modal and decides to close the modal anytime without going through all the contents.</p>
</div>
<div class="paragraph">
<p>Add the event listener for key presses.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('.modal-container')
    .addEventListener('keydown', handleESCKeyEventListener);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then this handleESCKeyEventListener function would look something like this.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const isOpen = document.querySelector('.modal-container')
                  .classList.contains('-open');
if (e.keyCode === 27 &amp;&amp; isOpen) {
    closeModal();
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Also, dont forget to remove this keydown event listener when you close the modal.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">function closeModal() {
    ...
    ...
    document.querySelector('.modal-container')
        .removeEventListener('keydown', handleESCKeyEventListener);
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_5_lock_the_focus_to_just_the_modal">5. Lock the focus to just the modal</h3>
<div class="paragraph">
<p>When the user is inside the modal, and if he keeps on pressing tab key, the focus will eventually go out of the modal container. In order to stop the user focus to go out, we are going to use the <code>focusout</code> event handler.</p>
</div>
<div class="paragraph">
<p>First we need to bind the focus out event to the modal container</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('.modal-container')
    .addEventListener('focusout', handleFocusOut);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then we need to make sure that the <code>relatedTarget</code> is outsite of the modal container to make it focus the modal again.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">function handleFocusOut(e) {
  const modalDOM = document.querySelector('.modal-container');
  const isOpen = modalDOM.classList.contains('-open');
  if(isOpen &amp;&amp; !modalDOM.contains(e.relatedTarget)) {
    e.stopPropagation();
    document.querySelector(".modal").focus();
  }
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_6_focus_back_to_the_next_element">6. Focus back to the next element</h3>
<div class="paragraph">
<p>In order to move the focus to the element which was selected before opening the modal, we will first need to get the last focussed element.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">function openModal() {
    lastFocussedElement = document.activeElement;
    ...
    ...
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>And now inside the close method, we can set focus back to this <code>lastFocussedElement</code> element.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">function closeModal() {
    ...
    ...
    lastFocussedElement.focus();
}</code></pre>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_final_product">Final Product</h2>
<div class="sectionbody">
<div class="paragraph">
<p>After implementing all these points, the final demo looks something like this. Try using the tab keys or the screen reader.</p>
</div>
<p data-height="549" data-theme-id="3991" data-slug-hash="GQrdpw" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="Modal with Accessibility" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/GQrdpw/">Modal with Accessibility</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="paragraph">
<p>[1] <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_dialog_role" class="bare">https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_dialog_role</a></p>
</div>
<div class="paragraph">
<p>[2] <a href="https://www.smashingmagazine.com/2014/09/making-modal-windows-better-for-everyone/" class="bare">https://www.smashingmagazine.com/2014/09/making-modal-windows-better-for-everyone/</a></p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2018/02/08/Accessibility-in-a-modal.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2018/02/08/Accessibility-in-a-modal.html</guid><category><![CDATA[accessibility]]></category><category><![CDATA[modal]]></category><category><![CDATA[html5]]></category><category><![CDATA[css3]]></category><category><![CDATA[javascript]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Thu, 08 Feb 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[:focus-within pseudo class]]></title><description><![CDATA[<div class="paragraph">
<p>I guess I will start with a piece of code</p>
</div>
<p data-height="279" data-theme-id="3991" data-slug-hash="eEeZjj" data-default-tab="js,result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="focusin and focusout demo in jquery" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/eEeZjj/">focusin and focusout demo in jquery</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>Here you will see in the JavaScript that you need to target the parent element of a particular element. Well, if you love writing logic in JavaScript, this might be a good solution. But thankfully, there is a new spec that lets you do the same using css. Yup, pure css. It is called the <code>:focus-within</code> pseudo class.</p>
</div>
<div class="paragraph">
<p>Here is the demo of this pseudo class.</p>
</div>
<p data-height="300" data-theme-id="3991" data-slug-hash="wqPGqz" data-default-tab="css,result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title=":focus-within demo" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/wqPGqz/">:focus-within demo</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>As you can see here, there is no JavaScript used in the demo. Instead the pseudo class <code>:focus-within</code> is used on the parent class to add the property.</p>
</div>
<div class="paragraph">
<p>This is relatively a new spec that exists on Chrome, Chrome Canary and Firefox Nightly at the time of writing. If you would like to read more about the spec, feel free to refer this <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within">link</a>.</p>
</div>]]></description><link>https://prateekjadhwani.github.io/2017/08/15/focus-within-pseudo-class.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/08/15/focus-within-pseudo-class.html</guid><category><![CDATA[CSS3]]></category><category><![CDATA[focus]]></category><category><![CDATA[focus-within]]></category><category><![CDATA[pseudo class]]></category><category><![CDATA[demo]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Tue, 15 Aug 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Network Information API]]></title><description><![CDATA[<div class="paragraph">
<p>With technology development in the past few decades, web apps have improved from running simply on a desktop computer to a mobile phone to an IOT device. With so many different clients, using so many different types of network, there will always be a time when a web app will need information i.e. the type of network being used or the downlink speed provided by the network provider. With this thing in mind, web browsers are now shipping with this new specification called the <a href="http://wicg.github.io/netinfo/">Network Information API</a>.</p>
</div>
<div class="paragraph">
<p>At the time of writing, only chrome for Android supported this spec. So, if you are on chrome for Android, you should be able to see the demo working properly. But in case you are unable to see the proper data due to an incomplete spec implementation, here is what you should be able to see.</p>
</div>
<div class="paragraph">
<p>Querying for <code>navigator.connection.type</code> would return one of these values</p>
</div>
<table class="tableblock frame-all grid-all" style="width: 35%;">
<colgroup>
<col style="width: 100%;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">bluetooth</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">cellular</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ethernet</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">mixed</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">other</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">unknown</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">wifi</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">wimax</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>This is basically the type of networks that a user can be on.</p>
</div>
<div class="paragraph">
<p>Querying for <code>navigator.connection.effectiveType</code> would return one of these values. And their meanings.</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Effective Type</th>
<th class="tableblock halign-left valign-top">Speed</th>
<th class="tableblock halign-left valign-top">Type of data downloadable</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2g</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Very Slow</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only Text and Small Images</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3g</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Good Speed</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Can download high quality images and SD Videos</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">4g</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">High Speed</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Can download HD Video and large files</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">slow-2g</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Very Very Slow</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Only Text</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><code>effectiveType</code> can be used to know the user network speed.</p>
</div>
<div class="paragraph">
<p>All these objects in the <code>navigator.connection</code> API might help decide web apps with the type of resources that can be downloaded in order to provide user with a better user experience. For example, a web app might be able to decide whether to serve the user with a low quality video or a high quality video, or if a news article can be displayed in terms of text or with images.</p>
</div>
<div class="paragraph">
<p>So, without any further delay, here is the demo.</p>
</div>
<p data-height="300" data-theme-id="3991" data-slug-hash="gxrwNb" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="Network Information API" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/gxrwNb/">Network Information API</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>]]></description><link>https://prateekjadhwani.github.io/2017/08/02/Network-Information-A-P-I.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/08/02/Network-Information-A-P-I.html</guid><category><![CDATA[network]]></category><category><![CDATA[network information api]]></category><category><![CDATA[API]]></category><category><![CDATA[specification]]></category><category><![CDATA[spec]]></category><category><![CDATA[demo]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 02 Aug 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Storage API: Persistent Large Storage for the Web]]></title><description><![CDATA[<div class="sect1">
<h2 id="_tl_dr">TL;DR</h2>
<div class="sectionbody">
<div class="sect4">
<h5 id="_early_1990s_internet">Early 1990s -Internet</h5>
<div class="paragraph">
<p>User downloads the site and views it on his screen. Reload the page, and resources get downloaded again</p>
</div>
</div>
<div class="sect4">
<h5 id="_early_2005_app_cache">Early 2005 - App cache</h5>
<div class="paragraph">
<p>User downloads the site, and saves the resources to be used again and again, until the browser looses its cache. Painful process. Needed hit and trial to make it work.</p>
</div>
</div>
<div class="sect4">
<h5 id="_2010_local_storage">2010 - Local Storage</h5>
<div class="paragraph">
<p>User gets to save important information in text format over long periods of time. Very easy to use.</p>
</div>
</div>
<div class="sect4">
<h5 id="_2016_service_workers">2016 - Service Workers</h5>
<div class="paragraph">
<p>User gets to save other types of resources and can control the response manually, including the type of file served. But can only save upto a max of 2GB and resources gets cleared if memory is less. Easy to implement.</p>
</div>
</div>
<div class="sect4">
<h5 id="_2017_storage_api">2017 - Storage API</h5>
<div class="paragraph">
<p>User gets to save resources on hard disk after querying for available space without loosing them even if the space is less. Best improvement to storage ever!!</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>So what is Storage API, and why do we need it. Its simple. With improvement in time, the resources consumed on the web have changed drastically, both in type and size. And looses these resources when the cache clears makes user experience pretty bad. Storage API is the next step in the improvement of storing website resources on a user&#8217;s computer.</p>
</div>
<div class="paragraph">
<p>The Storage API lets the website developer query for the available size on the user&#8217;s computer. And if it has space, with user&#8217;s permission, it can store data in a persistent form, like on a hard drive.</p>
</div>
<div class="paragraph">
<p>The most common scenarios where this specification can be used is for like games (to store game resources) , or a song streaming site( to store songs), or an image editor site (to store layer information). Just imagine, storing these things on a user&#8217;s computer, and user being able to use them while being offline, say on a flight or with choppy network would make the user experience even better.</p>
</div>
<div class="paragraph">
<p>Now that we know what Storage API is and what it can do, lets move on to how to use it and demo. At the time of writing, the APIs worked only on firefox nightly</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_demo">Demo</h2>
<div class="sectionbody">
<p data-height="544" data-theme-id="3991" data-slug-hash="qXOBKo" data-default-tab="js,result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="qXOBKo" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/qXOBKo/">qXOBKo</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>When you click on the "Check if navigator.storage API&#8217;s can run on your browser" button, it checks whether the APIs can run on your system. Refer <code>checkAPI()</code> function.</p>
</div>
<div class="paragraph">
<p>When you click on the "Estimate Available Space" button, it queries for the space available with the help of <code>navigator.storage.estimate()</code> API. Refer <code>showEstimate()</code> function.</p>
</div>
<div class="paragraph">
<p>When you click on the "Query For User Permission" button, it checks for <code>persistent-storage</code> permission for that particular origin with the help of <code>navigator.permissions.query</code> API and the on getting a <code>status</code> of either <code>granted</code> or <code>prompt</code> shows the dialog for Storage API. Refer <code>queryForPermission()</code> function.</p>
</div>
<div class="paragraph">
<p>When you click on the "Revoke User Permission" button, it revokes the permission granted by clicking in the previous button. In order to make this work, you will need to set the <code>dom.permissions.revoke.enable</code> in <code>about:config</code> URL and toggle the value to <code>true</code>. Once you have revoked the property, you will see the dialog again if you click on the previous button.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Storage API shows the true growth of the web. In all, it holds a really good future; especially for PWAs; but it depends on project to project how it can be leveraged upto its full potential.</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2017/07/28/Storage-A-P-I-Persistent-Large-Storage-for-the-Web.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/07/28/Storage-A-P-I-Persistent-Large-Storage-for-the-Web.html</guid><category><![CDATA[StorageAPI]]></category><category><![CDATA[API]]></category><category><![CDATA[specification]]></category><category><![CDATA[javascript]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Fri, 28 Jul 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[CSS Rhythmic Sizing]]></title><description><![CDATA[<div class="paragraph">
<p>There are always times when you are building a page with multiple columns and the content is a collection of headings and images just the same way as shown below or its varieties.</p>
</div>
<p data-height="300" data-theme-id="3991" data-slug-hash="WOPmgQ" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="line-step-height demo" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/WOPmgQ/">line-step-height demo</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>If you see at the bottom of the page, the text is a little bit displeasing to look at. If you are someone who like to see typography in a perfect way, that starts at the same line, and ends at the same height.</p>
</div>
<div class="paragraph">
<p>So, the question is what can be done make it look more pleasing? Well, there is a new css property for that. Its called the <code>line-height-step</code>. All you need to do is add <code>line-height-step</code> property to you container css with height more than that of the line height, and thats it</p>
</div>
<div class="paragraph">
<p>This is what it looks like with <code>line-height-step</code> set to <code>18pt</code>. Notice the end of the article. They all end on the same line.</p>
</div>
<p data-height="300" data-theme-id="3991" data-slug-hash="zzebeP" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="line-step-height demo2" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/zzebeP/">line-step-height demo2</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>If you are more interesting in this css property, feel free to read about it in <a href="https://drafts.csswg.org/css-rhythm/">this editor&#8217;s draft</a>.</p>
</div>]]></description><link>https://prateekjadhwani.github.io/2017/07/13/C-S-S-Rhythmic-Sizing.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/07/13/C-S-S-Rhythmic-Sizing.html</guid><category><![CDATA[CSS3]]></category><category><![CDATA[line-height-step]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Thu, 13 Jul 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Payment Request API]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>So I recently came across a browser specification called <a href="https://www.chromestatus.com/feature/5639348045217792">Payment Request API</a>. Its rare to come across a totally new api while browsing the internet, so I decided to look into it. Here is the <a href="https://w3c.github.io/browser-payment-api/">link to the Editor&#8217;s Draft</a> for this specification in case it has piqued your interest.</p>
</div>
<div class="paragraph">
<p>Reading the Editor&#8217;s draft is confusing and tough. I am just glad that  the chrome dev team <a href="https://developers.google.com/web/fundamentals/discovery-and-monetization/payment-request/">wrote a really good documentation</a> on this technology and how to use it.</p>
</div>
<div class="paragraph">
<p>At the time of writing of this article, chrome 60 is due release, but the PaymentRequest API is supported on chrome canary. So the demo has been tested on chrome canary and no other browser. So without any further delay, here is the demo.</p>
</div>
<p data-height="297" data-theme-id="3991" data-slug-hash="QgVxMN" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="Payment Request API DEMO" class="codepen">See the Pen <a href="https://codepen.io/prateekjadhwani/pen/QgVxMN/">Payment Request API DEMO</a> by Prateek Jadhwani (<a href="https://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
</div>
</div>
<div class="sect1">
<h2 id="_explanation">Explanation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Coming back to the explanation of what I have done in the demo, if you are familiar wiht online payment, then it will be really easy for you to understand. Every checkout process requires three things, type of payment and payment information, the total amount (with tax, discount, shipping etc) and optional information like shipping, phone number, etc. And the good thing is, the Payment request API requires these three things in the form of three different parameters as objects.</p>
</div>
<div class="sect3">
<h4 id="_payment_information">Payment information</h4>
<div class="paragraph">
<p>This is the way you can ask the payment Request API to support any payment card (credit or debit)</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const supportedPaymentMethods = [
  {
    supportedMethods: ['basic-card']
  }
];</code></pre>
</div>
</div>
<div class="paragraph">
<p>And this is the way you can limit the payment method to just visa and mastercard</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const supportedPaymentMethodsTwo = [
  {
    supportedMethods: ['basic-card'],
    data: {
      supportedNetworks: ['visa', 'mastercard'],
      supportedTypes: ['credit'],
    },
  }
];</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can also add another type of payment systems like paypal or android pay. This <a href="https://developers.google.com/web/fundamentals/discovery-and-monetization/payment-request/android-pay">link</a> is helpful in configuring, but the process is same</p>
</div>
</div>
<div class="sect3">
<h4 id="_total_amount_information">Total Amount Information</h4>
<div class="paragraph">
<p>You can provide the amount information in the following way</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const paymentDetails = {
  total: {
    label: 'Total',
    amount: {
      currency: 'USD',
      value: 0
    }
  }
};</code></pre>
</div>
</div>
<div class="paragraph">
<p>And you can add more information like shipping, tax etc in the following way</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const paymentDetails = {
  total: {
    label: 'Total',
    amount: {
      currency: 'USD',
      value: 0
    }
  },
  displayItems: [
    {
      label: 'Shipping Cost',
      amount: {
        currency: 'USD',
        value: 5.75
      }
    },
    {
      label: 'Tax',
      amount: {
        currency: 'USD',
        value: 0.75
      }
    },
  ]
};</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_extra_options">Extra Options</h4>
<div class="paragraph">
<p>You can ask for more options from the user here in this object. You can either leave it blank or you can add the things that you require for the payment.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const options = {};</code></pre>
</div>
</div>
<div class="paragraph">
<p>Or let&#8217;s say you want shipping information, you can go with this.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const optionsThree = {
  requestShipping: true
};</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getting_the_paymentrequest_object">Getting the PaymentRequest Object</h3>
<div class="paragraph">
<p>Once you are done creating the object for payment information, amount and options, you can create a PaymentRequest Object by passing them in the following way</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">const request = new PaymentRequest(
  supportedPaymentMethods,
  paymentDetails,
  options
);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Thats it!!!</p>
</div>
<div class="paragraph">
<p>Now lets say you have a Pay button and when the user clicks on it, it should let the users enter the payment information. So you can add an event listener on that button that would execute the show method of PaymentRequest API</p>
</div>
<div class="paragraph">
<p>This is how it can be done.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('.pay1').addEventListener('click', () =&gt; {
  request.show();  // this is a promise
});</code></pre>
</div>
</div>
<div class="paragraph">
<p>Just remember that <code>show()</code> method returns a promise so it needs to be handled correctly in the following way</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('.pay1').addEventListener('click', () =&gt; {
  request1.show()
  .then((response) =&gt; {
    // do stuff
  })
  .catch((e) =&gt; {
    console.log(e);
  });
});</code></pre>
</div>
</div>
<div class="paragraph">
<p>So, now, clicking on the button will show up the pay dialog box where user can enter the details as shown in the screenshot below. After entering correct information, the flow goes into the <code>then()</code> block and when anything goes wrong, or if the user clicks on the cancel button, it goes to the catch block.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/PaymentRequest.PNG" alt="screenshot">
</div>
</div>
<div class="paragraph">
<p>To close the payment dialog you can use the <code>complete()</code> method as shown in the then() block</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">document.querySelector('.pay1').addEventListener('click', () =&gt; {
  request1.show()
  .then((response) =&gt; {
    // do backend stuff
    console.log(response);

    //close the payment ui
    return response.complete()
  })
  .catch((e) =&gt; {
    console.log(e);
  });
});</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This is a fairly new technology / specification and is continuously improving. But it takes care of a lot of things by simply moving everything in the browser layer. And in terms of code, it is fairly easy to implement. But feel free to look through the demo and source code if yo have any questions and/or concerns.</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2017/07/07/Payment-Request-A-P-I.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/07/07/Payment-Request-A-P-I.html</guid><category><![CDATA[PaymentRequest]]></category><category><![CDATA[PaymentRequestAPI]]></category><category><![CDATA[spec]]></category><category><![CDATA[specification]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Fri, 07 Jul 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Building the web with position: sticky;]]></title><description><![CDATA[<div class="paragraph">
<p>Last week chrome announced that it is now supporting position: sticky. To tell you the truth, I never knew about this spec. Didn&#8217;t even know that it has been in firefox for a long time.</p>
</div>
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>Good job Firefox!!</p>
</div>
</blockquote>
</div>
<div class="paragraph">
<p>But when I heard the word sticky, it reminded me of one thing. Sticky Nav!!. I have seen it being used at a lot of places. And I have myself used a library called Waypoints to achieve the same. So this was a good use case for its application.</p>
</div>
<div class="paragraph">
<p>So, how to use it. Its pretty simple!! First you need to know which DOM needs to be sticky, then you need to decide at what location from the top it needs to be sticky. In my use case it was the navbar, which needs to be sticky when it reaches the top. So I added the following css to it.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-css" data-lang="css">nav {
  position: sticky;
  top: 0;
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>And that is it. Thats what it required to convert any DOM to sticky. No JavaScript, no event bindings, nothing!! Just pure css fun!!</p>
</div>
<p data-height="300" data-theme-id="3991" data-slug-hash="ZLxOdp" data-default-tab="html,result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="position: sticky" data-preview="true" class="codepen">See the Pen <a href="http://codepen.io/prateekjadhwani/pen/ZLxOdp/">position: sticky</a> by Prateek Jadhwani (<a href="http://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="http://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
<div class="paragraph">
<p>There is one more example that I would like to share. This is the demo in a parallax effect is achieved with the help of position: sticky</p>
</div>
<p data-height="300" data-theme-id="3991" data-slug-hash="vgWyRR" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" data-pen-title="Scroll Effect" data-preview="true" class="codepen">See the Pen <a href="http://codepen.io/prateekjadhwani/pen/vgWyRR/">Scroll Effect</a> by Prateek Jadhwani (<a href="http://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="http://codepen.io">CodePen</a>.</p>
<script async src="https://production-assets.codepen.io/assets/embed/ei.js"></script>]]></description><link>https://prateekjadhwani.github.io/2017/02/01/Building-the-web-with-position-sticky.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/02/01/Building-the-web-with-position-sticky.html</guid><category><![CDATA[css3]]></category><category><![CDATA[position sticky]]></category><category><![CDATA[sticky]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 01 Feb 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Pancake-CMS Improvements - Week 3]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This is the third continuous week that I am writing the blog on my side project "<a href="https://github.com/Pancake-CMS/developer-console">Pancake-CMS</a>". The reason that I decided to write weekly blogs is to make myself work on this project on regular basis. Not only it makes me wanna fight my laziness to work to the project, but it also gets my thinking hat on, as in to prepare what kind of work I have to do.</p>
</div>
<div class="paragraph">
<p>So yeah, here is the change-log for week 3 on Pancake-CMS</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_preview_mode_to_content_editor">Preview Mode to &lt;content-editor&gt;</h4>
<div class="paragraph">
<p>With this feature, the users who are creating and editing the content, say like adding translations to pages, will be able to see their changes in the preview mode; as in how the page would look like in production.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/preview1.png" alt="template">
</div>
</div>
<div class="paragraph">
<p>After the preview button is clicked, this is what it looks like.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/preview2.png" alt="template">
</div>
</div>
</div>
<div class="sect3">
<h4 id="_send_content_for_approvals">Send content for approvals</h4>
<div class="paragraph">
<p>Once a user is done making changes to the page, say like, done with translating the page, he/she can send the page for approvals by clicking on the save button. Having a second pair of eyes to content is always helpful, thus, this feature would help alot in terms of content workflow.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/preview1.png" alt="template">
</div>
</div>
</div>
<div class="sect3">
<h4 id="_addition_of_approvals_page">Addition of &lt;approvals-page&gt;</h4>
<div class="paragraph">
<p>This page acts more like a moderator&#8217;s page where the moderator can approve components or page translations. I am still playing around with the idea, like adding comments or user rights management etc. Lets see how it goes.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/approvals-page1.png" alt="template">
</div>
</div>
</div>
<div class="sect3">
<h4 id="__review_page_element">&lt;review-page&gt; element</h4>
<div class="paragraph">
<p>This element lets a moderator see a translated page with content changes. Here the moderator may approve or decline the content changes. Approving the translations move the node data to pages node so that the &lt;page-editor&gt; element is able to see the new content changes.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/review-page1.png" alt="template">
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Well this weekend was a busy one. With "Gravity Rush 2" coming out,and me being sick for two straight days, I wasn&#8217;t able to work alot on the project. But this week&#8217;s tasks were mostly concentrated on content-workflows and bug fixes. With this week&#8217;s work, the full cycle of a Content Management System is complete. Now, a user can</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>create individual components</strong>,</p>
</li>
<li>
<p><strong>build a template</strong> out of those components,</p>
</li>
<li>
<p><strong>create pages</strong> out of those templates,</p>
</li>
<li>
<p><strong>update translations and content</strong> of those pages,</p>
</li>
<li>
<p><strong>send them for approvals</strong> and</p>
</li>
<li>
<p><strong>get them approved</strong>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>There are tonnes of improvements that can be made to the project but I still need to work on some small and basic functionalities before I can move on to those. But if you are interested and would like to see how it all works, feels free to fork the project <a href="https://github.com/Pancake-CMS/developer-console">here</a>.</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2017/01/24/Pancake-C-M-S-Improvements-Week-3.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/01/24/Pancake-C-M-S-Improvements-Week-3.html</guid><category><![CDATA[cms]]></category><category><![CDATA[polymer]]></category><category><![CDATA[webcomponents]]></category><category><![CDATA[components]]></category><category><![CDATA[panckake-cms]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Tue, 24 Jan 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Pancake-CMS Improvements - Week 2]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Last week I posted a <a href="https://prateekjadhwani.github.io/2017/01/10/Pancake-C-M-S-A-new-approach-to-C-M-S-using-web-components-and-server-less-architecture.html">blog about my current side project - Pancake CMS</a>. And because of the long weekend, I was able to finish off substantial amount of work on the project. The updates involved creating a bunch of new elements and some bug fixes. Here are the details.</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_adding_template_manager_and_page_manager">Adding &lt;template-manager&gt; and &lt;page-manager&gt;</h4>
<div class="paragraph">
<p>What these elements do is that thay provide a list of <strong>templates</strong> and <strong>pages</strong> that have been already created by the user. Then, the authors or content creators can fork a template or a page into a new page using the options provided in this list.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/templates.png" alt="template">
</div>
</div>
<div class="paragraph">
<p>Also, if there are no templates available, the user can create a new template by clicking on the <strong>plus icon</strong>. A bunch of other routing relating operations were added as well to support this feature.</p>
</div>
</div>
<div class="sect3">
<h4 id="_adding_support_for_email_login_a_k_a_authentication_with_email_element">Adding support for email login a.k.a &lt;authentication-with-email&gt; element</h4>
<div class="paragraph">
<p>Even though this is an open source project, and I was anticipating most of the developers to be using either github or google for logging, it seems, some enterprises or companies might need email login for their project. So, The project now supports login via email and password. The enterprises will need to set up users in firebase for this.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/login.png" alt="login">
</div>
</div>
</div>
<div class="sect3">
<h4 id="__page_editor_element">&lt;page-editor&gt; element</h4>
<div class="paragraph">
<p>Previously, I was stuck at an architecture related problem and was trying to figure out the tradeoff with 3 different approaches. This weekend I finally applied a solution and the &lt;page-editor&gt; finally shows up a page in which user can edit content. I am using <strong>tinyMCE</strong> for now. I am not sure if this will be replaced by some other editor.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/page-editor.png" alt="login">
</div>
</div>
</div>
<div class="sect3">
<h4 id="_lots_of_bug_fixes">Lots of bug fixes</h4>
<div class="paragraph">
<p>As with any software, there are many bugs and they need to be fixed. So, yeah, I ended up fixing a bunch of bugs as well. Some were UI bugs which were messing up the look and feel; some were blockers which had to be fixed in order to move forward.</p>
</div>
</div>
<div class="sect3">
<h4 id="_separation_of_user_component_functionality_of_pancake_component_functionality">Separation of User Component functionality of Pancake Component functionality</h4>
<div class="paragraph">
<p>I ended up creating two behaviors which enhance the user components so that they can user properties and multi-lingual content in them. Earlier, some of this functionality was inside the Panckake&#8217;s components. Moving them out increased the performance, fixed some bugs and made it optional for inclusion by the user.</p>
</div>
</div>
<div class="sect2">
<h3 id="_conclusion">Conclusion</h3>
<div class="paragraph">
<p>In all, it was a fun weekend. I would say, the project is now 70% complete. Some of the future tasks would be as follows</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Adding content workflow, where it would follow a proper cycle of creation and approvals.</p>
</li>
<li>
<p>Adding versioning system where the content of the whole site can be stored with a proper version number.</p>
</li>
<li>
<p>Creation of a &lt;pancake-player&gt; element which will target the release version of the site and will work as a single page app with every thing minimised or in terms of polymer - vulcanised. It would work more like a release version of the site which companies could deploy on to the web servers.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>I am still not setting any deadline to the project, but for now I will keep on working it. If you are interested, feel free to look into the repo <a href="https://github.com/Pancake-CMS/developer-console">developer-console</a>.</p>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2017/01/18/Pancake-C-M-S-Improvements-Week-2.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/01/18/Pancake-C-M-S-Improvements-Week-2.html</guid><category><![CDATA[cms]]></category><category><![CDATA[polymer]]></category><category><![CDATA[webcomponents]]></category><category><![CDATA[components]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 18 Jan 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Pancake CMS - A new approach to CMS using web components and server less architecture]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Most of the content management systems that I have worked with so far, are slow AF. Not to mention that the ones that corporations use are painful for the developers. When I say painful, it means that the developer literally feels like committing suicide. The initial setup takes tonnes of time, then debugging environment issues, providing fast computers to developers etc. are some of the common problems that most companies spend a lot of time and money on. Its not worth it. Hence the <a href="https://github.com/Pancake-CMS">Pancake CMS</a>.</p>
</div>
<div class="paragraph">
<p>For the past one year I have been working on an open source project called the <a href="https://github.com/Pancake-CMS">Pancake-CMS</a>. It is a content management system which uses web-component libraries like <a href="https://www.polymer-project.org/1.0/">Polymer</a> for the UI and <a href="https://firebase.google.com/">Firebase</a> in the back-end. Just create a firebase account, add users, fork the github repo, update the auth keys and voila, you are good to go. Its that simple. The users can add other polymer elements / components dynamically, build templates that can be used to build pages and have various dialects and their associated content. Simple, right?</p>
</div>
<div class="paragraph">
<p>So, is it complete yet? No, not yet. There is a lot of work left in it. I wanted to create a "fork and play" type of software where the initial enterprise setup takes less than 10 minutes for every project/website/webapp. And 1 minute setup for developers. With that said, I have been using <a href="https://c9.io/">Cloud 9</a> as a developer environment, and it takes even less than a minute to start development. 90% of the time it takes is to install packages via <a href="https://bower.io/">Bower</a>. Thats it!!</p>
</div>
<div class="paragraph">
<p>And why am I writing an article about a project that is still under development? Its simple, I haven&#8217;t written anything on my blog for a long time. Friends have been asking me if the site is dead. The answer is, not yet, I have been busy with work, videogames, and this project. And I wanted to bring some attention to this project. Just wanted to see if there are other people who are working on a similar approach or are willing to contribute to this project.</p>
</div>
<div class="paragraph">
<p>By the way, here are some cool screenshots of the current working project. If you want you can fork the repo <a href="https://github.com/Pancake-CMS/developer-console">developer-console</a> and run it on your local, but my approach would be to run it on <a href="https://c9.io/">Cloud 9</a>. Its easy, and fast there plus you can simply delete the workspace if you dont like the project.</p>
</div>
</div>
</div>
<div class="sect5">
<h6 id="_login_screen">Login Screen</h6>
<div class="paragraph">
<p>Users can login using their Github or Google account.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290576/84cbb858-c48d-11e6-9d4f-9c26ecb0143a.png" alt="login">
</div>
</div>
</div>
<div class="sect5">
<h6 id="_components_page">Components Page</h6>
<div class="paragraph">
<p>This shows the list of developer components. Selecting them will show the readme file associated with the element / component. The green border on the component name shows that the component has been installed via bower. Orange border shows that installation is pending.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290591/6ded66f8-c48e-11e6-9a5b-0a7cc7163b70.png" alt="component page">
</div>
</div>
<div class="paragraph">
<p>A new component can be added by clicking on the plus icon and adding the component details.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290596/9f869d88-c48e-11e6-8759-99405bd8b94a.png" alt="addcomponent">
</div>
</div>
<div class="paragraph">
<p>A developer can install the project components by clicking on the download button.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290603/e39f77ce-c48e-11e6-9ac1-fbf062c32681.png" alt="downloadcomponent">
</div>
</div>
</div>
<div class="sect5">
<h6 id="_templates_page">Templates page</h6>
<div class="paragraph">
<p>New template section comes with an empty drag and drop container with all the added components.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290607/fcfd4a34-c48e-11e6-9213-c107324fd396.png" alt="newtemplate">
</div>
</div>
<div class="paragraph">
<p>This will auto save the template.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290609/3730e378-c48f-11e6-9a7d-f20c09460fa1.png" alt="savetemplate">
</div>
</div>
<div class="paragraph">
<p>Once you drag and drop the components in a template, this is what it looks like. Components can be copied/modified by a toolbar at the top right corner of every component.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290612/689dd29a-c48f-11e6-8154-ab66bbeca408.png" alt="draganddroptemplate">
</div>
</div>
<div class="paragraph">
<p>It also uses css grid for further layout enhancement</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290614/7dd238c2-c48f-11e6-8e33-1883613ca02a.png" alt="layouttemplate">
</div>
</div>
<div class="paragraph">
<p>And css-grid is awesome!!!</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290618/b39ee450-c48f-11e6-9d27-234ac1d45fe1.png" alt="layout2template">
</div>
</div>
</div>
<div class="sect5">
<h6 id="_localization_page_under_development">Localization Page (under development)</h6>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://cloud.githubusercontent.com/assets/2219900/21290623/d864ab58-c48f-11e6-8627-3f16a68666d0.png" alt="localization">
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2017/01/10/Pancake-C-M-S-A-new-approach-to-C-M-S-using-web-components-and-server-less-architecture.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2017/01/10/Pancake-C-M-S-A-new-approach-to-C-M-S-using-web-components-and-server-less-architecture.html</guid><category><![CDATA[cms]]></category><category><![CDATA[polymer]]></category><category><![CDATA[webcomponents]]></category><category><![CDATA[components]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Tue, 10 Jan 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Second release of #svg2css and Using it to build a Donkey Kong stage]]></title><description><![CDATA[<div class="sect1">
<h2 id="_wait_what_is_svg2css">Wait, What is svg2css?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Few weeks ago I created a project called <a href="https://prateekjadhwani.github.io/svg2css/">#svg2css</a>. What it does is that it lets a user create complex css3 animations with simple SVG path knowledge. A user needs to provide the web-app with SVG path info and in return it will generate a keyframe for the user. This is pretty helpful when it comes to complex css3 animations because human minds  cannot create these complex keyframe information without hours and hours of manual computation. To know more about it, feel free to checkout out <a href="https://prateekjadhwani.github.io/2016/02/29/Creating-Complex-C-S-S3-Animations.html">this blog about #svg2css</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_you_ve_piquid_my_interest_sir_where_is_this_svg2css_web_app">You&#8217;ve piquid my interest, Sir. Where is this #svg2css Web App?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can visit the webapp on the site <a href="https://prateekjadhwani.github.io/svg2css/">https://prateekjadhwani.github.io/svg2css/</a>. It is an open source project built using <a href="https://www.polymer-project.org/1.0/">PolymerJS</a>. You can find the source code of #svg2css on <a href="https://github.com/prateekjadhwani/svg2css">Github</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_woah_but_whats_up_with_the_2nd_version">Woah!! But whats up with the 2nd version?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The first version of the app could help a user create a new project, build complex css3 animations and save it to <a href="https://gist.github.com/">gist</a>. After all that is why this project was built initially. But when people decided to build something cool and were not able to show the output to other people without pasting the files to codepen or jsfiddle, it was time to get rid of this extra step.</p>
</div>
<div class="paragraph">
<p>The second version of #svg2css lets the user save the SVG information which was created during the project as well as lets the user load a project from gist directly into #svg2css with the help of a simple link. Now users can simply pass around their project link and open it in a browser to open the project. Please refer <a href="https://github.com/prateekjadhwani/svg2css/blob/master/TUTORIAL.md#sharing-a-project">this tutorial</a> link in order to understand how to generate the sharable link.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_so_wait_does_that_mean_that_you_actually_created_a_donkey_kong_stage_demo_using_svg2css">So wait, does that mean that you actually created a Donkey Kong stage demo using #svg2css ?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Oh hell yeah!!! This is a screenshot of the donkey kong stage project. The animation is applied to the drum that moves from the top to bottom. and left to right.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/donkeykong-demo.gif" alt="demo-donkeykong">
</div>
</div>
<div class="paragraph">
<p>But if you want to see a working demo, you can go to <a href="https://prateekjadhwani.github.io/svg2css/#a8dec9040aa6d5c973470b21ce1254bb">this link</a>. Feel free to fork the project and or see the generated source code from the webapp on <a href="https://gist.github.com/prateekjadhwani/a8dec9040aa6d5c973470b21ce1254bb">this gist</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_interesting_do_you_have_anything_planned_for_the_future_releases">Interesting!! Do you have anything planned for the future releases?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Yes, I do have a bunch of ideas that I would like to implement in the future releases. I usually keep a track of these things under the <a href="https://github.com/prateekjadhwani/svg2css/issues">issues</a> section of this project. If you have any ideas that could help improve this web app or if you find any bug, feel free to file them <a href="https://github.com/prateekjadhwani/svg2css/issues">here</a>.</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2016/04/19/Second-release-of-svg2css-and-Using-it-to-build-a-Donkey-Kong-stage.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2016/04/19/Second-release-of-svg2css-and-Using-it-to-build-a-Donkey-Kong-stage.html</guid><category><![CDATA[svg2css]]></category><category><![CDATA[css3]]></category><category><![CDATA[donkey-kong]]></category><category><![CDATA[css3-demo]]></category><category><![CDATA[animation]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Tue, 19 Apr 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[OMG!!! It's WebMIDI API!!!]]></title><description><![CDATA[<div class="paragraph">
<p>I am not even sure where to start, but new Web APIs like <a href="https://www.w3.org/TR/webmidi/">WebMidi</a> is what helps me kill time. In this experiment, I am glad I didn&#8217;t have to buy a new hardware. (Yup, you have no idea how many Firefox OS devices I have in my apartment. Some bricked, some still alive, and one daily driver). Anyways, I wanted to test how the WebMIDI api works, and thankfully, I had a Midi Fighter 3d at my disposal, that I bought long time ago (dont even ask why).</p>
</div>
<div class="paragraph">
<p>This experiment involves creating a WebMidi Polymer JS element that can be used directly by any web app. The link to the github project is <a href="https://github.com/prateekjadhwani/web-midi">this</a>. Or you can directly install it via bower using the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>bower install --save web-midi</code></pre>
</div>
</div>
<div class="paragraph">
<p>I am also working on another element called <a href="https://github.com/prateekjadhwani/midi-fighter-3d">midi-fighter-3d</a>. It is not complete yet, I am still experimenting with it. But here is the working video of WebMIDI api in the demo file of midi-fighter-3d element that uses web-midi element.</p>
</div>
<div class="paragraph">
<p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/tAAPqAW3tT4?rel=0" frameborder="0" allowfullscreen></iframe>
</p>
</div>
<div class="paragraph">
<p>I personally believe that this api definitely holds a good future; especially if we combine it with <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API">Web Audio api</a>.</p>
</div>
<div class="paragraph">
<p>FYI : In case you are thinking of testing out the <a href="https://github.com/prateekjadhwani/midi-fighter-3d">midi-fighter-3d</a> element, I havent tested it on Firefox (I dont think it has been implemented in Nightly yet, I could be wrong). I only tested it out in Canary.</p>
</div>]]></description><link>https://prateekjadhwani.github.io/2016/03/28/O-M-G-Its-Web-M-I-D-I-A-P-I.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2016/03/28/O-M-G-Its-Web-M-I-D-I-A-P-I.html</guid><category><![CDATA[WebMIDI API]]></category><category><![CDATA[POC]]></category><category><![CDATA[polymerjs]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Mon, 28 Mar 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Creating Complex CSS3 Animations]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Recently, I wanted to create a css3 demo to show flickering of light and after trying it for a couple of times, I was able to build something recognizable. To be honest, it was crap.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_problem_statement">Problem Statement</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Thinking about keyframes and writing down the values of every keyframe is not something human mind can do. This is just too complex. Just imagine, how would you write css keyframes for an animation if you need to manipulate 3-4 properties for a div. Not possible at all, right? In order to achieve this, I had to go with something that doesn&#8217;t involve human computation at all. Something that can be computed by a computer. Yup, you are right, I am talking about JavaScript.</p>
</div>
<div class="sect2">
<h3 id="_temporary_solution">Temporary Solution</h3>
<div class="paragraph">
<p>I instantly fell in love with the library <a href="http://mojs.io/">mo.js</a>. It does everything what I want. I just had to tell it what type of animation I want, and it made the element animate as per that instruction. Simple as that. <a href="https://github.com/legomushroom">Legomushroom</a> did an amazing job of creating something so beautiful.</p>
</div>
<div class="paragraph">
<p>But we all know the problem with using a JS library in a project. <strong>UPGRADING THE LIBRARY!!!</strong> I have always found it difficult to upgrade the libraries when my project is targeting millions of users. What if the browser that I want to support is not being supported by the library any more? What if a feature that I am using is being depreciated by the library? So many <em>What Ifs</em>!!</p>
</div>
</div>
<div class="sect2">
<h3 id="_permanent_solution">Permanent Solution</h3>
<div class="paragraph">
<p>I came up with a solution that could let users create <code>keyframes</code> based on the same concept that <a href="http://mojs.io/">mo.js</a> uses, but instead of creating those <code>keyframes</code> on runtime and performing animations on the fly, the `keyframes are generated on a <a href="https://prateekjadhwani.github.io/svg2css/">webapp called SVG2CSS</a> and can be downloaded as css files that can be included in the project.</p>
</div>
<div class="paragraph">
<p>This exporting of css animation keyframes makes a project independent of any library. Not only that, a user can export the files to <a href="https://gist.github.com">gist.github.com</a> which can be shared with anyone. All that a user needs to do is, create the div, and add animation SVG paths and their properties.</p>
</div>
<div class="paragraph">
<p>Here are some outputs of the demos I added in the project</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/svg2css/master/assets/svg2css-tublightoutput.gif" alt="demo1">
</div>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://github.com/prateekjadhwani/svg2css/raw/master/assets/svg2css-leftrefresh.gif" alt="demo2">
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_svg2css">SVG2CSS</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I created this webapp on top of <a href="https://www.polymer-project.org/1.0">Polymer JS</a> and hosted it on <a href="https://pages.github.com/">github pages</a>. All that a user needs to do is create a SVG path for the <code>property</code> he needs to manipulate, and add the <code>keyframes</code> generated from this path to a css-class.</p>
</div>
<div class="paragraph">
<p>I have also explained all the concepts and tutorials related to this SVG2CSS webapp in this <a href="https://github.com/prateekjadhwani/svg2css/blob/master/TUTORIAL.md">link</a>.</p>
</div>
<div class="paragraph">
<p>In all, I was able to create really complex animations including the ones involving physics in very small time.</p>
</div>
<div class="paragraph">
<p>
<p data-height="270" data-theme-id="3991" data-slug-hash="zqxKEV" data-default-tab="result" data-user="prateekjadhwani" class='codepen'>See the Pen <a href='http://codepen.io/prateekjadhwani/pen/zqxKEV/'>SVG2CSS dropball demo</a> by Prateek Jadhwani (<a href='http://codepen.io/prateekjadhwani'>@prateekjadhwani</a>) on <a href='http://codepen.io'>CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
</p>
</div>
<div class="paragraph">
<p>
<p data-height="256" data-theme-id="3991" data-slug-hash="VawZbd" data-default-tab="result" data-user="prateekjadhwani" class='codepen'>See the Pen <a href='http://codepen.io/prateekjadhwani/pen/VawZbd/'>SVG2CSS demo</a> by Prateek Jadhwani (<a href='http://codepen.io/prateekjadhwani'>@prateekjadhwani</a>) on <a href='http://codepen.io'>CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
</p>
</div>
<div class="paragraph">
<p>If you still find it difficult to use, feel free to reach out to me. If you find any bugs are if you face any problems with the tutorials, feel free to file a <a href="https://github.com/prateekjadhwani/svg2css/issues/new">bug</a>.</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2016/02/29/Creating-Complex-C-S-S3-Animations.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2016/02/29/Creating-Complex-C-S-S3-Animations.html</guid><category><![CDATA[CSS3]]></category><category><![CDATA[svg2css]]></category><category><![CDATA[animation]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Mon, 29 Feb 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Playing with CSS3 Filters]]></title><description><![CDATA[<div class="paragraph">
<p>Just wanted to see what happens when blur and contrast filters fight with each other.</p>
</div>
<p data-height="293" data-theme-id="3991" data-slug-hash="eJvjOq" data-default-tab="result" data-user="prateekjadhwani" class='codepen'>See the Pen <a href='http://codepen.io/prateekjadhwani/pen/eJvjOq/'>Gooey CSS3 Checkbox</a> by Prateek Jadhwani (<a href='http://codepen.io/prateekjadhwani'>@prateekjadhwani</a>) on <a href='http://codepen.io'>CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>]]></description><link>https://prateekjadhwani.github.io/2016/01/06/Playing-with-CSS3-Filters.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2016/01/06/Playing-with-CSS3-Filters.html</guid><category><![CDATA[Blob]]></category><category><![CDATA[CSS3]]></category><category><![CDATA[Filters]]></category><category><![CDATA[Gooey Effect]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 06 Jan 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Demo for mo.js Library]]></title><description><![CDATA[<div class="sect1">
<h2 id="_what_is_mo_js_library">What is mo.js Library</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I like to call mo.js a motion/animation library since I have only seen its use in creating animations or motion based UI. More details about the library can be found at <a href="http://mojs.io/">mo.js Website</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_to_use_this_library_em_tl_dr_version_em">How to use this library (<em>tl;dr version</em>)</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This library is pretty simple to use.</p>
</div>
<div class="paragraph">
<p>For example: to use the <a href="http://mojs.io/tutorials/easing/path-easing/">Path Easing</a> functionality, you just need to provide the following details:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A path easing graph, <em>usually in the form of a svg</em></p>
</li>
<li>
<p>Animation time</p>
</li>
<li>
<p>Property change code for a DOM element.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Of course this is the <strong>tl;dr version</strong>, so I am omitting a lot of optional parameters, but if you want, you can look for more details <a href="http://mojs.io/tutorials/easing/path-easing/">here</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_demo">Demo</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now that the basics of how to use this library is clear, I can finally show what the demo looks like.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://prateekjadhwani.github.io/images/elastic_menu.gif" alt="demo" width="300" height="200">
</div>
</div>
<div class="paragraph">
<p>The working demo can be accessed from this <a href="http://codepen.io/prateekjadhwani/full/rxMmpe/">codepen demo</a>. All you need is a touchscreen.</p>
</div>
<div class="paragraph">
<p>Or you can see the demo below:</p>
</div>
<p data-height="450" data-theme-id="3991" data-slug-hash="rxMmpe" data-default-tab="result" data-user="prateekjadhwani" class='codepen'>See the Pen <a href='http://codepen.io/prateekjadhwani/pen/rxMmpe/'>Elastic Menu</a> by Prateek Jadhwani (<a href='http://codepen.io/prateekjadhwani'>@prateekjadhwani</a>) on <a href='http://codepen.io'>CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
<div class="sect2">
<h3 id="_so_what_is_happening_in_the_demo">So what is happening in the demo?</h3>
<div class="paragraph">
<p>In the demo, I am just manipulating a SVG path. The touch start input decides the y-coordinate of the stretch, and touch drag computations decide the x-coordinate of the stretch. Once these coordinates have been calculated, SVG gets rendered on the screen.</p>
</div>
<div class="paragraph">
<p>When the touch is released, the animation functions (<em>close menu</em> or <em>open menu</em>) kicks in, which then uses <strong>mo.js</strong> path easing functionality to perform the wobble animation.</p>
</div>
</div>
<div class="sect2">
<h3 id="_references">References</h3>
<div class="paragraph">
<p>I used the following references to understand the pre-requisites and implement this demo:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://dribbble.com/shots/1949368-Sidebar-animation" class="bare">https://dribbble.com/shots/1949368-Sidebar-animation</a></p>
</li>
<li>
<p><a href="http://jxnblk.com/paths/" class="bare">http://jxnblk.com/paths/</a></p>
</li>
<li>
<p><a href="http://svg.dabbles.info/" class="bare">http://svg.dabbles.info/</a></p>
</li>
<li>
<p><a href="https://github.com/Thomaseustache/swipe-menu-svg" class="bare">https://github.com/Thomaseustache/swipe-menu-svg</a></p>
</li>
<li>
<p><a href="http://mojs.io/tutorials/easing/path-easing/" class="bare">http://mojs.io/tutorials/easing/path-easing/</a></p>
</li>
</ul>
</div>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2015/12/30/Demo-for-mojs-Library.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2015/12/30/Demo-for-mojs-Library.html</guid><category><![CDATA[mo.js]]></category><category><![CDATA[demo]]></category><category><![CDATA[elastic menu]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Wed, 30 Dec 2015 00:00:00 GMT</pubDate></item><item><title><![CDATA[Firefox OS on a High End Device]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>It all started with one tweet!!</p>
</div>
<div class="paragraph">
<p><blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">My Phone Runs on JavaScript - great Firefox OS intro deck from <a href="https://twitter.com/jedireza">@jedireza</a> <a href="http://t.co/JksO42aP2B">http://t.co/JksO42aP2B</a></p>&mdash; dietrich ayala (@dietrich) <a href="https://twitter.com/dietrich/status/628270494190542849">August 3, 2015</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
</div>
<div class="paragraph">
<p>Here you can clearly see from the slides that Firefos OS runs on Sony Xperia Z3 Compact. And so the experiment began!!</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_unlocking_the_bootloader">Unlocking the bootloader</h4>
<div class="paragraph">
<p>For someone who has never created android mods, or played with android, it was really difficult to understand the steps that had to be followed in order to install Firefox OS. And so the first step <em>Unlocking The Bootloader</em> turned out to be more challenging than I had originally thought. But in the end, the bootloader was unlocked, and I got to play with some of the bootloader options.</p>
</div>
</div>
<div class="sect3">
<h4 id="_building_for_aries_l">Building for aries-l</h4>
<div class="paragraph">
<p>Now that the bootloader was unlocked, I decided to install firefox os on this device which had Android 5.1.1 or you can say the most updated version of Android.</p>
</div>
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>aries-l is the code name for Sony Xperia Z3 Compact device running Android 5.</p>
</div>
</blockquote>
</div>
<div class="paragraph">
<p>After following the MDN docs on firefox OS for aries-l build, I started the build process on my mac. But after downloading the files, the build process failed. After talking to the community, I found out that the build process for Android 5.0+ was broken. Not only that, the build process doesnt work on Mac at all.</p>
</div>
</div>
<div class="sect3">
<h4 id="_flashing_the_phone_with_4_4">Flashing the phone with 4.4</h4>
<div class="paragraph">
<p>After realizing that the previous step was a total failure and talking to the people in community, I decided to flash the devices with Android 4.4.</p>
</div>
</div>
<div class="sect3">
<h4 id="_building_for_aries">Building for aries</h4>
<div class="paragraph">
<p>This time instead of using a Mac to build Firefox OS, I used a linux machine. <em><em>(incase you are wondering why I did not use a virtual machine, well I did, but the process kept on failing after pulling the files from the device.)</em></em></p>
</div>
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>aries is the code name for Sony Xperia Z3 Compact device running Android 4.4.</p>
</div>
</blockquote>
</div>
<div class="paragraph">
<p>And this time, it was a success. I was finally able to see the device running Firefox OS.</p>
</div>
<div class="paragraph">
<p><strong>Some of the settings from the device are as follows</strong></p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Setting Name</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Value</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Model</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Xperia Z3 Compact(B2G)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Software</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boot2Gecko 2.5.0.0-prerelease</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="_outcome">Outcome</h4>
<div class="paragraph">
<p>The final outcome was a High End Device runnning Firefox OS.</p>
</div>
<div class="videoblock">
<div class="content">
<iframe src="https://www.youtube.com/embed/EyGAyjMobb8?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2015/08/22/Firefox-OS-on-a-High-End-Device.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2015/08/22/Firefox-OS-on-a-High-End-Device.html</guid><category><![CDATA[Firefox OS]]></category><category><![CDATA[B2G]]></category><category><![CDATA[Sony Xperia Z3 Compact]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Sat, 22 Aug 2015 00:00:00 GMT</pubDate></item><item><title><![CDATA[Hello World 2.0]]></title><description><![CDATA[<div class="paragraph">
<p>You guys must be wondering what happened to my old site. Well, I got tired of all the maintainence work that I had to do every now and then. And all the money that I was spending on just a 100MB space. Plus, this way I can concentrate more on what I love to do, i.e. code.</p>
</div>
<div class="paragraph">
<p>I am pretty sure I won&#8217;t be importing any of the posts from by old blog site. Sorry about that :(</p>
</div>
<div class="paragraph">
<p>It&#8217;s a lot of effort for old technologies which I am never planning to use!! Although I will try to import some good ones.</p>
</div>
<div class="paragraph">
<p>In either case, I will try to keep you guys posted on the stuff that I have been doing or planning to do in the coming days.</p>
</div>]]></description><link>https://prateekjadhwani.github.io/2015/08/03/Hello-World-20.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2015/08/03/Hello-World-20.html</guid><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Mon, 03 Aug 2015 00:00:00 GMT</pubDate></item><item><title><![CDATA[Playing with Source Maps]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>So recently, I came across the word <strong>eval-source-map</strong> in a retweet by someone I follow. At first I had no idea what that word meant. Looking into the functionality of that parameter I came across the concept of Source Map.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/sourcemap.png" alt="tweet">
</div>
</div>
<div class="paragraph">
<p>After doing some research, I realized that Source Map is actually a pretty cool concept.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_is_source_map">What is Source Map ?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Let&#8217;s say you have a single compressed file in your web application that is live and you are just browsing through the functionalities of a module. Suddenly it stops working. Bug!!!! You just found a  bug in your live website. You open the dev tools and try to find out where that bug occurred. But the code is compressed. You have no idea what variable or function name the error message in dev tools is pointing to. Wouldn&#8217;t it be great if you could do that. As in view the original files despite using the compressed code.</p>
</div>
<div class="paragraph">
<p>Apparently, Source Map can help you with that. Source Map, as the name indicates can map the source code of the compressed file for you. It places a link to a map file that contains link to all the files that were compressed. This link to the map file can then be picked up by the browser to display you the source code instead of the unreadable minimized file. This way, even if the error happened in the compressed file, the variable or function name will be mapped to the source file and can be used to deal with the actual problem.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_can_i_have_the_source_map_in_my_code">How can I have the source map in my code ?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Actually, it is pretty simple. When you are compressing the files, you will need to provide the parameter to create source map. Let&#8217;s say you are using Closure for compressing the files. You just need to compress the files with an extra parameter <code>--create_source_map file-name-for-source-map</code> as given in the example below.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-shell" data-lang="shell">$ java -jar compiler.jar --js example.js --create_source_map ./example-map --js_output_file example-compiled.js</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will add the compiled file <code>xample-compiled.js</code> and the map file <code>example-map</code>  to your folder. Now you can add the following statement at the end of your <code>example-compiled.js</code>  file.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">//# sourceMappingURL=example-map</code></pre>
</div>
</div>
<div class="paragraph">
<p>And that&#8217;s it. You just added source maps to your file.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_okay_so_how_do_i_test_it">Okay, so how do I test it ?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Make sure your server is running and you are viewing your application on a browser. Also verify that you have the source map comment in your compressed file, the one that we added in the previous section.
Open Chrome Dev tools and see if you have Source maps enabled.</p>
</div>
<div class="imageblock" style="text-align: center">
<div class="content">
<img src="https://raw.githubusercontent.com/prateekjadhwani/prateekjadhwani.github.io/master/images/sourcemap2.png" alt="option">
</div>
</div>
<div class="paragraph">
<p>Now refresh the page and verify the files in the source tab of the Dev Tools. You should be able to see the un-compressed individual js files.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I hope this explanation of Source Map was useful. I can already see so many applications of this concept in mind right now. I am sure that similar thing can be done with CSS as well. If you have anything to share about the concept of Source Map, I would love to hear it in the comments below.</p>
</div>
</div>
</div>]]></description><link>https://prateekjadhwani.github.io/2015/07/13/Playing-with-Source-Maps.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2015/07/13/Playing-with-Source-Maps.html</guid><category><![CDATA[sourcemaps]]></category><category><![CDATA[minification]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Mon, 13 Jul 2015 00:00:00 GMT</pubDate></item><item><title><![CDATA[CSS3 Checkbox]]></title><description><![CDATA[<div class="paragraph">
<p>A simple checkbox (okay, not so simple!!) made using css3. The inspiration came from this <a href="https://dribbble.com/shots/580766-expswitch">Dribbble Post</a>.</p>
</div>
<p data-height="168" data-theme-id="3991" data-slug-hash="lcvHi" data-default-tab="result" data-user="prateekjadhwani" data-embed-version="2" class="codepen">See the Pen <a href="http://codepen.io/prateekjadhwani/pen/lcvHi/">expswitch</a> by Prateek Jadhwani (<a href="http://codepen.io/prateekjadhwani">@prateekjadhwani</a>) on <a href="http://codepen.io">CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>]]></description><link>https://prateekjadhwani.github.io/2014/05/11/C-S-S3-Checkbox.html</link><guid isPermaLink="true">https://prateekjadhwani.github.io/2014/05/11/C-S-S3-Checkbox.html</guid><category><![CDATA[CSS3]]></category><category><![CDATA[checkbox]]></category><category><![CDATA[demo]]></category><dc:creator><![CDATA[Prateek Jadhwani]]></dc:creator><pubDate>Sun, 11 May 2014 00:00:00 GMT</pubDate></item></channel></rss>