-
Notifications
You must be signed in to change notification settings - Fork 7
[3주차] 강태이/컴포넌트 모듈화 수정 및 주요 기능 구현 #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 강태이/main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uAC15\uD0DC\uC774/3\uC8FC\uCC28"
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| <<<<<<< HEAD | ||
| # 🖥️ Mission-FE-Zero100 | ||
| FE Zero100 미션을 위한 레포지토리입니다. | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,44 @@ | ||
| import "./index.css"; | ||
| import Text from "./component/Text"; | ||
| import Input from "./component/Input"; | ||
| import Button from "./component/Button"; | ||
| import Checkbox from "./component/Checkbox"; | ||
| import styled from "styled-components"; | ||
| import Header from "./component/Header"; | ||
| import AddTodo from "./component/AddTodo"; | ||
| import Category from "./component/Category"; | ||
| import TodoList from "./component/TodoList"; | ||
| import { useState } from "react"; | ||
|
|
||
| const Container = styled.div` | ||
| max-width: 800px; | ||
| margin: 0 auto; | ||
| padding: 20px; | ||
| background-color: #f9f9f9; | ||
|
|
||
| @media (max-width: 768px) and (orientation: portrait) { | ||
| max-width: 90%; | ||
| padding: 1.5rem; | ||
| } | ||
|
|
||
| @media (max-width: 480px) and (orientation: portrait) { | ||
| padding: 1rem; | ||
| } | ||
| `; | ||
|
|
||
| function App() { | ||
| return ( | ||
| <div className="app-container"> | ||
| {/* text part */} | ||
| <Text /> | ||
| const [todos, setTodos] = useState([]); | ||
| const [activeCategory, setActiveCategory] = useState("All"); | ||
|
|
||
| const handleAddTodo = (text) => { | ||
| if (text.trim() === "") return; | ||
| const newTodo = { id: Date.now(), text, completed: false }; | ||
| setTodos([...todos, newTodo]); | ||
| }; | ||
|
|
||
| {/* input part */} | ||
| <Input /> | ||
| {/* button part */} | ||
| <Button /> | ||
| {/* checkbox part */} | ||
| <Checkbox /> | ||
| </div> | ||
| return ( | ||
| <Container> | ||
| <Header /> | ||
| <AddTodo onAddTodo={handleAddTodo} /> | ||
| <Category activeCategory={activeCategory} setActiveCategory={setActiveCategory} /> | ||
| <TodoList todos={todos} setTodos={setTodos} activeCategory={activeCategory} /> | ||
| </Container> | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| export default App; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import React, { useState } from 'react'; | ||
| import styled from "styled-components"; | ||
|
|
||
| const AddTodoContainer = styled.div` | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| text-align: center; | ||
| `; | ||
|
|
||
| const StyledText = styled.h2` | ||
| text-align: center; | ||
| display: flex; | ||
| `; | ||
|
|
||
| const StyledInput = styled.input` | ||
| width: 500px; | ||
| padding: 14px; | ||
| border-radius: 0px; | ||
| margin-bottom: 8px; | ||
| `; | ||
|
|
||
| const StyledButton = styled.button` | ||
| background-color: black; | ||
| color: white; | ||
| width: 532px; | ||
| padding: 9px; | ||
| border: none; | ||
| border-radius: 0px; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0px로 주시는 건, 아무것도 지정하지 않은 상태와 동일하기 때문에 굳이 명시하실 필요 없습니다! |
||
| margin-bottom: 8px; | ||
| `; | ||
|
|
||
| const AddTodo = ({ onAddTodo }) => { | ||
| const [inputValue, setInputValue] = useState(""); | ||
|
|
||
| const handleInputChange = (e) => { | ||
| setInputValue(e.target.value); | ||
| }; | ||
|
|
||
| const handleAddClick = () => { | ||
| onAddTodo(inputValue); | ||
| setInputValue(""); | ||
| }; | ||
|
|
||
| return( | ||
| <AddTodoContainer> | ||
| <StyledText>What needs to be done?</StyledText> | ||
| <StyledInput | ||
| type="text" | ||
| placeholder="Add a task" | ||
| value={inputValue} | ||
| onChange={handleInputChange} | ||
| /> | ||
| <StyledButton onClick={handleAddClick}>Add</StyledButton> | ||
| </AddTodoContainer> | ||
| ) | ||
| } | ||
|
|
||
| export default AddTodo; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +0,0 @@ | ||
| import React from 'react' | ||
|
|
||
| const Button = ({label, onClick}) => { | ||
| return ( | ||
| <div className="filters"> | ||
| <button>Show all tasks</button> | ||
| <button>Show active tasks</button> | ||
| <button>Show completed tasks</button> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default Button; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import React, { useState } from 'react'; | ||
| import styled from "styled-components"; | ||
|
|
||
| const CategoryContainer = styled.div` | ||
| display: flex; | ||
| justify-content: center; | ||
| gap: 8px; | ||
| `; | ||
|
|
||
| const StyledButton = styled.button` | ||
| width: 130px; | ||
| padding: 7px; | ||
| background-color: white; | ||
| border: 2px solid ${(props) => (props.active ? "black" : "#ccc")}; | ||
| border-radius: 0px; | ||
| font-size: 14px; | ||
| `; | ||
|
|
||
| const Category = ({ activeCategory, setActiveCategory }) => { | ||
| return ( | ||
| <CategoryContainer> | ||
| {["All", "Active", "Completed"].map((label) => ( | ||
| <StyledButton | ||
| key={label} | ||
| active={activeCategory === label} | ||
| onClick={() => setActiveCategory(label)} | ||
| > | ||
| {label} | ||
| </StyledButton> | ||
| ))} | ||
| </CategoryContainer> | ||
| ); | ||
| }; | ||
|
|
||
| export default Category; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input 컴포넌트를 사용하지 않으시고, 새로 생성하셨네요!
Input, Button, Text와 같이 공통 컴포넌트를 만드셨으니, 해당 컴포넌트들을 활용하는 것이 좋을 것 같아요!