Skip to content

Commit

Permalink
fix(grid): grid style (nocobase#4715)
Browse files Browse the repository at this point in the history
* fix: grid style

* fix: bug
  • Loading branch information
Katherine authored Jun 20, 2024
1 parent e5cfe67 commit 362a838
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const ActionBar = withDynamicSchemaProps(
<Portal>
<DndContext>
<div
style={{ display: 'flex', alignItems: 'center', gap: 8, ...style, marginTop: token.marginLG }}
style={{ display: 'flex', alignItems: 'center', gap: 8, ...style }}
{...others}
className={cx(others.className, 'nb-action-bar')}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ const FormComponent: React.FC<FormProps> = (props) => {
<FormLayout layout={'vertical'} {...others}>
<div
className={css`
.nb-grid {
.nb-grid-container {
height: ${height ? height + 'px' : '100%'};
overflow-y: auto;
.nb-grid-warp {
width: 100%;
overflow-x: clip;
padding-right: ${token.paddingSM + 'px'};
}
margin: 0px -${token.marginLG}px;
padding: 0px ${token.paddingLG}px;
}
`}
>
Expand Down
13 changes: 2 additions & 11 deletions packages/core/client/src/schema-component/antd/form-v2/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,14 @@ export const useFormBlockHeight = () => {
}
return buf;
});
const isFilterForm = schema.parent?.['x-decorator'] === 'FilterFormBlockProvider';
const isDetailForm = schema.parent?.['x-decorator'] === 'DetailsBlockProvider';

const hasFormActions = Object.keys(actionSchema?.properties || {}).length > 0;
const unDesignableActionBar = () => {
return token.marginLG;
};
const actionBarHeight =
hasFormActions || designable
? token.controlHeight +
(isFilterForm || !isDetailForm ? (designable ? 2 : 1) * token.marginLG : 2 * token.marginLG)
: unDesignableActionBar();
const actionBarHeight = hasFormActions || designable ? token.controlHeight + 2 * token.marginLG : 2 * token.marginLG;
const blockTitleHeaderHeight = title ? token.fontSizeLG * token.lineHeightLG + token.padding * 2 - 1 : 0;
const { data } = useDataBlockRequest() || {};
const { count, pageSize } = (data as any)?.meta || ({} as any);
const hasPagination = count > pageSize;
const paginationHeight = hasPagination ? token.controlHeightSM + (designable ? 1 : 0) * token.paddingLG : 0;
const paginationHeight = hasPagination ? token.controlHeightSM + 1 * token.paddingLG : 0;
const dataTemplateHeight = display && enabled ? token.controlHeight + 2 * token.padding + token.margin : 0;
return height - actionBarHeight - token.paddingLG - blockTitleHeaderHeight - paginationHeight - dataTemplateHeight;
};
88 changes: 44 additions & 44 deletions packages/core/client/src/schema-component/antd/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,57 +361,57 @@ export const Grid: any = observer(
<GridContext.Provider value={gridContextValue}>
<div
className={cls(
`nb-grid ${styles.container}`,
'nb-grid-container',
css`
& {
margin-bottom: ${designable ? 0 : -token.marginLG}px;
}
`,
)}
style={{ position: 'relative' }}
ref={gridRef}
>
<div className="nb-grid-warp">
<DndWrapper dndContext={props.dndContext}>
{showDivider ? (
<RowDivider
rows={rows}
first
id={`${addr}_0`}
data={{
breakRemoveOn: breakRemoveOnGrid,
wrapSchema: wrapRowSchema,
insertAdjacent: 'afterBegin',
schema: fieldSchema,
}}
/>
) : null}
{rows.map((schema, index) => {
return (
<React.Fragment key={index}>
{distributedValue ? (
<SchemaComponent name={schema.name} schema={schema} distributed />
) : (
<MemorizedRecursionField name={schema.name} schema={schema} />
)}
{showDivider ? (
<RowDivider
rows={rows}
index={index}
id={`${addr}_${index + 1}`}
data={{
breakRemoveOn: breakRemoveOnGrid,
wrapSchema: wrapRowSchema,
insertAdjacent: 'afterEnd',
schema,
}}
/>
) : null}
</React.Fragment>
);
})}
</DndWrapper>
{render()}
<div className={cls(`nb-grid ${styles.container}`)} style={{ position: 'relative' }} ref={gridRef}>
<div className="nb-grid-warp">
<DndWrapper dndContext={props.dndContext}>
{showDivider ? (
<RowDivider
rows={rows}
first
id={`${addr}_0`}
data={{
breakRemoveOn: breakRemoveOnGrid,
wrapSchema: wrapRowSchema,
insertAdjacent: 'afterBegin',
schema: fieldSchema,
}}
/>
) : null}
{rows.map((schema, index) => {
return (
<React.Fragment key={index}>
{distributedValue ? (
<SchemaComponent name={schema.name} schema={schema} distributed />
) : (
<MemorizedRecursionField name={schema.name} schema={schema} />
)}
{showDivider ? (
<RowDivider
rows={rows}
index={index}
id={`${addr}_${index + 1}`}
data={{
breakRemoveOn: breakRemoveOnGrid,
wrapSchema: wrapRowSchema,
insertAdjacent: 'afterEnd',
schema,
}}
/>
) : null}
</React.Fragment>
);
})}
</DndWrapper>
{render()}
</div>
</div>
</div>
</GridContext.Provider>
Expand Down

0 comments on commit 362a838

Please sign in to comment.