Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Donggrina/Frontend into …
Browse files Browse the repository at this point in the history
…feature/start-family
  • Loading branch information
LDH98 committed Jun 3, 2024
2 parents fb89bec + af95c4e commit ee7902e
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 15 deletions.
6 changes: 3 additions & 3 deletions components/common/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { useFormContext } from 'react-hook-form';
import styles from '@/components/common/Input/Input.module.scss';

interface FormInput extends InputHTMLAttributes<HTMLInputElement> {
label: string;
name: string;
}
const FormInput = ({ name, label, type = 'text' }: FormInput) => {

const FormInput = ({ name, type = 'text' }: FormInput) => {
const {
register,
formState: { errors },
} = useFormContext();

return (
<div className={styles.container}>
<label htmlFor={name}>{label}</label>
<input
className={styles.input}
id={name}
Expand Down
11 changes: 11 additions & 0 deletions components/common/Label/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, { InputHTMLAttributes } from 'react';

interface FormLabel extends InputHTMLAttributes<HTMLInputElement> {
htmlFor: string;
}

const FormLabel = ({ htmlFor, children }: FormLabel) => {
return <label htmlFor={htmlFor}>{children}</label>;
};

export default FormLabel;
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
border-radius: 32px;
font-weight: 700;
font-size: 16px;
background-color: $background;
border: $border;
color: $color;
border: $border;
}

@mixin primaryButton {
Expand Down
2 changes: 1 addition & 1 deletion components/login/google-button/google-button.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '/components/common/button/button.module.scss';
@import '/components/common/common-button/common-button.module.scss';

.googleButton {
@include roundButton(var(--white), 1px solid var(--google-border), var(--google-color));
Expand Down
3 changes: 2 additions & 1 deletion components/login/google-button/google-button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import GoogleSVG from '@/public/images/login/google_logo.svg';
import styles from './google-button.module.scss';
import Link from 'next/link';
import { config } from '@/config';

export default function GoogleButton() {
const googleUrl = `백엔드에서 받기`;
const googleUrl = config.googleAuth;

return (
<Link className={styles.googleButton} href={googleUrl}>
Expand Down
2 changes: 1 addition & 1 deletion components/login/kakao-button/kakao-button.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '/components/common/button/button.module.scss';
@import '/components/common/common-button/common-button.module.scss';

.kakaoButton {
@include roundButton(var(--kakao-background), var(--kakao-color));
Expand Down
3 changes: 2 additions & 1 deletion components/login/kakao-button/kakao-button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Link from 'next/link';
import styles from './kakao-button.module.scss';
import KakaoSVG from '@/public/images/login/kakao_logo.svg';
import { config } from '@/config';

export default function KakaoButton() {
const kakaoURL = `백엔드에서 받기`;
const kakaoURL = config.kakaoAuth;

return (
<Link className={styles.kakaoButton} href={kakaoURL}>
Expand Down
2 changes: 1 addition & 1 deletion components/start-family/link-list/link-list.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '/components/common/Button/Button.module.scss';
@import '/components/common/common-button/common-button.module.scss';

.linkList {
display: flex;
Expand Down
4 changes: 4 additions & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const config = {
kakaoAuth: `${process.env.NEXT_PUBLIC_API_URL}/oauth2/authorization/kakao`,
googleAuth: `백엔드에서 받기`,
};
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AppProps } from 'next/app';
import '@/styles/globals.css';
import { Header } from '@/components/common/Header';
import { isHeader } from '@/utils/isHeader';
import { isHeader } from '@/utils/IsHeader';
import { useRouter } from 'next/router';

export default function App({ Component, pageProps }: AppProps) {
Expand Down
3 changes: 3 additions & 0 deletions pages/input-test/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.form {
padding-top: 72px;
}
23 changes: 18 additions & 5 deletions pages/input-test/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import React from 'react';
import { useForm, FormProvider } from 'react-hook-form';
import { useForm, FormProvider, SubmitHandler } from 'react-hook-form';
import FormInput from '@/components/common/Input';
import FormLabel from '@/components/common/Label';
import styles from './index.module.scss';

interface FormData {
name: string;
nickname: string;
}

function App() {
const methods = useForm();
const methods = useForm<FormData>();

const onSubmit = (data) => {
const onSubmit: SubmitHandler<FormData> = (data) => {
console.log(data);
};

return (
<FormProvider {...methods}>
<form onSubmit={methods.handleSubmit(onSubmit)}>
<FormInput name="name" label="가족의 이름을 알려주세요!" />
<FormInput name="nickname" label="가족 내 본인의 이름을 입력해주세요." />
<div className={styles.form}>
<FormLabel htmlFor="name">가족의 이름을 알려주세요!</FormLabel>
<FormInput name="name" />
</div>
<div>
<FormLabel htmlFor="nickname">가족 내 본인의 이름을 입력해주세요.</FormLabel>
<FormInput name="nickname" />
</div>
</form>
</FormProvider>
);
Expand Down

0 comments on commit ee7902e

Please sign in to comment.