refactor: two column layout

This commit is contained in:
chenos 2021-03-29 11:57:07 +08:00
parent 716b5e20b4
commit aedce5589d
3 changed files with 74 additions and 5 deletions

View File

@ -47,10 +47,11 @@ export function Page(props: any) {
</Helmet> </Helmet>
<PageHeader title={data.title} ghost={false} {...restProps} /> <PageHeader title={data.title} ghost={false} {...restProps} />
<div className={'page-content'}> <div className={'page-content'}>
<Row className={'nb-row'} gutter={24}> <div className={'noco-row'}>
{views.map(view => { {views.map(view => {
let viewName: string; let viewName: string;
let span = 24; let span = 24;
let float = 'left';
if (typeof view === 'string') { if (typeof view === 'string') {
viewName = view; viewName = view;
} }
@ -61,9 +62,12 @@ export function Page(props: any) {
} else if (view.width === '100%') { } else if (view.width === '100%') {
span = 24; span = 24;
} }
if (view.float == 'right') {
float = 'right';
}
} }
return ( return (
<Col style={{ marginBottom: 24 }} span={span}> <div className={`noco-col noco-col-${span} float-${float}`}>
<View <View
wrapper={'card'} wrapper={'card'}
currentRowId={currentRowId} currentRowId={currentRowId}
@ -110,10 +114,10 @@ export function Page(props: any) {
}} }}
viewName={viewName} viewName={viewName}
/> />
</Col> </div>
); );
})} })}
</Row> </div>
</div> </div>
</div> </div>
); );

View File

@ -22,3 +22,45 @@
} }
} }
} }
.noco-row {
margin: 0 -12px;
&::after {
content: ' ';
clear: both;
display: block;
}
.noco-col {
margin-left: 12px;
margin-right: 12px;
margin-bottom: 24px;
width: calc(50% - 24px);
float: left;
}
.noco-col-24 {
width: calc(100% - 24px);
}
.float-left {
float: left;
clear: left;
}
.float-right {
float: right;
clear: right;
}
}
@media only screen and (max-width: 800px) {
.page-content {
margin: 0;
margin-top: 1px;
}
.noco-row {
margin: 0;
.noco-col {
width: 100%;
margin: 0;
margin-bottom: 1px;
}
}
}

View File

@ -66,6 +66,26 @@ export default {
{ label: '50%', value: '50%' }, { label: '50%', value: '50%' },
{ label: '100%', value: '100%' }, { label: '100%', value: '100%' },
], ],
component: {
type: 'radio',
'x-linkages': [
{
"type": "value:visible",
"target": "float",
"condition": "{{ $self.value && $self.value === '50%' }}"
},
]
},
},
{
interface: 'radio',
type: 'string',
name: 'float',
title: '位置',
dataSource: [
{ label: '左边', value: 'left' },
{ label: '右边', value: 'right' },
],
component: { component: {
type: 'radio', type: 'radio',
}, },
@ -227,7 +247,8 @@ export default {
fields: [ fields: [
'view', 'view',
'view.collection.title', 'view.collection.title',
'width' 'width',
'float'
], ],
detailsOpenMode: 'drawer', // window detailsOpenMode: 'drawer', // window
details: ['form'], details: ['form'],
@ -241,6 +262,7 @@ export default {
fields: [ fields: [
'view', 'view',
'width', 'width',
'float',
'returnType', 'returnType',
'redirect', 'redirect',
'message', 'message',
@ -264,6 +286,7 @@ export default {
fields: [ fields: [
'view', 'view',
'width', 'width',
'float',
'returnType', 'returnType',
'redirect', 'redirect',
'message', 'message',