Skip to content

Commit

Permalink
Merge pull request #20 from sean2337/feat/#11/socialLoginButton
Browse files Browse the repository at this point in the history
Feat/#11/social login button
  • Loading branch information
sean2337 authored Jul 7, 2024
2 parents be80d65 + 334e5f0 commit e7ca080
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 5 deletions.
22 changes: 22 additions & 0 deletions src/assets/imgs/loginLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/component/Img/LoginSpriteSvg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import loginLogo from "@/assets/imgs/loginLogo.svg";
import { loginType } from "@/types/loginType";

const LoginSpriteSvg = ({ type }: loginType) => (
<svg width="1.8rem" height="1.833rem">
<use href={`${loginLogo}#${type}`} />
</svg>
);

export default LoginSpriteSvg;
36 changes: 36 additions & 0 deletions src/component/button/SocialLoginButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { css } from "@emotion/react";
import { loginTypeProvider, loginBtnProps, backgroundColors } from "@/types/loginType";
import LoginSpriteSvg from "../Img/LoginSpriteSvg";

const SocialLoginButton = ({ type, handler }: loginBtnProps) => {
return (
<button
css={css`
width: 100%;
height: 4.8rem;
border-radius: 0.8rem;
background-color: ${backgroundColors[type]};
text-align: center;
position: relative;
border: ${type === "google" ? "0.01rem solid rgba(0, 0, 0, 0.08)" : "none"};
`}
onClick={() => {
handler();
}}
>
<div
css={css`
position: absolute;
left: 1.6rem;
top: 50%;
transform: translateY(-50%);
`}
>
<LoginSpriteSvg type={type} />
</div>
{loginTypeProvider[type]}로 로그인
</button>
);
};

export default SocialLoginButton;
16 changes: 11 additions & 5 deletions src/style/global.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
html {
font-size: 62.5%;
font-size: 62.5%;
}

body {
font-size: 1.5rem;
margin: 0;
padding: 0;
}
font-size: 1.5rem;
margin: 0;
padding: 0;
}

button {
border: none;
outline: none;
user-select: none;
}
23 changes: 23 additions & 0 deletions src/types/loginType/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const loginTypeProvider = {
apple: "애플",
google: "구글",
kakao: "카카오",
};

// FIXME : 버튼 색 수정 필요
export const backgroundColors: Record<keyof typeof loginTypeProvider, string> = {
kakao: "#ffe400",
google: "#FFFFFF",
apple: "red",
};

type loginProvider = keyof typeof loginTypeProvider;

export type loginType = {
type: loginProvider;
};

export type loginBtnProps = {
type: loginProvider;
handler: () => void;
};

0 comments on commit e7ca080

Please sign in to comment.