catchup-library-web 1.12.14 → 1.12.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catchup-library-web",
3
- "version": "1.12.14",
3
+ "version": "1.12.16",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,85 @@
1
+ import { IProgressBarProperties } from "../../properties/BarProperties";
2
+
3
+ const ProgressBar = ({
4
+ title,
5
+ showRemainingTime,
6
+ totalTimeInSeconds,
7
+ remainingTimeInSeconds,
8
+ color,
9
+ borderColor,
10
+ height,
11
+ }: IProgressBarProperties) => {
12
+ const retrieveMinutes = () => {
13
+ return Math.floor(remainingTimeInSeconds / 60);
14
+ };
15
+
16
+ const retrieveSeconds = (minutes: number) => {
17
+ const minuteInSeconds = minutes * 60;
18
+ return Math.floor(remainingTimeInSeconds - minuteInSeconds);
19
+ };
20
+
21
+ const calculatePercentage = () => {
22
+ if (remainingTimeInSeconds < 0) {
23
+ return (totalTimeInSeconds / totalTimeInSeconds) * 100;
24
+ } else {
25
+ return (
26
+ ((totalTimeInSeconds - remainingTimeInSeconds) / totalTimeInSeconds) *
27
+ 100
28
+ );
29
+ }
30
+ };
31
+
32
+ const currentMinutes = retrieveMinutes();
33
+ const currentSeconds = retrieveSeconds(currentMinutes);
34
+
35
+ return (
36
+ <div className="relative w-full ">
37
+ <div className="">
38
+ {title ? (
39
+ <div className="absolute top-2 left-6">
40
+ <span className="text-xl">{title}</span>
41
+ </div>
42
+ ) : null}
43
+
44
+ {showRemainingTime ? (
45
+ <div className="absolute top-2 right-6">
46
+ <span className="flex flex-row text-xl">
47
+ <p className="mx-1">
48
+ {currentMinutes < 0
49
+ ? `00`
50
+ : currentMinutes < 10
51
+ ? `0${currentMinutes}`
52
+ : currentMinutes}{" "}
53
+ </p>
54
+ :
55
+ <p className="mx-1">
56
+ {currentSeconds < 0
57
+ ? `00`
58
+ : currentSeconds < 10
59
+ ? `0${currentSeconds}`
60
+ : currentSeconds}{" "}
61
+ </p>
62
+ </span>
63
+ </div>
64
+ ) : null}
65
+
66
+ <div
67
+ className={`${
68
+ borderColor ? borderColor : "border-catchup-red"
69
+ } border rounded-catchup-full`}
70
+ >
71
+ <div className={`w-full ${height ? height : ""} `}>
72
+ <div
73
+ className={`rounded-catchup-full ${
74
+ color ? color : "bg-catchup-red"
75
+ } ${height ? height : "h-catchup-quicktivity"}`}
76
+ style={{ width: `${calculatePercentage()}%` }}
77
+ ></div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+ );
83
+ };
84
+
85
+ export default ProgressBar;
@@ -0,0 +1,37 @@
1
+ import { IScoreBarProperties } from "../../properties/BarProperties";
2
+
3
+ const ScoreBar = ({ score, className }: IScoreBarProperties) => {
4
+ const getProgressBarColor = (score: number) => {
5
+ if (score >= 70) return "bg-catchup-green";
6
+ if (score >= 30) return "bg-catchup-orange";
7
+ return "bg-catchup-red";
8
+ };
9
+
10
+ const getTextColor = (score: number) => {
11
+ if (score >= 70) return "text-catchup-hover-green";
12
+ if (score >= 30) return "text-catchup-orange";
13
+ return "text-catchup-red";
14
+ };
15
+
16
+ return (
17
+ <div className={`flex items-center gap-2 ${className}`}>
18
+ <div className="flex-1 h-5 bg-catchup-gray-100 rounded-catchup-full overflow-hidden">
19
+ <div
20
+ className={`h-full rounded-catchup-full transition-all duration-300 ${getProgressBarColor(
21
+ score
22
+ )}`}
23
+ style={{ width: `${score}%` }}
24
+ />
25
+ </div>
26
+ <span
27
+ className={`min-w-[35px] font-semibold text-right ${getTextColor(
28
+ score
29
+ )}`}
30
+ >
31
+ {score}%
32
+ </span>
33
+ </div>
34
+ );
35
+ };
36
+
37
+ export default ScoreBar;
@@ -0,0 +1,58 @@
1
+ import { useEffect, useState } from "react";
2
+ import ProgressBar from "./ProgressBar";
3
+ import { ITimedProgressBarProperties } from "../../properties/BarProperties";
4
+
5
+ const TimedProgressBar = ({
6
+ title,
7
+ startTimer,
8
+ showRemainingTime,
9
+ totalTimeInSeconds,
10
+ remainingTimeInSeconds,
11
+ handleOnTimerEnds,
12
+ }: ITimedProgressBarProperties) => {
13
+ const [timerRemainingTimeInSeconds, setTimerRemainingTimeInSeconds] =
14
+ useState(remainingTimeInSeconds);
15
+ const [timerIntervalId, setTimerIntervalId] = useState<number | null>(null);
16
+ let timerRemainingTimeInSecondsValue: number = 999999999999999;
17
+
18
+ useEffect(() => {
19
+ timerRemainingTimeInSecondsValue = remainingTimeInSeconds;
20
+ setTimerRemainingTimeInSeconds(timerRemainingTimeInSeconds);
21
+ if (timerIntervalId) {
22
+ clearInterval(timerIntervalId);
23
+ }
24
+ if (startTimer) {
25
+ const currentTimerIntervalId = setInterval(() => {
26
+ timerRemainingTimeInSecondsValue =
27
+ timerRemainingTimeInSecondsValue - 0.05;
28
+ setTimerRemainingTimeInSeconds(timerRemainingTimeInSecondsValue);
29
+ }, 50);
30
+ setTimerIntervalId(currentTimerIntervalId);
31
+ } else {
32
+ if (timerIntervalId) {
33
+ clearInterval(timerIntervalId);
34
+ setTimerIntervalId(null);
35
+ }
36
+ }
37
+ }, [remainingTimeInSeconds, startTimer]);
38
+
39
+ useEffect(() => {
40
+ if (timerRemainingTimeInSeconds < 0) {
41
+ if (timerIntervalId) {
42
+ clearInterval(timerIntervalId);
43
+ }
44
+ handleOnTimerEnds(startTimer);
45
+ }
46
+ }, [timerRemainingTimeInSeconds]);
47
+
48
+ return (
49
+ <ProgressBar
50
+ title={title}
51
+ showRemainingTime={showRemainingTime}
52
+ remainingTimeInSeconds={timerRemainingTimeInSeconds}
53
+ totalTimeInSeconds={totalTimeInSeconds}
54
+ />
55
+ );
56
+ };
57
+
58
+ export default TimedProgressBar;
package/src/index.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export { default as ProgressBar } from "./components/bars/ProgressBar";
2
+ export { default as TimedProgressBar } from "./components/bars/TimedProgressBar";
3
+ export { default as ScoreBar } from "./components/bars/ScoreBar";
4
+
1
5
  export { default as PrimaryButton } from "./components/buttons/PrimaryButton";
2
6
  export { default as SecondaryButton } from "./components/buttons/SecondaryButton";
3
7
  export { default as CreateButton } from "./components/buttons/CreateButton";
@@ -0,0 +1,23 @@
1
+ export interface IProgressBarProperties {
2
+ title: string;
3
+ showRemainingTime: boolean;
4
+ totalTimeInSeconds: number;
5
+ remainingTimeInSeconds: number;
6
+ color?: string;
7
+ borderColor?: string;
8
+ height?: string;
9
+ }
10
+
11
+ export interface ITimedProgressBarProperties {
12
+ title: string;
13
+ startTimer: boolean;
14
+ showRemainingTime: boolean;
15
+ totalTimeInSeconds: number;
16
+ remainingTimeInSeconds: number;
17
+ handleOnTimerEnds: (startTimer: boolean) => void;
18
+ }
19
+
20
+ export interface IScoreBarProperties {
21
+ score: number;
22
+ className?: string;
23
+ }
@@ -123,3 +123,48 @@ export const constructWeekName = (
123
123
  }
124
124
  }
125
125
  };
126
+
127
+ export const retrieveTimeFilterOptionList = () => {
128
+ return [
129
+ {
130
+ text: i18n.t("all_time"),
131
+ value: "all",
132
+ },
133
+ {
134
+ text: i18n.t("today"),
135
+ value: "today",
136
+ },
137
+ {
138
+ text: i18n.t("yesterday"),
139
+ value: "yesterday",
140
+ },
141
+ {
142
+ text: i18n.t("this_week"),
143
+ value: "this_week",
144
+ },
145
+ {
146
+ text: i18n.t("last_week"),
147
+ value: "last_week",
148
+ },
149
+ {
150
+ text: i18n.t("this_month"),
151
+ value: "this_month",
152
+ },
153
+ {
154
+ text: i18n.t("last_month"),
155
+ value: "last_month",
156
+ },
157
+ {
158
+ text: i18n.t("last_7_days"),
159
+ value: "last_7_days",
160
+ },
161
+ {
162
+ text: i18n.t("last_30_days"),
163
+ value: "last_30_days",
164
+ },
165
+ {
166
+ text: i18n.t("last_90_days"),
167
+ value: "last_90_days",
168
+ },
169
+ ];
170
+ };