Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- isNaN()
- filter()
- Math.floor()
- substring()
- includes()
- indexOf()
- parseInt()
- setDate
- slice()
- 항해99솔직후기 #항해99장점 #항해99단점 #부트캠프추천
- new Date()
- getday()
- charAt()
- Eventlitener
- 3진수
- useState()
- 교집합
- reat if문
- useRef()
- 차집합
- React
- sort()
- useEffect()
- jsx반복문
- repeat()
- 소수점 올림내림
- toUpperCase()
- Math.sqrt()
- map()
- Number()
Archives
- Today
- Total
개발자로 전향중
리액트 3주차 개인과제 2022-01-23 진행상황 본문
import { Route, Routes } from "react-router-dom";
import React from "react";
import MyWeek from "./myweek";
import MyDay from "./myday";
import styled from "styled-components";
function App() {
const data = [
{
title: "월"
},
{
title: "화"
},
{
title: "수"
},
{
title: "목"
},
{
title: "금"
},
{
title: "토"
},
{
title: "일"
},
];
return (
<div className="App">
<Container>
<Title>내 일주일은?</Title>
<Line />
<Routes>
<Route path="/" element={<MyWeek data={data} />} />
<Route path="/myday/:title" element={<MyDay data={data}/>} />
</Routes>
</Container>
</div>
);
}
const Container = styled.div`
max-width: 350px;
min-height: 60vh;
background-color: #fff;
padding: 16px;
margin: 40px auto;
border-radius: 5px;
border: 1px solid #ddd;
`;
const Title = styled.h1`
color: slateblue;
text-align: center;
`;
const Line = styled.hr`
margin: 16px 0px;
border: 1px dotted #ddd;
`;
export default App;
// 리액트 패키지를 불러옵니다.
import React from "react";
import styled from "styled-components";
import { useNavigate } from "react-router-dom";
// import { Link } from 'react-router-dom'
const MyWeek = ({data}) => {
let navigate = useNavigate();
return (
<ListStyle>
{data.map((list, index) => {
return (
<ItemStyle className="list_item" key={index}>
{list.title}
{/* <Link to={`/myday/${list.title}`}>보자보자</Link> */}
<div onClick={() => {
navigate(`/myday/${list.title}`);
console.log(index)
}}
style={{
float: "right", width: "0px", height: "0px",
borderLeft: "30px solid #0931e3", borderTop: "15px solid transparent",
borderBottom: "15px solid transparent"
}}></div>
<Circle/>
<Circle/>
<Circle/>
<Circle/>
<Circle/>
</ItemStyle>
);
})}
</ListStyle>
);
};
const Circle = styled.div`
float: right;
margin: auto 10px;
width: 30px;
height: 30px;
background: #666666;
border-radius: 250px;
`;
const ListStyle = styled.div`
display: flex;
flex-direction: column;
height: 100%;
overflow-x: hidden;
overflow-y: auto;
`;
const ItemStyle = styled.div`
padding: 10px;
margin: 8px;
background-color: aliceblue;
line-height: 30px
`;
export default MyWeek;
// 리액트 패키지를 불러옵니다.
import React from 'react';
import styled from "styled-components";
import { useParams } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
const MyDay = ({data}) => {
const { title } = useParams()
let navigate = useNavigate();
const rate = React.useRef(null);
const hoverEvent = () => {
rate.current.style.background = "yellow"
}
React.useEffect(() => {
rate.current.addEventListener("mouseover", hoverEvent);
//컴포넌트 등록
}, []);
return (
<Box>
<Text>
{data
.filter((list) => list.title === title)
.map((list, index) => (
<div key={index} className="day">
{list.title}요일 평점 남기기
</div>
))}
</Text>
<ItemStyle>
<Circle ref={rate} />
<Circle />
<Circle />
<Circle />
<Circle />
</ItemStyle>
<Button onClick={() => {
navigate("/");
}}>평점 남기기</Button>
</Box>
);
};
const Button = styled.button`
color: white;
display:block;
margin: auto;
font-size: middle;
border-radius: 5px;
background: gray;
padding: 10px
`
const Text = styled.h3`
margin-left: 10px
`
const Box = styled.div`
margin: auto;
width: 220px;
height: 220px;
background: #aaaaaa;
`;
const Circle = styled.div`
float: left;
margin: 7px;
width: 30px;
height: 30px;
background: #666666;
border-radius: 250px;
`;
const ItemStyle = styled.div`
width: 100%;
margin-bottom:8vh;
`;
export default MyDay;
'React' 카테고리의 다른 글
리액트 3주차 버킷리스트 만들기 연습 2022-01-25 (0) | 2022.01.25 |
---|---|
리액트 3주차 평점 만들기 개인과제 2022-01-24 진행상황 (0) | 2022.01.24 |
꼭 알고 있어야 할 react 문법! (0) | 2022.01.23 |
리액트에서 자주쓰는 if문 작성패턴 5개 (0) | 2022.01.22 |
react(리액트) JSX 배열 반복문 렌더링 - for/map/forEach (0) | 2022.01.22 |