Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
169 changes: 167 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,10 @@
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';
export class StepsPlugin extends BasePlugin {
static id = 'StepsPlugin';
// 关联渲染器名字
Expand Down Expand Up @@ -39,7 +42,6 @@ export class StepsPlugin extends BasePlugin {
previewSchema = {
...this.scaffold
};

panelTitle = 'Steps';
panelBody = [
getSchemaTpl('tabs', [
Expand Down Expand Up @@ -136,13 +138,176 @@ 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('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
19 changes: 17 additions & 2 deletions packages/amis-ui/scss/components/_steps.scss
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,27 @@

.#{$ns}Steps-mobile.#{$ns}Steps--horizontal {
.#{$ns}StepsItem {
overflow: visible;
&-container {
&Tail:after {
display: none;
}
&Wrapper {
transform: translateX(px2rem(-5px));
.#{$ns}StepsItem-body {
.#{$ns}StepsItem-title {
flex-direction: column;
justify-content: center;
align-items: center;
&::after {
display: none !important;
}
span {
left: 0;
}
}
.#{$ns}StepsItem-description {
min-width: px2rem(140px);
}
}

Expand All @@ -429,15 +443,16 @@
&Icon {
position: relative;
display: block;
margin-left: px2rem(40px);

&:after {
content: '';
position: absolute;
right: 0;
top: px2rem(15px);
height: 1px;
left: px2rem(40px);
width: 99999px;
left: px2rem(35px);
width: px2rem(80px);
background-color: var(--Steps-line-bg);
}
}
Expand Down
Loading
Loading