Skip to content

Commit

Permalink
feat: title support fontSize、color configuration (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengshang918 committed Mar 31, 2022
1 parent e5bf6eb commit d83836c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
2 changes: 2 additions & 0 deletions packages/drip-form/src/components/Title/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const Title = memo<TitleType>(
alignItems: Align[titleUi?.verticalAlign],
}),
...(titleUi?.margin && { margin: titleUi.margin }),
...(titleUi?.fontSize && { fontSize: titleUi.fontSize }),
...(titleUi?.color && { color: titleUi.color }),
}}
>
{titleUi?.requiredIcon &&
Expand Down
32 changes: 19 additions & 13 deletions packages/drip-form/src/render/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,6 @@ const Render = ({
}
}

// 当前Field的标题样式, property的样式会覆盖全局标题样式
const titleUi = Object.assign(
{
placement: 'left',
width: '82px',
textAlign: 'left',
verticalAlign: 'center',
requiredFields: false,
},
globalTitleUi,
properties[item]?.title || {}
)

// 当前Field的query函数
const queryFunc = onQuery?.[item]
const asyncValidate = onValidate?.[item]
Expand Down Expand Up @@ -169,6 +156,25 @@ const Render = ({
title: uiTitle,
...uiProp
} = properties[item]

// 当前Field的标题样式, property的样式会覆盖全局标题样式
const titleUi = Object.assign(
{
placement: 'left',
width: '82px',
textAlign: 'left',
verticalAlign: 'center',
requiredFields: false,
fontSize: 12,
color:
(uiProp.formMode || formMode) === 'view'
? 'rgba(0,0,0,0.45)'
: '#000000',
},
globalTitleUi,
properties[item]?.title || {}
)

// 当前Field的提示信息
const description = uiProp.description || null
// Field控制函数体
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@ const unitedSchema = {
vcontrol: 'return props.formData.title.followRootConfig == false',
},
},
{
type: 'number',
title: '标题字体大小',
ui: {
type: 'number',
description: {
title: '单位为px',
type: 'icon',
trigger: 'hover',
},
vcontrol: 'return props.formData.title.followRootConfig == false',
},
default: '12',
fieldKey: 'fontSize',
},
{
type: 'string',
title: '标题字体颜色',
ui: {
type: 'colorPicker',
vcontrol: 'return props.formData.title.followRootConfig == false',
},
default: '#000000',
fieldKey: 'color',
},
{
fieldKey: 'textAlign',
type: 'string',
Expand Down
23 changes: 23 additions & 0 deletions packages/generator/src/fields/container/root.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ const unitedSchema = [
],
},
},
{
type: 'number',
title: '标题字体大小',
ui: {
type: 'number',
description: {
title: '单位为px',
type: 'icon',
trigger: 'hover',
},
},
default: '12',
fieldKey: 'fontSize',
},
{
type: 'string',
title: '标题字体颜色',
ui: {
type: 'colorPicker',
},
default: '#000000',
fieldKey: 'color',
},
{
fieldKey: 'textAlign',
type: 'string',
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/schemaHandle/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export type TitleUi = Partial<{
// 是否展示必填*号
requiredIcon: boolean
placement: TitlePlacement
color: string
fontSize: number | string
}> | null

type Properties = {
Expand Down

0 comments on commit d83836c

Please sign in to comment.