Styling the Recent Post Component
Welcome back to the React course. In the last guide, we fixed some of the styles for our logo and search bar. In this guide, we're going to be applying the styles for the recent posts component.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

Let's go ahead and head into our style folder, and create a new file and call it recentPosts.scss. Now we'll import it into main.scss.

large

Let's head over to our recentPosts.js and see what we have. We have a few tags and here we have recent-posts__wrapper, heading and posts. Then we'll add all of those to recentPosts.scss.

recentPosts.scss

.recent-posts {
    .recent-posts__wrapper {

        .recent-posts__heading {

        }
        .recent-posts__posts {

        }
    }
}

The first thing I want to do is actually get rid of these dots in our lists and I'll do this in main.scss because we're going to have a couple unordered lists throughout our application.

main.scss

ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
}

large

Awesome. Now, let's just worry about styling the recent posts on the homepage before we style the posts themselves. Let's head to our recentPosts.scss and get these in.

recentPosts.scss

.recent-posts {

    display: grid;
    align-content: center;
    justify-items: center;

    background-color: skyblue;

    .recent-posts__wrapper {

      background-color: rgb(71, 203, 154);
      display: grid;

        .recent-posts__heading {

        }
        .recent-posts__posts {

        }
    }
}

Here's our wrapper.

large

Now let's give this a gap.

recentPosts.scss

.recent-posts {

    display: grid;
    align-content: center;
    justify-items: center;

    background-color: skyblue;

    .recent-posts__wrapper {

      background-color: rgb(71, 203, 154);
      display: grid;
      grid-row-gap: 21px;

        .recent-posts__heading {

        }
        .recent-posts__posts {

        }
    }
}

Okay so that's all that's working. Let's go back to that SCSS file and we're going to apply a blue color to the heading.

recentPosts.scss

.recent-posts {

    display: grid;
    align-content: center;
    justify-items: center;

    background-color: skyblue;

    .recent-posts__wrapper {

      background-color: rgb(71, 203, 154);
      display: grid;
      grid-row-gap: 21px;
      width: 100%;

        .recent-posts__heading {
            color: $color-blue-one;
            font-size: 14px;
        }
        .recent-posts__posts {

        }
    }
}

Now let's go ahead and put this variable into our main.scss, then head back to our recentPosts.scss. Now what we want to do is style the Posts container.

recentPosts.scss

.recent-posts {

    display: grid;
    align-content: center;
    justify-items: center;

    background-color: skyblue;

    .recent-posts__wrapper {

      background-color: rgb(71, 203, 154);
      display: grid;
      grid-row-gap: 21px;
      width: 100%;

        .recent-posts__heading {
            color: $color-blue-one;
            font-size: 14px;
        }
        .recent-posts__posts {
            display: grid;
            justify-content: space-evenly;
            grid-template-columns: 1fr 1fr 1fr;
            grid-gap: 42px;
        }
    }
}

large

Now what I want to do is get rid of these background colors.

large

That looks good.

In the next guide, we will style our recent posts. we're going to style our posts component.

Let's commit our code.

git status
git add .
git commit -m "styled the recent posts component"

I'll see you in the next video.

Resources

Code at this stage