Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:添加steps外观配置 #11572

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/amis-core/src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2460,6 +2460,7 @@ export function formateCheckThemeCss(themeCss: any, type: string) {
if (!themeCss) {
return {};
}

const className = themeCss[`${type}ClassName`] || {};
const controlClassName = themeCss[`${type}ControlClassName`] || {};
const defaultControlThemeCss: any = {};
Expand Down
174 changes: 172 additions & 2 deletions packages/amis-editor/src/plugin/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import {registerEditorPlugin} from 'amis-editor-core';
import {BasePlugin} from 'amis-editor-core';
import {getSchemaTpl} from 'amis-editor-core';

import {
inputStepStateTpl,
inputSwitchStateTpl
} from '../renderer/style-control/helper';
import {StepStatus} from 'amis-ui';
export class StepsPlugin extends BasePlugin {
static id = 'StepsPlugin';
// 关联渲染器名字
Expand Down Expand Up @@ -39,7 +43,6 @@ export class StepsPlugin extends BasePlugin {
previewSchema = {
...this.scaffold
};

panelTitle = 'Steps';
panelBody = [
getSchemaTpl('tabs', [
Expand Down Expand Up @@ -136,13 +139,180 @@ export class StepsPlugin extends BasePlugin {
}
]
},
{
name: '__editorStateStep',
type: 'select',
label: '步骤状态',
value: 'Default',
clearable: true,
options: [
{
label: '常规',
value: 'Default'
},
{
label: '完成',
value: 'Finish'
},
{
label: '进行中',
value: 'Process'
},
{
label: '等待',
value: 'Wait'
},
{
label: '出错',
value: 'Error'
}
]
},
getSchemaTpl('switch', {
name: 'iconPosition',
label: '图标文字垂直展示',
value: false
})
]
},
getSchemaTpl('theme:base', {
label: '基本样式',
name: 'themeCss.base'
}),
getSchemaTpl('collapseGroup', [
{
title: '图标样式',
body: [
...inputSwitchStateTpl('themeCss.iconControlClassName', {}, [
getSchemaTpl('switch', {
name: 'themeCss.iconControlClassName.display',
label: '隐藏图标',
trueValue: 'none'
})
]),
...inputSwitchStateTpl(
'themeCss.iconControlClassName',
{
hiddenOn:
'themeCss.iconControlClassNameFinish.display ==="none"' +
'||' +
'themeCss.iconControlClassNameDefault.display ==="none"' +
'||' +
'themeCss.iconControlClassNameProcess.display ==="none"' +
'||' +
'themeCss.iconControlClassNameWait.display ==="none"' +
'||' +
'themeCss.iconControlClassNameError.display ==="none"'
},
[
getSchemaTpl('theme:select', {
label: '尺寸',
name: 'themeCss.iconControlClassName.iconSize'
}),
getSchemaTpl('theme:colorPicker', {
label: '颜色',
name: 'themeCss.iconControlClassName.backgroundColor',
labelMode: 'input'
})
]
)
]
}
]),
getSchemaTpl('collapseGroup', [
{
title: '标题样式',
body: [
...inputSwitchStateTpl('themeCss.titleControlClassName', {}, [
getSchemaTpl('switch', {
name: 'themeCss.titleControlClassName.display',
label: '隐藏标题',
trueValue: 'none'
})
]),
...inputStepStateTpl('themeCss.titleControlClassName', '', {
hideFont: false,
hiddenOn:
'themeCss.titleControlClassNameFinish.display ==="none"' +
'||' +
'themeCss.titleControlClassNameDefault.display ==="none"' +
'||' +
'themeCss.titleControlClassNameProcess.display ==="none"' +
'||' +
'themeCss.titleControlClassNameWait.display ==="none"' +
'||' +
'themeCss.titleControlClassNameError.display ==="none"'
})
]
}
]),
getSchemaTpl('collapseGroup', [
{
title: '副标题样式',
body: [
...inputSwitchStateTpl(
'themeCss.subTitleControlClassName',
{},
[
getSchemaTpl('switch', {
name: 'themeCss.subTitleControlClassName.display',
label: '隐藏副标题',
trueValue: 'none'
})
]
),
...inputStepStateTpl('themeCss.subTitleControlClassName', '', {
hideFont: false,
hiddenOn:
'themeCss.subTitleControlClassNameFinish.display ==="none"' +
'||' +
'themeCss.subTitleControlClassNameDefault.display ==="none"' +
'||' +
'themeCss.subTitleControlClassNameProcess.display ==="none"' +
'||' +
'themeCss.subTitleControlClassNameWait.display ==="none"' +
'||' +
'themeCss.subTitleControlClassNameError.display ==="none"'
})
]
}
]),
getSchemaTpl('collapseGroup', [
{
title: '描述样式',
body: [
...inputSwitchStateTpl(
'themeCss.descriptionControlClassName',
{},
[
getSchemaTpl('switch', {
name: 'themeCss.descriptionControlClassName.display',
label: '隐藏描述',
trueValue: 'none'
})
]
),
...inputStepStateTpl(
'themeCss.descriptionControlClassName',
'',
{
hideFont: false,
hiddenOn:
'themeCss.descriptionControlClassNameFinish.display ==="none"' +
'||' +
'themeCss.descriptionControlClassNameDefault.display ==="none"' +
'||' +
'themeCss.descriptionControlClassNameProcess.display ==="none"' +
'||' +
'themeCss.descriptionControlClassNameWait.display ==="none"' +
'||' +
'themeCss.descriptionControlClassNameError.display ==="none"'
}
)
]
}
]),
getSchemaTpl('theme:cssCode'),
getSchemaTpl('style:classNames', {isFormItem: false})
])
}
Expand Down
100 changes: 99 additions & 1 deletion packages/amis-editor/src/renderer/style-control/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,105 @@ interface InputStateOptions {
borderToken?: (state: string) => string | object;
}

export const inputSwitchStateTpl = (
className: string,
options?: InputStateOptions,
body?: any[]
) => {
const stateOptions = [
{
label: '常规',
value: 'Default'
},
{
label: '完成',
value: 'Finish'
},
{
label: '进行中',
value: 'Process'
},
{
label: '等待',
value: 'Wait'
},
{
label: '出错',
value: 'Error'
}
];
const hiddenOnCondition = options?.hiddenOn
? ` && !(${options.hiddenOn})`
: '';
const res: any = [
...stateOptions.map((item: any) => {
return {
type: 'container',
visibleOn:
`\${__editorStateStep == '${item.value}'` +
(item.value === 'Default' ? ` || !__editorStateStep` : '') +
hiddenOnCondition +
`}`,
body: body?.map((b: any) => ({
...b,
name: b.name.replace(/name/gi, (match: any) => match + item.value)
}))
};
})
];
return res;
};
export const inputStepStateTpl = (
className: string,
token: string,
options?: InputStateOptions,
body?: any[]
) => {
const stateOptions = options?.state || [
{
label: '常规',
value: 'Default'
},
{
label: '完成',
value: 'Finish'
},
{
label: '进行中',
value: 'Process'
},
{
label: '等待',
value: 'Wait'
},
{
label: '出错',
value: 'Error'
}
];
const hiddenOnCondition = options?.hiddenOn
? ` && !(${options.hiddenOn})`
: '';
const res: any = [
...stateOptions.map((item: any) => {
return {
type: 'container',
visibleOn:
`\${__editorStateStep == '${item.value}'` +
(item.value === 'Default' ? ` || !__editorStateStep` : '') +
hiddenOnCondition +
`}`,
body: inputStateFunc(
'default',
className + item.value,
item.token || token,
options
)
};
})
];
return res;
};
export const inputStateTpl = (
className: string,
token: string = '',
Expand Down Expand Up @@ -87,7 +186,6 @@ export const inputStateFunc = (
token = `${token}-${cssTokenState}`;
}
}

return [
!options?.hideFont &&
getSchemaTpl('theme:font', {
Expand Down
3 changes: 3 additions & 0 deletions packages/amis-ui/scss/_properties.scss
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,10 @@ $Table-strip-bg: transparent;
--Pagination-padding: 0 #{px2rem(8px)};
--Pagination-padding-sm: 0 #{px2rem(4px)};
--Pagination-light-color: var(--colors-neutral-text-4);
--Pagination-border: var(--borderWidth) var(--borders-style-2)
var(--colors-neutral-line-7);

--Panel--default-bg: var(--colors-neutral-fill-11);
--Panel--default-badgeBg: var(--colors-neutral-fill-3);
--Panel--default-badgeColor: var(--colors-neutral-fill-10);

Expand Down
Loading
Loading