-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#7] OAuth 회원가입, 로그인 UI 및 동작 #33
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0dec305
add: OAuth 버튼을 통해 type에 맞는 버튼 내부 구성
Choi-Jinwoo 8503058
fix: Facebook, Google, Kakao 로고 이미지 변경
Choi-Jinwoo f556b90
fix: OAuthButton의 type을 열거형으로 변경, 스타일 수정
Choi-Jinwoo aeccb9b
add: 개발 Webpack에서 SERVER_URL 환경변수 추가
Choi-Jinwoo b1909fe
fix: OAuthButton 에서 OAuth를 분기하지 않고 Login에서 분기
Choi-Jinwoo a73ba39
Merge branch 'develop' into feat/frontend-signup
Choi-Jinwoo c936e02
add: 로그인 페이지 버튼 UI 테스트
Choi-Jinwoo 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SERVER_URL= |
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,3 +1,6 @@ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
moduleNameMapper: { | ||
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2|svg)$': 'jest-transform-stub', | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import Login from './Login'; | ||
|
||
describe('Login 컴포넌트', () => { | ||
test('facebook 버튼 UI', () => { | ||
const login = render(<Login />); | ||
|
||
login.getByText('페이스북으로 로그인'); | ||
}); | ||
|
||
test('google 버튼 UI', () => { | ||
const login = render(<Login />); | ||
|
||
login.getByText('구글로 로그인'); | ||
}); | ||
}); |
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,69 @@ | ||
import React, { useCallback, useMemo } from 'react'; | ||
import styled from 'styled-components'; | ||
import OAuthButton from './OAuthButton'; | ||
import FACEBOOK from './facebook.svg'; | ||
import GOOGLE from './google.svg'; | ||
|
||
enum OAuthType { | ||
Facebook, | ||
Google, | ||
} | ||
|
||
const Header = styled.h1` | ||
font-size: 24px; | ||
font-weight: normal; | ||
`; | ||
|
||
const LoginContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
const OAuthButtonWrapper = styled.div` | ||
margin-top: 20px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
gap: 10px; | ||
`; | ||
|
||
const Login = (): JSX.Element => { | ||
const handleOAuthButtonClick = useCallback((redirectURL: string) => { | ||
return () => (location.href = redirectURL); | ||
}, []); | ||
|
||
const BUTTON_PROPS = useMemo( | ||
() => ({ | ||
[OAuthType.Facebook]: { | ||
backgroundColor: '#4267b2', | ||
fontColor: '#ffffff', | ||
icon: FACEBOOK, | ||
content: '페이스북으로 로그인', | ||
onClick: handleOAuthButtonClick(`${process.env.SERVER_URL}/auth/facebook-login`), | ||
}, | ||
[OAuthType.Google]: { | ||
backgroundColor: '#EA4335', | ||
fontColor: '#ffffff', | ||
icon: GOOGLE, | ||
content: '구글로 로그인', | ||
onClick: handleOAuthButtonClick(`${process.env.SERVER_URL}/auth/google-login`), | ||
}, | ||
}), | ||
[handleOAuthButtonClick] | ||
); | ||
|
||
return ( | ||
<LoginContainer> | ||
<Header>회원 로그인</Header> | ||
<OAuthButtonWrapper> | ||
<OAuthButton {...BUTTON_PROPS[OAuthType.Facebook]} /> | ||
<OAuthButton {...BUTTON_PROPS[OAuthType.Google]} /> | ||
</OAuthButtonWrapper> | ||
</LoginContainer> | ||
); | ||
}; | ||
|
||
export default Login; |
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,55 @@ | ||
import React, { MouseEventHandler } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
type ContainerProps = { | ||
backgroundColor: string; | ||
fontColor: string; | ||
}; | ||
|
||
const OAuthButtonContainer = styled.button<ContainerProps>` | ||
background-color: ${(props) => props.backgroundColor}; | ||
color: ${(props) => props.fontColor}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 15px; | ||
height: 50px; | ||
width: 300px; | ||
padding: 15px; | ||
border: none; | ||
cursor: pointer; | ||
`; | ||
|
||
const OAuthIcon = styled.img` | ||
max-width: 18px; | ||
max-height: 100%; | ||
`; | ||
|
||
const OAuthButtonContent = styled.span` | ||
font-size: 16px; | ||
`; | ||
|
||
type Props = { | ||
backgroundColor: string; | ||
fontColor: string; | ||
icon: string; | ||
content: string; | ||
onClick: MouseEventHandler; | ||
}; | ||
|
||
const OAuthButton = ({ | ||
icon, | ||
fontColor, | ||
backgroundColor, | ||
content, | ||
onClick, | ||
}: Props): JSX.Element => { | ||
return ( | ||
<OAuthButtonContainer fontColor={fontColor} backgroundColor={backgroundColor} onClick={onClick}> | ||
<OAuthIcon src={icon} /> | ||
<OAuthButtonContent>{content}</OAuthButtonContent> | ||
</OAuthButtonContainer> | ||
); | ||
}; | ||
|
||
export default OAuthButton; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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
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.
enum으로 처리되어서 이미 충분히 깔끔하지만 스타일 관련된 부분하고 아이콘은 컴포넌트 밖으로 빼도 되지 않을까 싶은데.. 잘 모르겠네요 ㅎㅎ
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.
아 처음엔 밖으로 뺏는데 또
onClick
때문에 결국 밖에 하나 안에 하나 만들어야 되더라구요 ㅠㅜ 그래서 이렇게 한번 해봤는데 저도 헷갈려서 다른 분들은 어떤게 나을까요? 👀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.
이 부분은 진짜 선택의 문제 같은 느낌이네요 .. 스타일 코드는 따로 다 빼놓고, handleOAuthButtonClick이 url을 받아서 작동하게 하면 될 것 같긴한데.. 잘모르겠습니다 진짜 .. ㅋㅋㅋ