Skip to content

Commit

Permalink
Merge pull request #948 from oceanbase/dengfuping-dev
Browse files Browse the repository at this point in the history
improve(ui): ProTable follow Table style in no padding Card
  • Loading branch information
dengfuping authored Jan 17, 2025
2 parents 00f0487 + 9c3461d commit 4466cac
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
4 changes: 0 additions & 4 deletions .dumi/theme/common/styles/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { css, Global } from '@emotion/react';
import React from 'react';
import useSiteToken from '../../../hooks/useSiteToken';

console.log(new TinyColor('#8592AD').getAlpha());

console.log(new TinyColor('#5c6b8a').toRgb());

const GlobalStyle: React.FC = () => {
const { token } = useSiteToken();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ exports[`ProTable > ConfigProvider pagination should work 1`] = `
</form>
</div>
<div
class="ant-pro-card"
class="ant-pro-card ant-pro-card-has-title ant-pro-card-no-divider ant-pro-card-no-padding"
>
<div
class="ant-pro-card-body"
Expand Down Expand Up @@ -1237,7 +1237,7 @@ exports[`ProTable > default pagination should work 1`] = `
</form>
</div>
<div
class="ant-pro-card"
class="ant-pro-card ant-pro-card-has-title ant-pro-card-no-divider ant-pro-card-no-padding"
>
<div
class="ant-pro-card-body"
Expand Down Expand Up @@ -2195,7 +2195,7 @@ exports[`ProTable > render 1`] = `
</form>
</div>
<div
class="ant-pro-card"
class="ant-pro-card ant-pro-card-has-title ant-pro-card-no-divider ant-pro-card-no-padding"
>
<div
class="ant-pro-card-body"
Expand Down
32 changes: 32 additions & 0 deletions packages/ui/src/ProTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ export { ProTableProps };

const ProTable: typeof AntProTable = ({
form,
headerTitle,
options,
optionsRender,
toolbar,
toolBarRender,
expandable,
rowSelection,
pagination: customPagination,
footer,
locale,
cardProps: outerCardProps,
prefixCls: customizePrefixCls,
tableClassName,
className,
Expand Down Expand Up @@ -47,6 +53,9 @@ const ProTable: typeof AntProTable = ({
const { emptyText = <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />, ...restLocale } =
locale || {};

const cardProps = typeof outerCardProps === 'boolean' ? {} : outerCardProps;
const proCardCls = getPrefixCls('pro-card', customizePrefixCls);

return tableWrapSSR(
lightFilterWrapSSR(
wrapSSR(
Expand All @@ -58,6 +67,29 @@ const ProTable: typeof AntProTable = ({
requiredMark: false,
...form,
}}
headerTitle={headerTitle}
options={options}
optionsRender={optionsRender}
toolbar={toolbar}
toolBarRender={toolBarRender}
cardProps={{
...cardProps,
className: classNames(
{
[`${proCardCls}-has-title`]:
!!headerTitle ||
options ||
options === undefined ||
optionsRender ||
toolbar ||
toolBarRender,
[`${proCardCls}-no-divider`]: !cardProps?.headerBordered,
[`${proCardCls}-no-padding`]: true,
[`${proCardCls}-contain-tabs`]: !!cardProps?.tabs,
},
cardProps?.className
),
}}
expandable={
expandable
? {
Expand Down
14 changes: 14 additions & 0 deletions packages/ui/src/ProTable/style/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { CSSObject } from '@ant-design/cssinjs';
import { Card } from '@oceanbase/design';
import type { GenerateStyle } from '@oceanbase/design/es/theme';
import { genComponentStyleHook } from '../../_util/genComponentStyleHook';
import type { OBToken } from '../../_util/genComponentStyleHook';

export const genProTableStyle: GenerateStyle<OBToken> = (token: OBToken): CSSObject => {
const { antCls, componentCls, proComponentsCls } = token;
const proCardComponentCls = `${proComponentsCls}-card`;
return {
[`${componentCls}`]: {
[`${proComponentsCls}-query-filter-actions`]: {
Expand All @@ -13,6 +15,18 @@ export const genProTableStyle: GenerateStyle<OBToken> = (token: OBToken): CSSObj
flexDirection: 'row-reverse',
},
},
[`${proCardComponentCls}${proCardComponentCls}-no-padding`]: {
[`${proCardComponentCls}-body`]: {
paddingInline: 0,
[`${componentCls}-list-toolbar-container`]: {
paddingInline: token.paddingLG,
},
},
...Card.genTableStyle(token.paddingLG, {
...token,
componentCls: proCardComponentCls,
}),
},
},
};
};
Expand Down

0 comments on commit 4466cac

Please sign in to comment.