Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/assets/constant/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const INPUT_DETAILS = Object.freeze({
MIN_TYPING: 0,
})

export const RECORD_TITLE_MAX_LENGTH = 12

export const TEXT_DETAILS = Object.freeze({
CELEBRATION: 'celebration',
CONSOLATION: 'consolation',
Expand Down
7 changes: 6 additions & 1 deletion src/pages/AddRecord/AddRecordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react'
import { CELEBRATION_ID, INPUT_DETAILS } from '@assets/constant/constant'
import {
CELEBRATION_ID,
INPUT_DETAILS,
RECORD_TITLE_MAX_LENGTH,
} from '@assets/constant/constant'
import { IsInputsHasValueType } from './AddRecord'
import { parentCategoryID } from 'types/category'

Expand Down Expand Up @@ -71,6 +75,7 @@ function AddRecordInput({
onChange={(e) => handleChange(e)}
type="text"
value={modifyTitle ? modifyTitle : recordTitle}
maxLength={RECORD_TITLE_MAX_LENGTH}
/>
<span className=" text-xs text-grey-4">{`${recordTitle.length}/${INPUT_DETAILS.MAX_INPUT_TYPING}`}</span>
</div>
Expand Down
16 changes: 13 additions & 3 deletions src/pages/MyRecord/Common/SearchInput.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
import React, { Dispatch, SetStateAction } from 'react'
import React, { Dispatch, SetStateAction, useRef } from 'react'
import { ReactComponent as SearchIcon } from '@assets/myRecordIcon/search.svg'
import { ReactComponent as CloseIcon } from '@assets/icon_closed.svg'
import { RECORD_TITLE_MAX_LENGTH } from '@assets/constant/constant'

interface SearchInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>) => void
setKeyword: Dispatch<SetStateAction<string>>
setIsClickedInput: Dispatch<SetStateAction<boolean>>
}

export default function SearchInput({
onKeyUp,
setKeyword,
setIsClickedInput,
...props
}: SearchInputProps) {
const inputRef = useRef<HTMLInputElement>(null)

return (
<div className="relative flex w-full items-center">
<SearchIcon className="absolute left-[12px] h-[14px] w-[14px]" />
<input
ref={inputRef}
className="w-full rounded-[10px] bg-grey-2 py-[10px] pl-[38px] text-[14px] font-medium outline-none placeholder:text-grey-5"
id="search-record-input"
placeholder="레코드 제목을 입력하세요"
autoComplete="off"
onChange={(e) => setKeyword(e.target.value)}
onFocus={() => setIsClickedInput(true)}
onKeyUp={onKeyUp}
maxLength={RECORD_TITLE_MAX_LENGTH}
{...props}
/>
<CloseIcon
className="absolute right-[10px] cursor-pointer"
onClick={() => setKeyword('')}
onClick={() => {
setKeyword('')
inputRef.current?.focus()
}}
/>
</div>
)
Expand Down
3 changes: 3 additions & 0 deletions src/pages/MyRecord/MyRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function MyRecord() {
const { isLoading, monthYear } = useMyRecordByDate()
const [isOpenCalendar, setIsOpenCalendar] = useState(false)
const [keyword, setKeyword] = useState('')
const [isClickedInput, setIsClickedInput] = useState(false)
const setSearchedKeyword = useSetRecoilState(searchedKeyword)

const handleSearch = (e: React.KeyboardEvent<HTMLInputElement>) => {
Expand All @@ -38,6 +39,8 @@ export default function MyRecord() {
value={keyword}
onKeyUp={handleSearch}
setKeyword={setKeyword}
setIsClickedInput={setIsClickedInput}
placeholder={isClickedInput ? `` : `레코드 제목을 입력하세요`}
/>
</section>
<section id="my-today-record">
Expand Down
6 changes: 3 additions & 3 deletions src/pages/MyRecord/Search/SearchRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import useDebounce from '@hooks/useDebounce'
import { useIntersect } from '@hooks/useIntersectionObserver'
import Spinner from '@components/Spinner'

const KEYWORD_MAX_LENGTH = 12

export default function SearchRecord() {
const { keyword: keywordInStore } = useRecoilValue(searchedKeyword)
const resetSearchedKeyword = useResetRecoilState(searchedKeyword)
const [keyword, setKeyword] = useState(keywordInStore || '')
const [isClickedInput, setIsClickedInput] = useState(false)
const {
myRecordByKeyword,
setKeywordWithQuery,
Expand Down Expand Up @@ -56,7 +55,8 @@ export default function SearchRecord() {
value={keyword}
onChange={(e) => setKeyword(e.target.value)}
setKeyword={setKeyword}
maxLength={KEYWORD_MAX_LENGTH}
setIsClickedInput={setIsClickedInput}
placeholder={isClickedInput ? `` : `레코드 제목을 입력하세요`}
/>
</section>
<section id="my-today-record">
Expand Down