Skip to content

Commit

Permalink
fix(button): fix export method (#1434)
Browse files Browse the repository at this point in the history
* fix(button): fix export method

* docs(table): add info in column

* feat(table): add padding prop

Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Nov 8, 2021
1 parent 0f4b524 commit 4710118
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
6 changes: 1 addition & 5 deletions src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import React from 'react';
import { LoadingOutlined } from '@gio-design/icons';
import { ButtonProps } from './interface';
import usePrefixCls from '../utils/hooks/use-prefix-cls';
import IconButton from './IconButton';
import WithRef from '../utils/withRef';
import WithSubComponent from '../utils/withSubComponent';

const InternalButton = WithRef<HTMLButtonElement, ButtonProps>((props, ref) => {
const Button = WithRef<HTMLButtonElement, ButtonProps>((props, ref) => {
const {
type = 'primary',
size = 'normal',
Expand Down Expand Up @@ -58,8 +56,6 @@ const InternalButton = WithRef<HTMLButtonElement, ButtonProps>((props, ref) => {
);
});

const Button = WithSubComponent(InternalButton, { IconButton });

Button.displayName = 'Button';

Button.defaultProps = {
Expand Down
5 changes: 4 additions & 1 deletion src/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Button from './Button';
import WithSubComponent from '../utils/withSubComponent';
import InternalButton from './Button';
import IconButton from './IconButton';

const Button = WithSubComponent(InternalButton, { IconButton });

export type { ButtonProps, IconButtonProps, ButtonType } from './interface';
export { Button, IconButton };

Expand Down
9 changes: 8 additions & 1 deletion src/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ import { TABLE_PREFIX_CLS, translateInnerColumns } from './utils';
import Loading from '../loading';
import useHackOnRow from './hook/useHackOnRow';

declare module 'React' {
interface CSSProperties {
'--table-cell-padding'?: React.CSSProperties['padding'];
}
}

interface TableContextType {
tableRef: React.ForwardedRef<HTMLDivElement>;
}
Expand All @@ -32,6 +38,7 @@ function Table<RecordType>(props: TableProps<RecordType>, ref: React.ForwardedRe
pagination = {},
rowSelection,
showIndex = false,
padding = '12px 16px',
emptyText,
empty,
onChange,
Expand Down Expand Up @@ -217,7 +224,7 @@ function Table<RecordType>(props: TableProps<RecordType>, ref: React.ForwardedRe
className={classNames(`${prefixCls}-wrapper`, className, {
[`${prefixCls}-showHover`]: showHover,
})}
style={style}
style={{ ...style, '--table-cell-padding': padding }}
ref={mergedRef}
data-testid="table"
>
Expand Down
1 change: 1 addition & 0 deletions src/table/demos/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const Basic = () => {
{
dataIndex: 'id',
title: 'Id',
info: 'description',
},
{
dataIndex: 'name',
Expand Down
6 changes: 6 additions & 0 deletions src/table/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ interface TableProps<RecordType> extends Omit<GioTableProps<RecordType>, 'title'
*/
title?: string | ((currentPageData: ReadonlyArray<RecordType>) => string);

/**
* 单元格的 padding 值
* @default `12px 16px`
*/
padding?: React.CSSProperties['padding'];

/**
* 表格列的配置详情
*/
Expand Down
17 changes: 6 additions & 11 deletions src/table/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -372,32 +372,27 @@
}
}

.table-size(@size, @padding-vertical, @padding-horizontal) {
.table-size(@size, @padding: 12px 16px) {
.@{table-prefix-cls}.@{table-prefix-cls}-@{size} {
.@{table-prefix-cls}-title,
.@{table-prefix-cls}-footer,
.@{table-prefix-cls}-thead > tr > th,
.@{table-prefix-cls}-tbody > tr > td,
tfoot > tr > th,
tfoot > tr > td {
padding: @padding-vertical @padding-horizontal;
padding: @padding;
}

.@{table-prefix-cls}-tbody .@{table-prefix-cls}-row-expand-icon-cell {
padding: calc(@padding-vertical - 1px) 20px;
padding: @padding;
}

.@{table-prefix-cls}-tbody .@{table-prefix-cls}-expanded-row > .@{table-prefix-cls}-cell {
padding: @padding-vertical 20px;

.@{table-prefix-cls}-expanded-row-fixed {
margin: -@padding-vertical -21px;
padding: @padding-vertical 20px;
}
padding: @padding;
}

.@{table-prefix-cls}-tbody .@{table-prefix-cls}-cell-with-append {
padding: calc(@padding-vertical - 1px) 16px;
padding: @padding;

.@{table-prefix-cls}-row-indent {
float: left;
Expand All @@ -412,4 +407,4 @@
}
}

.table-size(~'normal', 12px, 16px);
.table-size(~'normal', var(--table-cell-padding));

1 comment on commit 4710118

@vercel
Copy link

@vercel vercel bot commented on 4710118 Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.