Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(TooltipPopoverWrapper): scheduleUpdate as render prop (#1792)
Co-authored-by: Evan Sharp <dumbdrum@gmail.com>
- Loading branch information
1 parent
c4f86d5
commit cda6fe9
Showing
8 changed files
with
178 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { useState } from 'react'; | ||
import { Button, UncontrolledPopover, PopoverHeader, PopoverBody, Collapse } from 'reactstrap'; | ||
|
||
const PopoverContent = ({ scheduleUpdate }) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<PopoverHeader>Schedule Update</PopoverHeader> | ||
<PopoverBody> | ||
<Button onClick={() => setIsOpen(!isOpen)}>Click me</Button> | ||
<Collapse isOpen={isOpen} onEntered={scheduleUpdate} onExited={scheduleUpdate}> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut | ||
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco | ||
laboris nisi ut aliquip ex ea commodo consequat. | ||
</Collapse> | ||
</PopoverBody> | ||
</> | ||
); | ||
} | ||
|
||
const Example = (props) => { | ||
return ( | ||
<div className="text-center"> | ||
<Button id="ScheduleUpdateButton" type="button"> | ||
Open Popover | ||
</Button> | ||
<UncontrolledPopover trigger="click" placement="top" target="ScheduleUpdateButton"> | ||
{({ scheduleUpdate }) => ( | ||
<PopoverContent scheduleUpdate={scheduleUpdate} /> | ||
)} | ||
</UncontrolledPopover> | ||
</div> | ||
); | ||
} | ||
|
||
export default Example; |
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,37 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Button, UncontrolledTooltip } from 'reactstrap'; | ||
|
||
const shortText = 'Hi'; | ||
const longText = 'Long tooltip content to test scheduleUpdate'; | ||
|
||
const TooltipContent = ({ scheduleUpdate }) => { | ||
const [text, setText] = useState(shortText); | ||
|
||
useEffect(() => { | ||
const intervalId = setInterval(() => { | ||
setText(text === shortText ? longText : shortText); | ||
scheduleUpdate(); | ||
}, 2000); | ||
|
||
return () => clearInterval(intervalId); | ||
}); | ||
|
||
return ( | ||
<>{text}</> | ||
); | ||
} | ||
|
||
const Example = () => { | ||
return ( | ||
<div className="text-center"> | ||
<Button id="ScheduleUpdateTooltip">Click me</Button> | ||
<UncontrolledTooltip placement="top" target="ScheduleUpdateTooltip" trigger="click"> | ||
{({ scheduleUpdate }) => ( | ||
<TooltipContent scheduleUpdate={scheduleUpdate} /> | ||
)} | ||
</UncontrolledTooltip> | ||
</div> | ||
); | ||
} | ||
|
||
export default Example; |
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