Skip to content

Commit

Permalink
style: fix Card tabs of left position
Browse files Browse the repository at this point in the history
close #32673
  • Loading branch information
afc163 committed Oct 29, 2021
1 parent e40b02b commit a0f70b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 41 deletions.
79 changes: 39 additions & 40 deletions components/card/demo/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ title:
More content can be hosted.

```jsx
import React, { useState } from 'react';
import { Card } from 'antd';

const tabList = [
Expand Down Expand Up @@ -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 changes: 1 addition & 1 deletion components/card/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}
}

.@{ant-prefix}-tabs {
.@{ant-prefix}-tabs-top {
clear: both;
margin-bottom: @card-head-tabs-margin-bottom;
color: @text-color;
Expand Down

0 comments on commit a0f70b3

Please sign in to comment.