Browse Source

style: fix Card tabs of left position (#32695)

close #32673
pull/32705/head
afc163 3 years ago
committed by GitHub
parent
commit
a0982081fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 79
      components/card/demo/tabs.md
  2. 2
      components/card/style/index.less

79
components/card/demo/tabs.md

@ -14,6 +14,7 @@ title:
More content can be hosted.
```jsx
import React, { useState } from 'react';
import { Card } from 'antd';
const tabList = [
@ -53,49 +54,47 @@ const contentListNoTitle = {
project: <p>project content</p>,
};
class TabsCard extends React.Component {
state = {
key: 'tab1',
noTitleKey: 'app',
};
const TabsCard = () => {
const [activeTabKey1, setActiveTabKey1] = useState('tab1');
const [activeTabKey2, setActiveTabKey2] = useState('app');
onTabChange = (key, type) => {
console.log(key, type);
this.setState({ [type]: key });
const onTab1Change = key => {
setActiveTabKey1(key);
};
const onTab2Change = key => {
setActiveTabKey2(key);
};
render() {
return (
<>
<Card
style={{ width: '100%' }}
title="Card title"
extra={<a href="#">More</a>}
tabList={tabList}
activeTabKey={this.state.key}
onTabChange={key => {
this.onTabChange(key, 'key');
}}
>
{contentList[this.state.key]}
</Card>
<br />
<br />
<Card
style={{ width: '100%' }}
tabList={tabListNoTitle}
activeTabKey={this.state.noTitleKey}
tabBarExtraContent={<a href="#">More</a>}
onTabChange={key => {
this.onTabChange(key, 'noTitleKey');
}}
>
{contentListNoTitle[this.state.noTitleKey]}
</Card>
</>
);
}
}
return (
<>
<Card
style={{ width: '100%' }}
title="Card title"
extra={<a href="#">More</a>}
tabList={tabList}
activeTabKey={activeTabKey1}
onTabChange={key => {
onTab1Change(key);
}}
>
{contentList[activeTabKey1]}
</Card>
<br />
<br />
<Card
style={{ width: '100%' }}
tabList={tabListNoTitle}
activeTabKey={activeTabKey2}
tabBarExtraContent={<a href="#">More</a>}
onTabChange={key => {
onTab2Change(key);
}}
>
{contentListNoTitle[activeTabKey2]}
</Card>
</>
);
};
ReactDOM.render(<TabsCard />, mountNode);
```

2
components/card/style/index.less

@ -66,7 +66,7 @@
}
}
.@{ant-prefix}-tabs {
.@{ant-prefix}-tabs-top {
clear: both;
margin-bottom: @card-head-tabs-margin-bottom;
color: @text-color;

Loading…
Cancel
Save