2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { number } from '@storybook/addon-knobs';
|
|
|
|
import CountdownTimer from './countdown-timer';
|
2020-10-06 20:28:38 +02:00
|
|
|
|
|
|
|
export default {
|
2021-12-01 20:27:57 +01:00
|
|
|
title: 'Pages/Swaps/CountdownTimer',
|
2021-09-15 20:55:48 +02:00
|
|
|
id: __filename,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const getTimeStartedFromDecrimentSeconds = (seconds) =>
|
2021-02-04 19:15:23 +01:00
|
|
|
Date.now() - seconds * 1000;
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2021-12-01 20:27:57 +01:00
|
|
|
export const DefaultStory = () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const timeStartedSecondDecriment = number(
|
|
|
|
'Set timeStarted to curren time minus X seconds',
|
|
|
|
10,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-10-06 20:28:38 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CountdownTimer
|
2020-11-03 00:41:28 +01:00
|
|
|
timeStarted={getTimeStartedFromDecrimentSeconds(
|
|
|
|
timeStartedSecondDecriment,
|
|
|
|
)}
|
2020-10-06 20:28:38 +02:00
|
|
|
timeOnly
|
|
|
|
/>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
};
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2021-12-01 20:27:57 +01:00
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
2020-10-06 20:28:38 +02:00
|
|
|
export const CustomTimerBase = () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const timeStartedSecondDecriment = number(
|
|
|
|
'Set timeStarted to curren time minus X seconds',
|
|
|
|
10,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-10-06 20:28:38 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CountdownTimer
|
2020-11-03 00:41:28 +01:00
|
|
|
timeStarted={getTimeStartedFromDecrimentSeconds(
|
|
|
|
timeStartedSecondDecriment,
|
|
|
|
)}
|
2020-10-06 20:28:38 +02:00
|
|
|
timerBase={150000}
|
|
|
|
timeOnly
|
|
|
|
/>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
};
|
2020-10-06 20:28:38 +02:00
|
|
|
|
|
|
|
// Label keys used in below stories are just for demonstration purposes
|
|
|
|
export const WithLabelInfoTooltipAndWarning = () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const timeStartedSecondDecriment = number(
|
|
|
|
'Set timeStarted to curren time minus X seconds',
|
|
|
|
0,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-10-06 20:28:38 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<CountdownTimer
|
2020-11-03 00:41:28 +01:00
|
|
|
timeStarted={getTimeStartedFromDecrimentSeconds(
|
|
|
|
timeStartedSecondDecriment,
|
|
|
|
)}
|
2020-10-06 20:28:38 +02:00
|
|
|
timerBase={20000}
|
|
|
|
labelKey="disconnectPrompt"
|
|
|
|
infoTooltipLabelKey="disconnectAllAccountsConfirmationDescription"
|
|
|
|
warningTime="0:15"
|
|
|
|
/>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
};
|