-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #803 from oceanbase/dengfuping-dev
improve(design): primary Dropdown.Button divider and background style
- Loading branch information
Showing
6 changed files
with
249 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { Dropdown, Space } from '@oceanbase/design'; | ||
import type { MenuProps } from '@oceanbase/design'; | ||
import { DownOutlined, SmileOutlined } from '@oceanbase/icons'; | ||
|
||
const items: MenuProps['items'] = [ | ||
{ | ||
key: '1', | ||
label: ( | ||
<a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com"> | ||
menu item | ||
</a> | ||
), | ||
}, | ||
{ | ||
key: '3', | ||
label: ( | ||
<a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com"> | ||
disabled menu item | ||
</a> | ||
), | ||
disabled: true, | ||
}, | ||
{ | ||
key: '5', | ||
label: 'danger menu item', | ||
danger: true, | ||
}, | ||
{ | ||
key: '2', | ||
label: ( | ||
<a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com"> | ||
menu item with divider | ||
</a> | ||
), | ||
}, | ||
{ | ||
type: 'divider', | ||
}, | ||
{ | ||
key: '4', | ||
label: ( | ||
<a target="_blank" rel="noopener noreferrer" href="https://www.luohanacademy.com"> | ||
menu item with icon | ||
</a> | ||
), | ||
icon: <SmileOutlined />, | ||
}, | ||
{ | ||
key: '6', | ||
label: ( | ||
<a target="_blank" rel="noopener noreferrer" href="https://www.luohanacademy.com"> | ||
menu item with extra | ||
</a> | ||
), | ||
extra: '⌘S', | ||
}, | ||
]; | ||
|
||
const App: React.FC = () => ( | ||
<Dropdown menu={{ items }}> | ||
<a onClick={e => e.preventDefault()}> | ||
<Space> | ||
Hover me | ||
<DownOutlined /> | ||
</Space> | ||
</a> | ||
</Dropdown> | ||
); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from 'react'; | ||
import { Button, Dropdown, message, Space, Tooltip } from '@oceanbase/design'; | ||
import type { MenuProps } from '@oceanbase/design'; | ||
import { DownOutlined, UserOutlined } from '@oceanbase/icons'; | ||
|
||
const handleButtonClick = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
message.info('Click on left button.'); | ||
console.log('click left button', e); | ||
}; | ||
|
||
const handleMenuClick: MenuProps['onClick'] = e => { | ||
message.info('Click on menu item.'); | ||
console.log('click', e); | ||
}; | ||
|
||
const items: MenuProps['items'] = [ | ||
{ | ||
label: '1st menu item', | ||
key: '1', | ||
icon: <UserOutlined />, | ||
}, | ||
{ | ||
label: '2nd menu item', | ||
key: '2', | ||
icon: <UserOutlined />, | ||
}, | ||
{ | ||
label: '3rd menu item', | ||
key: '3', | ||
icon: <UserOutlined />, | ||
danger: true, | ||
}, | ||
{ | ||
label: '4rd menu item', | ||
key: '4', | ||
icon: <UserOutlined />, | ||
danger: true, | ||
disabled: true, | ||
}, | ||
]; | ||
|
||
const menuProps = { | ||
items, | ||
onClick: handleMenuClick, | ||
}; | ||
|
||
const App: React.FC = () => ( | ||
<Space wrap> | ||
<Dropdown.Button menu={menuProps} onClick={handleButtonClick}> | ||
Dropdown | ||
</Dropdown.Button> | ||
<Dropdown.Button menu={menuProps} placement="bottom" icon={<UserOutlined />}> | ||
Dropdown | ||
</Dropdown.Button> | ||
<Dropdown.Button menu={menuProps} onClick={handleButtonClick} disabled> | ||
Disabled | ||
</Dropdown.Button> | ||
<Dropdown.Button | ||
menu={menuProps} | ||
buttonsRender={([leftButton, rightButton]) => [ | ||
<Tooltip title="tooltip" key="leftButton"> | ||
{leftButton} | ||
</Tooltip>, | ||
React.cloneElement(rightButton as React.ReactElement<any, string>, { loading: true }), | ||
]} | ||
> | ||
With Tooltip | ||
</Dropdown.Button> | ||
<Dropdown.Button menu={menuProps} onClick={handleButtonClick} type="primary"> | ||
Dropdown | ||
</Dropdown.Button> | ||
<Dropdown.Button menu={menuProps} onClick={handleButtonClick} danger> | ||
Danger | ||
</Dropdown.Button> | ||
<Dropdown menu={menuProps}> | ||
<Button> | ||
<Space> | ||
Button | ||
<DownOutlined /> | ||
</Space> | ||
</Button> | ||
</Dropdown> | ||
<Dropdown menu={menuProps}> | ||
<Button type="primary"> | ||
<Space> | ||
Button | ||
<DownOutlined /> | ||
</Space> | ||
</Button> | ||
</Dropdown> | ||
</Space> | ||
); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: Dropdown 下拉菜单 | ||
nav: | ||
title: 基础组件 | ||
path: /components | ||
demo: | ||
cols: 2 | ||
--- | ||
|
||
- 🔥 完全继承 antd [Dropdown](https://ant.design/components/dropdown-cn) 的能力和 API,可无缝切换。 | ||
- 💄 定制主题和样式,符合 OceanBase Design 设计规范。 | ||
|
||
## 代码演示 | ||
|
||
<!-- prettier-ignore --> | ||
<code src="./demo/basic.tsx" title="基本"></code> | ||
<code src="./demo/dropdown-button.tsx" title="带下拉框的按钮"></code> | ||
|
||
## API | ||
|
||
- 详见 antd Dropdown 文档: https://ant.design/components/dropdown-cn |