Skip to content

Commit

Permalink
feat: sign-form을 추가한다
Browse files Browse the repository at this point in the history
  • Loading branch information
Zero-1016 committed May 21, 2024
1 parent 767e3a2 commit 64bf942
Show file tree
Hide file tree
Showing 36 changed files with 279 additions and 54 deletions.
5 changes: 0 additions & 5 deletions app/(site)/@modal/(.)i/sign-in/page.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions app/(site)/@modal/(.)i/sign-up/page.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions app/(site)/auth/layout.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.container {
display: flex;
justify-content: center;
align-items: center;
min-height: calc(100vh - 120px);
}
7 changes: 7 additions & 0 deletions app/(site)/auth/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PropsWithChildren } from 'react'

import styles from './layout.module.scss'

export default function Layout({ children }: PropsWithChildren) {
return <main className={styles.container}>{children}</main>
}
5 changes: 5 additions & 0 deletions app/(site)/auth/sign-in/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignInSection } from '@/widgets/auth'

export default function Page() {
return <SignInSection />
}
5 changes: 5 additions & 0 deletions app/(site)/auth/sign-up/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignUpSection } from '@/widgets/auth'

export default function Page() {
return <SignUpSection />
}
1 change: 1 addition & 0 deletions public/lottie/movie-sign-in.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/lottie/movie-sign-up.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export function GuestButtons() {
const router = useRouter()

const moveToSignIn = () => {
router.push(SITE_PATH.sign_in_modal)
router.push(SITE_PATH.sign_in)
}

const moveToSignUp = () => {
router.push(SITE_PATH.sign_up_modal)
router.push(SITE_PATH.sign_up)
}

return (
Expand Down
5 changes: 5 additions & 0 deletions src/features/auth/SignForm.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.form {
display: flex;
flex-direction: column;
gap: 1rem;
}
35 changes: 35 additions & 0 deletions src/features/auth/SignInForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use client'

import { KeyRound, Mail } from 'lucide-react'
import { ChangeEventHandler, useState } from 'react'

import { SubmitButton } from '@/features/auth/SubmitButton'
import { TextFiled } from '@/shared/ui/TextFiled'

import styles from './SignForm.module.scss'

export function SignInForm() {
const [id, setId] = useState(() => '')
const [pw, setPw] = useState(() => '')

const onIdChange: ChangeEventHandler<HTMLInputElement> = e => {
setId(e.target.value)
}

const onPasswordChange: ChangeEventHandler<HTMLInputElement> = e => {
setPw(e.target.value)
}
return (
<form className={styles.form}>
<TextFiled name={'id'} placeholder="Email" value={id} onChange={onIdChange} icon={<Mail color="#475069" />} />
<TextFiled
name={'pw'}
placeholder="password"
value={pw}
onChange={onPasswordChange}
icon={<KeyRound color="#475069" />}
/>
<SubmitButton>로그인</SubmitButton>
</form>
)
}
3 changes: 3 additions & 0 deletions src/features/auth/SignUpForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function SignUpForm() {
return <form></form>
}
13 changes: 13 additions & 0 deletions src/features/auth/SubmitButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { PropsWithChildren } from 'react'

import { poppins } from '@/shared/font'

import styles from './submit-button.module.scss'

export function SubmitButton({ children }: PropsWithChildren) {
return (
<button type="submit" className={`${styles.button} ${poppins.className}`}>
{children}
</button>
)
}
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/features/auth/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { GuestButtons } from './GuestButtons'
export {} from './SignInForm'
export {} from './SignUpForm'
export { UserButton } from './UserButton'
18 changes: 18 additions & 0 deletions src/features/auth/submit-button.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.button {
display: flex;
padding: 1rem 2rem;
justify-content: center;
align-items: center;
gap: 0.5rem;
flex: 1 0 0;

border-radius: 0.75rem;
border: 2px solid #7B6EF6;
background: #7B6EF6;

color: white;
font-size: 1rem;
font-style: normal;
font-weight: 400;
line-height: 1.5rem;
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/features/search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { HeaderSearchBar } from './HeaderSearchBar'
6 changes: 3 additions & 3 deletions src/shared/constants/SITE_PATH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ type MyMenu = 'famous' | 'like' | 'review'
type Image = 'backdrop' | 'poster'
export const SITE_PATH = {
home: '/home',
my: '/profile',
sign_in: '/auth/sign-in',
sign_up: '/auth/sign-up',
detail: (movieId: string | number) => `/detail/${movieId}`,
list: (path: Movie) => `/list/${path}`,
search: (keyword: string) => `/search?keyword=${keyword}`,
my: '/profile',
my_menu: (path: MyMenu) => `/profile/${path}`,
movie_modal: (movieId: string | number) => `/i/info/${movieId}`,
image_modal: (movieId: string | number, imageType: Image, imageUrl: string) =>
`/i/image/${movieId}/${imageType}/${imageUrl}`,
sign_in_modal: '/i/sign-in',
sign_up_modal: '/i/sign-up',
}
1 change: 1 addition & 0 deletions src/shared/hook/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { useBlockScroll } from './use-block-scroll'
export { useDragHandler } from './use-drag-handler'
export { useHistoryBack } from './use-history-back'
export { useScrollDown } from './use-scroll-down'
export { useTextInterval } from './use-title-interval'
26 changes: 26 additions & 0 deletions src/shared/hook/use-scroll-down.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use client'

import { useEffect, useState } from 'react'

export function useScrollDown() {
const [isScrollDown, setIsScrollDown] = useState(false)

useEffect(() => {
const handleScroll = () => {
const scrollY = window.scrollY
if (scrollY > 500) {
setIsScrollDown(true)
} else {
setIsScrollDown(false)
}
}

window.addEventListener('scroll', handleScroll)

return () => {
window.removeEventListener('scroll', handleScroll)
}
}, [])

return { isScrollDown }
}
21 changes: 21 additions & 0 deletions src/shared/ui/TextFiled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentPropsWithoutRef, ReactNode } from 'react'

import { poppins } from '@/shared/font'

import styles from './text-filed.module.scss'
type Props = {
icon: ReactNode
error?: string
} & ComponentPropsWithoutRef<'input'>

export function TextFiled({ name, onChange, icon, value, error }: Props) {
return (
<div>
<label className={styles.label}>
{icon}
<input className={`${styles.input} ${poppins.className}`} name={name} value={value} onChange={onChange} />
</label>
{error && <span className={styles.error}>{error}</span>}
</div>
)
}
37 changes: 37 additions & 0 deletions src/shared/ui/text-filed.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.label {
display: flex;
padding: 0.75rem 1rem;
align-items: center;
gap: 1rem;
flex: 1 0 0;

background: rgba(0,0,0,10%);
border-radius: 0.75rem;
border: 1px solid #323B54;
}

.input {
display: flex;
height: 2.5rem;
flex-direction: column;
justify-content: center;
align-items: flex-start;
flex: 1 0 0;

background: transparent;
border: none;
outline: none;

color: white;
font-size: 0.875rem;
font-style: normal;
font-weight: 400;
line-height: 1rem;
&::placeholder{
color: #475069;
}
}

.error {

}
5 changes: 0 additions & 5 deletions src/widgets/auth/SignInModal.tsx

This file was deleted.

18 changes: 18 additions & 0 deletions src/widgets/auth/SignInSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SignInForm } from '@/features/auth/SignInForm'
import { SignLottie } from '@/widgets/auth/SignLottie'

import styles from './sign-section.module.scss'

export function SignInSection() {
return (
<section className={styles.container}>
<SignLottie src="/lottie/movie-sign-in.json" />
<div className={styles.actionBox}>
<h4 className={styles.actionTitle}>로그인</h4>
<div className={styles.form}>
<SignInForm />
</div>
</div>
</section>
)
}
11 changes: 11 additions & 0 deletions src/widgets/auth/SignLottie.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client'

import { Player } from '@lottiefiles/react-lottie-player'

type Props = {
src: string
}

export function SignLottie({ src }: Props) {
return <Player speed={1} autoplay loop src={src} style={{ width: 600, height: 600 }} />
}
5 changes: 0 additions & 5 deletions src/widgets/auth/SignUpModal.tsx

This file was deleted.

18 changes: 18 additions & 0 deletions src/widgets/auth/SignUpSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SignUpForm } from '@/features/auth/SignUpForm'
import { SignLottie } from '@/widgets/auth/SignLottie'

import styles from './sign-section.module.scss'

export function SignUpSection() {
return (
<section className={styles.container}>
<SignLottie src="/lottie/movie-sign-up.json" />
<div className={styles.actionBox}>
<h4 className={styles.actionTitle}>회원가입</h4>
<div className={styles.form}>
<SignUpForm />
</div>
</div>
</section>
)
}
4 changes: 2 additions & 2 deletions src/widgets/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { SignInModal } from './SignInModal'
export { SignUpModal } from './SignUpModal'
export { SignInSection } from './SignInSection'
export { SignUpSection } from './SignUpSection'
20 changes: 20 additions & 0 deletions src/widgets/auth/sign-section.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.container {
display: flex;
justify-content: space-between;
width: 100%;
max-width: 1200px;
}

.actionBox {
flex: 1
}

.actionTitle {
text-align: left;
font-weight: bold;
font-size: 40px;
}

.form {
margin: 2.5rem 0;
}
31 changes: 7 additions & 24 deletions src/widgets/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,29 @@
'use client'

import classNames from 'classnames'
import { useEffect, useState } from 'react'

import { GuestButtons } from './GuestButtons'
import { HeaderSearchBar } from '@/features/search'
import { useScrollDown } from '@/shared/hook'

import styles from './header.module.scss'
import { HeaderNav } from './HeaderNav'
import { HeaderSearchBar } from './HeaderSearchBar'
import { MainLogo } from './MainLogo'
import { UserButton } from './UserButton'
import { UserStatusButton } from './UserStatusButton'

export function Header() {
const [isHeaderHidden, setIsHeaderHidden] = useState(false)
const isLogin = false

useEffect(() => {
const handleScroll = () => {
const scrollY = window.scrollY
if (scrollY > 500) {
setIsHeaderHidden(true)
} else {
setIsHeaderHidden(false)
}
}

window.addEventListener('scroll', handleScroll)

return () => {
window.removeEventListener('scroll', handleScroll)
}
}, [])
const { isScrollDown } = useScrollDown()

return (
<header className={classNames(styles.container, isHeaderHidden && styles.hidden)}>
<header className={classNames(styles.container, isScrollDown && styles.hidden)}>
<div className={styles.box}>
<div className={styles.section}>
<MainLogo />
<HeaderNav />
</div>
<div className={styles.section}>
<HeaderSearchBar />
{isLogin ? <UserButton /> : <GuestButtons />}
<UserStatusButton isLogin={isLogin} />
</div>
</div>
</header>
Expand Down
Loading

0 comments on commit 64bf942

Please sign in to comment.