<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: 🧸 🏳️‍🌈 cooper-codes  💻 🎮</title>
    <description>The latest articles on DEV Community by 🧸 🏳️‍🌈 cooper-codes  💻 🎮 (@coopercodes).</description>
    <link>https://dev.to/coopercodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F161541%2F04a3db3b-d9e5-488b-b77c-486f2140dcb7.jpg</url>
      <title>DEV Community: 🧸 🏳️‍🌈 cooper-codes  💻 🎮</title>
      <link>https://dev.to/coopercodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coopercodes"/>
    <language>en</language>
    <item>
      <title>Gratitude</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Fri, 29 Jan 2021 04:02:07 +0000</pubDate>
      <link>https://dev.to/coopercodes/gratitude-2hn0</link>
      <guid>https://dev.to/coopercodes/gratitude-2hn0</guid>
      <description>&lt;p&gt;&lt;a href="https://images.unsplash.com/photo-1503980599186-9cc36eda351a?ixid=MXwxMjA3fDB8MHxzZWFyY2h8MTB8fGdyYXRpdHVkZXxlbnwwfHwwfA%3D%3D&amp;amp;ixlib=rb-1.2.1&amp;amp;auto=format&amp;amp;fit=crop&amp;amp;w=500&amp;amp;q=60"&gt;image unsplash&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Good day friends
&lt;/h2&gt;

&lt;p&gt;Recently I have been blessed with a great new role, in a brand new industry, at an amazing company full of exceptional people with some life-changing business practices, and it is one of these practices that I would like to share.&lt;/p&gt;

&lt;p&gt;It is a small practice that kicks off our daily stand-up of practicing gratitude, and I was wildly unprepared for the ways this small element of our daily meeting would impact my life.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what of this process of gratitude?
&lt;/h2&gt;

&lt;p&gt;Practicing gratitude is about thankful appreciation for what an individual receives, be it tangible or intangible, according to the Harvard Medical Centre.&lt;/p&gt;

&lt;p&gt;In my own research, there are lots of ways people practice gratitude, usually by keeping a journal, &lt;a href="https://www.happify.com/hd/the-science-behind-gratitude/"&gt;an interesting one&lt;/a&gt; was writing one on a piece of paper every day and putting it in a jar and reading them on New Years to celebrate the year (something I am considering).&lt;/p&gt;

&lt;p&gt;But in relation to work, it is only a few mins introduction to the daily standup, where you start with one thing you are grateful for.&lt;/p&gt;

&lt;p&gt;There is no right or wrong answer and sometimes they are more personal and sometimes they're very simple, one morning I was thankful for Berocca after a rough night's sleep because it helped pep me up, but it has to be genuine.&lt;/p&gt;

&lt;h2&gt;
  
  
  How has it affected me?
&lt;/h2&gt;

&lt;p&gt;It started off small, I wanted to have a genuine gratitude to discuss in the morning so I was participating and carving out my own space in the team, I’d been a wallflower in previous organisations and I didn't want to make that mistake again.&lt;/p&gt;

&lt;p&gt;One of the immediate benefits I noticed was how quickly I build a rapport with the team, every morning as we each opened up with a gratitude I am actively listening to the things each found joy in and more often than not would find a connection with their gratitude, connections form quickly as it creates a genuine bond.&lt;/p&gt;

&lt;p&gt;Given we are all still working remotely at this time, and only just starting to trickle back into the office, this is quite a testament to the power of how it connects even total strangers and closes that digital distance gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it evolved.
&lt;/h2&gt;

&lt;p&gt;Even as I started by initially ‘preparing’ gratitude in the evening, this practice continued, but I'm not ‘preparing’ anymore, I am reflecting, reflecting on the day and what I have achieved, how I connected with my partner, the cute bursts of energy my cat has that endlessly entertain me, the food I had for lunch and what I may add to it next time to change it up.&lt;/p&gt;

&lt;p&gt;The daily gratitude process has created a cyclical buildup of positivity that has been gradually elevating my self-worth, and as it climbs I find my gratitudes are getting deeper and increasingly personal.&lt;/p&gt;

&lt;p&gt;2020 has been a tragic year for so many, it was also an exceptionally dark place for me, there were times I wondered if it was ever going to get better or if I would even survive it. But just a month later of twice-daily gratitudes and self-reflection has decreased my anxiety (or increased my ability to cope with anxiety, I feel there is an important distinction in there).&lt;/p&gt;

&lt;p&gt;There have been quite a few things over the last year that I've been repressing due to the lack of personal strength in facing them, but as I feel more confident each day in the things I am grateful for these scary dark parts are getting less daunting and I'm afforded the strength to deal with them.&lt;/p&gt;

&lt;p&gt;All of this has just come from a daily 5 min exercise of reflecting on moments I am grateful for.&lt;/p&gt;

&lt;h1&gt;
  
  
  And this is where I come to the important part.
&lt;/h1&gt;

&lt;p&gt;This article hasn't been for some self-therapy (although therapeutic it has been), I have borne a bit of my soul here because I would love to help share the impact, and it doesn't really come across without demonstrating the benefits I have received.&lt;/p&gt;

&lt;p&gt;I hope that after the terrible time that was 2020, this might be able to positively impact other people's lives, it may help someone build up confidence, or maybe your workplace is moving to a remote space and you want to try something to maintain a connection with your team and positively impact morale.&lt;/p&gt;

&lt;p&gt;I won't sit here and say it's a total solution, it might not work for everyone or every team, but I can assure you that if practiced consistently and properly I’d be shocked if you saw no results at all.&lt;/p&gt;

&lt;p&gt;I suggest giving it a go for a month, I highly recommend introducing it into your team meetings as this will amplify the effects in a shared social setting, and I would be extremely keen to hear back if it worked, what you tried, and what you did differently.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is next?
&lt;/h2&gt;

&lt;p&gt;Well, I have some ideas, I would like to bring my partner along on this journey to engage on a deeper level, the glass jar idea from the beginning of the article sounds great, I thought about creating a website and tracking my daily gratitudes (so basically a tech-heads journalling).&lt;/p&gt;

</description>
      <category>gratitude</category>
      <category>teambuilding</category>
      <category>positivity</category>
    </item>
    <item>
      <title>A11y :~ Alert</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Fri, 22 Jan 2021 04:08:22 +0000</pubDate>
      <link>https://dev.to/coopercodes/a11y-alert-dgj</link>
      <guid>https://dev.to/coopercodes/a11y-alert-dgj</guid>
      <description>&lt;p&gt;&lt;a href="https://unsplash.com/photos/vpOeXr5wmR4" rel="noopener noreferrer"&gt;Image from Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  intro
&lt;/h3&gt;

&lt;p&gt;Hi Friends!&lt;/p&gt;

&lt;p&gt;Welcome to the first blog in my accessibility series, where I will delve into the deep and nitty-gritty details of various ARIA features (as many as I can, if not all).&lt;/p&gt;

&lt;h3&gt;
  
  
  why
&lt;/h3&gt;

&lt;p&gt;Well, firstly, why not! Accessibility is a human right on the internet and it is our role as developers to ensure we aren't gatekeeping people out, it's discrimination for us to not do everything we can and utilise the tools available to us to get it right.&lt;/p&gt;

&lt;p&gt;Let's not be Dominos, who took a visually impaired man to the Supreme Court because they didn't want to make the site accessible, I mean WTF 🤷‍♂️ that is not cool '&lt;a href="https://www.cnbc.com/2019/10/07/dominos-supreme-court.html" rel="noopener noreferrer"&gt;source&lt;/a&gt;'.&lt;/p&gt;

&lt;p&gt;BTW, I buy much MUCH less dominos because of this.&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA" rel="noopener noreferrer"&gt;ARIA&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  what is it?
&lt;/h3&gt;

&lt;p&gt;ARIA is an acronym for Accessible Rich Internet Applications and is used by developers to create content that is accessible for assistive technology.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Alert_Role" rel="noopener noreferrer"&gt;ARIA Alert&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;MDN docs state that the alert role is used to provide the user with important, and usually time-sensitive, information, and often to tell the user an element has been dynamically updated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcgbwp1lnhvuv9ozb763x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcgbwp1lnhvuv9ozb763x.png" alt="list of different alerts"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/howto/howto_js_alert.asp" rel="noopener noreferrer"&gt;Image Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We use these all the time, they're great at popping up on the screen, grabbing the users attention to alert them of a message we want to display in a timely manner.&lt;/p&gt;

&lt;p&gt;Well, what happens if we don't provide an ARIA role to identify that? The message gets lost, Assistive Technology doesn't understand the importance.&lt;/p&gt;

&lt;p&gt;So this is when we use an ARIA alert &lt;code&gt;role="alert"&lt;/code&gt; within the content.&lt;/p&gt;
&lt;h3&gt;
  
  
  Impportant stuff
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is important to note, the alert must be placed &lt;strong&gt;within&lt;/strong&gt; the content for the Assistive Technology to identify the alert properly, if not the focus will not move to the alert and it will get missed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be very careful to not have alerts trigger too close to each other, it can get messy and will create a terrible and confusing user experience.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Show me some code
&lt;/h1&gt;

&lt;p&gt;So how can we set this up?&lt;/p&gt;

&lt;p&gt;We can use CSS styles to trigger an alert, &lt;code&gt;display: none&lt;/code&gt; hides the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element form the document, the moment we remove &lt;code&gt;display: none&lt;/code&gt; from the element, the alert role gets picked up by Assistive Technologies and read.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;role=&lt;/span&gt;&lt;span class="s"&gt;"alert"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"display: none;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;I'm an ALERT.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or in the codepen example, we can inject the alert into the document ensuring we set the attributes with &lt;code&gt;setAttribute("role", "alert");&lt;/code&gt;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  What's next?
&lt;/h3&gt;

&lt;p&gt;Thanks for taking a moment to read my intro to Accessibility with the Alert Role.&lt;/p&gt;

&lt;p&gt;Next up is the Application Role, this one is a bit more in-depth, so I look forward to bringing you that one soon.&lt;/p&gt;

&lt;p&gt;As I am still really new with Accessibility I encourage dialogue, if there is something missing or I've made a mistake please let me know and I will review edit, or add to the article.&lt;/p&gt;

&lt;p&gt;References: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/TR/wai-aria-1.1/#alert" rel="noopener noreferrer"&gt;W3C - Alert&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitala11y.com/" rel="noopener noreferrer"&gt;Digital A11y&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA" rel="noopener noreferrer"&gt;MDN Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/default.asp" rel="noopener noreferrer"&gt;W3S&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.accessibility-developer-guide.com/" rel="noopener noreferrer"&gt;Accessibility Developer Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>a11y</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Grace Papers work update</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Mon, 18 Jan 2021 21:06:09 +0000</pubDate>
      <link>https://dev.to/coopercodes/grace-papers-work-update-3335</link>
      <guid>https://dev.to/coopercodes/grace-papers-work-update-3335</guid>
      <description>&lt;h1&gt;
  
  
  Hi family
&lt;/h1&gt;

&lt;p&gt;Welcome back fam, it has been a few months since I have blogged, and for good reason.&lt;/p&gt;

&lt;p&gt;In the wake of the disaster that was 2020, I managed to find myself a dream role as a developer.&lt;/p&gt;

&lt;h1&gt;
  
  
  Organisation
&lt;/h1&gt;

&lt;p&gt;It couldn't have been a better fit from the get-go.&lt;/p&gt;

&lt;p&gt;The organisation is called &lt;a href="https://www.gracepapers.com.au/"&gt;Grace Papers&lt;/a&gt;, and we are committed to fighting gender discrimination, by working with governments and corporations to improve their employment practices to support people returning to work after having children, driving inclusion in the workplace, and instilling practices that will help retain talent through nurturing and supporting employees.&lt;/p&gt;

&lt;p&gt;It just couldn't have been more perfect, and it made 2020 worth the wait.&lt;/p&gt;

&lt;h1&gt;
  
  
  Tech &amp;amp; Learning
&lt;/h1&gt;

&lt;p&gt;The stack is a fresh React front-end and a Laravel back-end, and I plan to do a lot of regular blogging as I learn and skill up.&lt;/p&gt;

&lt;p&gt;My two main focuses will be &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;A11y ~ as we build the front-end in React I am committed to ensuring it is built with Accessibility in mind first, not as something we will add later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Laravel/PHP ~ the rest of my blogs will be about my learning path in the back-end.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Well, stay tuned I have my first A11y post coming tonight ot tomorrow morning.&lt;/p&gt;

</description>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Set-up Tailwind in a Next.JS app</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Fri, 16 Oct 2020 04:08:46 +0000</pubDate>
      <link>https://dev.to/coopercodes/set-up-tailwind-in-a-next-js-app-2dg7</link>
      <guid>https://dev.to/coopercodes/set-up-tailwind-in-a-next-js-app-2dg7</guid>
      <description>&lt;h1&gt;
  
  
  Welcome
&lt;/h1&gt;

&lt;p&gt;Hey, fam!&lt;/p&gt;

&lt;p&gt;It's ya boi Coops back with another article, recently I've been playing around in Next.js and freakin loving it so I wanted to share the love.&lt;/p&gt;

&lt;p&gt;I won't be building styles with it, that's coming in a future article.&lt;/p&gt;

&lt;p&gt;Today is just about the setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create New Next App
&lt;/h3&gt;

&lt;p&gt;It may seem obvious, but the best place I find to start is at the beginning.&lt;/p&gt;

&lt;p&gt;So let's create that shiny new project, I use Yarn these days, I've found it is faster and have only once needed to use NPM as one library wasn't supported.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $ yarn create next-app &amp;lt;project-title&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we have the launchpad setup, I like to do a safety check just to make sure it was created properly, if it's a package its checking the -version to ensure it's installed.&lt;/p&gt;

&lt;p&gt;But for a new project I like to kick off the server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $ yarn dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I call this a safety check because if you create a new app, start building and then something hasn't installed properly it can cause elevated heart rates and sometimes unsafe environments for technology within arms reach (haha!).&lt;/p&gt;




&lt;p&gt;We should then have a folder structure like the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root-folder
 &amp;gt; .next
 &amp;gt; node_modules
 &amp;gt; pages
    ├── api
    │   └── hello.js
    ├── _app.js
    └── index.js
 &amp;gt; public
    ├── favicon.ico
    └── vercel.svg
 &amp;gt; styles
    ├── globals.css
    └── Home.modules.css
 ─ .gitignore
 ─ package.json
 ─ README.md
 ─ yarn.lock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I won't be going over what files and folders do what, that is definitely for another lesson as I absolutely 💜 💜 💜 Next.JS and have a deep dive planned soon.&lt;/p&gt;




&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Firstly let's remove all our CSS imports at the beginning of the file, and anything in the code with styles reference &lt;code&gt;className={styles.&amp;lt;style&amp;gt;}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As this page is being rebuilt I am more likely to just delete all the code and start fresh anyway, but each to their own.&lt;/p&gt;

&lt;p&gt;Then kick off by installing the package&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $ yarn add --save-dev tailwindcss postcss-preset-env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember to follow that up with your version check to ensure we don't have any gotchya creep up later on&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $ yarn -v tailwind
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I know most of you don't do this, but that's because you've probably not been caught out for 30 mins wondering why code doesn't work only to find out that the package didn't install.&lt;/p&gt;

&lt;p&gt;As the docs say 'Now the fun begins!'&lt;/p&gt;

&lt;p&gt;Initialise tailwind with the NPX command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    npx tailwindcss init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(at this stage I'm not sure about yarn with NPX use, although I am investigating and if you know the answer do leave a comment below)&lt;/p&gt;

&lt;p&gt;Once that has run, we need to create ourselves the &lt;code&gt;postcss.config.js&lt;/code&gt; file in the root of our directory.&lt;/p&gt;

&lt;p&gt;We should be left with something like this now&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root-folder
 &amp;gt; .next
 &amp;gt; node_modules
 &amp;gt; pages
    ├── api
    │   └── hello.js
    ├── _app.js
    └── index.js
 &amp;gt; public
    ├── favicon.ico
    └── vercel.svg
 &amp;gt; styles
    ├── globals.css
    └── Home.modules.css
 ─ .gitignore
 ─ package.json
 ─ postcss.config.js
 ─ README.md
 ─ yarn.lock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in &lt;code&gt;postcss.config.js&lt;/code&gt; add&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tailwindcss&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;postcss-preset-env&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then clear out the &lt;code&gt;styles/globals.css&lt;/code&gt; file we don't need those anymore, and replace with the Tailwind imports&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And delete the &lt;code&gt;Home.module.css&lt;/code&gt; file completely.&lt;/p&gt;




&lt;p&gt;And for the setup of Tailwind in a Next.JS app thats completed!&lt;/p&gt;

&lt;p&gt;If you &lt;code&gt;yarn dev&lt;/code&gt; and run the server you'll notice your app defaults to a styleless app and this is where I say &lt;strong&gt;HERE COMES THE &lt;em&gt;FUN&lt;/em&gt; PART&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But wait there's more... but I am saving the actual Tailwind magic for another article.&lt;/p&gt;

&lt;p&gt;This was built with the guidance of &lt;a href="https://dev.to@jamesqquick"&gt;James Q Quick&lt;/a&gt; and his soothing southern accent.&lt;/p&gt;

&lt;p&gt;As well as the guidance of the &lt;a href="https://tailwindcss.com/"&gt;Tailwind docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>tailwindcss</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>object-orientated programming - an intro.</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Tue, 29 Sep 2020 09:26:40 +0000</pubDate>
      <link>https://dev.to/coopercodes/object-orientated-programming-an-intro-1g62</link>
      <guid>https://dev.to/coopercodes/object-orientated-programming-an-intro-1g62</guid>
      <description>&lt;p&gt;Hi fam and welcome back to another blog.&lt;/p&gt;

&lt;p&gt;Recently I was in a situation where I needed to describe some OOP fundamentals, and it had been so long that I'd actually coded strictly in OOP that I decided it was time for a refresher.&lt;/p&gt;

&lt;p&gt;Bare with me, the code examples I use will be templates and I've deliberately chosen to leave the methods empty, so use your imagination we should be able to work out what they return by the naming conventions 😇.&lt;/p&gt;

&lt;h1&gt;
  
  
  Functional programming
&lt;/h1&gt;

&lt;p&gt;So for comparison, what is OOP up against? That would primarily be functional programming.&lt;/p&gt;

&lt;p&gt;Functional programming is defined by two definitions&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It's deterministic: it will return the same result given the same arguments.&lt;/li&gt;
&lt;li&gt;It doesn't cause any observable side effects, ie modifying a global object passed by reference.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I won't go too deep here as we're discussing OOP and just wanted to give a comparison, but this is a topic I will probably discuss at a later date.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is OOP?
&lt;/h1&gt;

&lt;p&gt;OOP is a programming design model designed around objects, which themselves contain their own data in the form of fields and methods to operate the functions on that data.&lt;/p&gt;

&lt;p&gt;Most commonly OOP is arranged around Classes that create instances of objects to interact with other classes.&lt;/p&gt;

&lt;p&gt;So where functional programming can be considered smaller contained programs that return different results given data, OOP is an object that represents the stuff it and contains its own data structures, operating rules and mutates its own state/data.&lt;/p&gt;

&lt;h1&gt;
  
  
  The big 4
&lt;/h1&gt;

&lt;p&gt;While different OOP languages do mention more, there are 4 main principles of OOP, &lt;strong&gt;encapsulation&lt;/strong&gt;, &lt;strong&gt;abstraction&lt;/strong&gt;, &lt;strong&gt;inheritance&lt;/strong&gt; and &lt;strong&gt;polymorphism&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's dive straight into it with encapsulation and a little bit of code!&lt;/p&gt;

&lt;h2&gt;
  
  
  Encapsulation
&lt;/h2&gt;

&lt;p&gt;Wikipedia states that encapsulation is the bundling of data within the methods that operate on that data, meaning encapsulation is a nice way of controlling the data within a class to external objects.&lt;/p&gt;

&lt;p&gt;From within the class, we can use Getters and Setters to set the rules of what fields can be viewed/accessed and what data (if any) can be modified.&lt;/p&gt;

&lt;p&gt;Encapsulation adds security to the code itself and allows us to define what we want to be available and to what.&lt;/p&gt;

&lt;p&gt;Let's look at some code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Teacher&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Declare protected (private) fields&lt;/span&gt;
    &lt;span class="nx"&gt;_attendance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;birthday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subjects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;grades&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nx"&gt;showGrades&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Getter&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;calcGrades&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nx"&gt;showGrades&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Calculate grades formula&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;rollCall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Roll Call!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;updateAttendance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// add a day to the attendance days&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_attendance&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;teacherOne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Teacher&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cooper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;01/01/1984&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;teacherOne&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;showGrades&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, showGrades() is prefaced with get, and the get is calling set showGrades(grades) where all the work is being performed.&lt;/p&gt;

&lt;p&gt;This is extended upon in Abstraction.&lt;/p&gt;




&lt;h2&gt;
  
  
  Abstraction
&lt;/h2&gt;

&lt;p&gt;Abstraction shares similarities with Encapsulation, in an attempt to alleviate large unwieldy codebases and to improve maintainability, Abstraction is splitting large objects down into much smaller ones.&lt;/p&gt;

&lt;p&gt;For example, a car, when we start a vehicle we use the key, as we turn the key and the motor starts, all the inner operations of why that car starts are abstracted away behind the key turn object.&lt;/p&gt;

&lt;p&gt;We don't need to know all the inner workings of why the car started, it just did.&lt;/p&gt;




&lt;h2&gt;
  
  
  Inheritance
&lt;/h2&gt;

&lt;p&gt;Inheritance is a way to reuse objects and cut down on excess code when two objects share features.&lt;/p&gt;

&lt;p&gt;Take our Teacher and Student object for example, and while they have differences like date-of-birth, grades, etc, a Student has grades and a subjects field but a teacher wouldn't (or not in the same capacity, but more on that later).&lt;/p&gt;

&lt;p&gt;Well, Inheritance would be a swift way to incorporate all the shared fields from Teacher without having to duplicate everything.&lt;/p&gt;

&lt;p&gt;Let's look at some code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Teacher&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Declare protected (private) fields&lt;/span&gt;
    &lt;span class="nx"&gt;_attendance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;birthday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subjects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;grades&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nx"&gt;showGrades&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Getter&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;calcGrades&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nx"&gt;showGrades&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Calculate grades formula&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;rollCall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Roll Call!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;updateAttendance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// add a day to the attendance days&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_attendance&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Child class Student, inherits from parent Teacher&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Student&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Teacher&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;skipClass&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// additional method for Student child class&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I missed the bus&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;studentOne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Student&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cooper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;01/01/1984&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;studentOne&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rollCall&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see from the example, Student doesn't contain rollCall, but as Student class inherited from the parent Teacher class, we can create an instance of Student and call the roleCall method.&lt;/p&gt;

&lt;p&gt;TaDaa sweet huh&lt;/p&gt;




&lt;h2&gt;
  
  
  Polymorphism
&lt;/h2&gt;

&lt;p&gt;Probably the most complex of them all, but let's break it down.&lt;/p&gt;

&lt;p&gt;Polymorphism is the ability of an object to take many forms, or in a more readable term, it allows us to use a class like its parent so there are no mixups with data types, and each child class can implement its own version of the method.&lt;/p&gt;

&lt;p&gt;For example, our Teacher class has grades, and our Student class also inherits grades, but the student calculation of grades would be different from how a teacher would calculate grades, this is where Polymorphism comes in.&lt;/p&gt;

&lt;p&gt;Polymorphism means we can create different methods for the derived classes, and through Inheritance, objects can override the shared parent method with child-specific behaviors.&lt;/p&gt;

&lt;p&gt;Using rollCall as a code example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Teacher&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Declare protected (private) fields&lt;/span&gt;
    &lt;span class="nx"&gt;_attendance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;birthday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subjects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;grades&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;rollCall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Roll Call!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;updateAttendance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// add a day to the attendance days&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_attendance&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Child class Student, inherits from parent Teacher&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Student&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Teacher&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subjects&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;grades&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;rollCall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Here, teacher.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;studentOne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Student&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cooper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;01/01/1984&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;studentOne&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rollCall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Here&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;teacher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our example, both the Teacher and Student use the rollCall() method, but it would require different outcomes, a teacher would call for attendance and a student would reply.&lt;/p&gt;

&lt;p&gt;Polymorphism means that we can inherit a method from a parent class but also change it to suit our needs.&lt;/p&gt;

&lt;p&gt;This is one of those awesome rabbit hole moments that I could potentially do down for days, but hopefully, you get the idea.&lt;/p&gt;




&lt;p&gt;Well, I hope you enjoyed this recap on OOP as much as I did, if there are any further things you'd like to point out feel free to let me know.&lt;/p&gt;

&lt;p&gt;I am a big fan of constructive feedback as I start to blog more and more.&lt;/p&gt;

&lt;p&gt;Peace out!&lt;br&gt;
Coops&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>oop</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript Functions: a breakdown.</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Wed, 26 Aug 2020 11:14:43 +0000</pubDate>
      <link>https://dev.to/coopercodes/javascript-functions-a-breakdown-i4</link>
      <guid>https://dev.to/coopercodes/javascript-functions-a-breakdown-i4</guid>
      <description>&lt;p&gt;Welcome back Fam!&lt;/p&gt;

&lt;p&gt;Today I wanted to create a blog to break down the different types of JavaScript functions in the most basic terms.&lt;/p&gt;

&lt;p&gt;When I was first starting to code the MDN docs confused me most of the time, so this will be part of an ongoing series into the core fundamentals of JavaScript written by someone who didn't come from a CompSci background.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is a &lt;em&gt;Function&lt;/em&gt;
&lt;/h1&gt;

&lt;p&gt;That's right, we need to start from the beginning!&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;&lt;em&gt;function&lt;/em&gt;&lt;/strong&gt; is the very building block of coding, and whether it is JavaScript or Java you're going to want to get acquainted with the fundamentals of the fundamentals.&lt;/p&gt;

&lt;p&gt;In JavaScript (like most languages) a function is a block of code that performs a task or returns a value, one good thing to note at this point is a function should do that, perform one function (but that's a debatable story for another time).&lt;/p&gt;

&lt;p&gt;But to make it a bit more interesting, JavaScript has evolved and has quite a few different ways to declare and use them, so let's start.&lt;/p&gt;




&lt;h1&gt;
  
  
  Function Declaration
&lt;/h1&gt;

&lt;p&gt;I will start with a Function Declaration because it comes first, and I mean that because a Function Declaration gets hoisted the moment the program is compiled.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hoisting&lt;/em&gt; you ask? hoisting is the way JavaScript allocates functions to memory and in what order, and this is a topic worth exploring on its own and &lt;a href="https://flaviocopes.com/javascript-hoisting/"&gt;this article&lt;/a&gt; explains it well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function funcName(withParams) {
  // params can be declared, but are not enforced;
};

function funcName() {
  // without declared params;
};

funcName();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Syntax: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;starts with 'function'&lt;/li&gt;
&lt;li&gt;followed by the name &lt;/li&gt;
&lt;li&gt;with optional params, if you don't declare params, you can still pass them though and they'll be accessed with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments"&gt;arguments&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;invoked by calling the function name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The reason a Function Declaration gets hoisted first is that as it compiles, JavaScript looks for the declarations starting with 'function', makes sense, huh, this then hoists all those declarations to the top of the pile.&lt;/p&gt;

&lt;p&gt;This can lead to some gotcha moments though that we should be aware of, mainly that if a program is compiled and a Function Declaration gets invoked before the Function Declaration is hoisted.&lt;/p&gt;




&lt;h1&gt;
  
  
  Function Expressions
&lt;/h1&gt;

&lt;p&gt;A Function Expressions is where an anonymous function is assigned to a variable(var/let/const)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const funcName = function() {
  // do something;
};

funcName();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Syntax:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;starts with the name declared in a variable&lt;/li&gt;
&lt;li&gt;function() assigned to the variable&lt;/li&gt;
&lt;li&gt;params operate the same way&lt;/li&gt;
&lt;li&gt;invoked the same way&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Function Expressions are not hoisted, so this would prevent those icky instances of a Function Expressions getting invoked before it gets hoisted and stashed in memory.&lt;/p&gt;

&lt;p&gt;P.S. while Function Expressions are not hoisted the &lt;strong&gt;VAR&lt;/strong&gt; declaration IS, so if you declare a function with &lt;strong&gt;VAR&lt;/strong&gt; it will be hoisted.&lt;/p&gt;

&lt;p&gt;But wait,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t98MBe8p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/syeg02mi0rlunw87c4s1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t98MBe8p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/syeg02mi0rlunw87c4s1.jpg" alt="Yoda Quote 'there is another'"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it's called a &lt;strong&gt;&lt;em&gt;Named Function Expression&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const funcName = function yoda(){
  // do something
};

typeof yoda; // -&amp;gt; "undefined"
funcName(); // -&amp;gt; "function"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So why do this right? as Yoda is 'undefined' when we checked the type, the bonus with a named function expression is the name is recognised within the function itself and can help dramatically when debugging as the name will show up in your call stack, whereas an anonymous function wouldn't show up in the stack.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const funcName = function yoda(param) {
  console.log(typeof yoda === 'function'); // -&amp;gt; true
  return typeof param;
}

funcName(3);     // -&amp;gt; 'number'
funcName.name;   // -&amp;gt; 'yoda'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So as you level-up it might be worth considering if &lt;strong&gt;&lt;em&gt;Named Function Expressions&lt;/em&gt;&lt;/strong&gt; are for you?&lt;/p&gt;




&lt;h1&gt;
  
  
  Arrow Functions
&lt;/h1&gt;

&lt;p&gt;Ahh Arrow Functions, everyone's new favourite addition to ES6.&lt;/p&gt;

&lt;p&gt;Arrow Functions are a Syntactic extension of Function Expressions, utilising what we call a fat arrow (or I prefer to call a rocket), and it can be constructed in a few different ways.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// -&amp;gt; no params
const funcName = () =&amp;gt; {
  // do something;
};

// -&amp;gt; one param
const funcName = param =&amp;gt; {
  // if one param the brackets arent needed;
};

// -&amp;gt; more than one param
const funcName = (paramOne, paramTwo, paramThree) =&amp;gt; {
  // but if more than one they are required;
};

// -&amp;gt; if the function is simple enough it can be simplified to a single line, removing the need for brackets after the rocket.
const funcName = (x, y) =&amp;gt; x * y;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Like with all our functions so far there are some times when Arrow Functions, so let's go over a few of these gotchas.&lt;/p&gt;

&lt;h3&gt;
  
  
  It gets funky with This
&lt;/h3&gt;

&lt;p&gt;Wes Bos can probably do a way better at explaining this, with &lt;a href="https://wesbos.com/arrow-functions-this-javascript/"&gt;this&lt;/a&gt;.&lt;br&gt;
As he does such a good job I'll phone a friend and leave you to review that article rather than repeat.&lt;/p&gt;
&lt;h3&gt;
  
  
  Constructors
&lt;/h3&gt;

&lt;p&gt;Arrows Functions can't be used as constructors, therefore 'New' cant be invoked with an Arrow Function.&lt;/p&gt;
&lt;h3&gt;
  
  
  Object literals
&lt;/h3&gt;

&lt;p&gt;And the final sticky part ill cover is object literals, due to the syntax Arrow Functions can't decipher them, for example.&lt;/p&gt;

&lt;p&gt;An ES5 object literal would operate like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const setColour = function (colour) {
    return {value: colour}
};

let backgroundColour = setColour('Blue');
backgroundColour.value; // -&amp;gt; "Blue"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But since the Arrow Functions use the curly braces by default, they can't differentiate between a block scope and an object literal and would result in an error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const setColour = colour =&amp;gt; {value: colour };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But this can be overcome but wrapping them as such.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const setColour = colour =&amp;gt; ({value: colour });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Immediately Invoked Function Expressions(IIFE)
&lt;/h1&gt;

&lt;p&gt;As the name does suggest, this is a function that is invoked the moment it is defined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function () {
    // do something;
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one looks a bit weirder, but it is just an anonymous function wrapped in brackets and invoked immediately after.&lt;/p&gt;

&lt;p&gt;They can be handy as they're invoked immediately, and not hoisted into the global scope (and this could be considered pollution), they cannot be expressed with a Rocket.&lt;/p&gt;

&lt;p&gt;As they are invoked due to the compile process, they do not need a name, but they can be given one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(function funcName() {
  // do something;
})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are plenty of bonus features with IIFE but I will point you to an amazing &lt;a href="https://medium.com/@vvkchandra/essential-javascript-mastering-immediately-invoked-function-expressions-67791338ddc6"&gt;article&lt;/a&gt; that covers all those quite clearly.&lt;/p&gt;




&lt;p&gt;Well, I hope you liked the article if you reached this far a like or a share would be lovely if you were so inclined.&lt;/p&gt;

&lt;p&gt;I will be back soon with some more JavaScript-related content.&lt;/p&gt;

&lt;p&gt;Much luv&lt;br&gt;
Coops&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building the React Scaffolding from scratch</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Tue, 18 Aug 2020 03:52:00 +0000</pubDate>
      <link>https://dev.to/coopercodes/building-a-react-app-from-scratch-1h</link>
      <guid>https://dev.to/coopercodes/building-a-react-app-from-scratch-1h</guid>
      <description>&lt;p&gt;Welcome, Fam!&lt;/p&gt;

&lt;p&gt;While I originally planned to do a fair bit more blogging it's been a roller-coaster ride the last 6 months, stepping into the C# world spending some time with a company working on an older asp.net application.&lt;/p&gt;

&lt;p&gt;As I find myself gravitating back to React, I realised 🤔... I'd forgotten so much! and since I dropped off just before Hooks became so stable/adopted, I recognized very little JSX code anymore.&lt;/p&gt;

&lt;p&gt;So back on the horse I go! but this time if I was going back to the start it wasn't going to be from 'create-react-app' scaffolding, I wanted to level up my knowledge and learn from the ground up.&lt;/p&gt;

&lt;p&gt;And I felt it was worth a blog, so if you are relatively new to React or haven't built a project from scratch this article might be for you.&lt;/p&gt;

&lt;p&gt;The most surprising part really is just how easy this was!&lt;/p&gt;




&lt;h3&gt;
  
  
  Setting up the folder structure and web-server.
&lt;/h3&gt;

&lt;p&gt;First off we need to create a few folders and get the HTML file running with the web-server.&lt;/p&gt;

&lt;p&gt;I like to get this running and make sure there aren't any critical issues (I try and identify known issues early and weed them out).&lt;/p&gt;

&lt;p&gt;In the root project create a Public file and an HTML document, this will be the entry point for our React app.&lt;/p&gt;

&lt;p&gt;But while we're at it, I like to just create the skeleton structure (and if you've started a react app before it should be pretty familiar).&lt;/p&gt;

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

    &amp;lt;!-- Folder Structure --&amp;gt;

root-folder/
    ├── public/
    │   ├── scripts/
    │   │   └── app.js
    │   └── index.html
    └── src
        └── app.js



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

&lt;/div&gt;

&lt;p&gt;Once that is done add your basic HTML page, my emmet creates this for me automatically if I start an empty HTML page with the character '!', but if you don't have the emmet plugin it should look something like this (get emmet too).&lt;/p&gt;

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

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;There are two more things required in the HTML page to get React to run (ok so three), the script tags in the body, and the div attribute that acts as the injection point.&lt;/p&gt;

&lt;p&gt;In the body add a div with an id attribute of "app", the two unpkg.com script links in Part 2 of the &lt;a href="https://reactjs.org/docs/add-react-to-a-website.html" rel="noopener noreferrer"&gt;React instructions&lt;/a&gt; page, and finally a script tag with a source that points to the app.js in the scripts folder.&lt;/p&gt;

&lt;p&gt;But before we run off, above the div with the id of 'app' and just for testing purposes add some text in that body so that we know everything is working when the page loads.&lt;/p&gt;

&lt;p&gt;So your body should look like this...&lt;/p&gt;

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

&amp;lt;body&amp;gt;
    Test Text
    &amp;lt;div id="app"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin&amp;gt;&amp;lt;/script&amp;gt;
   &amp;lt;script src="/scripts/app.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;Head back to your command line and while &lt;strong&gt;ensuring you are pointing to the root folder&lt;/strong&gt;, we want to kick-off our packages.&lt;/p&gt;

&lt;p&gt;Now I am using Yarn in this instance, basically, as I have always used NPM I wanted to try something a bit different, but all commands can easily be replicated in NPM.&lt;/p&gt;

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

    $ yarn global add live-server


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

&lt;/div&gt;

&lt;p&gt;const postScript = (hol-up-a-min moment) =&amp;gt; { &lt;br&gt;
Yes, I am aware there is a live server extension in VS Code, but I am backing up and going manual right now.  The point of manually creating what can be done in scaffolding is to get a better understanding of how things work at the root level.&lt;br&gt;
return 'Back to the regular program'&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;After I install something with Yarn/NPM I always like to check installs properly with a package version check, for live-server it's&lt;/p&gt;

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

    $ live-server -v


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

&lt;/div&gt;

&lt;p&gt;This will give you the version number, or an error, and I'd rather locate the error now than have to debug and find it later.&lt;/p&gt;

&lt;p&gt;Now to kick off live-server and see our HTML page simply run live-server and the target folder, in my case&lt;/p&gt;

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

    live-server public


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

&lt;/div&gt;

&lt;p&gt;This will find the index.html page and whatever you wrote in the body will display as text on the page.&lt;/p&gt;

&lt;p&gt;SUCCESS, we have our live-server setup (you are now free to remove the Test Text from the page).&lt;/p&gt;




&lt;h3&gt;
  
  
  Babel + JSX
&lt;/h3&gt;

&lt;p&gt;If you aren't aware of &lt;a href="https://babeljs.io/" rel="noopener noreferrer"&gt;Babel&lt;/a&gt; or what it does, that's OK we're all here to learn (and tbh I only knew OF it before I went down this lesson too).&lt;/p&gt;

&lt;p&gt;Babel is a JavaScript compiler that React uses to compile JSX down to browser-friendly JavaScript.&lt;/p&gt;

&lt;p&gt;const postScript = (hol-up-a-min moment) =&amp;gt; { &lt;br&gt;
I am assuming you know what &lt;a href="https://reactjs.org/docs/introducing-jsx.html" rel="noopener noreferrer"&gt;JSX&lt;/a&gt; is and I wasn't planning on covering that here, if not it's a JavaScript Syntax Extension that I like to call ReactScript it's a combination of JS+XML.&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;So let's add see what Babel does by adding some JSX, in the script/app.js file we need to add 3 things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;JSX&lt;/li&gt;
&lt;li&gt;The document element: this is the div in our HTML page that react uses as the injection point.&lt;/li&gt;
&lt;li&gt;ReactDOM.render(): is the method that takes our JSX code and the HTML injection point and creates the magic, more info can be found &lt;a href="https://reactjs.org/docs/react-dom.html#render" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

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

    const template = (
    &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;React from Scratch&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;Thanks for reading my article&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
    );

    const appRoot = document.getElementById("app");

    ReactDOM.render(template, appRoot);


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

&lt;/div&gt;

&lt;p&gt;Making sure live-server is running, what happens without Babel?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8lyw7fwksm91i9gsza11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8lyw7fwksm91i9gsza11.png" alt="React without Babel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This doesn't give us much of an explanation, but basically what's happening, is the browser is unable to decypher the JSX encryption.&lt;/p&gt;

&lt;p&gt;So let's add Babel!&lt;/p&gt;

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

    $ yarn global add babel-cli


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

&lt;/div&gt;

&lt;p&gt;And check the install just to be sure&lt;/p&gt;

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

    $ babel --version


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

&lt;/div&gt;

&lt;p&gt;Next, the project needs to be initialised, so run the init command and cycle through the project initiation questions (I'm also assuming I don't need to explain this process).&lt;/p&gt;

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

    $ yarn init

    name (application name):
    version (1.0.0):
    description:
    entry point (index.js):
    repository URL:
    author:
    license (MIT):


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

&lt;/div&gt;

&lt;p&gt;This will generate your package.json file.&lt;/p&gt;

&lt;p&gt;Then we need to install the two Babel packages that will convert the JSX&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://babeljs.io/docs/en/babel-preset-react" rel="noopener noreferrer"&gt;babel-preset-react&lt;/a&gt;: As the title suggests, this is the React specific extension.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://babeljs.io/docs/en/babel-preset-env" rel="noopener noreferrer"&gt;babel-preset-env&lt;/a&gt;: env is the magic that manages which type of JavaScript the JSX gets compiled down to, so the magic basically.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Add these with:&lt;/p&gt;

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

    $ yarn add babel-preset-react babel-preset-env


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

&lt;/div&gt;

&lt;p&gt;Once you see that's completed your folder structure should now look like this.&lt;/p&gt;

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

root-folder/
    ├── node_modules
    ├── public/
    │   ├── scripts/
    │   │   └── app.js
    │   └── index.html
    ├── src
    │   └── app.js
    ├── package.json
    └── yarn.lock


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

&lt;/div&gt;




&lt;h3&gt;
  
  
  Running the project
&lt;/h3&gt;

&lt;p&gt;Finally, we need to invoke Babel.&lt;/p&gt;

&lt;p&gt;Grab all the code that is in the scripts/app.js folder and move that to src/app.js, the reason for this is src/app.js is where we write all the JSX and the scripts/app.js folder is where Babel compiles the readable JavaScript to that gets injected into the HTML.&lt;/p&gt;

&lt;p&gt;In a new Command Window pointed to the project root folder (leave live-server running in another), we need to invoke summon that Babel magic with 3 inputs (and one option to make your life easier)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The JSX file that needs to be read (src/app.js).&lt;/li&gt;
&lt;li&gt;The out file where babel compiles the JS to (public/scripts/app.js).&lt;/li&gt;
&lt;li&gt;The presets required (env + react).&lt;/li&gt;
&lt;li&gt;A watch flag to refresh the page on each save (--watch)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These commands according to my file structure, would look like this:&lt;/p&gt;

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

    $ babel src/app.js --out-file=public/scripts/app.js --presets=env,react --watch


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

&lt;/div&gt;

&lt;p&gt;With this, we have now created the (basic) boilerplate of a React app, from here it's up to you to create and add the packages as you go along.&lt;/p&gt;




&lt;p&gt;Well, I'll leave it there short and sweet! &lt;/p&gt;

&lt;p&gt;Next steps will involve adding webpack later down the road and I'm sure there'll be a blog on that too!&lt;/p&gt;

&lt;p&gt;Signing off for now...&lt;/p&gt;

&lt;p&gt;Cooper 🍕 🍺 🍔 🍶&lt;/p&gt;

</description>
      <category>react</category>
      <category>babel</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building an A4 resume to add to your website (and making it printable)</title>
      <dc:creator>🧸 🏳️‍🌈 cooper-codes  💻 🎮</dc:creator>
      <pubDate>Tue, 18 Feb 2020 10:48:26 +0000</pubDate>
      <link>https://dev.to/coopercodes/building-an-a4-resume-to-add-to-your-website-and-making-it-printable-1la8</link>
      <guid>https://dev.to/coopercodes/building-an-a4-resume-to-add-to-your-website-and-making-it-printable-1la8</guid>
      <description>&lt;p&gt;Hi, and welcome to my first ever blog post.&lt;/p&gt;

&lt;p&gt;I'm Cooper, a developer from Melbourne that recently started looking for a new job, so while I am redesigning and building a new Portfolio Website I thought I'd share some knowledge.&lt;/p&gt;

&lt;p&gt;One of the main goals was to build a resume into my website, but one that would be in the A4 format, making it easier for potential recruiters or employers to save as a PDF or print off (for those truly retro organisations).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; if you just want to see the &lt;a href="https://github.com/CoopsCodes/resume" rel="noopener noreferrer"&gt;code&lt;/a&gt; repo, or visit the published site it's &lt;a href="https://coopscodes.github.io/resume/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I recently learned a bit of SASS so I've used that, nested styles alone worked wonders rather than having to class up every individual div, so SASS is bae 💁🏼‍♀️.&lt;/p&gt;

&lt;p&gt;Once it was built I transposed it to my Svelte portfolio, I won't go into detail there but I will cover the Gotcha later on that tripped me up for a few hours.&lt;/p&gt;

&lt;p&gt;First things first, you need to create the page template, in your HTML body create a container div (I called mine resumeCanvas, but you do you), in the SCSS we create a canvas to paint our masterpiece on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fj2tyjse6m632txxwrgru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fj2tyjse6m632txxwrgru.png" alt="Canvas"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So what's happening here?&lt;/p&gt;


&lt;li&gt; Box-sizing - border-box we ensure everything stays within the chosen dimensions. 
&lt;/li&gt;
&lt;li&gt; Margin - at 0 and auto sets everything to the center.
&lt;/li&gt;
&lt;li&gt; Padding - this one sets 0.3 of an inch between the border and the insides, you can add a bit more like maybe 0.5 but I ended up shortening it because I ran out of enough room in the end.
&lt;/li&gt;
&lt;li&gt; Width &amp;amp; Height - these are the important ones, I did a bit of research and got the Width &amp;amp; Height for an A4 page (ok there might be a slight discrepancy but it won't matter when we set print properties).
&lt;/li&gt;
&lt;li&gt; Background-color - this should be white, you could make this any colour you want but remember it should be made with printing in mind so try not to think dark mode here.
&lt;/li&gt;
&lt;li&gt; Box-shadow - this give a nice little grey outline on the webpage to differentiate itself from the background page.


&lt;h1&gt;
  
  
  grid me
&lt;/h1&gt;

&lt;p&gt;Great! at this point, we have a nice little A4 sized page, now how do we fill it?&lt;/p&gt;

&lt;p&gt;Well as we are using a fixed size that isn't designed to be responsive and we need a layout, a grid is the perfect solution...&lt;/p&gt;

&lt;p&gt;Grid you say...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Think I just heard a collective sigh&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Well, don't worry my friend because there is a superstar out there called &lt;a href="https://twitter.com/sarah_edo?s=20" rel="noopener noreferrer"&gt;Sarah Drasner&lt;/a&gt; (who also has an amazing &lt;a href="https://sarah.dev/" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt;), that created a &lt;a href="https://cssgrid-generator.netlify.com/" rel="noopener noreferrer"&gt;grid template generator site&lt;/a&gt; just for us.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fabaoytvjoh938z9kxfj2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fabaoytvjoh938z9kxfj2.png" alt="grid maker"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see above, I went for the header for my name, a left panel for all the guts, and a right panel to display all the links (this I later changed to a set pixel length as I found things moved around as I sorted out the canvas width and height over the time of the project).  But however you want to layout your project, this is how you do it.&lt;/p&gt;

&lt;p&gt;Now go on and click that &lt;strong&gt;Please may I have some code&lt;/strong&gt; button, and get that cheddar 🧀.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4mhn6cw15by4nnxllyor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4mhn6cw15by4nnxllyor.png" alt="grid code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I went on and renamed parent to gridParent, div1 to titleHeader, div2 to leftSummary and div3 to rightInfo just to help myself from getting confused. Naming conventions and all that.&lt;/p&gt;

&lt;p&gt;Pop that into your CSS/SCSS file and create those divs in the HTML file and you're all set up to fill your HTML file with your resume data.&lt;/p&gt;

&lt;p&gt;This is the fun part 🙊 and I'll leave that part up to you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhzbnprp5kuzhsxlw2ltp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhzbnprp5kuzhsxlw2ltp.jpeg" alt="spongebob 'several days later' meme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I won't lie, that part takes some time, not just the words but also some styling, since I hate boring black and white documents I added in some rainbow interactive elements on hover, but these won't show when a document is printed out.&lt;/p&gt;




&lt;p&gt;At this stage when you have your page generated and run your OS's print command you should have a perfectly A4 sized PDF/Print page.&lt;/p&gt;

&lt;p&gt;And it was perfect, till I transposed it into my Svelte app, then I had all sorts of problems as it didn't just grab the desired div, it started cropping from the top left-hand corner of the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzx806fa3z3welaruf093.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzx806fa3z3welaruf093.png" alt="print offset"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where I learned about the print media query, and this can be done two ways but the other was a lot more heavy-handed for what I was trying to achieve.&lt;/p&gt;

&lt;p&gt;By adding the  tag into your header you can create a whole different stylesheet, this would be good if you wanted to design a pretty website style resume and then have the alternate code in that style sheet that would only display when it was called to be printed off (and I'll explore this option later).&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;link rel="stylesheet" type="text/css" href="print.css" media="print"&amp;gt;


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

&lt;p&gt;But since I just wanted to print it off as is we just add the &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/media"&gt;@media&lt;/a&gt; print {}&lt;/strong&gt; block in the &lt;strong&gt;&lt;/strong&gt; section or CSS/SCSS file of the Svelte page, and target the parent div class (what I renamed resumeCanvas) and it ignores everything higher up the tree.&lt;/p&gt;

&lt;p&gt;The other little gotcha I mentioned earlier was getting the formatting right once I transposed everything to my Svelte app, and thanks to another CSS superstar &lt;a href="https://twitter.com/rachelandrew?s=20" rel="noopener noreferrer"&gt;Rachel Andrew&lt;/a&gt; (&lt;a href="//rachelandrew.co.uk"&gt;website&lt;/a&gt;), I &lt;a href="https://www.smashingmagazine.com/2015/01/designing-for-print-with-css/" rel="noopener noreferrer"&gt;read&lt;/a&gt; that the page needs to be defined according to the dimensions we set in the Canvas, as demonstrated in the code below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdsuolyxp5zjgkxhowux8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdsuolyxp5zjgkxhowux8.png" alt="print media code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Setting &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/page"&gt;@page&lt;/a&gt; { size: 8.5in 12in; }&lt;/strong&gt; to match made it fit like a glove.&lt;/p&gt;




&lt;p&gt;At this stage, I can't yet link the Svelte app as it's still under construction, but when it's ready it'll replace my current &lt;a href="https://cooper-codes.dev/" rel="noopener noreferrer"&gt;website&lt;/a&gt;, so maybe keep checking back.&lt;/p&gt;

&lt;p&gt;If there are any questions, or if I could've done anything better, reach out to me.&lt;/p&gt;


&lt;/li&gt;

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