🆕 长文本添加背景,填充, 圆角属性设置

This commit is contained in:
xujiang 2020-12-07 17:00:17 +08:00
parent 158aedf317
commit e24cf191cd
2 changed files with 43 additions and 2 deletions

View File

@ -3,7 +3,18 @@ import styles from './index.less';
import { ILongTextConfig } from './schema';
import logo from '@/assets/08-长文本.png';
const LongText = memo((props: ILongTextConfig & { isTpl: boolean }) => {
const { text, fontSize, color, indent, lineHeight, textAlign, isTpl } = props;
const {
text,
fontSize,
color,
indent,
lineHeight,
textAlign,
bgColor,
padding,
radius,
isTpl,
} = props;
return (
<>
{isTpl ? (
@ -13,7 +24,16 @@ const LongText = memo((props: ILongTextConfig & { isTpl: boolean }) => {
) : (
<div
className={styles.textWrap}
style={{ color, textIndent: indent + 'px', fontSize, lineHeight, textAlign }}
style={{
color,
textIndent: indent + 'px',
fontSize,
lineHeight,
textAlign,
backgroundColor: bgColor,
padding,
borderRadius: radius,
}}
>
{text}
</div>

View File

@ -23,6 +23,9 @@ export interface ILongTextConfig {
indent: TNumberDefaultType;
lineHeight: TNumberDefaultType;
textAlign: TSelectDefaultType<TLongTextSelectKeyType>;
bgColor: TColorDefaultType;
padding: TNumberDefaultType;
radius: TNumberDefaultType;
}
export interface ILongTextSchema {
@ -78,6 +81,21 @@ const LongText: ILongTextSchema = {
type: 'Number',
step: 0.1,
},
{
key: 'bgColor',
name: '背景颜色',
type: 'Color',
},
{
key: 'padding',
name: '填充间距',
type: 'Number',
},
{
key: 'radius',
name: '背景圆角',
type: 'Number',
},
],
config: {
text: '我是长文本有一段故事dooring可视化编辑器无限可能赶快来体验吧骚年们奥利给~',
@ -86,6 +104,9 @@ const LongText: ILongTextSchema = {
indent: 20,
lineHeight: 1.8,
textAlign: 'left',
bgColor: 'rgba(255,255,255,0)',
padding: 0,
radius: 0,
},
};