728x90
반응형
App.js
import React from 'react';
import './App.css';
import './global-style.css';
import { BrowserRouter, Routes, Route, Link } from 'react-router-dom';
import Sidebar from './Sidebar';
import Tweets from './Pages/Tweets';
import MyPage from './Pages/MyPage';
import About from './Pages/About';
const App = () => {
return (
<div>
<BrowserRouter>
<div className="App">
<main>
<Sidebar />
<section className="features">
<Routes>
<Route path="/" element={<Tweets />} />
<Route path="/about" element={<About />} />
<Route path="/mypage" element={<MyPage />} />
</Routes>
</section>
</main>
</div>
</BrowserRouter>
</div>
);
};
// ! 아래 코드는 수정하지 않습니다.
export default App;
Sidebar.js
import React from 'react';
// TODO - import문을 이용하여 react-router-dom 라이브러리의 Link 컴포넌트를 불러옵니다.
import { Link } from 'react-router-dom';
const Sidebar = () => {
return (
<section className="sidebar">
{/* TODO : About 메뉴 아이콘과 Mypage 메뉴 아이콘을 작성하고 Link 컴포넌트를 이용하여 경로(path)를 연결합니다. */}
<Link to="/">
<i className="far fa-comment-dots"></i>
</Link>
<Link to="/about">
<i className="far fa-question-circle"></i>
</Link>
<Link to="/mypage">
<i className="far fa-user"></i>
</Link>
</section>
);
};
export default Sidebar;
Mypage.js
import React from "react";
import { dummyTweets } from "../static/dummyData";
import "./MyPage.css";
// ! 위 코드는 수정하지 않습니다.
// TODO - import문을 이용하여 Tweet, Footer 컴포넌트를 불러옵니다.
import Footer from "../Footer";
const MyPage = () => {
// TODO - filter 메소드를 이용하여 username이 kimcoding인 요소만 있는 배열을 filteredTweet에 할당합니다.
const filteredTweets = dummyTweets.filter(
(tweet) => tweet.username === "kimcoding"
);
return (
<section className="myInfo">
<div className="myInfo__container">
<div className="myInfo__wrapper">
<div className="myInfo__profile">
<img src={filteredTweets[0].picture} />
</div>
<div className="myInfo__detail">
<p className="myInfo__detailName">
{filteredTweets[0].username} Profile
</p>
<p>28 팔로워 100 팔로잉</p>
</div>
</div>
</div>
<ul className="tweets__mypage">
{filteredTweets.map((tweet) => {
return (
<li className="tweet" id={tweet.id} key={tweet.id}>
<div className="tweet__profile">
<img src={tweet.picture} />
</div>
<div className="tweet__content">
<div className="tweet__userInfo">
<span className="tweet__username">{tweet.username}</span>
<span className="tweet__createdAt">{tweet.createdAt}</span>
</div>
<div className="tweet__message">{tweet.content}</div>
</div>
</li>
);
})}
</ul>
<Footer />
</section>
);
};
export default MyPage;
Tweets.js
import React from "react";
import { dummyTweets } from "../static/dummyData";
import "./Tweets.css";
// ! 위 코드는 수정하지 않습니다.
// TODO - import문을 이용하여 Footer 컴포넌트를 불러오세요.
import Footer from "../Footer";
const Tweets = () => {
return (
<div>
<div className="tweetForm__container">
<div className="tweetForm__wrapper">
<div className="tweetForm__input">
<div className="tweetForm__inputWrapper">
<div className="tweetForm__count" role="status">
<span className="tweetForm__count__text">
{"total: " + dummyTweets.length}
</span>
</div>
</div>
</div>
</div>
</div>
<ul className="tweets">
{/* TODO : 트윗 메세지가 있어야 합니다. */}
{dummyTweets.map((tweet) => {
return (
<li className="tweet" id={tweet.id} key={tweet.id}>
<div className="tweet__profile">
<img src={tweet.picture} />
</div>
<div className="tweet__content">
<div className="tweet__userInfo">
<span className="tweet__username">{tweet.username}</span>
<span className="tweet__createdAt">{tweet.createdAt}</span>
</div>
<div className="tweet__message">{tweet.content}</div>
</div>
</li>
);
})}
</ul>
{/* TODO - Footer 컴포넌트를 작성합니다. */}
<Footer />
</div>
);
};
export default Tweets;
728x90
반응형
'Codestates FE' 카테고리의 다른 글
[Codestates FE] 블로깅 챌린지 1주차 - CORS (1) | 2023.04.21 |
---|---|
[Codestates FE] S3U2 - UI/UX (0) | 2023.04.13 |
[Codestates FE] S2U8 - REST API (0) | 2023.03.29 |
[Codestates FE] S2U2 - 객체 지향 프로그래밍 (0) | 2023.03.15 |
[Codestates FE] S2U2 객체지향 (0) | 2023.03.15 |
댓글