huangkairan
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
36 additions and
2 deletions
-
components/card/Card.tsx
-
components/card/__tests__/index.test.tsx
|
|
@ -116,10 +116,12 @@ const Card = React.forwardRef((props: CardProps, ref: React.Ref<HTMLDivElement>) |
|
|
|
}; |
|
|
|
|
|
|
|
let head: React.ReactNode; |
|
|
|
const mergedSize = customizeSize || size; |
|
|
|
const tabSize = !mergedSize || mergedSize === 'default' ? 'large' : mergedSize; |
|
|
|
const tabs = |
|
|
|
tabList && tabList.length ? ( |
|
|
|
<Tabs |
|
|
|
size="large" |
|
|
|
size={tabSize} |
|
|
|
{...extraProps} |
|
|
|
className={`${prefixCls}-head-tabs`} |
|
|
|
onChange={onTabChange} |
|
|
@ -152,7 +154,6 @@ const Card = React.forwardRef((props: CardProps, ref: React.Ref<HTMLDivElement>) |
|
|
|
<ul className={`${prefixCls}-actions`}>{getAction(actions)}</ul> |
|
|
|
) : null; |
|
|
|
const divProps = omit(others, ['onTabChange']); |
|
|
|
const mergedSize = customizeSize || size; |
|
|
|
const classString = classNames( |
|
|
|
prefixCls, |
|
|
|
{ |
|
|
|
|
|
@ -87,6 +87,39 @@ describe('Card', () => { |
|
|
|
expect(container.querySelectorAll('.ant-tabs-small').length === 0).toBeFalsy(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('tab size extend card size', () => { |
|
|
|
const { container: largeContainer } = render( |
|
|
|
<Card |
|
|
|
title="Card title" |
|
|
|
tabList={[ |
|
|
|
{ |
|
|
|
key: 'key', |
|
|
|
tab: 'tab', |
|
|
|
}, |
|
|
|
]} |
|
|
|
> |
|
|
|
<p>Card content</p> |
|
|
|
</Card>, |
|
|
|
); |
|
|
|
expect(largeContainer.querySelectorAll('.ant-tabs-large').length === 0).toBeFalsy(); |
|
|
|
|
|
|
|
const { container } = render( |
|
|
|
<Card |
|
|
|
title="Card title" |
|
|
|
tabList={[ |
|
|
|
{ |
|
|
|
key: 'key', |
|
|
|
tab: 'tab', |
|
|
|
}, |
|
|
|
]} |
|
|
|
size='small' |
|
|
|
> |
|
|
|
<p>Card content</p> |
|
|
|
</Card>, |
|
|
|
); |
|
|
|
expect(container.querySelectorAll('.ant-tabs-small').length === 0).toBeFalsy(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('get ref of card', () => { |
|
|
|
const cardRef = React.createRef<HTMLDivElement>(); |
|
|
|
|
|
|
|