Skip to content

Commit

Permalink
Merge pull request #11 from joaoD3V/show-nudge
Browse files Browse the repository at this point in the history
Ajuste na exibicao e remocao do nudge
  • Loading branch information
joaoD3V authored Nov 5, 2023
2 parents 85cad15 + 9106773 commit 4caad18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions islands/Nudge/Nudge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export type Position =
export interface NudgeBaseProps {
/**
* @description Nudge will appear after the set time
* @default 2
*/
delayToShowInSeconds: number;
delayToShowInSeconds?: number;

/**
* @description Nudge will disappear after the set time
* @default 0
*/
disappearAfterSeconds?: number;

Expand Down Expand Up @@ -59,7 +61,7 @@ const POSITION_STYLE = {

function Nudge({
children,
delayToShowInSeconds = 0,
delayToShowInSeconds = 2,
position = "left-bottom",
disappearAfterSeconds,
badge,
Expand All @@ -78,15 +80,15 @@ function Nudge({
}, []);

useEffect(() => {
if (disappearAfterSeconds) {
if (isShowing && disappearAfterSeconds) {
const disappear = setTimeout(() => {
setIsShowing(false);
}, disappearAfterSeconds * 1000);
return () => {
clearTimeout(disappear);
};
}
}, []);
}, [isShowing]);

if (!isShowing) return null;

Expand Down
2 changes: 1 addition & 1 deletion static/tailwind.css

Large diffs are not rendered by default.

0 comments on commit 4caad18

Please sign in to comment.