From 2d385662e1c886e99bac18e9eb819c6ba70e1d30 Mon Sep 17 00:00:00 2001 From: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:25:37 +0800 Subject: [PATCH] =?UTF-8?q?theme:=20=E5=88=86=E6=A0=8F=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=96=B0=E7=89=88=E5=A4=96=E8=A7=82=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/plugin/Grid.tsx | 19 +++++++++---------- packages/amis/src/renderers/Grid.tsx | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/amis-editor/src/plugin/Grid.tsx b/packages/amis-editor/src/plugin/Grid.tsx index 6ca18b1ff..f33707311 100644 --- a/packages/amis-editor/src/plugin/Grid.tsx +++ b/packages/amis-editor/src/plugin/Grid.tsx @@ -367,10 +367,12 @@ export class GridPlugin extends BasePlugin { : { title: '外观', body: [ - getSchemaTpl('className'), - getSchemaTpl('subFormItemMode'), - getSchemaTpl('subFormHorizontalMode'), - getSchemaTpl('subFormHorizontal') + getSchemaTpl('collapseGroup', [ + getSchemaTpl('subFormItemMode'), + getSchemaTpl('subFormHorizontalMode'), + getSchemaTpl('subFormHorizontal'), + ...getSchemaTpl('theme:common', ['layout']) + ]) ] } ]) @@ -546,12 +548,9 @@ export class GridPlugin extends BasePlugin { { title: '外观', body: [ - this.panelWithOutOthers - ? null - : getSchemaTpl('className', { - label: '栏 CSS 类名', - name: 'columnClassName' - }) + getSchemaTpl('collapseGroup', [ + ...getSchemaTpl('theme:common', ['layout']) + ]) ] } ]) diff --git a/packages/amis/src/renderers/Grid.tsx b/packages/amis/src/renderers/Grid.tsx index a95c8bbe9..af6ff55ed 100644 --- a/packages/amis/src/renderers/Grid.tsx +++ b/packages/amis/src/renderers/Grid.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import {FormHorizontal, Renderer, RendererProps} from 'amis-core'; +import {FormHorizontal, Renderer, RendererProps, buildStyle} from 'amis-core'; import pick from 'lodash/pick'; import {BaseSchema, SchemaClassName, SchemaCollection} from '../Schema'; @@ -50,6 +50,11 @@ export type GridColumnObject = { * 列类名 */ columnClassName?: SchemaClassName; + + /** + * 样式 + */ + style?: any; }; export type GridColumn = GridColumnObject; @@ -152,9 +157,10 @@ export default class Grid extends React.Component { subFormHorizontal, formHorizontal, translate: __, - disabled + disabled, + data } = this.props; - + const styleVar = buildStyle(column.style, data); return (
extends React.Component { [`Grid-col--v${ucFirst(column.valign)}`]: column.valign } )} + style={styleVar} > {this.renderChild(`column/${key}`, (column as any).body || '', length, { disabled, @@ -193,8 +200,10 @@ export default class Grid extends React.Component { valign: vAlign, align: hAlign, loading = false, - loadingConfig + loadingConfig, + data } = this.props; + const styleVar = buildStyle(style, data); return (
extends React.Component { }, className )} - style={style} + style={styleVar} > {this.renderColumns(this.props.columns)}