بتل کد Battle Codeدارد باز می‌شود…

جواب «Step 4: Colour and Footer» چالش 4 از جلسه‌ی 5

سؤال

دو کار آخر:
1. کامپوننت Footer را بنویس: یک p با id برابر foot، کلاس gold و متن Made with React. آن را آخر کارت بگذار.
2. در App یک متغیر color برابر "tomato" بساز و با style رنگ دور کارت (borderColor) را از آن بگیر.

راهنما

در App قبل از return: const color = "tomato"; و روی div کارت: style={{ borderColor: color }}.

یک جواب درست

<style>
body { font-family: sans-serif; text-align: center; padding: 16px; }
button, input, select { font-size: 16px; min-height: 40px; margin: 4px; }
.card { max-width: 260px; margin: 12px auto; padding: 16px; border: 2px solid #334155; border-radius: 16px; background: #f8fafc; }
.avatar { font-size: 64px; }
.badge { display: inline-block; margin: 4px; padding: 4px 12px; border-radius: 999px; background: #bae6fd; }
.gold { color: goldenrod; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
</style>

<div id="root" dir="ltr"></div>

<script type="text/jsx">
import { createRoot } from "react-dom/client";

function Avatar() {
  return <p className="avatar">🦊</p>;
}

function Name() {
  return <h2 id="name">Sara</h2>;
}

function Bio() {
  const age = 13;
  const city = "Tabriz";
  return <p id="bio">{age} years old, from {city}</p>;
}

function Skills() {
  return (
    <div id="skills" className="row">
      <span className="badge">HTML</span>
      <span className="badge">CSS</span>
      <span className="badge">React</span>
    </div>
  );
}

function Footer() {
  return <p id="foot" className="gold">Made with React</p>;
}

function App() {
  const color = "tomato";
  return (
    <div id="card" className="card" style={{ borderColor: color }}>
      <Avatar />
      <Name />
      <Bio />
      <Skills />
      <Footer />
    </div>
  );
}

createRoot(document.getElementById("root")).render(<App />);
</script>

اول خودت امتحان کن؛ جواب‌های دیگر هم قبول است. برگرد و خودت حلش کن