修改发布
This commit is contained in:
35
src/components/TitleTextarea/TitleTextarea.tsx
Normal file
35
src/components/TitleTextarea/TitleTextarea.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react'
|
||||
import { View } from '@tarojs/components'
|
||||
import { TextArea } from '@nutui/nutui-react-taro'
|
||||
import './index.scss'
|
||||
|
||||
interface TitleTextareaProps {
|
||||
value: string
|
||||
onChange: (value: string) => void
|
||||
maxLength?: number
|
||||
placeholder?: string
|
||||
}
|
||||
|
||||
const TitleTextarea: React.FC<TitleTextareaProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
maxLength = 20,
|
||||
placeholder = '好的标题更吸引人哦'
|
||||
}) => {
|
||||
return (
|
||||
<View className='title-input-wrapper'>
|
||||
<TextArea
|
||||
className='title-input'
|
||||
placeholder={placeholder}
|
||||
value={value}
|
||||
onInput={(e) => onChange(e.detail.value)}
|
||||
maxlength={maxLength}
|
||||
autoSize={true}
|
||||
placeholderClass='title-input-placeholder'
|
||||
/>
|
||||
<View className='char-count'>{value.length}/{maxLength}</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default TitleTextarea
|
||||
34
src/components/TitleTextarea/index.scss
Normal file
34
src/components/TitleTextarea/index.scss
Normal file
@@ -0,0 +1,34 @@
|
||||
.title-input-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-around;
|
||||
.title-input {
|
||||
width: 83%;
|
||||
min-height: 44px;
|
||||
padding: 12px 16px;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
line-height: 1.4;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
// 使用 placeholderClass 来控制 placeholder 样式
|
||||
.title-input-placeholder {
|
||||
color: rgba(60, 60, 67, 0.60) !important;
|
||||
font-size: 16px !important;
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.char-count {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
pointer-events: none;
|
||||
padding-top: 12px;
|
||||
}
|
||||
}
|
||||
1
src/components/TitleTextarea/index.ts
Normal file
1
src/components/TitleTextarea/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './TitleTextarea'
|
||||
Reference in New Issue
Block a user