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

Step 4: Colour and Footer چالش 4 از جلسه‌ی 5، سخت

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

<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; }
.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 App() {
  return (
    <div id="card" className="card">
      <Avatar />
      <Name />
      <Bio />
      <Skills />
    </div>
  );
}

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

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 5: پروژه: کارت معرفی من

بیشتر بخوان: جاوااسکریپت چیست؟ از دکمه‌ی وب تا Node.js