Skip to content

Commit

Permalink
Merge pull request #8 from primus-teoSprint/feat/#3
Browse files Browse the repository at this point in the history
[#3] step1 νŽ˜μ΄μ§€ ui 및 νŽ˜μ΄μ§€κ°„ 이동 κ΅¬ν˜„
  • Loading branch information
03hoho03 authored Apr 6, 2024
2 parents 19f22c2 + d8a78e6 commit fb88de7
Show file tree
Hide file tree
Showing 21 changed files with 398 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.cancel_btn {
display: flex;
justify-content: center;
align-items: center;
width: 24px;
height: 24px;
}
32 changes: 32 additions & 0 deletions app/(route)/verification/ibulsin/_components/CancelBtn/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use client'

import React from 'react'
import S from './index.module.css'
import { MdChevronLeft } from 'react-icons/md'
import { useRouter } from 'next/navigation'

function CancelBtn() {
const router = useRouter()

const handleClickCancelBtn = () => {
const verify = confirm(
'μ •λ§λ‘œ μž‘μ„±μ„ κ·Έλ§Œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ? μž‘μ„±ν•œ 문항듀이 μ‚¬λΌμ§‘λ‹ˆλ‹€.',
)

if (verify) {
router.push('/')
}
}

return (
<button
className={S.cancel_btn}
onClick={handleClickCancelBtn}
type="button"
>
<MdChevronLeft size={20} />
</button>
)
}

export default CancelBtn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.btn {
display: flex;
justify-content: center;
align-items: center;
border-radius: 999px;
background-color: #B9CCFF;
color:#939BFF;
width:30px;
height:30px
}
.darken {
color: #6C76F4;
background-color: #FFFFFF;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'
import S from './index.module.css'
import cn from 'classnames'
import { useSearchParams } from 'next/navigation'
import Link from 'next/link'

function PaginationBtn({ step }: { step: number }) {
const params = useSearchParams()

const stepParam = params.get('step')

return (
<Link
className={cn(S.btn, {
[S.darken]: stepParam && parseInt(stepParam) === step,
})}
href={`/verification/ibulsin?step=${step}`}
>
{step}
</Link>
)
}

export default PaginationBtn
18 changes: 18 additions & 0 deletions app/(route)/verification/ibulsin/_components/Step/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.main_container {
display: flex;
flex-direction: column;
justify-content: space-between;
background-color: var(--purple-700);
min-height: 100vh;
}
.main_container > .survey_header {
display: flex;
width: 100%;
padding: 12px;
align-items: center;
justify-content: space-between;
}
.main_container > .survey_header > .fake {
width: 24px;
height: 24px;
}
31 changes: 31 additions & 0 deletions app/(route)/verification/ibulsin/_components/Step/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client'

import React from 'react'
import S from './index.module.css'
import { useSearchParams } from 'next/navigation'
import Step1 from '../Step1'
import Step2 from '../Step2'
import Step3 from '../Step3'
import StepPagination from '../StepPagination'
import CancelBtn from '../CancelBtn'

function Step() {
const params = useSearchParams()

const stepParam = params.get('step')

return (
<div className={S.main_container}>
<div className={S.survey_header}>
<CancelBtn />
<StepPagination />
<div className={S.fake}></div>
</div>
{stepParam === '1' && <Step1 />}
{stepParam === '2' && <Step2 />}
{stepParam === '3' && <Step3 />}
</div>
)
}

export default Step
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.main_container {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.step_info {
color: #FFFFFF;
margin: 24px;
margin-bottom: 32px;
}
.step_info > h3 {
padding: 12px 0;
font-weight: 500;
font-size: 24px;
}
.step_info > p {
font-size: 24px;
}
.survey_container {
background-color: #FFFFFF;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
padding: 12px;
}
.input_container {
margin-bottom: 8px;
}
.input_container > .input_title {
font-size: 16px;
padding:12px 0;
}
.input_container > .input_explain {
font-size: 12px;
margin-bottom: 8px;
}
.input_container > .input_textarea {
font-size: 14px;
width: 100%;
height: 100px;
resize: none;
border: 1px solid #9d9d9d;
border-radius: 4px;
}
.direction_btns {
display: flex;
align-items: center;
justify-content: center;
}
.next_btn {
background-color: var(--purple-700);
color: #FFFFFF;
padding: 12px 20px;
font-size: 14px;
font-weight: bold;
border-radius: 8px;
}
48 changes: 48 additions & 0 deletions app/(route)/verification/ibulsin/_components/Step1/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use client'

import React from 'react'
import style from './index.module.css'
import Link from 'next/link'
import Textarea from '../Textarea'

function Step1() {
return (
<div className={style.main_container}>
<div className={style.step_info}>
<h3 className={style.step}>STEP 1</h3>
<p className={style.step_explain}>
μƒκ°ν•œ 아이디어λ₯Ό
<br />
μž‘μ„±ν•΄μ£Όμ„Έμš”
</p>
</div>
<div className={style.survey_container}>
<div className={style.input_container}>
<h3 className={style.input_title}>아이디어 κ°œμš”</h3>
<p className={style.input_explain}>
μƒκ°ν•œ 아이디어λ₯Ό 자유둭게 μž‘μ„±ν•΄λ΄μš”! μ΄κ³³μ—μ„œλŠ” μ˜€λ‘œμ§€
μ•„μ΄λ””μ–΄μ—λ§Œ μ§‘μ€‘ν•΄μš”.
</p>
<Textarea fieldKey={'outline'} />
</div>
<div className={style.input_container}>
<h3 className={style.input_title}>μƒκ°ν•˜κ²Œ 된 λ°°κ²½</h3>
<p className={style.input_explain}>
ν•΄λ‹Ή 아이디어λ₯Ό μ–΄λ–»κ²Œ μƒκ°ν•˜κ²Œ λ˜μ—ˆλ‚˜μš”?
</p>
<Textarea fieldKey={'why'} />
</div>
<div className={style.direction_btns}>
<Link
className={style.next_btn}
href={'/verification/ibulsin?step=2'}
>
λ‹€μŒ 단계
</Link>
</div>
</div>
</div>
)
}

export default Step1
10 changes: 10 additions & 0 deletions app/(route)/verification/ibulsin/_components/Step2/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client'

import React from 'react'
import S from './index.module.css'

function Step2() {
return <div className={S.main}>hello</div>
}

export default Step2
Empty file.
10 changes: 10 additions & 0 deletions app/(route)/verification/ibulsin/_components/Step3/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client'

import React from 'react'
import S from './index.module.css'

function Step3() {
return <div className={S.main}>hello</div>
}

export default Step3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.step_pagination_container {
display: flex;
}
.step_pagination_container > * {
margin: 0 12px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import S from './index.module.css'
import PaginationBtn from '../PaginationBtn'

function StepPagination() {
return (
<div className={S.step_pagination_container}>
{Array.from({ length: 3 }, (_, idx) => (
<PaginationBtn key={idx} step={idx + 1} />
))}
</div>
)
}

export default StepPagination
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.textarea_container {
position: relative;
padding: 12px;
padding-bottom: 28px;
border: 1px solid #ccc;
border-radius: 8px;
}
.textarea_container:focus-within {
border: 1px solid #000000;
}
.textarea_container > textarea {
width: 100%;
height: 80px;
border:none;
outline: none;
resize: none;
}
.letter_count_container {
position: absolute;
font-size: 12px;
bottom: 8px;
right: 8px;
}
.letter_max {
color: rgba(255, 0, 0, 0.8);
}
62 changes: 62 additions & 0 deletions app/(route)/verification/ibulsin/_components/Textarea/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use client'

import React from 'react'
import S from './index.module.css'
import cn from 'classnames'
import { useForm } from 'react-hook-form'

interface TextAreaProps {
fieldKey: 'outline' | 'why'
}

function Textarea({ fieldKey }: TextAreaProps) {
const { register, watch } = useForm()

const outlineField = register('outline', {
required: '',
maxLength: { value: 500, message: 'μ΅œλŒ€ 500μžκΉŒμ§€ μž‘μ„±κ°€λŠ₯ν•©λ‹ˆλ‹€.' },
})
const whyField = register('whyField', {
required: '',
maxLength: { value: 500, message: 'μ΅œλŒ€ 500μžκΉŒμ§€ μž‘μ„±κ°€λŠ₯ν•©λ‹ˆλ‹€.' },
})
const fields = {
outline: {
register: outlineField,
MaxLength: 500,
},
why: {
register: whyField,
MaxLength: 500,
},
}

const countCharacters = () => {
const content = watch(fieldKey)
if (!content) {
return 0
}
return content.length
}

return (
<div className={S.textarea_container}>
<textarea
{...fields[fieldKey].register}
maxLength={fields[fieldKey].MaxLength - 1}
/>
<div className={S.letter_count_container}>
<span
className={cn({
[S.letter_max]: countCharacters() >= fields[fieldKey].MaxLength,
})}
>
{countCharacters()}
</span>
<span>{`/${fields[fieldKey].MaxLength}`}</span>
</div>
</div>
)
}

export default Textarea
14 changes: 14 additions & 0 deletions app/(route)/verification/ibulsin/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { Suspense } from 'react'
import Step from './_components/Step'

function page() {
return (
<div>
<Suspense fallback={<div>loading...</div>}>
<Step />
</Suspense>
</div>
)
}

export default page
2 changes: 1 addition & 1 deletion app/_types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module '*.css'

declare module '*.sass'
declare module '*.sass'
Loading

0 comments on commit fb88de7

Please sign in to comment.