Skip to content

Commit

Permalink
feat: delay till introduction bubble is shown can now be configured - f…
Browse files Browse the repository at this point in the history
…ixes #118
  • Loading branch information
axe312ger committed Dec 19, 2023
1 parent fd4e04d commit 964230e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/interface-default/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface ButtonProps {
export interface ConsentManagerDefaultInterfaceDesignProps {
useDefaultButtonForIntroduction?: boolean
slideDuration?: number
noActionDelay?: number
styles?: Styles
animationStyles?: Styles
ToggleButton?: React.ComponentType<ToggleButtonProps>
Expand Down
2 changes: 2 additions & 0 deletions packages/interface-default/src/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Interface: React.FC<InterfaceProps> = ({
initialValues,
onSubmit,
useDefaultButtonForIntroduction = true,
noActionDelay = 4000,
slideDuration = 700,
styles = defaultStyles,
CloseIcon = IoClose,
Expand Down Expand Up @@ -139,6 +140,7 @@ export const Interface: React.FC<InterfaceProps> = ({
slideDuration={slideDuration}
CloseIcon={CloseIcon}
Button={useDefaultButtonForIntroduction ? DefaultButton : Button}
noActionDelay={noActionDelay}
/>
)}
<Backdrop fadeDuration={slideDuration} styles={styles} />
Expand Down
12 changes: 11 additions & 1 deletion packages/interface-default/src/introduction.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { MouseEvent, useCallback, useContext, useEffect, useState } from 'react'
import React, {
MouseEvent,
useCallback,
useContext,
useEffect,
useState,
} from 'react'
import clsx from 'clsx'
import { CSSTransition } from 'react-transition-group'
import createActivityDetector from 'activity-detector-ssr'
Expand Down Expand Up @@ -45,6 +51,10 @@ export const Introduction: React.FC<IntroductionProps> = ({

// Listen for user interaction
React.useEffect(() => {
if (noActionDelay === 0) {
setIsIdle(true)
return
}
const activityDetector: ActivityDetector = createActivityDetector({
timeToIdle: noActionDelay,
inactivityEvents: [],
Expand Down

0 comments on commit 964230e

Please sign in to comment.