修改标题对齐问题
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback } from 'react'
|
import React, { useCallback, useState } from 'react'
|
||||||
import { View } from '@tarojs/components'
|
import { View } from '@tarojs/components'
|
||||||
import { TextArea } from '@nutui/nutui-react-taro';
|
import { TextArea } from '@nutui/nutui-react-taro';
|
||||||
|
|
||||||
@@ -22,6 +22,10 @@ const TitleTextarea: React.FC<TitleTextareaProps> = ({
|
|||||||
onBlur
|
onBlur
|
||||||
}) => {
|
}) => {
|
||||||
const isOverflow = value.length > maxLength
|
const isOverflow = value.length > maxLength
|
||||||
|
// const [isFocused, setIsFocused] = useState(false)
|
||||||
|
|
||||||
|
// const showPlaceholder = !isFocused && !value
|
||||||
|
|
||||||
const handleChange = useCallback((values) => {
|
const handleChange = useCallback((values) => {
|
||||||
// if (values.length > maxLength ) {
|
// if (values.length > maxLength ) {
|
||||||
// const newValues = values.slice(0, maxLength)
|
// const newValues = values.slice(0, maxLength)
|
||||||
@@ -29,20 +33,38 @@ const TitleTextarea: React.FC<TitleTextareaProps> = ({
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
onChange(values)
|
onChange(values)
|
||||||
}, [])
|
}, [onChange])
|
||||||
|
|
||||||
|
const handleFocus = useCallback(() => {
|
||||||
|
// setIsFocused(true)
|
||||||
|
onFocus?.()
|
||||||
|
}, [onFocus])
|
||||||
|
|
||||||
|
const handleBlur = useCallback(() => {
|
||||||
|
// setIsFocused(false)
|
||||||
|
onBlur?.()
|
||||||
|
}, [onBlur])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className='title-input-wrapper'>
|
<View className='title-input-wrapper'>
|
||||||
|
<View className='title-input-box'>
|
||||||
<TextArea
|
<TextArea
|
||||||
className='title-input'
|
className='title-input'
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
onInput={(e) => handleChange(e.detail.value)}
|
onInput={(e) => handleChange(e.detail.value)}
|
||||||
// maxlength={maxLength}
|
// maxlength={maxLength}
|
||||||
autoSize={true}
|
|
||||||
placeholderClass='title-input-placeholder'
|
placeholderClass='title-input-placeholder'
|
||||||
onFocus={onFocus}
|
autoSize={true}
|
||||||
onBlur={onBlur}
|
onFocus={handleFocus}
|
||||||
|
onBlur={handleBlur}
|
||||||
/>
|
/>
|
||||||
|
{/* {showPlaceholder && (
|
||||||
|
<View className='title-input-placeholder-custom'>
|
||||||
|
{placeholder}
|
||||||
|
</View>
|
||||||
|
)} */}
|
||||||
|
</View>
|
||||||
<View className={`char-count${isOverflow ? ' char-count--error' : ''}`}>
|
<View className={`char-count${isOverflow ? ' char-count--error' : ''}`}>
|
||||||
{value.length}/{maxLength}
|
{value.length}/{maxLength}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -4,9 +4,22 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 8px 12px;
|
padding: 10px 12px;
|
||||||
min-height: 36px;
|
min-height: 32px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
.title-input-box {
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.title-input-placeholder {
|
||||||
|
color: rgba(60, 60, 67, 0.60) !important;
|
||||||
|
font-weight: normal !important;
|
||||||
|
position: relative;
|
||||||
|
line-height: 22px !important;
|
||||||
|
height: 22px;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
.title-input {
|
.title-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -17,22 +30,23 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
resize: none;
|
resize: none;
|
||||||
line-height: 26px;
|
line-height: 22px;
|
||||||
min-height: 26px;
|
min-height: 22px;
|
||||||
}
|
}
|
||||||
|
.title-input-placeholder-custom {
|
||||||
// 使用 placeholderClass 来控制 placeholder 样式
|
position: absolute;
|
||||||
.title-input-placeholder {
|
left: 7px;
|
||||||
color: rgba(60, 60, 67, 0.60) !important;
|
top: 50%;
|
||||||
font-size: 16px !important;
|
width: 100%;
|
||||||
font-weight: normal !important;
|
padding: 0;
|
||||||
line-height: 26px !important;
|
color: rgba(60, 60, 67, 0.60);
|
||||||
height: 26px;
|
font-size: 16px;
|
||||||
flex: 1;
|
font-weight: normal;
|
||||||
|
line-height: 22px;
|
||||||
|
pointer-events: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transform: translateY(-50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.char-count {
|
.char-count {
|
||||||
color: #999;
|
color: #999;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user