Kim-aide / frontend

https://kim-aide.github.io/frontend/
0 stars 0 forks source link

[FEAT] 공용 로그인 버튼 신규 생성 #1

Closed baesee0806 closed 2 months ago

baesee0806 commented 3 months ago

작업 대상

작업 내용

폴더

컴포넌트

import React from 'react';
#1)
import * as S from './LoginBtn.styled';
import googleIcon from '../../assets/loginicon/google-icon.png';
import naverIcon from '../../assets/loginicon/naver-icon.png';
#2)
interface LoginBtnProps {
    type: string;
}
const LoginBtn = (props: LoginBtnProps) => {
#3)
    const handleLogin = () => {
        alert('로그인 되었습니다.');
    };
#4
    if (props.type === 'google') {
        return (
            <S.LoginButton onClick={handleLogin}>
                <S.LoginIcon src={googleIcon} alt="googleIcon" />
                <S.LoginText>Google 계정으로 로그인 하기</S.LoginText>
            </S.LoginButton>
        );
    }
    if (props.type === 'naver') {
        return (
            <S.LoginButton $type="naver" onClick={handleLogin}>
                <S.LoginIcon src={naverIcon} alt="naverIcon" />
                <S.LoginText $type="naver">네이버 계정으로 로그인 하기</S.LoginText>
            </S.LoginButton>
        );
    }
    return null;
};

export default LoginBtn;

emotion css

import styled from '@emotion/styled';

const LoginButton = styled.button<{ $type?: string }>`
    display: flex;
    justify-content: center;
    align-items: center;
    width: 302px;
    height: 52px;
    border: none;
    background-color: ${(props) =>
        props.$type === 'naver' ? '#1EC800' : '#FFFFFF'};
    border-radius: 5px;
`;
const LoginIcon = styled.img`
    width: 24px;
    height: 24px;
`;
const LoginText = styled.p<{ $type?: string }>`
    font-size: 16px;
    margin-left: ${(props) => (props.$type === 'naver' ? '32px' : '22px')};
    color: ${(props) => (props.$type === 'naver' ? '#FFFFFF' : '#000000')};
`;

export { LoginButton, LoginIcon, LoginText };