-
-
Notifications
You must be signed in to change notification settings - Fork 236
feat: Support unique box moving #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
f9dc1fa
chore: init
zombieJ bf0ddfe
chore: post info
zombieJ 1693516
chore: use hooks
zombieJ 3c96456
chore: api update
zombieJ eaa0583
chore: comment
zombieJ 592d0a3
chore: comment
zombieJ 6064ded
chore: wrapper
zombieJ 0161493
chore: move to show
zombieJ 12c41b6
chore: update demo
zombieJ a5c946d
chore: align it
zombieJ a0319b9
chore: motion pending
zombieJ 91b66bd
docs: update demo
zombieJ 5273538
chore: demo update
zombieJ 8426ae2
chore: delay of context
zombieJ a7ff7d2
chore: tmp of it
zombieJ e1c6fd1
chore: get a hooks
zombieJ 2579ec5
chore: floating
zombieJ 5a53dd6
chore: motion of bg
zombieJ 98cfa02
chore: flying
zombieJ 4db2dba
chore: unique it
zombieJ ca80e9d
test: init
zombieJ 3007967
test: init
zombieJ b2341f1
test: add test case
zombieJ 48e70fd
chore: lint
zombieJ 6509c4a
Update src/context.ts
zombieJ 2d376b1
Update src/UniqueProvider/useTargetState.ts
zombieJ ea9e47b
chore: of it
zombieJ 79566ee
Update src/UniqueProvider/useTargetState.ts
zombieJ 5e9bcf0
chore: of it
zombieJ 948c859
chore: fix ts
zombieJ 947972e
chore: fix ts
zombieJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,8 @@ | ||
--- | ||
title: Moving Popup | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/two-buttons.tsx"></code> |
This file contains hidden or 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,140 @@ | ||
import Trigger, { UniqueProvider } from '@rc-component/trigger'; | ||
import React, { useState } from 'react'; | ||
import '../../assets/index.less'; | ||
|
||
const LEAVE_DELAY = 0.2; | ||
|
||
const builtinPlacements = { | ||
left: { | ||
points: ['cr', 'cl'], | ||
offset: [-10, 0], | ||
}, | ||
right: { | ||
points: ['cl', 'cr'], | ||
offset: [10, 0], | ||
}, | ||
top: { | ||
points: ['bc', 'tc'], | ||
offset: [0, -10], | ||
}, | ||
bottom: { | ||
points: ['tc', 'bc'], | ||
offset: [0, 10], | ||
}, | ||
}; | ||
|
||
const MovingPopupDemo = () => { | ||
const [useUniqueProvider, setUseUniqueProvider] = useState(true); | ||
const [triggerControl, setTriggerControl] = useState('none'); // 'button1', 'button2', 'none' | ||
|
||
const getVisible = (name: string) => { | ||
if (triggerControl === 'none') { | ||
return undefined; | ||
} | ||
if (triggerControl === name) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
|
||
const content = ( | ||
<div style={{ margin: 100 }}> | ||
<div style={{ display: 'flex', gap: 20 }}> | ||
<Trigger | ||
mouseLeaveDelay={LEAVE_DELAY} | ||
action={['hover']} | ||
popupPlacement="top" | ||
builtinPlacements={builtinPlacements} | ||
popupVisible={getVisible('button1')} | ||
popupMotion={{ | ||
motionName: 'rc-trigger-popup-zoom', | ||
}} | ||
popup={<div>这是左侧按钮的提示信息</div>} | ||
popupStyle={{ | ||
border: '1px solid #ccc', | ||
padding: 10, | ||
background: 'white', | ||
boxSizing: 'border-box', | ||
}} | ||
unique | ||
> | ||
<button type="button">左侧按钮</button> | ||
</Trigger> | ||
|
||
<Trigger | ||
mouseLeaveDelay={LEAVE_DELAY} | ||
action={['hover']} | ||
popupPlacement="top" | ||
builtinPlacements={builtinPlacements} | ||
popupVisible={getVisible('button2')} | ||
popupMotion={{ | ||
motionName: 'rc-trigger-popup-zoom', | ||
}} | ||
popup={<div>This is the tooltip for the right button</div>} | ||
popupStyle={{ | ||
border: '1px solid #ccc', | ||
padding: 10, | ||
background: 'white', | ||
boxSizing: 'border-box', | ||
}} | ||
unique | ||
> | ||
<button type="button">Right Button</button> | ||
</Trigger> | ||
</div> | ||
|
||
<div style={{ marginBottom: 20 }}> | ||
<label> | ||
<input | ||
type="checkbox" | ||
checked={useUniqueProvider} | ||
onChange={(e) => setUseUniqueProvider(e.target.checked)} | ||
/> | ||
使用 UniqueProvider | ||
</label> | ||
</div> | ||
|
||
<div style={{ marginBottom: 20 }}> | ||
<div>Trigger 控制:</div> | ||
<label> | ||
<input | ||
type="radio" | ||
name="triggerControl" | ||
value="button1" | ||
checked={triggerControl === 'button1'} | ||
onChange={(e) => setTriggerControl(e.target.value)} | ||
/> | ||
Button 1 显示 Trigger | ||
</label> | ||
<label style={{ marginLeft: 20 }}> | ||
<input | ||
type="radio" | ||
name="triggerControl" | ||
value="button2" | ||
checked={triggerControl === 'button2'} | ||
onChange={(e) => setTriggerControl(e.target.value)} | ||
/> | ||
Button 2 显示 Trigger | ||
</label> | ||
<label style={{ marginLeft: 20 }}> | ||
<input | ||
type="radio" | ||
name="triggerControl" | ||
value="none" | ||
checked={triggerControl === 'none'} | ||
onChange={(e) => setTriggerControl(e.target.value)} | ||
/> | ||
都不受控 (Hover 控制) | ||
</label> | ||
</div> | ||
</div> | ||
); | ||
|
||
return useUniqueProvider ? ( | ||
<UniqueProvider>{content}</UniqueProvider> | ||
) : ( | ||
content | ||
); | ||
}; | ||
|
||
export default MovingPopupDemo; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.