Skip to content

Commit

Permalink
feat(tooltip&pop-confirm): Tooltip和PopConfirm组件同步增加设置间距功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Sep 8, 2022
1 parent ad3c82a commit e2b0f21
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/ui/pop-confirm/src/use-pop-confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export interface UsePopConfirmProps {
* 点击确认按钮时回调
*/
onConfirm?: () => void
/**
* 设置基于 reference 元素的间隙偏移量
*/
gutterGap?: number
/**
* 是否开启禁用。暂不对外暴露
* @private
Expand Down
19 changes: 19 additions & 0 deletions packages/ui/pop-confirm/stories/gutter-gap.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import PopConfirm from '../src'
import Button from '@hi-ui/button'

/**
* @title 设置基于依附元素的间隙偏移量
*/
export const GutterGap = () => {
return (
<>
<h1>Gutter Gap</h1>
<div className="pop-confirm-basic__wrap">
<PopConfirm title="Delete this item along with the entered content?" gutterGap={30}>
<Button>Trigger</Button>
</PopConfirm>
</div>
</>
)
}
1 change: 1 addition & 0 deletions packages/ui/pop-confirm/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PopConfirm from '../src'
export * from './basic.stories'
export * from './custom-icon.stories'
export * from './async.stories'
export * from './gutter-gap.stories'

export default {
title: 'FeedBack/PopConfirm',
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/tooltip/src/use-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export interface UseTooltipProps extends PopperOverlayProps {
* 鼠标移出后隐藏延时,单位:毫秒
*/
mouseLeaveDelay?: number
/**
* 设置基于 reference 元素的间隙偏移量
*/
gutterGap?: number
}

export type UseTooltipReturn = ReturnType<typeof useTooltip>
19 changes: 19 additions & 0 deletions packages/ui/tooltip/stories/gutter-gap.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import Tooltip from '../src'
import Button from '@hi-ui/button'

/**
* @title 设置基于依附元素的间隙偏移量
*/
export const GutterGap = () => {
return (
<>
<h1>Gutter Gap</h1>
<div className="Tooltip-basic__wrap">
<Tooltip title="Tooltip Title" gutterGap={30} trigger="hover">
<Button>trigger</Button>
</Tooltip>
</div>
</>
)
}
1 change: 1 addition & 0 deletions packages/ui/tooltip/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './trigger.stories'
export * from './placement.stories'
export * from './break-word.stories'
export * from './with-api.stories'
export * from './gutter-gap.stories'

export default {
title: 'Data Display/Tooltip',
Expand Down

0 comments on commit e2b0f21

Please sign in to comment.