Back to Freecodecamp

Step 7

curriculum/challenges/english/blocks/workshop-reusable-profile-card-component/674ef2d357676e50e469165d.md

latest4.0 KB
Original Source

--description--

Again, use the Card component two more times with the following:

PropsFirst Card ValuesSecond Card Values
name"Tiffany""Doug"
title"Engineering manager""Back-End developer"
bio"I have worked in tech for 15 years and love to help people grow in this industry.""I have been a software developer for over 20 years and I love working with Go and Rust."

--hints--

You should not modify the existing Card component in your App component.

js
const zerothCard = document.querySelectorAll('.card')[0];

assert.equal(zerothCard.querySelector('h2').textContent, 'Mark');
assert.equal(zerothCard.querySelector('.card-title').textContent, 'Front-End developer');
assert.equal(zerothCard.querySelector('p:last-child').textContent, 'I like to work with different front-end technologies and play video games.');

You should use the Card component as an element with the appropriate props and first card values.

js
const firstCard = document.querySelectorAll('.card')[1];

assert.equal(firstCard.querySelector('h2').textContent, 'Tiffany');
assert.equal(firstCard.querySelector('.card-title').textContent, 'Engineering manager');
assert.equal(firstCard.querySelector('p:last-child').textContent, 'I have worked in tech for 15 years and love to help people grow in this industry.');

You should use the Card component as an element with the appropriate props and second card values.

js
const secondCard = document.querySelectorAll('.card')[2];

assert.equal(secondCard.querySelector('h2').textContent, 'Doug');
assert.equal(secondCard.querySelector('.card-title').textContent, 'Back-End developer');
assert.equal(secondCard.querySelector('p:last-child').textContent, 'I have been a software developer for over 20 years and I love working with Go and Rust.');

--seed--

--seed-contents--

html
<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Reusable Card component</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.development.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.development.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.26.3/babel.min.js"></script>
    <script
      data-plugins="transform-modules-umd"
      type="text/babel"
      src="index.jsx"
    ></script>
     <link rel="stylesheet" href="./styles.css" />
  </head>
  <body>
    <div id="root"></div>
    <script
      data-plugins="transform-modules-umd"
      type="text/babel"
      data-presets="react"
      data-type="module"
    >
      import { App } from './index.jsx';
      ReactDOM.createRoot(document.getElementById('root')).render(
        <App />
      );
    </script>
  </body>
</html>
css
:root {
  --dark-grey: #1b1b32;
  --light-grey: #f5f6f7;
  --dark-orange: #f89808;
}

body {
  background-color: var(--dark-grey);
}

.flex-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
}

.card {
  border: 5px solid var(--dark-orange);
  border-radius: 10px;
  width: 100%;
  padding: 20px;
  margin: 10px 0;
  background-color: var(--light-grey);
}

.card-title {
  border-bottom: 4px solid var(--dark-orange);
  width: fit-content;
}

@media (min-width: 768px) {
  .card {
    width: 300px;
  }
}
jsx
export function Card({ name, title, bio }) {
  return (
    <div className="card">
      <h2>{name}</h2>
      <p className="card-title">{title}</p>
      <p>{bio}</p>
    </div>
  )
}

export function App() {
  return (
    <div className="flex-container">
      <Card
        name="Mark"
        title="Front-End developer"
        bio="I like to work with different front-end technologies and play video games."
      />
      --fcc-editable-region--
      
      --fcc-editable-region--
    </div>
  );
}