<?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 Sarah Rivas on Medium]]></title>
        <description><![CDATA[Stories by Sarah Rivas on Medium]]></description>
        <link>https://medium.com/@sarah.r.rivas?source=rss-1360a053e0af------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QuCd7pZxm6w6K8g7NiNVFQ.jpeg</url>
            <title>Stories by Sarah Rivas on Medium</title>
            <link>https://medium.com/@sarah.r.rivas?source=rss-1360a053e0af------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:04:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sarah.r.rivas/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[React Components Made Simple]]></title>
            <link>https://medium.com/@sarah.r.rivas/react-components-made-simple-a4d348a5e47a?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4d348a5e47a</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Wed, 10 Oct 2018 03:52:53 GMT</pubDate>
            <atom:updated>2018-10-10T04:14:21.622Z</atom:updated>
            <content:encoded><![CDATA[<p>React is designed around the concept of simple and reusable components. After having learned Vanilla JavaScript and having to constantly update innerText or appendChild(), the manner in which React components simply updated and re-rendered themselves was otherworldly! Let’s dive into a React component and make one ourselves.</p><h3>Setting Up Your Component</h3><p>Components are defined as classes or functions. A functional component is the simplest form of a component and is also often known as a presentational component. The function component receives an object of properties which are passed down as props. Like the functional component, the class component also receives props, but it can also consider a private internal state. We will touch upon this in the next section.</p><p>Something else to note for both functional and class components are that the names generally start with a capital letter, which allows us to identify the React elements versus the HTML elements, which are lowercased.</p><p>When defining a React Component class, you need to extendReact.Component and set up the render() method, which is the only required method in a class component. Implementing therender() method takes in data and returns what should be displayed to the page. This data can be accessed by render() via this.props. For example, let’s say we want to set up a message in our UI that tells the person what they’ve ordered and that their order is coming up. Our component would look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bed1171e12d70a0b88191db20e1f64ed/href">https://medium.com/media/bed1171e12d70a0b88191db20e1f64ed/href</a></iframe><p>As you can see, the render() method returns some JSX code. To familiarize yourself with JSX syntax, check out this really useful <a href="https://reactjs.org/docs/introducing-jsx.html">introduction</a>.</p><h3>Components with State</h3><p>In addition to being able to taking props, components can also maintain their own internal state data, which is accessed by this.state. Any change to the component’s state data will re-render the component automatically. Changes to the state can be triggered by event listeners or other functions with access to the component. Class components can only change their internal state, but not their properties.</p><p>In order to set up the state object, we first need to initialize it inside a constructor function of the class. The constructor function will receive a props object and call the super method to inherit from the component. Say we wanted to add state to our FlavorPicker. We want to keep an internal state object that will track if the customer has paid or not, so that the message will only show once the customer has paid.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84cef3827b3ef29d426c2e65b0fa6d8d/href">https://medium.com/media/84cef3827b3ef29d426c2e65b0fa6d8d/href</a></iframe><p>In this case, we added the key paid to our state object and set it to false, so that it is set to false by default and changes to true once the cashier has pressed the paid button. As soon as the cashier hits the paid button, an event listener will prompt a change to the state by using this.setState(). Upon the change of state, the component will automatically re-render and showcase our message to the customer. Magical isn’t it?!</p><p>For a deeper dive into React components and other examples, I found the <a href="https://reactjs.org/">React</a> documents to be extremely useful! Try out the tutorials and behold the power of React!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4d348a5e47a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using FormData Objects]]></title>
            <link>https://medium.com/@sarah.r.rivas/using-formdata-objects-3bca92a8b6c5?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bca92a8b6c5</guid>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Wed, 03 Oct 2018 03:55:00 GMT</pubDate>
            <atom:updated>2018-10-03T04:45:58.181Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, while building a React-Redux and Ruby on Rails backend, I came across an issue with regards to Active Storage photo uploads. While having used Active Storage in the past with Ruby frontend and Rails backend was relatively simple due to the form view, implementing this on the React side took a little more research!</p><p>After setting up <a href="https://github.com/rails/rails/tree/master/activestorage">Active Storage on the backend</a>, I came across FormData objects! These objects let you compile a set of key/value pairs to send using <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequest</a> and is intended for sending form data. This is exactly what I needed for the submission of my form, which included the picture upload.</p><p>Let’s take a look at how to build your FormData objects yourself:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/227a3f28a53eba3a53def284359bc778/href">https://medium.com/media/227a3f28a53eba3a53def284359bc778/href</a></iframe><p>In the code snippet above, we set a new variable equal to new FormData(),which creates the FormData object. Once the object has been created, you can append the form fields individually. Once all form fields have been appended to data, it will be passed along as the body within our fetch request, as you can see on line 14.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bca92a8b6c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Promises in JavaScript]]></title>
            <link>https://medium.com/@sarah.r.rivas/promises-in-javascript-61e59bedf59?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/61e59bedf59</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Tue, 25 Sep 2018 17:21:16 GMT</pubDate>
            <atom:updated>2018-09-25T17:21:16.697Z</atom:updated>
            <content:encoded><![CDATA[<p>Promises are incredibly useful in JavaScript and help you handle asynchronous calls. Promises are objects and return the value of the completion or failure to complete of the asynchronous operation. Although promises can be a bit tricky to understand at first, but they provide a much cleaner way of handling async calls compared to the pre-ES6 methods of handling them via callbacks.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FIl1dji926Y7qo%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fpromise-Il1dji926Y7qo&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FIl1dji926Y7qo%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/210086dba5d2f91e817dd463f4e319ad/href">https://medium.com/media/210086dba5d2f91e817dd463f4e319ad/href</a></iframe><p>A promise object has two internal properties:</p><ol><li>State- the initial value is “pending” and after the operation completes, it changes to either “fulfilled” or “rejected”. If rejected, it returns the message provided, if any.</li><li>Result- the initial value is “undefined” and after the operation completes, it changes to the value of the operation executed or error if the promise was “rejected”.</li></ol><p>An important thing to note is promises can only succeed or fail once. They cannot switch state or fail/succeed twice. If you do add a callback to the promise, the correct callback will be called even though the event took place at some point earlier.</p><p>Callbacks will not be called before the completion of the current run of the event loop and callbacks for both success and failures are optional, so you can just add a callback for the success or failure case only. Once a promise is settled, its value cannot change. Note that the value can be undefined.</p><p>Let’s take a look at what a promise looks like!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/168805d6fd23ae484308e179b575b802/href">https://medium.com/media/168805d6fd23ae484308e179b575b802/href</a></iframe><p>Every promise must supply a standard .then() method. Multiple .then() can be used on the same promise to chain or aggregate callbacks and every callback is executed one after another, in the order they appear. Each .then() returns a new promise, which passes on the value to the callback in the next .then(). Since each .then() returns new promises, it is pretty difficult to control the behavior of errors along the process.</p><p>For deeper dive into promises, check these awesome resources out:</p><ul><li><a href="https://developers.google.com/web/fundamentals/primers/promises">JavaScript Promises: an introduction</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises">Using promises - JavaScript | MDN</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61e59bedf59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make Fetch Happen!]]></title>
            <link>https://medium.com/@sarah.r.rivas/make-fetch-happen-243cdd04445b?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/243cdd04445b</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Thu, 23 Aug 2018 14:43:02 GMT</pubDate>
            <atom:updated>2018-08-23T14:43:02.708Z</atom:updated>
            <content:encoded><![CDATA[<p>Working with APIs in your applications will often require you to send API requests to access and manipulate parts of the HTTP pipeline. A basic fetch request is really simple to set up and the Fetch API provides the interface for fetching resource even across networks. It serves as a courier between you and the API, sending, delivering and running the tasks directed through the fetch request.</p><p>The fetch() method will take one argument, which is the path of the resource that you want to fetch. When creating, deleting, or updating with fetch() you can also pass in an object as a second argument, which will serve as your configuration. The configuration can contain specifications for the type of method, the header, and the body of your fetch method. The fetch() will return a Promise that resolves to a response.</p><p>Now, let’s dive into examples of fetch for each of the CRUD (Create, Read, Update, Delete) functionalities and see fetch in action!</p><h3>Read with Fetch</h3><p>In order to retrieve data from the API, you can include the URL of the API as the single argument to the fetch(). Success! We received a response and then used json() to read and parse the data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1102092ffee4ee5062e36a289c0ea022/href">https://medium.com/media/1102092ffee4ee5062e36a289c0ea022/href</a></iframe><h3>Create with Fetch</h3><p>When submitting a request to create a new object and post it to the API, our fetch method will look similar to the one above, but with some extra pieces of data in your request. As you can see in the example below, the fetch will take an extra argument, which includes an object containing the following information:</p><ol><li>The method we will use for creating with fetch is ‘POST’. Make sure you use caps when setting up your config. Otherwise, your fetch may not complete the action.</li><li>The body you submit will be dependent on the requirements of the API. Check the API docs which will specify exactly what keys you will need to successfully post the data. This object will be placed inside JSON.stringify() which converts a JavaScript value to a JSON string.</li><li>Lastly, headers allow the client and the server to pass additional information with the request or the response. A simple header will specify the Content-type. However, you can browse the various <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">header options</a> and choose the best one for your application.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77f06595a48e6cae5e5b7c3d4eda6b4f/href">https://medium.com/media/77f06595a48e6cae5e5b7c3d4eda6b4f/href</a></iframe><h3>Update with Fetch</h3><p>The fetch() method for updating an item works similarly to the post, except that you will also take in the id of the object that you want to edit/update.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b96daa7a3a81fe9bc83ceaa5e93e0f96/href">https://medium.com/media/b96daa7a3a81fe9bc83ceaa5e93e0f96/href</a></iframe><h3>Delete with Fetch</h3><p>Similarly, the delete functionality will take in an id of the object we requested to delete and will delete it from the API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65358ec20b90dc5f5de750d194465c3f/href">https://medium.com/media/65358ec20b90dc5f5de750d194465c3f/href</a></iframe><p>For additional reading on the Fetch API, check out the docs<a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API"> here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=243cdd04445b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An overview of debugging tools for ReactJS applications]]></title>
            <link>https://medium.com/@sarah.r.rivas/an-overview-of-debugging-tools-for-reactjs-applications-4a81fc7ee292?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a81fc7ee292</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 03:54:37 GMT</pubDate>
            <atom:updated>2018-08-11T21:05:19.003Z</atom:updated>
            <content:encoded><![CDATA[<p>Debugging is an essential skill for software developers of all experience levels. By providing a way to test out the syntax and scope expectations for your code in real-time, debugging tools will help you feel confident about your code and will also help you prevent serious bugs in your application. Mastering these tools and techniques takes time, but through practice, you will uncover the power of these tools and have a better sense of what tool to use for the particular problem you are trying to solve, so that your debugging experience is not like that of our developer friend below!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FKhaP8mZew3llK%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FKhaP8mZew3llK&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FKhaP8mZew3llK%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="223" frameborder="0" scrolling="no"><a href="https://medium.com/media/2542e2d273214703daf4f785380e13c9/href">https://medium.com/media/2542e2d273214703daf4f785380e13c9/href</a></iframe><h3>Chrome Dev Tools and the Console</h3><p>Chrome Dev Tools provides you with a series of tools for inspecting your code, as well as monitoring network requests and responses. It also allows you to manipulate the code within the browser in a testing environment to see how it will render or respond. You can open up the console by right clicking on your webpage and selecting “Inspect”. This will open up a second window inside of your browser that contains the various tools at your disposal!</p><p>The elements panel highlighted below shows you the current status of your HTML and CSS. You can manipulate your CSS directly in the “Styles” tab and see the style changes rendered directly on the browser.</p><p>If your application has any type of communication with a server, the Network tab will come in handy to review the request types, content and responses. As you can see below, the request method was successfully made and in the adjoining tab, you will be able to see the response object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRZowg9jYoE1NnbbHWTOuQ.png" /></figure><h3>Console.log()</h3><p>Between the Elements and Network tabs, you will find the Console tab.What makes this tool so awesome is that this window will provide you with a list of error messages and their location in your code. By default error messages are cleared out on page reload, but if you want to persist your messages use the handy “Preserve Log” option in the console settings.</p><p>Another amazing thing you can see in the console are any messages your application has logged through console.log. For example, let’s say you added an event listener that calls a function every time you click on a particular button on the page. You want to see if it is working and if the event listener is being triggered appropriately. Add a console.log inside the event listener with a message and open up your console. If the event listener is working properly, you should see the message printed in the console when you click on the button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PV4JvZtNRPryZF2lZjTEMw.png" /></figure><h3>Debugger and Breakpoints</h3><p>Breakpoints allow you to pause your code in the middle of execution to examine the scope, variables, and values that are available at that particular point in time. This can be really useful for debugging errors that are related to closures and scope, since you can see the values of all variables and functions at that moment in time by hovering over them or checking the Scope panel on the right hand side. You can also add in event listener breakpoints and pause on different lines of code or iterations within loops. To learn more about these available options to enhance your debugging, check out the <a href="https://developers.google.com/web/tools/chrome-devtools/javascript/?hl=en">Google Developer Tools Docs</a>.</p><h3>React Developer Tools</h3><p>A must-have for debugging your ReactJs applications is the React Developer Tools browser extension. You can download this directly to your browser. Once the extension is installed, the React icon will appear in your icon bar. The extension icon will light up on any websites using React. Additionally, you will also see a tab within the Chrome Developer Tools for any of the sites using react. In this tab, you will see the current selected component and you can click on each component to see, view, or modify it’s state or props.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1uVP7ZX1Mk-lq7eiS84u2Q.png" /></figure><p>If you inspect a React element on our webpage and view it on your regular Elements tab, it will automatically be selected for you if you switch over to the React tab. Similarly, if you right-click on a React element and choose “find the DOM node, the corresponding DOM node will be selected for you in the Elements page.</p><p>The React tab also has an amazing search bar that allows you to search for a specific component and facilitates the view of the console by allowing you to open up a sub-window underneath the React window by pressing Esc from within the React window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PGhQrVcImdN2ehnOTTsOEA.png" /></figure><h3>Other Tools to Improve Code Quality</h3><p><a href="https://eslint.org/docs/user-guide/getting-started">ES Lint</a> is a pretty awesome tool similar to the Microsoft Word grammar and spell checker, but better! It is particularly good at pointing out syntax errors and bugs related to variable scope such as the use of undeclared variables or undefined variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VgnGN_8951HPuN9D9y1U6Q.png" /></figure><p>To use ES Lint, install the package and its dependencies in your code editor and test it out on your next project!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a81fc7ee292" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Read, Add and Remove HTML Element Classes]]></title>
            <link>https://medium.com/@sarah.r.rivas/how-to-read-add-and-remove-html-element-classes-a21689ad0ec7?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/a21689ad0ec7</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 02:35:37 GMT</pubDate>
            <atom:updated>2018-07-25T02:35:37.118Z</atom:updated>
            <content:encoded><![CDATA[<p>A common task when working with elements is wanting to read and update class attributes, but like many things with the DOM, there is more than one way to get it done. Let’s start with the older solution, className first.</p><h3>className</h3><p>The simplest task is reading classes from an element.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/975d5d7cf78006d69e335f6c39a275b0/href">https://medium.com/media/975d5d7cf78006d69e335f6c39a275b0/href</a></iframe><p>This works great for when we need to get the entire class string. What about when we want to check if a certain class is on an element? Now we need to start using string methods on our className.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89ad9b871b5aa18c348a41c93810a111/href">https://medium.com/media/89ad9b871b5aa18c348a41c93810a111/href</a></iframe><p>So far, className isn’t too difficult to work with, but things get a little trickier when we want to remove a certain class from an element.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b1fc3ed889f533c6a20f5953213a935/href">https://medium.com/media/7b1fc3ed889f533c6a20f5953213a935/href</a></iframe><p>That solution was probably a little lengthier than it should be. Here is where we can start seeing the benefits of a more modern solution- introducing classList! Let’s start by trying the read, first.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ea847728b70e42984fd313f22fdd800/href">https://medium.com/media/5ea847728b70e42984fd313f22fdd800/href</a></iframe><p>As you can see, if we want a class string, we can get that from the classList.value and even cooler, classList returns a collection (DOMTokenList) that allows us to pass an index and get a certain class.</p><p>But, I promised you an easier way to remove classes and I didn’t forget!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3338b4acf0d33977f44954351701d55e/href">https://medium.com/media/3338b4acf0d33977f44954351701d55e/href</a></iframe><p>Removing classes is really straightforward with classList. Similarly, adding them is just as simple.</p><p>classList also has its own way to check if a class is in an element using the contains() method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfaebe51b056bb114562530fdbe7eb67/href">https://medium.com/media/dfaebe51b056bb114562530fdbe7eb67/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FWUq1cg9K7uzHa%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmrw-wall-thedonald-WUq1cg9K7uzHa&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FWUq1cg9K7uzHa%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c9099bf64dd48cfa59a38638c74adfc/href">https://medium.com/media/8c9099bf64dd48cfa59a38638c74adfc/href</a></iframe><h3>Further Reading</h3><p>If you are curious to explore more of the classList API check out toggle and replace for more powerful ways to add and remove classes.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/className">className</a></p><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/classList">classList</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a21689ad0ec7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CSS Animations with Emojis ]]></title>
            <link>https://medium.com/@sarah.r.rivas/simple-css-animations-with-emojis-92364276e79c?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/92364276e79c</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[css-animation]]></category>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Thu, 12 Jul 2018 05:06:10 GMT</pubDate>
            <atom:updated>2018-07-12T05:09:19.650Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s summertime and we just arrived at a beach in the digital world! We start to observe the trees swaying, a surfer riding waves, a sailboat in the distance, and your friend cartwheeling across the beach. How is this all happening?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Frivass%2Fembed%2Fpreview%2FVBYOEr%3Fheight%3D600%26slug-hash%3DVBYOEr%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Frivass%2Fpen%2FVBYOEr%3Feditors%3D1100&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F2158973.VBYOEr.small.639cc064-7616-44a0-b063-9b91d8c21fa4.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/0ebf2c41cf1972a839aa5493f9a301dd/href">https://medium.com/media/0ebf2c41cf1972a839aa5493f9a301dd/href</a></iframe><p>One way to animate our page is to use CSS animations. By defining animations and their keyframes, we can animate elements on our page. Let’s explore a few simple CSS animations that can add some excitement to your sites.</p><p>Before we start playing around with the behavior of our emojis, a quick note on our html set-up: the .ocean and .sand elements are divs that serve as containers for emoji divs. The emojis work like fonts and each div contains an emoji that can be sized and animated.</p><p>Now, we are ready to explore all our beach elements!</p><h3>The Surfer</h3><p>Our surfer is positioned absolutely relative to the .ocean div. We define an animation called surfing using @keyframes.We keep it simple by creating a from keyframe for the start of the animation and a to keyframe for the end of the animation. By changing our top and left values across these keyframes, we can have our surfer cross the ocean.</p><p>As you can see, we did not specify percentages for the keyframe and so, from and to work as 0% and 100%, respectively.</p><p>We control how long an iteration of our animation runs for with animation-duration and we can have it iterate infinitely by using an animation-iteration-count. We setanimation-timing-function to linearto keep the surfer’s speed consistent throughout the animation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4409cd81529bc1522e570d6d1814191c/href">https://medium.com/media/4409cd81529bc1522e570d6d1814191c/href</a></iframe><h3>Sailboat</h3><p>The sailboat works in a similar way to the surfer. An interesting difference is that, we use percentage keyframes to vary the top position and create a meandering path. This is achieved by bringing the top position up and down by 30 pixels from the base value of 150 pixels.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1138276fce263a90890dd21b1cd32530/href">https://medium.com/media/1138276fce263a90890dd21b1cd32530/href</a></iframe><h3>Cartwheeler</h3><p>For the cartwheeler, we use the rotate transform to make the emoji spin. As you can see below, the rotation starts at 0 degrees and we spin it around by rotating it to 360 degrees. By setting the animation-direction to alternate and the animation-iteration-count to infinite, we make the emoji cartwheel back and forth until the end of time!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/550e8046e92a3482c2c877d0b0dcafb2/href">https://medium.com/media/550e8046e92a3482c2c877d0b0dcafb2/href</a></iframe><h3>Palm Tree</h3><p>In order to have the palm trees sway from side to side, the transform CSS property allows us to skew the emoji along the X-axis. To give the palms their sway, we skew back and forth by 15 degrees. Like the cartwheeler, the animation will loop over and over and over…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3ac9cffd5c201216f43b6dedaec6895/href">https://medium.com/media/e3ac9cffd5c201216f43b6dedaec6895/href</a></iframe><h3>Waves and Umbrella</h3><p>The waves and umbrella have been added in for scenery and also because adding emojis to this setting is oddly addictive. One cool thing to note is that you can change emoji opacity and this helped me blend the waves with the ocean background.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0a0b5ed26bf9d659f0ec2f47091605a/href">https://medium.com/media/f0a0b5ed26bf9d659f0ec2f47091605a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27cd49ed3c537fb082ccc52a4c755191/href">https://medium.com/media/27cd49ed3c537fb082ccc52a4c755191/href</a></iframe><p>If you want to dig deeper into CSS animations, be sure to check out <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations">MDN’s docs</a> or visit <a href="https://css-tricks.com/almanac/properties/t/transform/">CSS tricks’</a> for more information on transforms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92364276e79c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Arrays: From Ruby to JavaScript]]></title>
            <link>https://medium.com/@sarah.r.rivas/working-with-arrays-from-ruby-to-javascript-86fa1425b9c8?source=rss-1360a053e0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/86fa1425b9c8</guid>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[array-methods]]></category>
            <dc:creator><![CDATA[Sarah Rivas]]></dc:creator>
            <pubDate>Thu, 28 Jun 2018 02:28:58 GMT</pubDate>
            <atom:updated>2018-06-28T02:28:58.387Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first started working with arrays, I kept running into a few common problems. The need to iterate, filter, and map collections came up over and over, regardless of whether I was using Ruby or JavaScript. Let’s take a quick look into how we can apply these methods to arrays in both JavaScript and Ruby.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3orieUe6ejxSFxYCXe%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3orieUe6ejxSFxYCXe%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExOTFmaW9rNGw2cjNobTRjZDU0dW5xano0MDhueXZoYWM0dzd1ZXF6aCZlcD12MV9naWZzX2dpZklkJmN0PWc%2F3orieUe6ejxSFxYCXe%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="328" frameborder="0" scrolling="no"><a href="https://medium.com/media/a63e768480b595492411784a3b6f56c6/href">https://medium.com/media/a63e768480b595492411784a3b6f56c6/href</a></iframe><h3>each (Ruby) and forEach (JS)</h3><p>One of the most common array tasks is iteration. Both Ruby and JavaScript offer multiple ways to do this. Let’s take a closer look at using each and forEach.</p><p>Ruby’seachmethod will call a given block for each element in the array. A block can be made up of one or more statements and will receive the element as a parameter. As long as a block is provided, the return value for the method is the original array. Take a look at the example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ab68d689b62563193c6c8eb1f4da9aa/href">https://medium.com/media/1ab68d689b62563193c6c8eb1f4da9aa/href</a></iframe><p>In JavaScript, the forEach method executes a given function for each element in the array. The return value for the forEach method is undefined.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ddcedcad507c06b959c00076f148372/href">https://medium.com/media/1ddcedcad507c06b959c00076f148372/href</a></iframe><p>Both each andforEach iterate through an array and give us a chance to perform actions per each element. However, one major difference between the two is that Ruby will return the original array, while JavaScript will return undefined. JavaScript also makes the index of the element and the array itself available as a second and third parameters to the callback function. If you are looking to use the index of the given element in Ruby, you may want to use the method each_with_index.</p><h3>map (Ruby) and map (JS)</h3><p>Another common use case when working with arrays is the need to map existing values to new values. Similar to each, map(also known as collect) will execute a given block for each element in the array. But what makes map special is that it will store the return value of each block call in a new array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12a273c9992eb6efd495fae5018a0bfc/href">https://medium.com/media/12a273c9992eb6efd495fae5018a0bfc/href</a></iframe><p>Similarly, in JavaScript, the map method will return a new array containing the element’s returned from each call of the callback function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0950d080a8d2b2eb1d8c2a9011942f16/href">https://medium.com/media/0950d080a8d2b2eb1d8c2a9011942f16/href</a></iframe><p>An interesting difference is that Ruby gives the option of changing the original array, by instead calling map!. Like forEach, JavaScript’s map can provide the callback function with additional arguments such as an index and array.</p><h3>select (Ruby) and filter (JS)</h3><p>Both Ruby and JavaScript allow us to easily filter out elements from an array. Again, Ruby allows us to do this by creating a new array or manipulating the existing one. If a block is given, select will return a new array containing all the elements for which the block returned a true value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35dc08bbc3444e1bef78a9e80f916cf6/href">https://medium.com/media/35dc08bbc3444e1bef78a9e80f916cf6/href</a></iframe><p>select!works similarly except that it will actually delete values from the existing array. Note that if no values are deleted, it will return nil. Otherwise, it will return the existing array minus the deleted values.</p><p>JavaScript’s filter works similarly to the select method and will not mutate the array on which it is called. The callback function will be executed for each array element. Elements will be excluded from the new array if the callback function returns a falsy value. Like the other JavaScript array methods we explored, the callback supports additional parameters for index and array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b42520bba3f53075a9e762a3b3bc4065/href">https://medium.com/media/b42520bba3f53075a9e762a3b3bc4065/href</a></iframe><h3>Further Reading…</h3><p>This is just a small sample of some techniques for working with arrays in JavaScript and Ruby. For a more array methods, I highly encourage taking a look at <a href="https://ruby-doc.org/core-2.5.1/Array.html">Ruby’s API docs</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Mozilla Developer Network (MDN)</a> docs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86fa1425b9c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>