<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Paul Ryan Codes on Medium]]></title>
        <description><![CDATA[Stories by Paul Ryan Codes on Medium]]></description>
        <link>https://medium.com/@paulryan17?source=rss-c23e1d013b34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IP7BnSGcL6J2XdEWqzlNeA.png</url>
            <title>Stories by Paul Ryan Codes on Medium</title>
            <link>https://medium.com/@paulryan17?source=rss-c23e1d013b34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 18:55:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paulryan17/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I am building an app to beat the Algorithms]]></title>
            <link>https://medium.com/@paulryan17/i-am-building-an-app-to-beat-the-algorithms-f93ea9af2950?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/f93ea9af2950</guid>
            <category><![CDATA[internet-addiction]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[productivity-hacks]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Mon, 17 Jun 2024 17:03:18 GMT</pubDate>
            <atom:updated>2024-06-17T17:03:18.333Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*ym5tznnqQSzm7hdQEh5Tfg.png" /></figure><p>As a knowledge worker, I often find myself caught in the labyrinth of distracting websites, with productivity slipping through my fingers. The lure of social media, news sites, and endless scrolling can turn productive work hours into a haze of procrastination. Enter NoSurf, a SAAS application designed to help people like me manage and reduce their online time, enabling us to stay focused on our goals.</p><h3>The Challenge of Distraction</h3><p>In today’s digital age, distractions are just a click away. As someone who spends most of the workday on a laptop, it’s easy to fall into the trap of visiting non-work-related websites. The result? Reduced productivity, missed deadlines, and a constant battle to stay focused. This problem isn’t unique to me. Engineers, marketers, and countless other professionals face the same issue. We need a solution that helps us reclaim our time and stay on track.</p><h3>Introducing NoSurf</h3><p>NoSurf is designed with one primary goal: to provide a comprehensive solution for managing and reducing online time. Initially launching for macOS, with plans to extend to Windows, NoSurf offers a range of features tailored to encourage mindful internet usage.</p><h3>Key Features</h3><p><strong>Live Dashboard</strong>:</p><ul><li>The live dashboard is a real-time display of the most visited websites and the time spent on each. This feature provides immediate insights into browsing habits and highlights areas where excessive time is spent. It’s a wake-up call for those moments when you realize just how much time you’ve wasted on non-essential sites.</li></ul><p><strong>Block List with Warnings</strong>:</p><ul><li>Users can add websites to a block list. When attempting to visit these sites, a message appears asking, “Are you sure you want to spend time on this app?” This gentle reminder encourages reconsideration of choices and alignment with personal and professional goals. Additionally, users can configure specific times when these websites are allowed, such as a break period between 9–10 AM.</li></ul><p><strong>Complete Website Ban</strong>:</p><ul><li>For those needing a stricter approach, NoSurf offers the option to completely ban specific websites. This ensures that the most distracting content is inaccessible, helping users maintain focus and avoid temptation.</li></ul><p><strong>Goal Setting and Reminders</strong>:</p><ul><li>Users can set personal and professional goals within the application. When attempting to visit blocked or restricted websites, NoSurf will remind them of these goals, reinforcing their commitment to staying on track and reducing procrastination.</li></ul><h3>Future Enhancements</h3><p>The development roadmap for NoSurf includes several future enhancements:</p><ul><li><strong>Cross-Platform Sync</strong>: Sync settings and data across multiple devices for a seamless experience.</li><li><strong>Detailed Analytics</strong>: Provide in-depth reports and analytics on internet usage patterns to help users identify trends and make informed decisions.</li><li><strong>Customizable Alerts and Notifications</strong>: Enable users to tailor the types and frequencies of alerts to their specific needs.</li><li><strong>Productivity Mode</strong>: A special mode that enhances restrictions during critical work periods for maximum focus and productivity.</li></ul><h3>Conclusion</h3><p>NoSurf aims to be the ultimate tool for individuals seeking to manage their time spent online more effectively. By providing a blend of real-time insights, gentle reminders, and strict restrictions, NoSurf helps users stay focused on their goals and reduce distractions. The phased implementation approach ensures a steady rollout of features and continuous improvement based on user needs and feedback.</p><p>For those of us who struggle with digital distractions, NoSurf offers a lifeline — a way to beat the algorithms and reclaim our productivity. With NoSurf, staying focused and achieving our goals is not just a dream but a reality waiting to be realized.</p><p>If you would like to join beta access, then feel free to sign up to the <a href="https://nosurf.io/">waitlist</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f93ea9af2950" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CSS Transitions in 2019]]></title>
            <link>https://medium.com/@paulryan17/simple-css-transitions-in-2019-67a3b68126c?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/67a3b68126c</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[transitions]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Fri, 25 Jan 2019 23:30:27 GMT</pubDate>
            <atom:updated>2019-01-25T23:31:02.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bbJ7bBuGVGFAr_cvnZWiw.png" /></figure><h3>Simple CSS Transitions in 2019</h3><p>CSS Transitions can breathe life into our web applications, from smooth slide-down effects to fading elements out, without these our applications can seem very static and dull.</p><p>Yet, even with the importance and <a href="https://caniuse.com/#feat=css-transitions">support</a> of CSS transitions , they are still woefully misunderstood and many developers (I know I was) are guilty of copying and pasting code they don’t understand. This can lead to unmanageable code and transitions that aren’t behaving correctly.</p><p>This article will rectify this by giving you a concise guide on how to use CSS Transitions to improve your web applications.</p><h3>CSS Transitions</h3><p>The code to create a CSS transition is incredibly simple:</p><pre>transtion: height .25s ease-in</pre><p><em>This way of writing transitions is short hand, you can also write:</em></p><pre>transition-property: height,<br>transition-duration: 0.25,<br>transition-timing-function: ease-in</pre><p><em>I find this way of writing transitions adds a lot of bloat and essentially complicates things.</em></p><p>What this code is saying is, when the height changes I want to transition it at a speed of 250ms and ease-in basically says I want it to start slow.</p><p>I find it much easier to write transitions by just looking at the following, which clearly states the order of the transition properties:</p><pre>transition: &lt;property&gt; &lt;duration&gt; &lt;timing-function&gt; &lt;delay&gt;</pre><p>The part of this which is normally most misunderstood is ‘ease-in’, this isn’t surprising as the property name for ‘ease-in’ is ‘transition-timing-function’ , which let’s be honest doesn’t make it any less easier to understand.</p><p>However it can explained quite simply:</p><blockquote>Easing describes an animation’s rate of change over time</blockquote><p>It really is that simple!</p><p><em>should my transition start fast?</em></p><p><em>start slow?</em></p><p><em>start slow and endfast?</em></p><p>The following is the values you can pass to your transition-timing-function:</p><pre>transition-timing-function: linear;<br>transition-timing-function: ease;<br>transition-timing-function: ease-in;<br>transition-timing-function: ease-out;<br>transition-timing-function: ease-in-out;</pre><p>Rather than me explaining all of them here, you can check out what they all do <a href="https://www.w3schools.com/cssref/css3_pr_transition-timing-function.asp">here</a>.</p><p>As a side note, you can also use <em>cubic-bezier(n,n,n,n)</em> which we will use in our example.</p><p>I think that is enough theory, believe it or not even with this core knowledge you are well on your way to understanding transitions.</p><p>The best way to learn CSS Transitions is by looking at an example.</p><p>I have created a very simple CodePen showing everything we discussed here in action.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FPaulRyan17%2Fembed%2Fpreview%2FxYKjgj%3Fheight%3D600%26slug-hash%3DxYKjgj%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2FPaulRyan17%2Fpen%2FxYKjgj&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F1464352.xYKjgj.small.ce10d672-3d3a-43f4-814c-befb252153b5.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/da01fa0a0734cf13260a83fdda176b30/href">https://medium.com/media/da01fa0a0734cf13260a83fdda176b30/href</a></iframe><p>As you can see from the CodePen, it is quite basic and shows a bat pushing a ball. (this may not look quite right but if you click ‘edit on codepen’, you can see it in all its glory)</p><p>So lets go through the different parts to achieve this:</p><h3>1. The Bat</h3><p>So sometimes its best to think of the start and end position rather than the transition. So basically what we want is to move the bat a certain amount so that it reaches the ball, the code to achieve this:</p><pre>.baseballbat.move{<br>  transform: translateX(200px) rotate(50deg);<br>}</pre><p>This code is very simple, translateX(200px) will move the bat 200px to the right when the class move is applied (classes can be added with JavaScript).</p><p><em>Ignore rotate, I just used it to flatten out the bat as it was pointed to the corner from the image I got.</em></p><p>So the next step is to transition the baseballbat.</p><p>The following code will accomplish this.</p><pre>.baseballbat{<br>  height: 250px;<br>  width: 200px;<br>  transform: rotate(50deg);<br>  margin-left: 30px;<br>  transition: transform 350ms ease-in;<br>}</pre><p>The main part to focus on here is:</p><pre>transition: transform 350ms ease-in;</pre><p>This is very basic, we apply a transition to the transform property, it will take 350ms and it will have a transition-timing-function of ease-in.</p><p>Now the baseballbat moves much more fluidly.</p><h3>2. The Ball</h3><p>So now its time to move the ball when the baseballbat reaches it.</p><p>So like before, we first focus on the end position of the ball, very similar to the baseballbat we add a transform property:</p><pre>.ball.move{<br>  transform: translateX(300px);  <br>}</pre><p>When the move class is applied to theball, it will move 300px to the right.</p><p>So far, so good?</p><p>Ok, so like before (see how similar everything is), we now add a transition to the transform property of the ball.</p><p>The code looks like this:</p><pre>.ball{<br>  height: 100px;<br>  margin-left: 250px;<br>  top: -50px;<br>  transition: transform 550ms cubic-bezier(.02,.63,.79,1.33) 350ms;<br>}</pre><p>Ok so everything looks the same, we apply a transition on the transform property, the transition will take 550ms and the last value is the delay, note that the delay matches the transition length of the baseballbat to ensure the ball will only move when the bat stops.</p><p>So we have a new value here:</p><pre>cubic-bezier(.02,.63,.79,1.33)</pre><p>Cubic-Bezier allows us to achieve much more real transitions, you can see using this cubic-bezier, the ball moves forward then goes back, almost like there is a backspin on it.</p><p>Cubic-Bezier can look quite complicated but it doesn’t need to be, using <a href="http://cubic-bezier.com/#.17,.67,.83,.67">cubic-bezier.com</a>, you can easily create these cool transitions. With a little playing around on the website, you will be fully comfortable with it and easily able to copy and paste it into your transitions.</p><h3>Summary</h3><p>Believe or not, that is basically everything you need to know to use transitions. It is incredible how simple transitions are, but yet how many developers still don’t understand them. I hope with this guide I have converted more developers to learn their tools rather than copying and pasting.</p><p>Any questions/problems, just leave a comment below.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67a3b68126c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Animate a Robot SVG with Greensock]]></title>
            <link>https://medium.com/@paulryan17/animate-a-robot-svg-with-greensock-e62baa5f05b6?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/e62baa5f05b6</guid>
            <category><![CDATA[robots]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[greensock]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Sun, 20 Jan 2019 19:35:25 GMT</pubDate>
            <atom:updated>2019-01-20T19:35:25.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*zuRgRQ9Zv5FzpfX6" /></figure><p>So, today we are going to animate a Robot SVG using the <a href="https://greensock.com/">GreenSock</a> library. I haven’t even started the work yet, but by the time you’re reading this article I will be done. I have decided to document my journey of creating this animation so by the end I can teach you so you won’t have to face the same struggles (fingers crossed 🤞) . This article will focus on creating 3 animations for our robot; blinking, antenna wiggle and making the robot move a little. So let’s get started!</p><p>The first thing we need to do is go find a Robot SVG. I absolutely love <a href="https://undraw.co/illustrations">Illustrations</a> for finding cool SVG images. I downloaded the Robot SVG from there but I made it a lot cleaner than the original so it is actually possible to animate it. The following is our Robot.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FPaulRyan17%2Fembed%2Fpreview%2FpQRGmN%3Fheight%3D600%26slug-hash%3DpQRGmN%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2FPaulRyan17%2Fpen%2FpQRGmN&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F1464352.pQRGmN.small.8fba49b7-34c7-4899-bb1e-108c4b5cef9a.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/548541beb4c347a54df72fa5699ec53a/href">https://medium.com/media/548541beb4c347a54df72fa5699ec53a/href</a></iframe><p>So with the SVG in place, we have our starting point, now let’s go animate this shit! Make sure to fork my pen if you want to follow along as you will need the Greensock dependency.</p><p><strong>Link to the final Codepen is </strong><a href="https://codepen.io/PaulRyan17/pen/WLzYzL?editors=1010"><strong>here</strong></a><strong>.</strong></p><h3>Making The Robot Move</h3><p>Let’s write some Javascript.</p><p>Create a function called moveUpAndDown which will will do as it says.</p><pre>const moveUpAndDown = () =&gt; {}</pre><p>For this movement to work, we need to move 3 areas of the robot — the arms, the body and the head. We use document.querySelector(). Code is:</p><pre>const body = document.querySelector(&#39;#body&#39;)<br>const head = document.querySelector(&#39;#head&#39;)<br>const arms = document.querySelector(&#39;#arms&#39;)</pre><p>As you can see, we haven’t used the wonderful Greensock library yet, we will start now by using TweenMax to animate all the parts at the same time. You don’t actually need to put the elements in variables, you can just pass the selector to TweenMax but this is the way I prefer to do it.</p><p>We will use the to method to move our robot parts, the code is:</p><pre>TweenMax.to([body, head, arms], 0.3, {y: &#39;20px&#39;, yoyo: true, repeat: 1});</pre><p>This may look a bit daunting but it is actually quite simple, the signature of the method is:</p><pre>.to( target:Object, duration:Number, vars:Object, position:* ) :</pre><p>So the object in our case is the body, head, arms , the duration is 300ms and we want to move the y position 20px. The yoyo property will animate the animation back to the start, this saves us having to write code to move it all back which is very useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/176/1*3zs-xLJvU2lHQlogflzIhg.gif" /></figure><h4>Wiggle The Antenna</h4><p>This is quite a bit more challenging than above, but will also be a lot more beneficial to our learning so let’s do it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K1tyV0bMtowMDkwf.gif" /></figure><p>Create a wiggleAntenna function as follows:</p><pre>const wiggleAntenna = () =&gt; {}</pre><p>So to get the antenna to wiggle I needed to change my rect to be a path as we don’t have enough control over the rect to achieve the animation. To learn more about SVG paths <a href="https://medium.com/@paulryan17/svg-path-basics-79a0334faab6">check out my article here</a>. I then used the q command to add a small curve, the q command accepts two arguments —the control point and end point of the curve (that’s the actual definition for it, don’t worry, it confuses me too)</p><pre>q x1 y1, x y</pre><p>Thankfully q is one the easier commands to understand, I’ll explain each point:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kuK1lOJBhBTkvGPbNT3xfA.png" /></figure><p>Visually it look’s like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hg-e-EmFUUAsOY-WTvh1Iw.png" /></figure><p>Our two antenna’s svg code will now look like:</p><pre>&lt;path id=&quot;antenna-1&quot; fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; d = &quot;M 54 5 <strong>q 0 0 0 50</strong>&quot; x=&quot;54&quot; y=&quot;5&quot; stroke-width=&quot;5.38452043&quot;&gt;&lt;/path&gt;<br>&lt;path id=&quot;antenna-2&quot; fill=&quot;none&quot; d=&quot;M 108 5 <strong>q 0 0 0 50</strong>&quot; width=&quot;5.38452043&quot; stroke-width=&quot;5.38452043&quot; stroke=&quot;#3DA4AB&quot; height=&quot;46.926779&quot;&gt;&lt;/path&gt;</pre><p>Visually:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*yxD3YXo3GEXTomiqwVENcw.png" /><figcaption>Robot’s Antenna</figcaption></figure><p>I added ids to the antenna and the ellipses so I can get a reference to them like so:</p><pre>const antenna_one = document.querySelector(&#39;#antenna-1&#39;)<br>const antenna_one_ball = document.querySelector(&#39;#antenna-1-ball&#39;)<br>const antenna_two = document.querySelector(&#39;#antenna-2&#39;)<br>const antenna_two_ball = document.querySelector(&#39;#antenna-2-ball&#39;)</pre><p>What we need to do is simply animate the x1 value, once in a positive direction and once in a negative direction. We will use TimeLineMax so we can chain animations.</p><p>Code is:</p><pre>const wiggle = new TimelineMax()<br>wiggle.to(antenna_one, 0.1, {attr: {d: &quot;M 54 5 q <strong>10</strong> 10 0 50&quot;}, repeat: 1, yoyo: true})<br>  .to(antenna_one, 0.1, {attr: {d: &quot;M 54 5 q <strong>-10</strong> 10 0 50&quot;}, repeat: 1, yoyo: true})</pre><p>We will also give a small animation to the antenna ball so it slightly moves</p><pre>const antenna_one_ball = document.querySelector(&#39;#antenna-1-ball&#39;)<br> TweenMax.to(antenna_one_ball, 0.1, {repeat: 1, yoyo: true, x:1, y:0})</pre><p>We will do the same for the other antenna and ball, you can see the code in the Codepen but best to do it yourself as a little test.</p><p>We should now have the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/176/1*OOUkpUTtdhlhoUdaSUR87Q.gif" /><figcaption>Wiggle Animation</figcaption></figure><p>Certainly not the sexiest, but served as a good lesson to learn the q command.</p><p><strong>Make The Robot Blink</strong></p><p>This is not quite as challenging as above, we just need to set scaleY to 0 and have our time set as 100ms which simulates a blink.</p><p>Let’s create a blink function:</p><pre>const blink = () =&gt; {}</pre><p>Get a reference to our eyes:</p><pre>const eye = document.querySelector(&#39;#eye-1&#39;)<br>const eye2 = document.querySelector(&#39;#eye-2&#39;)</pre><p>Then we just need (note that we can pass multiple elements in an array) :</p><pre>TweenMax.to([eye, eye2], 0.2, { scaleY: 0, yoyo: true, repeat: 1, transformOrigin: &#39;center&#39;})</pre><blockquote>The transform-origin property is used to change the position of the origin of transformation of an element.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/176/1*qO4Fhyk4ZYWv-aN8AyQ09g.gif" /><figcaption>Blinking animation</figcaption></figure><h4>BOUS — Sleep and Wake</h4><p>I have the code for the SVG in the Codepen, but you should try this one yourself, basically make the robot close his eyes and open them back up through two function calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/176/1*wN2uTVnRAO9n-KWssR-sFg.gif" /><figcaption>Sleep &amp; Wake</figcaption></figure><h4>Conclusion</h4><p>This article is getting a little long so I am going to finish it here, this is some core animations for our robot. I will continue adding more animations and polishing the current ones until we have a fully animated robot.</p><p>Hope you learned something.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e62baa5f05b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SVG Path Basics]]></title>
            <link>https://medium.com/@paulryan17/svg-path-basics-79a0334faab6?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/79a0334faab6</guid>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[rectangle]]></category>
            <category><![CDATA[attributes]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[path]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Mon, 03 Dec 2018 21:16:22 GMT</pubDate>
            <atom:updated>2018-12-03T21:30:49.030Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2mC0818w3ugEhOz_Zlkijg.png" /></figure><p>SVG Paths can look incredibly intimidating, with seemingly random numbers and letters scattered throughout. I have recently learned what some of these letters and numbers mean and I want to help out other people out who are as lost as I was.</p><p>I think the best way to tackle learning SVG Paths is to draw something, so we will attempt to draw a rectangle using a path. Yes we could use rect but learning how to do this with a path will really help us understand how they work.</p><p>For coding along, I recommend using Codepen or anything that will allow you to see the changes quickly as it is freaking cool to see lines come on the screen from just writing numbers! (well I think it is cool anyway 😎).</p><p>The first step is creating our basic SVG:</p><pre>&lt;svg height=&quot;700&quot; width=&quot;500&quot;&gt;</pre><pre>&lt;/svg&gt;</pre><p>Now we can create an SVG path (everything from this point on will go in between the &lt;svg&gt; tags)</p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;7px&quot; /&gt;</pre><p>Sooooo… nothing will be drawn to the screen (which is expected), but before we start drawing, let me explain the <strong>path attributes:</strong></p><p><strong>fill — </strong>when this is passed a color (hex or string) it will fill in the path with this color</p><p><strong>stroke — </strong>what color should our stroke be</p><p><strong>stroke-width — </strong>how thick should our stroke be</p><p>Ok now onto the fun part, actually drawing, we will add the <strong>d </strong>(draw) attribute to our path element:</p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;7px&quot; d=&quot;&quot; /&gt;</pre><p>We can now pass <strong>commands </strong>to <strong>d </strong>and the first one we will pass is <strong>m </strong>(move), <strong>m </strong>takes two arguments<strong>(x,y)</strong> which will set where we will begin drawing (imagine we are holding a pencil to draw with) i.e.</p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;7px&quot; d=&quot;M 20 20&quot; /&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*sunGPS_Nee4SYDXITIKiIg.png" /><figcaption>Move our pencil 20,20</figcaption></figure><p>We have told our SVG that we will start drawing from the coordinates 20,20.</p><p>The next step is to draw, and for that we will use the <strong>l </strong>(lineto) command which accepts an <strong>x </strong>and <strong>y </strong>argument. Lowercase is relative position whereas uppercase is absolute positioning.</p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;7px&quot; d=&quot;M 20 20 l 0 100&quot; /&gt;</pre><p>Our path now looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*PL1wa9aOaX1wNBqnjpr_tg.png" /></figure><p>Deadly! We have drawn the left side of our rectangle, our pencil will now be at the bottom of the line. Can you guess how to draw the bottom? We can basically do the opposite of above:</p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;7px&quot; d=”M 100 100 l 0 100 <strong>l 200 0</strong>&quot; /&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*3JakBlxn1cbtwIjhwucZ4Q.png" /><figcaption>Oh my god! We have the bottom!</figcaption></figure><p>So we add another <strong>l </strong>command and we move the pencil <strong>200 </strong>across the x axis and keep the <strong>y </strong>position the same.</p><p>To draw the right hand side of our rectangle, we want our pencil to remain in the same place on <strong>x </strong>axis but move up <strong>200 </strong>on the y axis, to move up we add a negative value for <strong>y -200.</strong></p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;7px&quot; d=”M 100 100 l 0 100 l 200 0<strong> l 0 -200</strong>&quot; /&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*Srfkw4tegHsLUz-Dg0J63A.png" /><figcaption>Nearly there!!</figcaption></figure><p>Now instead of drawing a line back here, we can use the <strong>z </strong>command which will draw a line back to the start.</p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;7px&quot; d=”M 100 100 l 0 100 l 200 0 l 0 -200<strong> z</strong>&quot; /&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*f_FpJyJMsDX1RWfSG980sg.png" /><figcaption>Our beautiful rectangle!</figcaption></figure><p>We have achieved what we have set out to do, but we can make it easier. We also have the <strong>h (horizontal)</strong> and <strong>v (vertical) </strong>commands .</p><p>Both these commands accept just one argument, the argument tells the command where to move our pencil to. It will simply draw <strong>horizontally</strong> or <strong>vertically</strong> to that point.</p><p>So our path would now look like this, like before we specify where to start drawing from.</p><pre>&lt;path fill=&quot;none&quot; stroke=&quot;#3DA4AB&quot; stroke-width=&quot;4&quot; d=&quot;M 100 100 v 100 h 200 v -100 z&quot; /&gt;</pre><p>You see how much cleaner this is? We <strong>v</strong>ertically move our pencil and then <strong>h</strong>orizontally move our pencil to create our rectangle.</p><p>For a more in depth guide on <strong>d attribute</strong>, check out this <a href="https://css-tricks.com/svg-path-syntax-illustrated-guide/">great article on CSS Tricks.</a></p><p>I will now be moving onto learning about Bezier Curves and I will be sure to share my findings here.</p><p>Thanks for reading and I hope you have learned something.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79a0334faab6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Kickass Save Button in React]]></title>
            <link>https://medium.com/@paulryan17/create-a-kickass-save-button-in-react-2e0fa725f0ba?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e0fa725f0ba</guid>
            <category><![CDATA[jsx]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[button]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Wed, 14 Nov 2018 21:48:29 GMT</pubDate>
            <atom:updated>2018-11-14T21:48:29.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VErN6_erzSCXdciclkwKtg.png" /></figure><p>All Web/Mobile Apps have a save button or a button that when clicked causes data to persist. Unfortunately, we aren’t at the stage yet where this is instant, so we need to give some feedback to the user when the save is occurring.</p><p>It is common to set the button to a disabled state while the save is processing to indicate to the user that something is happening, but wouldn’t it be nicer to just replace the save button with a spinner? (HINT: the answer is yes) 🤩</p><p>By the end of this article we will have created the following animation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*J4VdZbHGhQiA2DarVN2g8g.gif" /><figcaption>Save Animation</figcaption></figure><p>If you just want to see the code, <a href="https://codesandbox.io/s/woqo5rvqqw">then click here my friend!</a></p><p>Let’s break down how we create this animation.</p><h4>The Button</h4><p>We first create our button (I will leave out unimportant parts of the css such as basic button styling):</p><pre>// css<br>button { ... button styles}</pre><pre>button::after{<br> content: &quot;Apply Changes&quot;;<br>}</pre><p>:<strong>:after??😕</strong></p><p>You don’t have to set the text for the button in a pseudo selector, you just need to make sure you hide it when the button is clicked. For this example, since we set the spinner in a pseudo selector it will override this selector.</p><p>The next step is to create a Button component. This will accept two props — isSaving &amp; onClick . The isSaving prop is what will trigger our animation, and this value will be changed using the onClick prop.</p><p>Our Button component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7U9kD55E5VEQTrAi9ig1A.png" /><figcaption>Our gorgeous Button component</figcaption></figure><p>So as you can see in the above code, when the isSaving prop is true we add the class save-animation to our button. This is where the spinner kicks into action and our button text disappears.</p><h4>The Spinner</h4><p>The first step is to animate the width of the button:</p><pre>button.save-animation {<br>  animation: saveAnimation 450ms ease forwards;<br>}</pre><pre>@keyframes saveAnimation {<br>  0% { width: 200px; }<br>  100% { width: 0px;, background: #fff;}<br>}</pre><p>Very simple, we now want to add the spinner (I am far too lazy to copy and paste this in and format it — formatting code on Medium is such a pain!):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*mZOBOwclmzUISvRPqGHEEg.png" /></figure><p>The last step is to create our spinner animation:</p><pre>@keyframes spinner {<br> to { transform: rotate(360deg); }<br>}</pre><p><strong>Conclusion</strong></p><p>That is all there is to it, I left out some parts so I wouldn’t bore you telling you things you can do in your sleep. Now go clap the shit out of that button!!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fupg0i1m4DLe5q%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fupg0i1m4DLe5q%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fupg0i1m4DLe5q%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="327" frameborder="0" scrolling="no"><a href="https://medium.com/media/b89fd1c84b439bc86c7f4c0bf1cbf860/href">https://medium.com/media/b89fd1c84b439bc86c7f4c0bf1cbf860/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e0fa725f0ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding The CSS Values, inherit, initial and unset]]></title>
            <link>https://medium.com/@paulryan17/understanding-the-css-values-inherit-initial-and-unset-c5d890743536?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5d890743536</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[inheritance]]></category>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[scss]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Mon, 01 Oct 2018 19:04:27 GMT</pubDate>
            <atom:updated>2018-10-01T19:04:27.019Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*01UR1Y2IVtH3ArtMs1lvFQ.png" /></figure><p>I will keep this post short, I find that sometimes these values can be over complicated so I am going to keep it simple.</p><h4>Inherit</h4><p><strong>Inherit</strong> is probably the easiest to understand, what it basically says is, ‘<em>I will inherit this value from my parent’</em>.</p><pre>// HTML<br>&lt;div class = &#39;parent&#39;&gt;<br>     &lt;div class = &#39;child&#39;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><pre>/CSS<br>.parent{<br>   background-color: red;<br>}</pre><pre>.child{<br>   background-color:inherit<br>}</pre><p>In the above example, the child will have the background-color:red as it is inheriting this value from it’s parent.</p><p>Totally simples! 👍</p><h4><strong>Initial</strong></h4><p>Initial says, ‘<em>hey just take the browser default for this value</em>’.</p><pre>.text{color:initial} </pre><p>The text class here will have the color <strong>black </strong>as this is the default for the browser.</p><p>If you are interested in what browser defaults there are, then head <a href="https://www.w3schools.com/cssref/css_default_values.asp">here</a>.</p><h4>Unset</h4><p>Unset can sometimes confuse people, but it is really quite simple.</p><p>Unset says, ‘<em>if there is a parent with a matching value, then I will act as inherit, otherwise I will act as initial</em>’.</p><pre>// HTML<br>&lt;div class = &#39;parent&#39;&gt;<br>     &lt;div class = &#39;child&#39;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><pre>/CSS<br>.parent{<br>   background-color: red;<br>}</pre><pre>.child{<br>   background-color:unset; <br>   color: unset;<br>}</pre><p>So this time the child class has two css properties ( background-color&amp; color) , we give these two properties the value of <strong>unset.</strong></p><p>So for the background-color, it will inherit the background-colorfrom it’s parent whereas the colorproperty will be set to the browser default i.e. black as the parent does not have a colorproperty.</p><p>I created the following codepen to showcase this.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FPaulRyan17%2Fembed%2Fpreview%2FMPwZmj%3Fheight%3D600%26slug-hash%3DMPwZmj%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2FPaulRyan17%2Fpen%2FMPwZmj&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fm.cdpn.io%2Fscreenshot-coming-soon-small.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2d2312806c864b6580c6978135274e3/href">https://medium.com/media/b2d2312806c864b6580c6978135274e3/href</a></iframe><h4>Conclusion</h4><p>There you have it, in around 1 minute I have explained these 3 css values and showed just how simple they are.</p><p>I hope you learned you something :).</p><h4>If this helped….</h4><p>If you learned something useful here, you can <a href="http://buymeacoff.ee/X4MKIOW0G">buy me a coffee to keep me well refreshed</a>. If you’re like, ‘<em>fuck that guy, he can buy his own coffee</em>’ , then it be great if you could leave a clap and if you’re like ‘<em>fuck that guy, he can clap for himself</em>’, well then……. fuck you! 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5d890743536" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand Webpack — Taming The Webpack Beast]]></title>
            <link>https://medium.com/@paulryan17/taming-the-webpack-beast-28fad01b2bf4?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/28fad01b2bf4</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Wed, 26 Sep 2018 18:43:48 GMT</pubDate>
            <atom:updated>2018-09-27T12:14:28.790Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dx5J82YUZDvIRdLhVBe_BA.png" /></figure><blockquote>Webpack is like a beast that no-one seems to understand, I decided to challenge this beast and unlock it’s secrets and I am about to share that journey.</blockquote><blockquote>This is Part 1 and it will focus on the basics, this will get you started and Part 2 will get you finished so you too can tame this beast!</blockquote><h4>What is Webpack?</h4><p>Ok I am presuming that the majority reading this article already have a fair idea of what Webpack is so I will keep this short and simple.</p><blockquote>Webpack is a module bundler</blockquote><p>So after that great explanation, let’s get started ✌️</p><h4>Let’s Use Webpack Without A Config File</h4><p>So as many of you may know, you can configure webpack through a webpack.config.js file, but you can also use webpack without this file for bundling your JS.</p><p>Many tutorials at this point will get you to clone a repo, then take you through the different files and get you to install the node modules. I think it is much better to just start off with an empty directory and build out from there so nothing is hidden behind the curtains! 🔍</p><p>So create an empty directory and run npm init , this will create a package.json file for us. Now install webpack &amp; webpack-cli by running npm install -D webpack webpack-cli. In the scripts section in your package.json, add &quot;webpack&quot;: &quot;webpack&quot;.</p><p>Your package.json will now look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9L43QIJL5L0hyOwnLbuG9A.png" /><figcaption>Your gorgeous package.json file with all the sh*t we need</figcaption></figure><p>So before you use webpack, lets create a src directory and add an index.js file, do whatever you want in the index.js file — I will simply add a console.log(&quot;HELLO&quot;) .</p><p>At this point your folder structure should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*dKV7aDaBD6u7r09iYcdL9w.png" /></figure><p>Finally, we can use WEBPACK 😍</p><p>Run npm run webpack and a dist folder will be magically created in your root directory, this is where your JavaScript is bundled.</p><p><strong><em>Why did it go in there? </em></strong>😕<strong><em> Webpack has a couple of defaults that it uses if they are not overridden, so basically it will look for JavaScript in a src directory with an index file, this is the entry file and the output defaults to the dist folder to a file called main.js. Pretty cool that it does this without us telling it to do anything.</em></strong></p><p>So before I bring this section to an end, we will run our bundled JavaScript by running node ./dist/main.js and you will see the following in the console (or whatever you did in your index.js file)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*r1SlrVb2IJVMhi6QE7oGzw.png" /></figure><p>There we go, webpack bundled our code (all without a config) and we were able to run it, this is the core concept of webpack so I think this introduction will serve you well as you continue on in this epic voyage👌</p><h3>Webpack’s 4 Core Concepts</h3><p>So before we get to creating a webpack.config.js file, lets look at the 4 core concepts of Webpack which are:</p><h4><strong>Entry</strong></h4><p>Entry is what we saw above, basically where should Webpack start to build out it’s <strong>dependency graph.</strong></p><p><em>The Dependency Graph is a graph of all the modules your application uses</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7MbtsyKUU3F9o_x9thQ1g.png" /><figcaption>Modules can require other modules — simples</figcaption></figure><p>To change the entry of webpack, simply add this to the config file:</p><pre>// shorthand<br>module<em>.</em>exports = {<br>  entry: ‘./sexyfile.js’<br>}</pre><pre>// longer way<br>module.exports = { <br>   entry: { <br>     main: &#39;./sexyfile.js&#39; <br>   } <br>};</pre><p>This is great when you have an application with a single entry point, but as you can tell it is not very scalable when there are more entry points.</p><p>For more complicated scenarios, such as a Multi Page Application and multiple entry points then check out the <a href="https://webpack.js.org/concepts/entry-points/">docs here.</a></p><h4><strong>Output</strong></h4><p>Output is the second core concept, it tells Webpack where to write the compiled files.</p><p>Simply add the following to the config file to set it’s destination:</p><pre>module.exports = {<br>  output: {<br>    path: &#39;./dist&#39;,<br>    filename: &#39;./sexyoutputfile.js&#39;<br>  }<br>}</pre><p>The output concept is quite simple, for multiple entry points it becomes a little more complicated as you need to make sure each output file has a unique name (we will look at this in Part 2).</p><h4><strong>Loaders</strong></h4><p>The third core concept is Loaders, this is basically a way of saying — ‘<em>Hey webpack, these files are a little funky and I would like to modify them a little before adding them to the dependency graph</em>’</p><p>So take typescript for example, files using typescript will have the .ts extension and webpack will get a little confused with these type of files so we add a <strong>rule.</strong></p><p>A <strong>rule </strong>is an object with two minimum criteria, which are the <strong>test </strong>and <strong>use </strong>property. A rule looks like this:</p><pre>rules: [<br>   {test: \/.ts$/, use: &#39;ts-loader&#39;}<br>]</pre><p>So the test property is a regex - <em>hey webpack if you come across a file with the .ts extension then </em><strong><em>use</em></strong><em> this loader on it. </em><em>ts-loader </em>will convert the TypeScript to JavaScript</p><p>This is an example of one loader, but there is a whole bunch of them, dealing with things like scss , css etc.</p><p><strong>Chaining Loaders</strong></p><blockquote>Chaining loaders is a pretty common pattern, each loader applies its transformations and then passes it to the next loader</blockquote><p>Something interesting I found in the Webpack docs is that when chaining loaders, they execute from right to left so if we have the following:</p><pre>rules: [<br>      {<br>        test: /\.css$/,<br>        use: [<br>          { loader: <a href="https://webpack.js.org/loaders/style-loader">&#39;style-loader&#39;</a> },<br>          {<br>            loader: <a href="https://webpack.js.org/loaders/css-loader">&#39;css-loader&#39;</a>,<br>          },<br>          { loader: <a href="https://webpack.js.org/loaders/sass-loader">&#39;sass-loader&#39;</a> }<br>        ]<br>      }<br>    ]</pre><p>The order of execution here will be — <strong>sass-loader</strong> then <strong>css-loader</strong> and finally <strong>style-loader.</strong></p><p>This is the core idea behind loaders, the Webpack team have made loaders very flexible so you can also add other props like <strong>exlude </strong>or <strong>include </strong>but what we have learned so far is enough to proceed and we will tackle more complex rules in Part 2.</p><h4><strong>Plugins</strong></h4><p>The final concept is <strong>plugins.</strong></p><blockquote>Plugins are the backbone of webpack. webpack itself is built on the same plugin system that you use in your webpack configuration! — webpack docs</blockquote><p>In a nutshell, plugins add extra functionality to Webpack, loaders can’t do everything so plugins come in to save the day!</p><p>An example of a plugin isuglifyjs which will minify your JavaScript.</p><p>There is basically three steps to using a plugin:</p><ol><li>Install the plugin npm install uglifyjs-webpack-plugin -D</li><li>Require the plugin at the top of your config file . const UglifyJsPlugin = require(&#39;uglifyjs-webpack-plugin&#39;);</li><li>Add it to your webpack plugins array by creating a new instance of the plugin</li></ol><p>Your config file will then look like this:</p><pre>// top of config file<br>const UglifyJsPlugin = require(&#39;uglifyjs-webpack-plugin&#39;);</pre><pre>module.exports = {<br>  plugins: [ <br>   new UglifyJsPlugin()<br>  ]<br>}</pre><p>As you can imagine there is a bunch of plugins, and we will go into the more common ones later.</p><p>Whew! 😫</p><p>I know that was a lot of theory but with this core knowledge in our heads it makes the rest of the journey go a lot smoother.</p><h4>Creating A Config File</h4><p>So now let’s start configuring Webpack.</p><p>If you do not have one already, then add a webpack.config.js file to the root of your project.</p><p>We will start off by adding in our module.exports like so (there are other ways of doing this but I like this way):</p><pre>module.exports = () =&gt; { <br>  return {}<br>}</pre><p>So Webpack now has a <strong>mode </strong>option that if emitted will give you a warning like so in the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HvQ0XDMfa6dm-31rkFLJ1A.png" /></figure><p>This can be one of two values, <strong>production </strong>or <strong>development</strong>. When the mode is set to <strong>development, </strong>it will give the best development experience (useful error messages etc) and when it is set to <strong>production, </strong>it will give an optimised production build (small output size etc).</p><p>I won’t go into detail about the idiosyncrasies of both as it is outside the scope of this article but if you would like to know more, the <a href="https://webpack.js.org/concepts/mode/">webpack docs are great</a>.</p><p>The goal we want to achieve is to pass the mode to our config file, we will add two scripts to our package.json like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*iDRHHqf-wCizd4wb6SSBxw.png" /></figure><p>This will pass an env object to our config, so if we were to run npm run dev , we would pass {mode: &#39;development&#39;} to the config file, in order to access this in the config file we need to do the following (the following example uses destructuring):</p><pre>module.exports= ({ mode }) =&gt; {<br>   return {<br>       mode<br>   }<br>};</pre><pre>// equivalent<br>module.exports = (env) =&gt; {<br>return {<br>   mode: env.mode<br> }<br>}</pre><p>And voila 💛 the warning from the console is gone.</p><h4>Adding Plugins so we can start doing stuffs 😍</h4><p>So we talked about <strong>plugins </strong>earlier, we are going to add our first one which is the <strong>HtmlWebpackPlugin</strong>. We first need to add the plugin to webpack, just run npm install -D html-webpack-plugin .</p><p>At the top of our webpack config we will require this plugin like so:</p><pre>const<em> </em>HtmlWebpackPlugin<em> </em>=<em> require</em>(&quot;html-webpack-plugin&quot;);</pre><p>We now can add this plugin to our plugins array:</p><pre>module.exports= ({ mode }) =&gt; {<br>   return {<br>       mode,<br>       <strong>plugins: [new HtmlWebpackPlugin()]</strong>   <br>   },<br>};</pre><p>The <strong>HtmlWebpackPlugin() </strong>will create an index.html file for us and it will insert our bundled js into a script tag.</p><p>To see this in action just run npm run prod and you will now see an index.html file in your dist folder, which should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rVR3YakqZMa8rOb60FPdHg.png" /></figure><p>So now we are in web app land, we have an index.html page and in it we have a link to our bundled JavaScript.</p><h4>Whoa, that’s enough my brain is sore!</h4><p>I think this is a nice point to leave this article, we are now ready to truly start taming Webpack.</p><p>Part 2 will include more goodies such as <strong>webpack-dev-server</strong>, <strong>hot module reload, css, images, common plugins </strong>and <strong>much more!</strong></p><p>If this has helped at all, then leave a clap, also if you want, <a href="http://eepurl.com/dIhJkz">feel free to join my newsletter</a> where I will notify you of any content I share which could range from tech tips to fully fledged articles!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28fad01b2bf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up A VueJS Project From Scratch (Webpack)]]></title>
            <link>https://medium.com/@paulryan17/setting-up-a-vuejs-project-from-scratch-webpack-7ed156ac55d7?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ed156ac55d7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[babel]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuejs-2]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Sat, 12 May 2018 12:47:38 GMT</pubDate>
            <atom:updated>2018-05-12T12:47:38.545Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDWOzEqMuncyTFv1nqupHQ.png" /></figure><p>Nowadays we are blessed with many tools at our disposal, by just running <em>vue init webpack my-project, </em>I will have a vue project with webpack within a matter of seconds. <a href="https://unicode.org/emoji/charts/full-emoji-list.html#1f603">U+1F603</a></p><p>Great, right?</p><p>Overall yes it is great but the issue is so many beginner developers and even some more experienced can start a project like this without actually knowing the tools this gives you and when it comes time to add something they just don’t know where to start <a href="https://unicode.org/emoji/charts/full-emoji-list.html#1f615">U+1F615</a></p><p>So today we will set up a Vue project from scratch including Webpack. This will show us why we use NPM and Webpack in the first place.</p><p>After you have a basic understanding, I would still recommend using scaffolded projects that we create from the command line as they do a lot of work which can be frankly a pain in the ass!!</p><p>So let’s get going!!!</p><p>** please make sure you have node installed to follow this tutorial</p><h3>First Step</h3><p>The first step is creating a folder for our project, the project I will be creating is a MacroNutrient Tracker so this is the name I will give my folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*z8qmThFzte__OFr_O_Sm6g.png" /></figure><p>So as you can see above in my VSCode, I have an empty directory called MacroTracker.</p><p>Now let’s create our index.html page in the root of our directory with the following code:</p><pre>&lt;!-- index.html --&gt;</pre><pre>&lt;!DOCTYPE html&gt;</pre><pre>&lt;html lang=&quot;en&quot;&gt;</pre><pre>&lt;head&gt;</pre><pre>     &lt;meta charset=&quot;UTF-8&quot;&gt;</pre><pre>     &lt;title&gt;MacroTracker&lt;/title&gt;</pre><pre>&lt;/head&gt;</pre><pre>&lt;body&gt;</pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>We can transform this into a Vue application by adding the following to the body</p><pre><br>&lt;!-- index.html --&gt;</pre><pre>&lt;!DOCTYPE html&gt;</pre><pre>&lt;html lang=&quot;en&quot;&gt;</pre><pre>&lt;head&gt;</pre><pre>&lt;meta charset=&quot;UTF-8&quot;&gt;</pre><pre>&lt;title&gt;MacroTracker&lt;/title&gt;</pre><pre>&lt;/head&gt;</pre><pre>&lt;body&gt;</pre><pre><strong>  &lt;div id=&quot;container&quot;&gt;</strong></pre><pre><strong>  {{value}}</strong></pre><pre><strong>  &lt;/div&gt;</strong></pre><pre><strong>   &lt;script        src=&quot;https://cdnjs.cloudflare.com/ajax/libs/vue/0.11.10/vue.min.js&quot;    &gt;&lt;/script&gt;</strong></pre><pre><strong>&lt;script&gt;</strong></pre><pre><strong>   new Vue({</strong></pre><pre><strong>      el: &#39;#container&#39;,</strong></pre><pre><strong>      data: {</strong></pre><pre><strong>           value: &#39;Welcome to Vue!&#39;,</strong></pre><pre><strong>        },</strong></pre><pre><strong>});</strong></pre><pre><strong>&lt;/script&gt;</strong></pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>If we open this file in the browser we will get the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*KuRRLbAiFn80UcjqhJfozA.png" /><figcaption>Our Vue Application Up &amp; Running</figcaption></figure><p>Beautiful, we have now officially began our journey of creating a Vue application, sure its not much so far but taking little steps like this will help us really understand our project architecture.</p><h3>JavaScript Package manager</h3><p>So if you are just coming into web development, you may ask what is a package manager?</p><p>So first, a package is a piece of software you can use in your project, there are literally thousands of packages from things like date pickers to Javascript frameoworks (like Vue).</p><p>In the last section we used the following code:</p><pre>&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/vue/0.11.10/vue.min.js&quot;&gt;&lt;/script&gt;</pre><p>Our package here is the vuejs library, frontend projects have come a long way and require many more dependencies so we needed a better way to manage our packages and along came NPM (there was others before but NPM is now the most used although Yarn is gaining popularity).</p><p>So a package manager will let us manage our packages and easily update and remove them if we so wish.</p><p>Getting started with npm is simple, navigate to your project using the command line and run</p><pre>$ npm init</pre><p>You will be now asked questions, all the defaults are fine so just keep pressing enter.</p><p>We now have a package.json file in the root of our project which should look something like this:</p><pre>{</pre><pre>   &quot;name&quot;: &quot;macrotracker&quot;,</pre><pre>   &quot;version&quot;: &quot;1.0.0&quot;,</pre><pre>   &quot;description&quot;: &quot;&quot;,</pre><pre>   &quot;main&quot;: &quot;index.js&quot;,</pre><pre>   &quot;scripts&quot;: {</pre><pre>      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;</pre><pre>   },</pre><pre>   &quot;author&quot;: &quot;&quot;,</pre><pre>    &quot;license&quot;: &quot;ISC&quot;</pre><pre>}</pre><p>Believe it or not we now have our package manger set up, not too bad eh?</p><h3>Adding Dependencies</h3><p>So since we took all that effort to set up our package manager, we should actually use it and add some dependencies.</p><p>Since we are developing a Vue project, the first dependency we will add will be VueJS</p><p>To add Vue just ran the following command in the CMD</p><pre>$ npm install vue --save</pre><p>So what has just happened?</p><p>Vue has been added to our package.json file like so:</p><pre>&quot;dependencies&quot;: {</pre><pre>    &quot;vue&quot;: &quot;^2.5.16&quot;</pre><pre>}</pre><p>We also have a new directory called <em>node_modules</em>, this is where all our packages will be kept (so handy).</p><p>We could link to Vue in our index.html like this:</p><pre><strong>&lt;script src=&quot;node_modules/vue/dist/vue.min.js&quot;&gt;&lt;/script&gt;</strong></pre><p>But you may be thinking, ‘isn’t it a pain in the ass to have to map directly to the location of each dependency’ and yes you would be right in thinking that, so the next step is getting the beast that is Webpack introduced!</p><h3>Say Hi to Webpack</h3><p>Webpack is a module bundler and what this means is it will bundle all our modules into just one file that we will link to in our index.html.</p><p>So like Vue, Webpack is a dependency that we must install in order to use it:</p><pre>$ npm install webpack --save-dev</pre><p>This looks different to our last npm install , the param --save-dev means that we want to add this dependency to our dev dependencies, which are dependences we need for our development environment but not for production.</p><p>So now let’s create an index.js file with the following:</p><pre>//index.js</pre><pre>import Vue from &#39;vue&#39;;</pre><pre>new Vue({</pre><pre>el: &#39;#container&#39;,</pre><pre>data: {</pre><pre>value: &#39;Hello From Vue Again&#39;</pre><pre>}</pre><pre>});</pre><p>The next step is to create a webpack.config.js file, this is what we use to tell webpack what it should do:</p><pre>const HtmlWebPackPlugin = require(&#39;html-webpack-plugin&#39;);</pre><pre>const htmlPlugin = new HtmlWebPackPlugin({</pre><pre>template: &#39;./src/index.html&#39;,</pre><pre>filename: &#39;./index.html&#39;</pre><pre>});</pre><pre>module.exports = {</pre><pre>// This is the &quot;main&quot; file which should include all other modules</pre><pre>entry: &#39;./index.js&#39;,</pre><pre>module: {</pre><pre>rules: [</pre><pre>{</pre><pre>test: /\.js$/,</pre><pre>exclude: /node_modules/,</pre><pre>use: {</pre><pre>loader: &#39;babel-loader&#39;</pre><pre>}</pre><pre>}</pre><pre>]</pre><pre>},</pre><pre>resolve: {</pre><pre>alias: {</pre><pre>vue: &#39;vue/dist/vue.js&#39;</pre><pre>}</pre><pre>},</pre><pre>plugins: [htmlPlugin]</pre><pre>};</pre><p>You may be quite confused right now but this is a minimal webpack set up and is actually quite readable.</p><p>At the top we are using the HTML plugin which will create a index.html file in our dist folder which will be the root of our project.</p><p>Next we say where we want webpack to start in our project, this is the file where we would do all of our imports so Webpack will bundle everything we need.</p><p>Finally we add rules which in our case is saying we want to use babel on any file that ends in .js, babel allows us to use ES6 features which are not supported across all browsers. At the end we add in an alias which is needed to get Vue to work (don’t ask my why as I do not know :/)</p><p>So we now need to go to our package.json and make it match the following, I bolded anything new added in:</p><pre>{</pre><pre>&quot;name&quot;: &quot;macrotracker&quot;,</pre><pre>&quot;version&quot;: &quot;1.0.0&quot;,</pre><pre>&quot;description&quot;: &quot;&quot;,</pre><pre>&quot;main&quot;: &quot;index.js&quot;,</pre><pre>&quot;scripts&quot;: {</pre><pre>&quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,</pre><pre><strong>&quot;start&quot;: &quot;webpack --mode development&quot;,</strong></pre><pre><strong>&quot;build&quot;: &quot;webpack --mode production&quot;</strong></pre><pre>},</pre><pre>&quot;author&quot;: &quot;&quot;,</pre><pre>&quot;license&quot;: &quot;ISC&quot;,</pre><pre>&quot;dependencies&quot;: {</pre><pre>&quot;vue&quot;: &quot;^2.5.16&quot;</pre><pre>},</pre><pre>&quot;devDependencies&quot;: {</pre><pre><strong>&quot;babel-core&quot;: &quot;^6.26.3&quot;,</strong></pre><pre><strong>&quot;babel-loader&quot;: &quot;^7.1.4&quot;,</strong></pre><pre><strong>&quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,</strong></pre><pre><strong>&quot;html-webpack-plugin&quot;: &quot;^3.2.0&quot;,</strong></pre><pre>&quot;webpack&quot;: &quot;^4.6.0&quot;,</pre><pre><strong>&quot;webpack-cli&quot;: &quot;^2.1.3&quot;,</strong></pre><pre><strong>&quot;vue-template-compiler&quot;: &quot;^2.5.13&quot;,</strong></pre><pre><strong>&quot;vue-loader&quot;: &quot;^14.1.1&quot;</strong></pre><pre>}</pre><pre>}</pre><p>So we added a bunch of dev dependencies which helps us to use Vue and Webpack together, we also added into two useful scripts we can use so Webpack can work it’s magic for us.</p><p>We now will change our index.html file to look like the following:</p><pre>&lt;!-- index.html --&gt;</pre><pre>&lt;!DOCTYPE html&gt;</pre><pre>&lt;html lang=&quot;en&quot;&gt;</pre><pre>&lt;head&gt;</pre><pre>     &lt;meta charset=&quot;UTF-8&quot;&gt;</pre><pre>     &lt;title&gt;MacroTracker&lt;/title&gt;</pre><pre>&lt;/head&gt;</pre><pre>&lt;body&gt;</pre><pre>     &lt;div id=&quot;container&quot;&gt;</pre><pre>           {{value}}</pre><pre>       &lt;/div&gt;</pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>If you now run npm install and then npm run start , you will now have a dist folder with an index.html file and also a main.js file.</p><p>If you simply drag the index.html file into the browser you should see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*Ug9Jtl34vWjD4oTb1l4XOQ.png" /></figure><p><strong>Conclusion</strong></p><p>Ok this was a lengthy tutorial but we have went through most of the tools for modern Frontend Web Development. Has it become more complicated? Yes but it is also much more powerful.</p><p>Webpack can be confusing but it offers so much and normally you would not configure it by hand, instead you would use the great vue cli which will generate a perfect config for you for both development and production.</p><p>Thanks for reading and I hope you learned something.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ed156ac55d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HIGHER ORDER FUNCTIONS IN 1 MINUTE]]></title>
            <link>https://medium.com/@paulryan17/higher-order-functions-in-1-minute-6820df20a6ba?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/6820df20a6ba</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[higher-order-function]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Fri, 11 May 2018 21:20:33 GMT</pubDate>
            <atom:updated>2018-05-12T11:21:05.811Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*koquk27gTTc01Jv6yEK8lg.png" /></figure><p><strong>What are Higher Order Functions?</strong></p><p>The first time I heard someone say ‘Higher Order Function’, I imagined it was some incredibly complex topic only the programming elite understood.</p><p>Even with the fear, I decided to challenge myself and learn this incredibly difficult subject, I realised very early on in my journey that Higher Order Functions although sounding fancy are actually incredibly simple.</p><p>They can actually be summed up in just one line which is:</p><blockquote>A Higher Order Function is a function which accepts another function as a parameter</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*Uj0dR7-SkUdB39LyV6rnwQ.png" /></figure><p>As you can see above I am passing a <em>function to my function which I decided to call operation.</em></p><p><strong>Learn By Example</strong></p><p>Ok so let’s do an example to really understand why Higher Order Functions are useful.</p><p>Let’s create an array of numbers</p><pre>let myNumbers = [1,2,3,4,5]</pre><p>So let’s write a function to add 1 to each of the numbers in our array</p><pre>function addOne(nums){return nums.map(num =&gt; return num+1)}</pre><p>This function will return us a new array where each number will be one higher than our original array.</p><p>So now we decide we want to square each number in the array</p><pre>function squareNum(nums){return nums.map(num =&gt; return num * num)}</pre><p>You can see we have basically wrote the same as our previous function with the one change being that we are now squaring the number.</p><p>Wouldn’t it be better if we could just reuse our code for looping over the numbers and instead pass an operation to our function that we want to carry out on each number?</p><p>This is where Higher Order Functions come into play.</p><p>I have created the following fiddle which shows the implementation of this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjsfiddle.net%2FPaulRyan17%2Fxgu14qco%2Fembedded%2F&amp;url=https%3A%2F%2Fjsfiddle.net%2FPaulRyan17%2Fxgu14qco%2F&amp;image=https%3A%2F%2Fwww.gravatar.com%2Favatar%2Fa71f1d047dce7357bd30daf28cdc9a75%2F%3Fdefault%3D%26s%3D120&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/a76cbe7a2a41fbfa66c936835f116320/href">https://medium.com/media/a76cbe7a2a41fbfa66c936835f116320/href</a></iframe><p>You can see in the above example, we first create our operations which are add, squared and minus,</p><p>We then create a Higher Order Function that is passed an array of numbers and an operation to carry out on each number.</p><p>We then just call our function which returns a new array that was ran through the operation we passed (above we passed the add operation to increment each number).</p><p>So let’s explain the <em>carryOutSomeMathsOnNumbers </em>(yes I know what a long function name but hey it’s descriptive)<em> </em>function. So like our examples above we loop through each element in our nums array, but this time we use our operation to change the number so in the above example we would increment each value.</p><p>This makes the function much more generic and reusable and we can keep creating new operations while keeping the code in this function the same.</p><p>That is the beauty of passing functions around!</p><h3>Conclusion</h3><p>Believe it or not you now have a clear understanding of Higher Order Functions.</p><p>The beauty of Javascript is that functions are first class objects and we can pass them around very easily between methods which makes it great for functional programming.</p><p>I hope you learned something.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6820df20a6ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ES6 JavaScript Class vs Pseudoclassical JavaScript — Dog Example]]></title>
            <link>https://medium.com/@paulryan17/es6-javascript-class-vs-pseudoclassical-javascript-dog-example-a6b2e5b8b089?source=rss-c23e1d013b34------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6b2e5b8b089</guid>
            <category><![CDATA[ecmascript]]></category>
            <category><![CDATA[pseduoclassical]]></category>
            <category><![CDATA[class]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Paul Ryan Codes]]></dc:creator>
            <pubDate>Tue, 01 May 2018 15:31:24 GMT</pubDate>
            <atom:updated>2018-05-01T15:35:38.308Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*voLrhj3RN0p43aehaiVLrQ.png" /></figure><p>I was recently taking a course on Frontend Masters and one of the topics was Object Oriented JavaScript. I decided to write this tutorial to show you the difference in writing a modern JavaScript class using the class keyword and writing a Javascript class the older way.</p><h3>Pseudoclassical JavaScript</h3><p>Writing a pseudoclassical class is actually quite simple, we just need to create a function like so</p><pre>let Dog = function(species){this.species = species}</pre><p>Here we have created what is known as a <strong>constructor </strong>to create something, in our case it is a constructor to create a <strong>Dog. </strong>The constructor also takes an argument which will be a <strong>property for each instance of Dog</strong>.</p><p>We also want our dog to be able to do something so we add a method to the dog as follows:</p><pre>Dog.prototype.bark = function(numberOfBarks){console.log(`I am a ${this.species} and I am barking ${numberOfBarks} times`)}</pre><p>So the bit here you’re probably looking at is the <strong>prototype </strong>keyword, <strong>prototype </strong>is an object where we attach our methods, what we are saying here is that we want each <strong>instance </strong>of the Dog class to be able to bark.</p><p>You may also ask, <strong>why didn’t we just put the method in the constructor?</strong> <br> 😕</p><p>If we were to put the method in the constructor, we would create a new method for every instance of Dog, what we actually want is just one method that every dog uses and we achieve this by using the <strong>prototype keyword.</strong></p><p>So let’s create an instance of our Dog class:</p><pre>let greyHound = new Dog(&#39;greyHound&#39;)</pre><p>We have now created an instance of our Dog class called greyHound and we have also set the <strong>species </strong>of the Dog instance to be <strong>greyHound</strong>.</p><p>We can call the bark method as follows:</p><pre>greyHound.bark(50);</pre><p>This will return:<br><em>I am a greyHound and I am barking 50 times</em></p><p>A common mistake that can be made here is doing the following:</p><pre>Dog.prototype.bark = (numberOfBarks)=&gt; {<em>&lt;same code as above&gt;</em>}</pre><p>Yes this looks neater because we are using an ES6 fat arrow function but <strong>this </strong>will not reference the object now, it will instead reference the <strong>window object</strong>.</p><p>Why? The <strong>this </strong>keyword always references the owner of the function it is in, arrow functions lexically bind their context so <strong>this </strong>actually refers to the originating context which in our case would be the window object.</p><p>So that is how we create a JavaScript class the Pseudoclassical way, so now let’s look at how to create a class the ES6 way.</p><h3>ES6 JavaScript Class</h3><p>If you have a Java/C# background then I think you will feel more at home here.</p><p>So again let’s create a <strong>Dog class</strong></p><pre>class Dog{constructor(species){this.species = species}}</pre><p>So you see this time we use the <strong>class </strong>keyword to define our class, we also add in a special function called <strong>constructor </strong>where we define our properties.</p><p>So as a little challenge, I would like you to add the bark method to this class.</p><p>*********************************************************** solution below ****************************************************************************</p><p>Adding a method to a class is simple, we just have to do the following:</p><pre>class ES6Dog {<br>    constructor(species) {<br>        this.species = species;<br>    }<br>    bark(numberOfBarks) {<br>      console.log(`I am a ${this.species} and I am barking ${numberOfBarks} times`);<br>    }<br>}</pre><p>We do not use the function keyword, we just add a method called bark which like above takes an argument and logs some output.</p><p>We create an instance of this exactly the same way as above</p><pre>let greyHound = new Dog(&#39;greyHound&#39;)</pre><p>We also invoke our instance’s method the same way</p><pre>greyHound.bark(50);</pre><p>This will give the same output as above.</p><p><strong>Conclusion</strong></p><p>As you can see, creating a JavaScript class using ES6 is easier and in my opinion it looks much neater (bear in mind I do come from a Java background), although you will still see the older way in many libraries you may use so its good to have an understanding.</p><p>I hope you enjoyed this article and learned something. 😊</p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6b2e5b8b089" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>