-
Notifications
You must be signed in to change notification settings - Fork 35
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
[DOTORI] 1주차 두번째 PR #57
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e7746bc
chore: 프로젝트 초기 셋팅 (#2)
mogooee 39401cb
feat:VendingMachine, Wallet 라우팅 (#5)
mogooee c7fc0db
Wallet Component - Markup (#6)
mogooee 1931cae
VendingMachine Component - Markup (#9)
mogooee d7e799f
Common Components 분리(1) (#10)
mogooee f063227
chore: gh-pages 라이브러리 설치
mogooee c5ba58b
Display Mode(dark/light) (#13)
mogooee daa9354
PR1 Refactoring (#16)
mogooee f2df099
Wallet Component - 동전 투입 기능 (#17)
mogooee a249a85
Merge remote-tracking branch 'origin' into develop1
mogooee 7081dc3
remove: merge로 생성된 중복 파일 제거
mogooee 5160b7c
rename: 컴포넌트 디렉토리명 대문자로 변경
mogooee 3dabc6c
refactor: balance state 제거, useBalance삭제
mogooee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import styled from "styled-components"; | ||
|
||
const ToggleWrapper = styled.div` | ||
display: grid; | ||
place-items: center; | ||
align-content: center; | ||
min-height: 100vh; | ||
width: 100vw; | ||
border-radius: 0px; | ||
background-color: ${({ display }) => display.backgroundColor}; | ||
`; | ||
|
||
function AppLayout({ display, children }) { | ||
return <ToggleWrapper display={display}>{children}</ToggleWrapper>; | ||
} | ||
|
||
export { AppLayout }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useContext, memo } from "react"; | ||
import { InsertCoinContext, CoinContext } from "context"; | ||
import { Button } from "components"; | ||
|
||
function Coin({ unit, count }) { | ||
const { selectCoin } = useContext(CoinContext); | ||
const { insertCoin, setInsertCoin } = useContext(InsertCoinContext); | ||
|
||
const clickCoin = () => { | ||
if (!count) return; | ||
selectCoin(unit, count); | ||
setInsertCoin(insertCoin + unit); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Button color="yellow" size="medium" onClick={clickCoin}> | ||
<strong>{unit}</strong> | ||
</Button> | ||
<span>{count}</span> | ||
</> | ||
); | ||
} | ||
|
||
const areEqual = (prevProps, nextProps) => prevProps.count === nextProps.count; | ||
const MemoizedCoin = memo(Coin, areEqual); | ||
|
||
export { MemoizedCoin }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useContext } from "react"; | ||
import styled from "styled-components"; | ||
import { CoinContext } from "context"; | ||
import { MemoizedCoin } from "components"; | ||
|
||
const StyledCoinContainer = styled.ul` | ||
li { | ||
display: grid; | ||
justify-items: center; | ||
align-items: center; | ||
grid-template-columns: 50% 50%; | ||
margin: 10px; | ||
|
||
span { | ||
width: 100%; | ||
background-color: #fff7bc; | ||
display: grid; | ||
place-items: center; | ||
height: 50px; | ||
color: #000; | ||
border-radius: 10px; | ||
} | ||
} | ||
`; | ||
|
||
function CoinContainer() { | ||
const { coin } = useContext(CoinContext); | ||
|
||
return ( | ||
<StyledCoinContainer> | ||
{coin.map(({ id, unit, count }) => ( | ||
<li key={id}> | ||
<MemoizedCoin unit={unit} count={count} /> | ||
</li> | ||
))} | ||
</StyledCoinContainer> | ||
); | ||
} | ||
|
||
export { CoinContainer }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import styled from "styled-components"; | ||
import { Nav } from "components"; | ||
|
||
const StyledNav = styled.nav` | ||
position: absolute; | ||
top: 0; | ||
padding-top: 20px; | ||
margin-bottom: 10px; | ||
|
||
ul { | ||
display: flex; | ||
margin-bottom: 20px; | ||
} | ||
`; | ||
|
||
const Li = styled.li` | ||
& + & { | ||
margin-left: 1rem; | ||
} | ||
|
||
a { | ||
display: grid; | ||
place-items: center; | ||
width: 200px; | ||
height: 50px; | ||
border-radius: 10px; | ||
text-decoration: none; | ||
color: #fff; | ||
font-weight: 500; | ||
} | ||
`; | ||
|
||
function MainNav() { | ||
const activeStyle = ({ isActive }) => ({ backgroundColor: isActive ? "#512d6d" : "#9772fb" }); | ||
|
||
return ( | ||
<StyledNav> | ||
<ul> | ||
<Li> | ||
<Nav link="/vendingmachine" activeStyle={activeStyle}> | ||
자판기 | ||
</Nav> | ||
</Li> | ||
<Li> | ||
<Nav to="/wallet" activeStyle={activeStyle}> | ||
지갑 | ||
</Nav> | ||
</Li> | ||
</ul> | ||
</StyledNav> | ||
); | ||
} | ||
|
||
export { MainNav }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { BrowserRouter, Route, Routes } from "react-router-dom"; | ||
import { Home, VendingMachine, Wallet, NotFound } from "pages"; | ||
|
||
function Routers() { | ||
return ( | ||
<BrowserRouter basename={process.env.PUBLIC_URL}> | ||
<Routes> | ||
<Route path="/" element={<Home />}> | ||
<Route index element={<VendingMachine />} /> | ||
<Route path="/vendingmachine" element={<VendingMachine />} /> | ||
<Route path="/wallet/*" element={<Wallet />} /> | ||
</Route> | ||
<Route path="*" element={<NotFound />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
); | ||
} | ||
|
||
export { Routers }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import styled from "styled-components"; | ||
import { Button } from "components"; | ||
import { useDisplay } from "hooks"; | ||
|
||
const StyledDisplay = styled.div` | ||
position: absolute; | ||
top: 30px; | ||
right: 100px; | ||
|
||
button { | ||
box-shadow: 0px 0px 7px; | ||
} | ||
`; | ||
|
||
function ToggleDisplay() { | ||
const { displayMode, toggleDisplay } = useDisplay(); | ||
const color = displayMode === "light" ? "white" : "black"; | ||
const icon = displayMode === "light" ? "🌚" : "🌝"; | ||
Comment on lines
+17
to
+18
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. 다크모드를 구현하셨군요! |
||
|
||
return ( | ||
<StyledDisplay> | ||
<Button color={color} size="small" onClick={toggleDisplay}> | ||
{icon} | ||
</Button> | ||
</StyledDisplay> | ||
); | ||
} | ||
|
||
export { ToggleDisplay }; |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from "react"; | ||
import { NavLink } from "react-router-dom"; | ||
|
||
function Nav({ children, link, activeStyle, ...rest }) { | ||
return ( | ||
<NavLink to={link} style={activeStyle} {...rest}> | ||
{children} | ||
</NavLink> | ||
); | ||
} | ||
|
||
export { Nav }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
export * from "./Coin"; | ||
export * from "./Balance"; | ||
export * from "./VendProduct"; | ||
export * from "./VendController"; | ||
export * from "./InsertCoin"; | ||
export * from "./ChangeOutlet"; | ||
export * from "./HistoryBox"; | ||
export * from "./Button"; | ||
export * from "./common/Button"; | ||
export * from "./common/Nav"; | ||
export * from "./Routers/Routers"; | ||
export * from "./AppLayout/AppLayout"; | ||
export * from "./MainNav/MainNav"; | ||
export * from "./ToggleDisplay/ToggleDisplay"; | ||
export * from "./coin/CoinContainer"; | ||
export * from "./coin/Coin"; | ||
export * from "./Balance/Balance"; | ||
export * from "./vend-product/VendProductContainer"; | ||
export * from "./vend-product/VendProduct"; | ||
export * from "./vend-controller/VendController"; | ||
export * from "./vend-controller/InsertCoin"; | ||
export * from "./vend-controller/ChangeOutlet"; | ||
export * from "./vend-controller/HistoryBox"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
early return 👍