Skip to content

Commit 5609826

Browse files
committed
feat: delay till introduction bubble is shown can now be configured - fixes #118
1 parent fd4e04d commit 5609826

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

.changeset/silly-phones-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@consent-manager/interface-default': patch
3+
---
4+
5+
You can now configure the delay till the introduction popup is shown

packages/interface-default/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface ButtonProps {
4141
export interface ConsentManagerDefaultInterfaceDesignProps {
4242
useDefaultButtonForIntroduction?: boolean
4343
slideDuration?: number
44+
noActionDelay?: number
4445
styles?: Styles
4546
animationStyles?: Styles
4647
ToggleButton?: React.ComponentType<ToggleButtonProps>

packages/interface-default/src/interface.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const Interface: React.FC<InterfaceProps> = ({
4646
initialValues,
4747
onSubmit,
4848
useDefaultButtonForIntroduction = true,
49+
noActionDelay = 4000,
4950
slideDuration = 700,
5051
styles = defaultStyles,
5152
CloseIcon = IoClose,
@@ -139,6 +140,7 @@ export const Interface: React.FC<InterfaceProps> = ({
139140
slideDuration={slideDuration}
140141
CloseIcon={CloseIcon}
141142
Button={useDefaultButtonForIntroduction ? DefaultButton : Button}
143+
noActionDelay={noActionDelay}
142144
/>
143145
)}
144146
<Backdrop fadeDuration={slideDuration} styles={styles} />

packages/interface-default/src/introduction.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import React, { MouseEvent, useCallback, useContext, useEffect, useState } from 'react'
1+
import React, {
2+
MouseEvent,
3+
useCallback,
4+
useContext,
5+
useEffect,
6+
useState,
7+
} from 'react'
28
import clsx from 'clsx'
39
import { CSSTransition } from 'react-transition-group'
410
import createActivityDetector from 'activity-detector-ssr'
@@ -45,6 +51,10 @@ export const Introduction: React.FC<IntroductionProps> = ({
4551

4652
// Listen for user interaction
4753
React.useEffect(() => {
54+
if (noActionDelay === 0) {
55+
setIsIdle(true)
56+
return
57+
}
4858
const activityDetector: ActivityDetector = createActivityDetector({
4959
timeToIdle: noActionDelay,
5060
inactivityEvents: [],

0 commit comments

Comments
 (0)