Skip to content

Commit

Permalink
changes to fix doc rendering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelthorpe committed Nov 10, 2023
1 parent 1a34d2e commit 9482e64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 8 additions & 4 deletions components/timeout-modal/spec/TimeoutModal.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@ import readMe from '../README.md';
component={ TimeoutModal }
parameters={ {
chromatic: { viewports: [640, 480] },
description: 'HODS timeout modal',
description: 'Inform a user their current session will soon time out.',
jest: ['TimeoutModal'],
notes: readMe,
docs: {
inlineStories: false,
iframeHeight: 500,
}
story: {
inline: false,
iframeHeight: 500,
}
},
} }
/>

# timeout-modal

HODS Timeout Modal
Inform a user their current session will time out in 5 minutes.

<Preview withToolbar>
<Story name="5 Minutes Timeout Modal">
<Page>
<TimeoutModal
isOpen={true}
timerDurationInSeconds={60}
timerDurationInSeconds={300}
onTimeout={() => console.log("timed out")}
onContinue={() => console.log("continue")}
onSignout={() => console.log("sign out")}
Expand Down
8 changes: 3 additions & 5 deletions components/timeout-modal/src/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ export const Timer: FC<TimerProps> = ({
onTimeout,
...attrs
}) => {
const [runTimer, setRunTimer] = useState(true)
const [timer, setTimer] = useState(timerFrom);
let formattedTimer = timer < 61 ? Math.ceil(timer / 20) * 20 : Math.ceil(timer / 60);
const interval = useRef(null);

useEffect(() => {
if(runTimer) interval.current = setInterval(() => setTimer((timer) => timer - 1), 1000);
else clearInterval(interval.current);
interval.current = setInterval(() => setTimer((timer) => timer - 1), 1000);
return () => clearInterval(interval.current);
}, [runTimer])
}, [])

if(runTimer && timer == 0) {
if(timer == 0) {
clearInterval(interval.current);
onTimeout();
}
Expand Down

1 comment on commit 9482e64

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.