-
Notifications
You must be signed in to change notification settings - Fork 0
[BAZ] 같이 바다보러갈래? 구현 #16
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
Open
kand193
wants to merge
25
commits into
week4
Choose a base branch
from
week4-baz
base: week4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
62eafdb
feat: Add routing features
kand193 d2c3c34
chore: Add ant.design library
kand193 34fca99
Merge pull request #3 from mash-up-kr-web/week4-baz-yjp
godjoy 593bfbd
Add crypto-js module
minsour e6c9fcb
Add serialize and deserialize utils
minsour 44ab695
Extract key as const
minsour 8a2711a
Merge pull request #5 from mash-up-kr-web/week4-baz-minsour
kand193 adc5304
feat: Implement Game Page without result state
kand193 b3c462f
fix: Fix import order
kand193 c9cce45
fix: Add count variable
kand193 61cb2c1
Add frame of result page
minsour 16873ec
Add logic for creating url
minsour e12d257
Add url copy logic using clipboard
minsour c7ed395
fix: Fix title for feedback
kand193 8fe1ada
Add messages
minsour 5663000
Customize the OceanSelection to remove the cursor attribute from the …
minsour faab8f1
Merge pull request #8 from mash-up-kr-web/week4-baz-yjp
minsour 9d99352
Merge branch 'week4-baz' into week4-baz-minsour
minsour d8308b5
Add user's name to messages
minsour bcee389
add ocean background
godjoy 2798961
Index Name 관련 ContextAPI
godjoy c8a0a8a
add Index contents
godjoy 6fe8899
prettier 적용
godjoy 6d49b88
Merge pull request #13 from mash-up-kr-web/week4-baz-joy
godjoy ecfed44
Merge pull request #14 from mash-up-kr-web/week4-baz-minsour
kand193 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,26 @@ | ||
| /* External dependencies */ | ||
| import { IndexContextProvider } from 'components/index/IndexContext'; | ||
| import IndexPage from 'pages'; | ||
| import GamePage from 'pages/game'; | ||
| import ResultPage from 'pages/result'; | ||
| import React from 'react'; | ||
| import { Route, BrowserRouter as Router, Switch } from 'react-router-dom'; | ||
|
|
||
| function App() { | ||
| return <div>Hello World!</div>; | ||
| return ( | ||
| <> | ||
| <IndexContextProvider> | ||
| <Router> | ||
| <Switch> | ||
| <Route exact path="/game" component={GamePage} /> | ||
| <Route exact path="/result" component={ResultPage} /> | ||
| <Route path="/" component={IndexPage} /> | ||
| </Switch> | ||
| </Router> | ||
| </IndexContextProvider> | ||
|
|
||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default App; | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 React from 'react'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| import OceanInfo from 'types/OceanInfo'; | ||
|
|
||
| interface OceanSelectionProps extends React.HTMLProps<HTMLDivElement> { | ||
| ocean: OceanInfo; | ||
| isResult?: boolean; | ||
| } | ||
|
|
||
| // TODO: 선택시 인터렉션 필요 | ||
| const OceanSelection = ({ ocean, isResult, onClick }: OceanSelectionProps) => ( | ||
| <Selection isResult={isResult} onClick={onClick}> | ||
| <img src={ocean.imageSrc} alt="ocean" /> | ||
| <Title>{ocean.name}</Title> | ||
| <Description>{ocean.description}</Description> | ||
| </Selection> | ||
| ); | ||
|
|
||
| export default OceanSelection; | ||
|
|
||
| const Selection = styled.div<{ isResult?: boolean }>` | ||
| position: relative; | ||
| width: 50%; | ||
| height: 100%; | ||
| background-color: blue; | ||
| border: 1px solid black; | ||
| cursor: ${props => (props.isResult ? '' : 'pointer')}; | ||
|
|
||
| > img { | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
| `; | ||
|
|
||
| const Title = styled.div` | ||
| position: absolute; | ||
| width: 100%; | ||
| top: 30px; | ||
| color: white; | ||
| text-align: center; | ||
| font-size: 30px; | ||
| font-weight: bold; | ||
| `; | ||
|
|
||
| const Description = styled.div` | ||
| position: absolute; | ||
| width: 100%; | ||
| bottom: 30px; | ||
| color: white; | ||
| text-align: center; | ||
| font-size: 20px; | ||
| font-weight: bold; | ||
| `; |
This file contains hidden or 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 React, { createContext, Dispatch, useContext, useReducer } from 'react'; | ||
|
|
||
| export type State = { | ||
| name: string; | ||
| }; | ||
|
|
||
| type Action = { type: 'SET_NAME'; name: string }; | ||
|
|
||
| type IndexDispatch = Dispatch<Action>; | ||
|
|
||
| const IndexStateContext = createContext<State | undefined>(undefined); | ||
| const IndexDispatchContext = createContext<IndexDispatch | undefined>( | ||
| undefined, | ||
| ); | ||
|
|
||
| function reducer(state: State, action: Action): State { | ||
| switch (action.type) { | ||
| case 'SET_NAME': | ||
| return { | ||
| name: action.name, | ||
| }; | ||
| default: | ||
| throw new Error('Unhandled action'); | ||
| } | ||
| } | ||
|
|
||
| export function IndexContextProvider({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| const initialState: State = { name: '' }; | ||
| const [state, dispatch] = useReducer(reducer, initialState); | ||
|
|
||
| return ( | ||
| <IndexStateContext.Provider value={state}> | ||
| <IndexDispatchContext.Provider value={dispatch}> | ||
|
Comment on lines
+36
to
+37
Collaborator
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. 오 저는 보통 하나의 context에 state와 dispatch를 묶어서 보냈는데 이렇게 분리시키는것도 좋아보이네요 |
||
| {children} | ||
| </IndexDispatchContext.Provider> | ||
| </IndexStateContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export function useIndexState() { | ||
| const state = useContext(IndexStateContext); | ||
| if (!state) throw new Error('IndexProvider not found'); | ||
| return state; | ||
| } | ||
|
|
||
| export function useIndexDispatch() { | ||
| const dispatch = useContext(IndexDispatchContext); | ||
| if (!dispatch) throw new Error('IndexProvider not found'); | ||
| return dispatch; | ||
| } | ||
This file contains hidden or 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 React from 'react'; | ||
| import styled from 'styled-components'; | ||
| import ocean from '../../assets/ocean.jpg'; | ||
|
|
||
| const OceanBackground = () => ( | ||
| <> | ||
| <svg | ||
| width="0" | ||
| height="0" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| xlinkHref="http://www.w3.org/1999/xlink" | ||
| > | ||
| <filter id="water"> | ||
| <feTurbulence | ||
| type="fractalNoise" | ||
| baseFrequency=".05 .05" | ||
| numOctaves="1" | ||
| result="noise1" | ||
| /> | ||
| <feColorMatrix in="noise1" type="hueRotate" values="0" result="noise2"> | ||
| <animate | ||
| attributeName="values" | ||
| from="0" | ||
| to="360" | ||
| dur="1s" | ||
| repeatCount="indefinite" | ||
| /> | ||
| </feColorMatrix> | ||
| <feDisplacementMap | ||
| xChannelSelector="R" | ||
| yChannelSelector="G" | ||
| scale="7" | ||
| in="SourceGraphic" | ||
| in2="noise2" | ||
| /> | ||
| </filter> | ||
| </svg> | ||
| <BackgroundImg src={ocean} alt="ocean Image" /> | ||
| </> | ||
| ); | ||
|
|
||
| export default OceanBackground; | ||
|
|
||
| const BackgroundImg = styled.img` | ||
| width: 105vw; | ||
| height: 105vh; | ||
| position: absolute; | ||
| top: -5vh; | ||
| left: -5vw; | ||
| object-fit: cover; | ||
| filter: url(#water); | ||
| position: absolute; | ||
| z-index: -1; | ||
| `; |
This file contains hidden or 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,88 @@ | ||
| import { Button, Input } from 'antd'; | ||
| import React, { useState } from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
| import styled from 'styled-components'; | ||
| import { useIndexDispatch } from './IndexContext'; | ||
|
|
||
| interface IndexProps { | ||
| isValid: boolean; | ||
| name: string; | ||
| } | ||
|
|
||
| function NameExistComp(props) { | ||
| const name = props.name; | ||
| return ( | ||
| <> | ||
| <Title>{name} 님의 초대</Title>; | ||
| <Link to="/game"> | ||
| <StartButton>🎮start🎮</StartButton> | ||
| </Link> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| function NameNotExistComp() { | ||
| const [value, setValue] = useState(''); | ||
| const dispatch = useIndexDispatch(); | ||
|
|
||
| const handleSubmit = () => { | ||
| dispatch({ type: 'SET_NAME', name: value }); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <form onSubmit={handleSubmit}> | ||
| <StyledInput | ||
| value={value} | ||
| placeholder="이름을 입력해 주세요." | ||
| onChange={e => setValue(e.target.value)} | ||
| /> | ||
| <br /> | ||
| <Link to="/game"> | ||
| <StartButton onClick={handleSubmit}>🎮start🎮</StartButton> | ||
| </Link> | ||
| </form> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| function Contents({ isValid, name }: IndexProps) { | ||
| if (isValid) { | ||
| return <NameExistComp name={name} />; | ||
| } else { | ||
| return <NameNotExistComp />; | ||
| } | ||
| } | ||
|
|
||
| function IndexContents(props: IndexProps) { | ||
| const isValid = props.isValid; | ||
| const name = props.name; | ||
| return ( | ||
| <> | ||
| <Contents isValid={isValid} name={name} /> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default IndexContents; | ||
|
|
||
| const Title = styled.div` | ||
| margin-top: 400px; | ||
| font-weight: bolder; | ||
| font-size: 30pt; | ||
| `; | ||
|
|
||
| const StyledInput = styled(Input)` | ||
| margin-top: 400px; | ||
| width: 200px; | ||
| height: 50px; | ||
| `; | ||
|
|
||
| const StartButton = styled(Button)` | ||
| margin-top: 20px; | ||
| width: 200px; | ||
| height: 50px; | ||
| font-weight: bolder; | ||
| font-size: 20pt; | ||
| text-align: center; | ||
| `; |
This file contains hidden or 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
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.
이 부분을 좀 흥미로웠는데요! 제가 로직을 잘 이해못해서 그런지 모르겠지만. 저는 보통
path="/"에exact를 걸어두는데, 이 코드에서는path="/"제외한 곳에exact가 걸려있더라구요! 근데 이러면 일일이Route가 생성될때마다exact를 걸어주거나 하는등 유지보수 측면에서 안좋아 보이는데,exact옵션을 저렇게 주신 이유가 있을까요?Uh oh!
There was an error while loading. Please reload this page.
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.
저도 이렇게 써본적은 없는데 이렇게 '/'에 exact를 안넣고 마지막에 위치시키면 약간 404페이지 느낌으로 아무 route에나 접근해도 IndexPage띄울순 있겠군요! 가끔씩 404페이지 따로 없을때 이렇게 써봐야겠네요ㅎㅎ