-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
241 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@hi-ui/popper": minor | ||
--- | ||
|
||
feat: 增加 animationType API |
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,5 @@ | ||
--- | ||
"@hi-ui/menu": minor | ||
--- | ||
|
||
feat: 增加 render 和 extraHeader API |
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,107 @@ | ||
import React from 'react' | ||
import Menu, { MenuDataItem } from '../src' | ||
import { | ||
RightOutlined, | ||
AppStoreOutlined, | ||
UserOutlined, | ||
SunOutlined, | ||
PadOutlined, | ||
SearchOutlined, | ||
} from '@hi-ui/icons' | ||
import Popper from '@hi-ui/popper' | ||
import Search from '@hi-ui/search' | ||
|
||
/** | ||
* @title 自定义渲染 | ||
*/ | ||
export const Render = () => { | ||
const menuData = [ | ||
{ | ||
title: '首页', | ||
id: 1, | ||
icon: <AppStoreOutlined />, | ||
}, | ||
{ | ||
title: '小米MIX', | ||
id: 2, | ||
icon: <UserOutlined />, | ||
}, | ||
{ | ||
title: '手机', | ||
id: 3, | ||
icon: <SunOutlined />, | ||
}, | ||
{ | ||
title: '电脑', | ||
id: 4, | ||
icon: <PadOutlined />, | ||
}, | ||
] | ||
|
||
const menuRef = React.useRef<HTMLDivElement | null>(null) | ||
const [currentMenu, setCurrentMenu] = React.useState<MenuDataItem>(menuData[0]) | ||
const [visible, setVisible] = React.useState(false) | ||
|
||
return ( | ||
<> | ||
<h1>Render</h1> | ||
<div | ||
className="menu-render__wrap" | ||
style={{ background: '#f5f7fa', padding: 20, minWidth: 600 }} | ||
> | ||
<Menu | ||
ref={menuRef} | ||
showCollapse | ||
extraHeader={ | ||
<div style={{ padding: '10px 0' }}> | ||
<Search prefix={<SearchOutlined />} append={null} /> | ||
</div> | ||
} | ||
defaultExpandedIds={[3]} | ||
render={(item) => { | ||
return ( | ||
<div | ||
style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }} | ||
> | ||
{item.title} | ||
<RightOutlined style={{ marginLeft: 4 }} /> | ||
</div> | ||
) | ||
}} | ||
onClick={(id, data) => { | ||
console.log('click', id, data) | ||
|
||
setCurrentMenu(data) | ||
setVisible(true) | ||
}} | ||
data={menuData} | ||
/> | ||
{/* 如果不需要阴影,可以设置 className 去覆盖样式 */} | ||
<Popper | ||
className="menu-render__popper" | ||
visible={visible} | ||
attachEl={menuRef.current} | ||
placement="right" | ||
gutterGap={0} | ||
flip={false} | ||
animationType="scaleX" | ||
onClose={() => { | ||
setVisible(false) | ||
}} | ||
onOutsideClick={() => console.log('onOutsideClick')} | ||
> | ||
<div | ||
style={{ | ||
width: 200, | ||
height: menuRef.current?.getBoundingClientRect().height, | ||
padding: 10, | ||
boxSizing: 'border-box', | ||
}} | ||
> | ||
菜单:{currentMenu.title} | ||
</div> | ||
</Popper> | ||
</div> | ||
</> | ||
) | ||
} |
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