mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-06 05:59:25 +08:00
fix: block height calculation (#4629)
* fix: block height calculation * fix: test
This commit is contained in:
parent
20f85cd6e5
commit
aecc4a9739
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
import { useFieldSchema } from '@formily/react';
|
import { useFieldSchema } from '@formily/react';
|
||||||
import cls from 'classnames';
|
import cls from 'classnames';
|
||||||
|
import { css } from '@emotion/css';
|
||||||
|
import { theme } from 'antd';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
||||||
import { CustomCreateStylesUtils, createStyles } from '../../../style';
|
import { CustomCreateStylesUtils, createStyles } from '../../../style';
|
||||||
@ -18,6 +20,7 @@ import { useGetAriaLabelOfBlockItem } from './hooks/useGetAriaLabelOfBlockItem';
|
|||||||
import { ErrorBoundary } from 'react-error-boundary';
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import { ErrorFallback } from '../error-fallback';
|
import { ErrorFallback } from '../error-fallback';
|
||||||
import { useSchemaToolbarRender } from '../../../application';
|
import { useSchemaToolbarRender } from '../../../application';
|
||||||
|
import { useDesignable } from '../../';
|
||||||
|
|
||||||
const useStyles = createStyles(({ css, token }: CustomCreateStylesUtils) => {
|
const useStyles = createStyles(({ css, token }: CustomCreateStylesUtils) => {
|
||||||
return css`
|
return css`
|
||||||
@ -81,15 +84,29 @@ export const BlockItem: React.FC<BlockItemProps> = withDynamicSchemaProps(
|
|||||||
// 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema
|
// 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema
|
||||||
const { className, children } = useProps(props);
|
const { className, children } = useProps(props);
|
||||||
const { styles: blockItemCss } = useStyles();
|
const { styles: blockItemCss } = useStyles();
|
||||||
|
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { render } = useSchemaToolbarRender(fieldSchema);
|
const { render } = useSchemaToolbarRender(fieldSchema);
|
||||||
const { getAriaLabel } = useGetAriaLabelOfBlockItem(props.name);
|
const { getAriaLabel } = useGetAriaLabelOfBlockItem(props.name);
|
||||||
|
const { token } = theme.useToken();
|
||||||
|
const { designable } = useDesignable();
|
||||||
const label = useMemo(() => getAriaLabel(), [getAriaLabel]);
|
const label = useMemo(() => getAriaLabel(), [getAriaLabel]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SortableItem role="button" aria-label={label} className={cls('nb-block-item', className, blockItemCss)}>
|
<SortableItem
|
||||||
|
role="button"
|
||||||
|
aria-label={label}
|
||||||
|
className={cls(
|
||||||
|
'nb-block-item',
|
||||||
|
className,
|
||||||
|
blockItemCss,
|
||||||
|
css`
|
||||||
|
margin-bottom: ${designable ? token.marginLG : 0}px !important;
|
||||||
|
.ant-card {
|
||||||
|
margin-bottom: ${designable ? token.marginLG : 0}px !important;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
)}
|
||||||
|
>
|
||||||
{render()}
|
{render()}
|
||||||
<ErrorBoundary FallbackComponent={ErrorFallback} onError={(err) => console.log(err)}>
|
<ErrorBoundary FallbackComponent={ErrorFallback} onError={(err) => console.log(err)}>
|
||||||
{children}
|
{children}
|
||||||
|
@ -50,7 +50,7 @@ describe('CollectionSelect', () => {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-label="block-item-demo title"
|
aria-label="block-item-demo title"
|
||||||
class="nb-sortable-designer nb-block-item nb-form-item acss-gw2dva"
|
class="nb-sortable-designer nb-block-item nb-form-item acss-gw2dva css-vua9sf"
|
||||||
role="button"
|
role="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@ -187,7 +187,7 @@ describe('CollectionSelect', () => {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-label="block-item-demo title"
|
aria-label="block-item-demo title"
|
||||||
class="nb-sortable-designer nb-block-item nb-form-item acss-gw2dva"
|
class="nb-sortable-designer nb-block-item nb-form-item acss-gw2dva css-vua9sf"
|
||||||
role="button"
|
role="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -120,7 +120,7 @@ export const useStyles = genStyleHook('nb-page', (token) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'.nb-page-wrapper': {
|
'.nb-page-wrapper': {
|
||||||
padding: `${token.paddingPageVertical}px ${token.paddingPageHorizontal}px 0px ${token.paddingPageHorizontal}px`,
|
padding: `${token.paddingPageVertical}px`,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -34,6 +34,11 @@ const getPageHeaderHeight = (disablePageHeader, enablePageTabs, hidePageTitle, t
|
|||||||
}
|
}
|
||||||
return token.controlHeight + token.marginXS + (token.paddingXXS + 2) * 2 + token.paddingContentHorizontalLG;
|
return token.controlHeight + token.marginXS + (token.paddingXXS + 2) * 2 + token.paddingContentHorizontalLG;
|
||||||
} else {
|
} else {
|
||||||
|
if (enablePageTabs) {
|
||||||
|
return (
|
||||||
|
token.controlPaddingHorizontal + 3 * token.controlPaddingHorizontalSM + 22 + token.paddingContentHorizontalLG
|
||||||
|
);
|
||||||
|
}
|
||||||
return token.paddingContentHorizontalLG + 12;
|
return token.paddingContentHorizontalLG + 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user