<?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: sam-a-code</title>
    <description>The latest articles on DEV Community by sam-a-code (@samacode).</description>
    <link>https://dev.to/samacode</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%2F926865%2F9cfeb0b3-8c44-4620-9221-d595cce72675.png</url>
      <title>DEV Community: sam-a-code</title>
      <link>https://dev.to/samacode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samacode"/>
    <language>en</language>
    <item>
      <title>CSS Tips!</title>
      <dc:creator>sam-a-code</dc:creator>
      <pubDate>Fri, 18 Nov 2022 22:32:08 +0000</pubDate>
      <link>https://dev.to/samacode/css-tips-9h9</link>
      <guid>https://dev.to/samacode/css-tips-9h9</guid>
      <description>&lt;p&gt;I've found the blogs I like the most to be the ones who get right into it – so below are my go-to strategies for adding some pizzazz to your website/project/app. &lt;/p&gt;

&lt;p&gt;One key element of an aesthetically pleasing project or app is consistency in design. To have all of your h1 headers show the text in all caps, regardless of how you've written them in your code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 {
text-transform: uppercase; 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another key to nice design is the positioning on your page. There may be some instances where you'll want an element to always be visible on page, regardless of how far down you've scrolled. To anchor a button on a page, use the following code! In this instance, the button will be anchored 30px from the top of the page regardless of how far down you've scrolled.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button {
position: sticky;
top: 30px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally – my favorite way to add more personality to a page is by adding images. I've found that they make a really lovely text backdrop (as long as you have your text in another div with a background so your text is accessible and easy to read!). &lt;/p&gt;

&lt;p&gt;To set an image as a background for the header div:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.header-background-image {
  background-image: url("https://images.unsplash.com/photo-1514525253161-7a46d19cd819?ixlib=rb-4.0.3&amp;amp;ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8Y29uY2VydHxlbnwwfHwwfHw%3D&amp;amp;auto=format&amp;amp;fit=crop&amp;amp;w=500&amp;amp;q=60");
  background-repeat: no-repeat;
  background-position: center;
  margin-top: 150px;
}

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

&lt;/div&gt;



&lt;p&gt;To break down the code above: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;background-repeat&lt;/code&gt; allows you to control how many times the image repeats over the page. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;background-position&lt;/code&gt; allows you to control where the image is positioned. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;margin&lt;/code&gt; allows you to control the margin around the image. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ps - &lt;a href="https://unsplash.com/" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt; is one of my favorite places for stock images - enjoy! &lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>My Favorite Methods (max_by, find_by, and sum)</title>
      <dc:creator>sam-a-code</dc:creator>
      <pubDate>Thu, 27 Oct 2022 19:39:36 +0000</pubDate>
      <link>https://dev.to/samacode/my-favorite-enumerable-methods-3-3639</link>
      <guid>https://dev.to/samacode/my-favorite-enumerable-methods-3-3639</guid>
      <description>&lt;p&gt;We're just about done with Phase 3 of our program, so I'm back with another blog post! Today I'm going to highlight some of my favorite methods in Ruby. &lt;/p&gt;

&lt;p&gt;For the examples below, let's say that we have a &lt;code&gt;plant_store&lt;/code&gt; with &lt;code&gt;plants&lt;/code&gt; and &lt;code&gt;customers&lt;/code&gt; that we'll want to look through, sort, and find. &lt;/p&gt;

&lt;h3&gt;
  
  
  max_by
&lt;/h3&gt;

&lt;p&gt;Say we wanted to find the &lt;code&gt;customer&lt;/code&gt; who had purchased the most number of &lt;code&gt;plants&lt;/code&gt; from the &lt;code&gt;plant_store&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def self.most_plant_purchases 
    self.all.max_by {|customer| customer.plants.count }
 end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above &lt;em&gt;class&lt;/em&gt; method, the &lt;code&gt;self&lt;/code&gt; is referring to &lt;code&gt;PlantStore&lt;/code&gt;. &lt;br&gt;
When we call this method on the &lt;code&gt;PlantStore&lt;/code&gt; class, we iterate through every instance of customer. We do &lt;code&gt;plants.count&lt;/code&gt; on each &lt;code&gt;customer&lt;/code&gt; to get the total number of plants they've purchased. Once this method has gone through each &lt;code&gt;customer&lt;/code&gt;, it will return the &lt;code&gt;customer&lt;/code&gt; with the highest number of plants (lucky customer!). &lt;/p&gt;
&lt;h3&gt;
  
  
  find_by
&lt;/h3&gt;

&lt;p&gt;What if our &lt;code&gt;customer&lt;/code&gt; is looking for a specific plant? We can search for what they're looking for using find_by!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def find_plant(plant_name)
    self.plants.find_by(plant_name: plant_name)
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;em&gt;instance&lt;/em&gt; method is called on the PlantStore class. We pass in one argument of a &lt;code&gt;plant name&lt;/code&gt; and the method searches for any &lt;code&gt;plant_name&lt;/code&gt; that matches our argument in the &lt;code&gt;plant_name:&lt;/code&gt; attribute. It will return the first instance of a &lt;code&gt;plant&lt;/code&gt; that has a name that matches &lt;code&gt;plant_name&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  sum
&lt;/h3&gt;

&lt;p&gt;Finally, what if we wanted to find out how much a &lt;code&gt;customer&lt;/code&gt; had spent on plants at that &lt;code&gt;plant_store&lt;/code&gt;?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  def total_plant_cost
    self.plants.sum {|plant| plant.price}
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;em&gt;instance&lt;/em&gt; method is called on the &lt;code&gt;Customer&lt;/code&gt; class. It calculates the sum of all of a customer's plants by adding up the values of the price attribute for each plant that is associated with that customer. &lt;/p&gt;

&lt;h5&gt;
  
  
  Thanks for reading!
&lt;/h5&gt;

&lt;p&gt;Hopefully these methods are helpful references for your own projects! I tried to keep it simple so this would be an easy reference :) &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mapping in React</title>
      <dc:creator>sam-a-code</dc:creator>
      <pubDate>Thu, 06 Oct 2022 14:13:05 +0000</pubDate>
      <link>https://dev.to/samacode/mapping-in-react-54m9</link>
      <guid>https://dev.to/samacode/mapping-in-react-54m9</guid>
      <description>&lt;p&gt;Something I've learned recently is how to map in React. Below I'll walk through one example of how to set up mapping in a React app. &lt;/p&gt;

&lt;h4&gt;
  
  
  1. Set up your parent component
&lt;/h4&gt;

&lt;p&gt;Identify the component that should contain the data you fetch. This will likely be a parent component – make sure to think about which child components need access to the data! You'll be passing the data to those components as props. &lt;/p&gt;

&lt;p&gt;In this example, we'll pull a list of resources (the data), map the data, create cards for each resource, and then pass the data to a separate component as props to format the cards. The parent component is called &lt;code&gt;ResourceList&lt;/code&gt; and the child is &lt;code&gt;ResourceCard&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, {useState, useEffect} from "react";
import ResourceCard from "./ResourceCard";

function ResourceList() {
  const [resources, setResources] = useState([])

  useEffect(() =&amp;gt; {
    fetch('http://localhost:3000/resources')
    .then((r) =&amp;gt; r.json())
    .then((resources) =&amp;gt; setResources(resources))
    }, [])

  const resourceList = resources.map((resource) =&amp;gt; {
    return (
      &amp;lt;ResourceCard
      key={resource.id}
      name={resource.name}
      url={resource.url}
      summary={resource.summary}
      image={resource.image}
        /&amp;gt;
    ) })

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h2&amp;gt;Resources&amp;lt;/h2&amp;gt;
      &amp;lt;ul&amp;gt;
        {resourceList}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default ResourceList;


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

&lt;/div&gt;



&lt;p&gt;Let's break down that code. &lt;/p&gt;

&lt;p&gt;First, we import React, useState, and useEffect from "react". We also import our &lt;code&gt;ResourceCard&lt;/code&gt; since we need to include it in our &lt;code&gt;ResourceList&lt;/code&gt; return. &lt;/p&gt;

&lt;p&gt;Then, we set up our &lt;code&gt;ResourceList&lt;/code&gt; function. Within that, we start with creating state for our data – using an empty array so the data we fetch has somewhere to go! &lt;/p&gt;

&lt;p&gt;Next is our useEffect function. We pull our data from &lt;code&gt;/resources&lt;/code&gt;, convert it to json, and then set our resources. We include an empty array at the end of the function so that this fetch only happens once, when the page loads. &lt;/p&gt;

&lt;p&gt;Now we get to map our data! We put it in a new variable (&lt;code&gt;resourceList&lt;/code&gt;) and set it equal to our mapping method. Note that this &lt;code&gt;resourceList&lt;/code&gt; is different than our &lt;code&gt;ResourceList&lt;/code&gt;. While they have almost the exact same name, components in React start with capital letters and variables use camelcase (at least as a best practice!). What we're saying with this method is: create a &lt;code&gt;ResourceCard&lt;/code&gt; for every &lt;code&gt;resource&lt;/code&gt; in the &lt;code&gt;resources&lt;/code&gt; list. &lt;/p&gt;

&lt;p&gt;We've also made sure to include the parameters we'll need to pass down to &lt;code&gt;ResourceCard&lt;/code&gt; (key, name, url, summary, image). This can also be accomplished by using a spread operator, but I like writing it all out because it's easier for my brain to see all of the parameters listed individually. &lt;/p&gt;

&lt;p&gt;Below our mapping function we set up our return for &lt;code&gt;ResourceList&lt;/code&gt;. We wrap everything in one &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, then within that &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; we set up &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; elements. The &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; will hold our title and the &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; will contain our {resourceList} (the bit we just mapped above!). &lt;/p&gt;

&lt;p&gt;Finally, we write &lt;code&gt;export default ResourceList&lt;/code&gt; so our App.js can import it! &lt;/p&gt;

&lt;h4&gt;
  
  
  2. Set up your child component
&lt;/h4&gt;

&lt;p&gt;In this instance, our child component is pretty simple! We just have to set up the JSX for our &lt;code&gt;ResourceCard&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

function ResourceCard({summary, name, url, image}) {
    return (
        &amp;lt;div&amp;gt;
            &amp;lt;img src={image}/&amp;gt;
            &amp;lt;h2&amp;gt;{name}&amp;lt;/h2&amp;gt;
            &amp;lt;p&amp;gt;{summary}&amp;lt;/p&amp;gt;
            &amp;lt;a href={url} target="_blank"&amp;gt;Read more!&amp;lt;/a&amp;gt;
        &amp;lt;/div&amp;gt;
    )
}

export default ResourceCard;

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

&lt;/div&gt;



&lt;p&gt;We'll break the code of this component down as well: &lt;/p&gt;

&lt;p&gt;We start off by importing React from 'react', of course. &lt;/p&gt;

&lt;p&gt;Then, we set up our &lt;code&gt;ResourceCard&lt;/code&gt; function. This function won't work if we don't accept the parameters being passed down from &lt;code&gt;ResourceList&lt;/code&gt;. By including {summary, name, url, image} in this function, we are facilitating the data flow between the parent and child components. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ResourceCard&lt;/code&gt; return sets up how we want our mapped data displayed. Again, we set up a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; to contain everything. Within that &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, we create elements for our {image}, {name}, {summary}, and {url} data points. &lt;/p&gt;

&lt;p&gt;Finally, we write &lt;code&gt;export default ResourceCard&lt;/code&gt; so that &lt;code&gt;ResourceList&lt;/code&gt; can import it. Our data is now mapped and rendering on individual cards for each &lt;code&gt;resource&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hopefully this was a helpful overview of mapping data and passing it between components! One note – I removed all &lt;code&gt;className&lt;/code&gt; references so that this example was easier to read, but of course I'd recommend styling your cards once they're mapped. It's half the fun – at least for me!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My first blog: Community + CSS</title>
      <dc:creator>sam-a-code</dc:creator>
      <pubDate>Thu, 15 Sep 2022 20:44:07 +0000</pubDate>
      <link>https://dev.to/samacode/my-first-blog-community-css-4j1e</link>
      <guid>https://dev.to/samacode/my-first-blog-community-css-4j1e</guid>
      <description>&lt;p&gt;Hi, I'm Sam! &lt;/p&gt;

&lt;p&gt;I recently started Flatiron's Software Engineering bootcamp, and I love it. When thinking about what to include in a blog post (my first ever!), I know that it's important to include new concepts I've learned. I also know that no matter what I'm doing, the output is infinitely better if I approach it with authenticity. So, I'm going to start with how welcoming this community has been, and then I'll get into a handful of delightful CSS lessons I've learned. &lt;/p&gt;

&lt;h2&gt;
  
  
  Starting my SE Adventure
&lt;/h2&gt;

&lt;p&gt;When I first mentioned an interest in software engineering to a real engineer, it was an off-hand comment. We were just chatting (one of those get-to-know-you coffees, which can be either fun or grueling, depending on everyone's energy) and she was so supportive of my learning more about this entire field. She recommended Codecademy, and I loved it, but knew I needed more structure if I really wanted to dive in. Over the next few months, I talked to more developers. Without fail, they were all incredibly enthusiastic about talking to (and sharing knowledge with) a coding newbie. &lt;/p&gt;

&lt;p&gt;One of them sent a TON of resources – from YouTube videos to conferences to a list of bootcamps. He's checked in consistently, and has been a huge champion of my becoming a developer. Another set up a handful of meetings with me to start teaching me some key concepts (it was &lt;em&gt;very&lt;/em&gt; helpful to have some background on arrays before I started bootcamp). Another, just as he found out I was leaving my job to start this bootcamp, set up time to talk through our company's codebase as a real-world example of some of the concepts I'd be learning. There have been &lt;em&gt;so&lt;/em&gt; many people who are enthusiastic, helpful, and eager to share their experience as I make this transition. &lt;/p&gt;

&lt;p&gt;I thoroughly underestimated the kindness of the software engineering community and just how excited they would be to have a new member. One of the best lessons I've learned is that community is a key element of this field – from sharing helpful resources to helping others troubleshoot to welcoming new developers with open arms (and open source). &lt;/p&gt;

&lt;h2&gt;
  
  
  CSS
&lt;/h2&gt;

&lt;p&gt;Two other students from my cohort and I have been working on our first project together. We've created a page that returns recipes based on seasonal items from the farmers market. It's a good idea (if I do say so myself), but without CSS it's a bit... meh. &lt;/p&gt;

&lt;p&gt;The CSS portion of this project was one of the parts I was a bit nervous about. I had less experience with CSS and it felt overwhelming to try to transform a simple page of lists and divs and headers into something pretty, user-friendly, and readable. &lt;/p&gt;

&lt;p&gt;Another key lesson in this experience has been to take a breath and break down whatever I'm working on into smaller, manageable sections. So, I started by tackling the part by which I was most intimidated – how to get four lists (one for each season) to display side-by-side. After some googling and experimenting, I got the grid layout set up correctly. &lt;/p&gt;

&lt;p&gt;Once I realized that CSS was actually fun – like an art project but my hands won't get covered in glue and I won't step on a runaway rhinestone – I started to enjoy myself. Below are some of my favorite bits of CSS that I learned throughout this project. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout"&gt;Grid layouts&lt;/a&gt;: grid layouts not only allow you to divide your page and its content into sections using HTML primitives, but they also enable you to have overlapping/layered elements. See the Mozilla link above for more information!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sharkcoder.com/visual/underline"&gt;Underlines&lt;/a&gt;: I didn't realize there were so many creative ways to underline your text. I &lt;em&gt;really&lt;/em&gt; get a kick out of the wavy underline (&lt;code&gt;text-decoration-line:underline; text-decoration-style: wavy;&lt;/code&gt;). In looking up different types of underlines, I found some real gems. Underlines that look like they were drawn by marker, or ones that are animated, or ones that consist of a row of little hearts.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://getcssscan.com/css-box-shadow-examples"&gt;Boxes&lt;/a&gt;: the same way I underestimated the amount of pizzazz in underlines, I was unprepared for all of the different box-shadow options. This was where the full power and nuance of CSS really clicked for me. I have a lot to learn, but it's really helpful to have a visual representation of how many options there are – that's why I loved the page of box-shadow examples I linked above. Who knew there were so many different ways to style a box?! You can click on any of those box-shadow examples to copy the code and then easily add those boxes to your own CSS files. This goes back to community – how cool that there are so many resources that allow you to share and implement other people's code! &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I love the immediacy of this work – you change the background color in your file and you can see it change in your browser after a quick refresh. You set up a grid layout and you know almost instantly if it's working as it should. You edit your JS file to clean it up for readability and – wait – you ordered your functions and variables incorrectly (you can't use your form event listener before you've declared all the variables it involves!). A quick fix to the order of those functions and variables in your index.js, and now your code is &lt;em&gt;both&lt;/em&gt; organized and working. &lt;/p&gt;

&lt;p&gt;I'm looking forward to challenging myself and finding my voice as a software engineer – identifying which areas I'm passionate about and which languages speak to me the most. I am really grateful to be part of this community and can't wait to see where this adventure takes me.&lt;/p&gt;

&lt;h6&gt;
  
  
  References:
&lt;/h6&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout"&gt;Mozilla: CSS Grid Layout&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sharkcoder.com/visual/underline"&gt;Shark Coder: Underlines&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://getcssscan.com/css-box-shadow-examples"&gt;Get CSS Scan: Box Shadow Examples&lt;/a&gt;&lt;/p&gt;

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