Skip to content

Commit bcac76b

Browse files
authored
Merge pull request #15 from dev-five-git/fix-landing
Fix landing
2 parents 3dd518a + 9a89443 commit bcac76b

2 files changed

Lines changed: 111 additions & 54 deletions

File tree

apps/landing/src/app/Trans.tsx

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use client'
2-
import { Box, Flex, Image, Input, Text, VStack } from '@devup-ui/react'
2+
import { Box, Flex, Image, Text, VStack } from '@devup-ui/react'
33
import { useEffect, useState } from 'react'
44

5+
import { TransInput } from './TransInput'
6+
57
export function Trans() {
68
const [input, setInput] = useState('')
79
const [translateToUnicode, setTranslateToUnicode] = useState<
@@ -19,6 +21,10 @@ export function Trans() {
1921
})
2022
})
2123
}, [input])
24+
25+
const [inputFocused, setInputFocused] = useState(false)
26+
const [translationFocused, setTranslationFocused] = useState(false)
27+
2228
return (
2329
<VStack gap={['16px', null, null, '30px']}>
2430
<Flex
@@ -45,34 +51,25 @@ export function Trans() {
4551
alignItems="center"
4652
flexDirection={['column', null, null, 'row']}
4753
gap={['12px', null, null, '30px']}
48-
h={['auto', null, null, '500px']}
54+
h={[inputFocused ? '50dvh' : 'auto', null, null, '500px']}
4955
>
50-
<Flex flex="1" h="100%" w="100%">
51-
<Input
52-
as="textarea"
53-
bg="$containerBackground"
54-
border="none"
55-
borderRadius={['16px', null, null, '30px']}
56-
color="$text"
57-
h={['400px', null, null, 'auto']}
58-
onChange={(e) => setInput(e.target.value)}
59-
p={['16px', null, null, '40px']}
60-
placeholder={
61-
'braillify는 한글 점역을 빠르고 안정적으로 처리하는 Rust 기반 라이브러리입니다.\nNode.js, WebAssembly, Python 등 다양한 환경에서 사용할 수 있어요.\n\n점역하고 싶은 문장이나 단어를 여기에 입력해 직접 확인해보세요!'
62-
}
63-
resize="none"
64-
selectors={{
65-
'&::placeholder': {
66-
color: '$text',
67-
typography: 'braille',
68-
opacity: 0.5,
69-
},
70-
}}
71-
typography="braille"
72-
value={input}
73-
w="100%"
74-
/>
75-
</Flex>
56+
<TransInput
57+
blurPlaceholder={
58+
'braillify는 한글 점역을 빠르고 안정적으로 처리하는 Rust 기반 라이브러리입니다.\nNode.js, WebAssembly, Python 등 다양한 환경에서 사용할 수 있어요.\n\n점역하고 싶은 문장이나 단어를 여기에 입력해 직접 확인해보세요!'
59+
}
60+
focusPlaceholder="이곳에 점역할 내용을 입력해주세요!"
61+
isFocused={inputFocused}
62+
onBlur={() => {
63+
setInputFocused(false)
64+
setTranslationFocused(false)
65+
}}
66+
onChange={(e) => setInput(e.target.value)}
67+
onFocus={() => {
68+
setInputFocused(true)
69+
setTranslationFocused(true)
70+
}}
71+
value={input}
72+
/>
7673
<Flex>
7774
<Image
7875
alt=""
@@ -88,32 +85,15 @@ export function Trans() {
8885
w={['16px', null, null, '24px']}
8986
/>
9087
</Flex>
91-
<Flex flex="1" h="100%" w="100%">
92-
<Input
93-
as="textarea"
94-
bg="$containerBackground"
95-
border="none"
96-
borderRadius={['16px', null, null, '30px']}
97-
color="$text"
98-
h={['400px', null, null, 'auto']}
99-
p={['16px', null, null, '40px']}
100-
placeholder={
101-
'⠴⠃⠗⠁⠊⠇⠇⠊⠋⠽⠲⠉⠵ ⠚⠒⠈⠮ ⠨⠎⠢⠱⠁⠮ ⠠⠘⠐⠪⠈⠥ ⠣⠒⠨⠻⠨⠹⠪⠐⠥ ⠰⠎⠐⠕⠚⠉⠵ ⠴⠠⠗⠥⠌⠲ ⠈⠕⠘⠒ ⠐⠣⠕⠘⠪⠐⠎⠐⠕⠕⠃⠉⠕⠊⠲\n⠴⠠⠝⠕⠙⠑⠲⠚⠎⠂ ⠠⠺⠑⠃⠠⠁⠎⠎⠑⠍⠃⠇⠽⠂ ⠠⠏⠽⠹⠕⠝⠲ ⠊⠪⠶ ⠊⠣⠜⠶⠚⠒ ⠚⠧⠒⠈⠻⠝⠠⠎ ⠇⠬⠶⠚⠂ ⠠⠍ ⠕⠌⠎⠬⠲\n\n⠨⠎⠢⠱⠁⠚⠈⠥ ⠠⠕⠲⠵ ⠑⠛⠨⠶⠕⠉ ⠊⠒⠎⠐⠮ ⠱⠈⠕⠝ ⠕⠃⠐⠱⠁⠚⠗ ⠨⠕⠁⠨⠎⠃ ⠚⠧⠁⠟⠚⠗⠘⠥⠠⠝⠬⠖'
102-
}
103-
readOnly
104-
resize="none"
105-
selectors={{
106-
'&::placeholder': {
107-
color: '$text',
108-
typography: 'braille',
109-
opacity: 0.5,
110-
},
111-
}}
112-
typography="braille"
113-
value={translateToUnicode(input)}
114-
w="100%"
115-
/>
116-
</Flex>
88+
<TransInput
89+
blurPlaceholder={
90+
'⠴⠃⠗⠁⠊⠇⠇⠊⠋⠽⠲⠉⠵ ⠚⠒⠈⠮ ⠨⠎⠢⠱⠁⠮ ⠠⠘⠐⠪⠈⠥ ⠣⠒⠨⠻⠨⠹⠪⠐⠥ ⠰⠎⠐⠕⠚⠉⠵ ⠴⠠⠗⠥⠌⠲ ⠈⠕⠘⠒ ⠐⠣⠕⠘⠪⠐⠎⠐⠕⠕⠃⠉⠕⠊⠲\n⠴⠠⠝⠕⠙⠑⠲⠚⠎⠂ ⠠⠺⠑⠃⠠⠁⠎⠎⠑⠍⠃⠇⠽⠂ ⠠⠏⠽⠹⠕⠝⠲ ⠊⠪⠶ ⠊⠣⠜⠶⠚⠒ ⠚⠧⠒⠈⠻⠝⠠⠎ ⠇⠬⠶⠚⠂ ⠠⠍ ⠕⠌⠎⠬⠲\n\n⠨⠎⠢⠱⠁⠚⠈⠥ ⠠⠕⠲⠵ ⠑⠛⠨⠶⠕⠉ ⠊⠒⠎⠐⠮ ⠱⠈⠕⠝ ⠕⠃⠐⠱⠁⠚⠗ ⠨⠕⠁⠨⠎⠃ ⠚⠧⠁⠟⠚⠗⠘⠥⠠⠝⠬⠖'
91+
}
92+
focusPlaceholder="⠕⠈⠥⠄⠝⠀⠨⠎⠢⠱⠁⠚⠂⠀⠉⠗⠬⠶⠮⠀⠕⠃⠐⠱⠁⠚⠗⠨⠍⠠⠝⠬⠖"
93+
isFocused={translationFocused}
94+
readOnly
95+
value={translateToUnicode(input)}
96+
/>
11797
</Flex>
11898
</VStack>
11999
)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
'use client'
2+
3+
import { Box, DevupProps, Flex, Input, Text } from '@devup-ui/react'
4+
import { useEffect, useRef, useState } from 'react'
5+
6+
import { Merge } from '@/types'
7+
8+
export function TransInput({
9+
blurPlaceholder,
10+
focusPlaceholder,
11+
isFocused,
12+
...props
13+
}: {
14+
blurPlaceholder: string
15+
focusPlaceholder: string
16+
isFocused?: boolean
17+
} & Merge<React.ComponentProps<'textarea'>, DevupProps<'textarea'>>) {
18+
const [boxHeight, setBoxHeight] = useState(0)
19+
const placeholderRef = useRef<HTMLSpanElement>(null)
20+
21+
useEffect(() => {
22+
if (placeholderRef.current) {
23+
setBoxHeight(placeholderRef.current.clientHeight)
24+
}
25+
}, [isFocused])
26+
27+
return (
28+
<Flex flex="1" h="100%" pos="relative" w="100%">
29+
<Box
30+
bg="transparent"
31+
borderRadius={['16px', null, null, '30px']}
32+
minH="25dvh"
33+
onClick={(e) => e.currentTarget.querySelector('textarea')?.focus()}
34+
overflow="hidden"
35+
p={['16px', null, null, '40px']}
36+
style={{ height: boxHeight + 32 }}
37+
transition="height 0.3s ease-in-out"
38+
w="100%"
39+
>
40+
<Input
41+
as="textarea"
42+
bg="$containerBackground"
43+
border="none"
44+
borderRadius={['16px', null, null, '30px']}
45+
color="$text"
46+
h="100%"
47+
left="0"
48+
onBlur={props.onBlur}
49+
onChange={props.onChange}
50+
onFocus={props.onFocus}
51+
p={['16px', null, null, '40px']}
52+
pos="absolute"
53+
resize="none"
54+
top="0"
55+
typography="braille"
56+
value={props.value}
57+
w="100%"
58+
{...props}
59+
/>
60+
{(!props.value || (props.value as string).length === 0) && (
61+
<Text
62+
ref={placeholderRef}
63+
color="$text"
64+
display="inline-block"
65+
h="fit-content"
66+
lineBreak="anywhere"
67+
opacity={0.5}
68+
typography="braille"
69+
whiteSpace="pre-line"
70+
>
71+
{isFocused ? focusPlaceholder : blurPlaceholder}
72+
</Text>
73+
)}
74+
</Box>
75+
</Flex>
76+
)
77+
}

0 commit comments

Comments
 (0)