-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from 80000Coding/feat/input-components-with-n…
…extui 🚧 nextui 를 활용한 input component 생성
- Loading branch information
Showing
9 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use client' | ||
import { InputComment, InputSearch } from '@80000coding/ui' | ||
import { useState } from 'react' | ||
|
||
export default function Page() { | ||
const [value, setValue] = useState('') | ||
const [commentValue, setComment] = useState('') | ||
|
||
return ( | ||
<div className='flex h-screen w-screen flex-col items-start gap-2 p-10'> | ||
{/* <Input value={value} setValue={setValue} /> | ||
<Input value={value} setValue={setValue} label={'조직 이름'} description={'조직 이름을 입력해 주세요'} /> | ||
<Input value={value} setValue={setValue} isInvalid={value === '가나다라'} description='' displayLength={false}></Input> | ||
<Input | ||
value={value} | ||
setValue={setValue} | ||
isInvalid={false} | ||
description='' | ||
displayLength={false} | ||
isCorrect={value === '가나다라'} | ||
></Input> */} | ||
<InputSearch value={value} setValue={setValue}></InputSearch> | ||
<InputSearch value={value} setValue={setValue} isBackBtn={true}></InputSearch> | ||
<InputComment value={commentValue} setValue={setComment}></InputComment> | ||
</div> | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { StaticConfirmIcon } from '@80000coding/web-icons' | ||
import { Input as Input$1 } from '@nextui-org/react' | ||
import { Dispatch, SetStateAction, useState } from 'react' | ||
|
||
export type InputProps = { | ||
value: string | ||
setValue: Dispatch<SetStateAction<string>> | ||
displayLength?: boolean | ||
isDescription?: boolean | ||
isCorrect?: boolean | ||
} & Omit<React.ComponentProps<typeof Input$1>, 'classNames'> | ||
|
||
export function Input({ | ||
value, | ||
setValue, | ||
isInvalid = false, | ||
placeholder = 'placeholder', | ||
errorMessage: errorMessage$1 = 'Please enter a valid value', | ||
displayLength = true, | ||
description: description$1 = 'Please enter a value', | ||
isDescription = true, | ||
isCorrect = false, | ||
label, | ||
...rest | ||
}: InputProps) { | ||
const [isFocus, setIsFocus] = useState(false) | ||
const description = displayLength ? ( | ||
<> | ||
<span className='absolute top-[12px]'>{description$1}</span> | ||
<span className='absolute right-[12px] top-[12px]'>{value.length + '/20'}</span> | ||
</> | ||
) : ( | ||
description$1 | ||
) | ||
|
||
const errorMessage = displayLength ? ( | ||
<> | ||
<span className='absolute top-[12px]'>{errorMessage$1}</span> | ||
<span className='absolute right-[12px] top-[12px] text-gray-400'>{value.length + '/20'}</span> | ||
</> | ||
) : ( | ||
errorMessage$1 | ||
) | ||
|
||
return ( | ||
<Input$1 | ||
/* strings */ | ||
value={value} | ||
label={label} | ||
placeholder={placeholder} | ||
description={isDescription && description} | ||
errorMessage={isInvalid && errorMessage} | ||
/* status */ | ||
isInvalid={isInvalid} | ||
isClearable={isFocus || !isCorrect} | ||
/* actions */ | ||
onValueChange={setValue} | ||
onFocusChange={(e) => { | ||
setIsFocus(e) | ||
}} | ||
/* styles */ | ||
type='text' | ||
radius='full' | ||
labelPlacement='outside' | ||
endContent={isCorrect && !isFocus && <StaticConfirmIcon className='pointer-events-none absolute right-[13px]' />} | ||
classNames={{ | ||
label: ['mx-[12px]', 'body-2'], | ||
description: ['w-full', 'text-gray-400', 'caption-2', 'left-[12px]'], | ||
errorMessage: ['w-full', 'text-red-warning', 'caption-2', 'left-[12px]'], | ||
input: ['!bg-white', 'text-black', 'placeholder:text-gray-300', 'body-3', 'h-100'], | ||
innerWrapper: [], | ||
inputWrapper: [ | ||
'items-start', | ||
'!bg-white', | ||
'border', | ||
isInvalid ? 'border-red-warning' : isCorrect ? 'border-green' : 'border-gray-300', | ||
isInvalid ? 'hover:border-red-warning' : 'hover:border-green', | ||
isInvalid ? 'focus-within:border-red-warning' : 'focus-within:border-green', | ||
'!cursor-text', | ||
'rounded-[20px]', | ||
'px-[20px]', | ||
'py-[13px]', | ||
], | ||
mainWrapper: 'pb-[28px]', // 28px = padding 12px + lineheight 16px | ||
}} | ||
{...rest} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Textarea as TextArea$1 } from '@nextui-org/react' | ||
import { Dispatch, SetStateAction, useState } from 'react' | ||
|
||
export type InputCommentProps = { | ||
value: string | ||
setValue: Dispatch<SetStateAction<string>> | ||
displayLength?: boolean | ||
isDescription?: boolean | ||
isCorrect?: boolean | ||
} & Omit<React.ComponentProps<typeof TextArea$1>, 'classNames'> | ||
|
||
export function InputComment({ | ||
value, | ||
setValue, | ||
isInvalid = false, | ||
placeholder = '댓글을 입력해주세요', | ||
isCorrect = false, | ||
label, | ||
...rest | ||
}: InputCommentProps) { | ||
const [isFocus, setIsFocus] = useState(false) | ||
|
||
return ( | ||
<TextArea$1 | ||
/* strings */ | ||
value={value} | ||
label={label} | ||
placeholder={placeholder} | ||
/* status */ | ||
isInvalid={isInvalid} | ||
isClearable={isFocus || !isCorrect} | ||
/* actions */ | ||
onValueChange={setValue} | ||
onFocusChange={(e) => { | ||
setIsFocus(e) | ||
}} | ||
/* styles */ | ||
maxRows={3} | ||
minRows={1} | ||
type='text' | ||
radius='full' | ||
labelPlacement='outside' | ||
classNames={{ | ||
label: ['mx-[12px]', 'body-2'], | ||
input: ['!bg-white', 'text-black', 'placeholder:text-gray-300', 'body-3', 'px-[0px]', 'py-[0]'], | ||
innerWrapper: [], | ||
inputWrapper: [ | ||
'items-start', | ||
'!bg-white', | ||
'border', | ||
isInvalid ? 'border-red-warning' : isCorrect ? 'border-green' : 'border-gray-300', | ||
isInvalid ? 'hover:border-red-warning' : 'hover:border-green', | ||
isInvalid ? 'focus-within:border-red-warning' : 'focus-within:border-green', | ||
'!cursor-text', | ||
'rounded-[20px]', | ||
'px-[20px]', | ||
'py-[10px]', | ||
], | ||
}} | ||
{...rest} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { DynamicBackIcon, DynamicDeleteIcon, DynamicSearchIcon } from '@80000coding/web-icons' | ||
import { Input as Input$1 } from '@nextui-org/react' | ||
import { Dispatch, SetStateAction, useState } from 'react' | ||
|
||
export type InputSearchProps = { | ||
value: string | ||
setValue: Dispatch<SetStateAction<string>> | ||
isBackBtn?: boolean | ||
} & Omit<React.ComponentProps<typeof Input$1>, 'classNames'> | ||
|
||
export function InputSearch({ value, setValue, isInvalid = false, isBackBtn = false, ...rest }: InputSearchProps) { | ||
// const [value, setValue] = useState('') | ||
|
||
const onClear = () => { | ||
setValue('') | ||
} | ||
|
||
const onSearch = () => { | ||
console.log('search') | ||
} | ||
|
||
const onClickGoBack = () => { | ||
console.log('Go Back!') | ||
} | ||
|
||
const [isFocus, setIsFocus] = useState(false) | ||
|
||
return ( | ||
<Input$1 | ||
labelPlacement='outside' | ||
value={value} | ||
startContent={isBackBtn && <DynamicBackIcon onClick={onClickGoBack} className='text-gray-500' />} | ||
endContent={ | ||
<div className='flex-column flex'> | ||
{value !== '' && <DynamicDeleteIcon className='text-gray-500' onClick={onClear}></DynamicDeleteIcon>} | ||
<DynamicSearchIcon className='text-green ml-[16px]' onClick={onSearch}></DynamicSearchIcon> | ||
</div> | ||
} | ||
onFocusChange={(e) => { | ||
setIsFocus(e) | ||
}} | ||
onValueChange={setValue} | ||
isInvalid={isInvalid} | ||
type='text' | ||
placeholder='검색어를 입력하세요' | ||
radius='full' | ||
classNames={{ | ||
label: ['mx-[12px]', 'body-2'], | ||
description: ['mx-[12px]', 'caption-2'], | ||
input: ['!bg-white', 'text-black', 'placeholder:text-gray-300', 'body-3', 'h-100'], | ||
innerWrapper: [], | ||
inputWrapper: [ | ||
'items-start', | ||
'!bg-white', | ||
'border', | ||
'hover:border-green', | ||
'focus-within:border-green', | ||
'!cursor-text', | ||
'rounded-[20px]', | ||
'px-[20px]', | ||
'py-[13px]', | ||
], | ||
}} | ||
/> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.