@unitedstatespowersquadrons/components 1.3.1 → 1.3.3

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/Badges/Branch.tsx CHANGED
@@ -4,7 +4,7 @@ import { badgeify } from "./helpers";
4
4
 
5
5
  interface Props {
6
6
  branch: string;
7
- primaryBranch?: "main" | "master";
7
+ primaryBranch?: "main" | "master" | undefined;
8
8
  repo?: string;
9
9
  }
10
10
 
package/Badges/Date.tsx CHANGED
@@ -7,28 +7,28 @@ interface Props {
7
7
  logo?: string;
8
8
  }
9
9
 
10
+ export const dateBadgeColor = (diff: number) => {
11
+ // Age
12
+ if (diff <= -60 * 60 * 24 * 14) return "63a2c7";
13
+ else if (diff <= -60 * 60 * 24) return "blue";
14
+ else if (diff <= -60 * 60) return "green";
15
+ else if (diff <= -60) return "yellowgreen";
16
+
17
+ // Expiration Time
18
+ else if (diff <= 60) return "orange";
19
+ else if (diff <= 60 * 10) return "yellowgreen";
20
+ else if (diff <= 60 * 60) return "green";
21
+ else return "brightgreen";
22
+ };
23
+
10
24
  const DateBadge = (props: Props) => {
11
25
  const { timestamp, label, logo } = props;
12
26
 
13
27
  const now = Math.floor(Date.now() / 1000);
14
28
  const diff = timestamp - now;
15
29
 
16
- const color = () => {
17
- // Age
18
- if (diff <= -60 * 60 * 24 * 14) return "63a2c7";
19
- else if (diff <= -60 * 60 * 24) return "blue";
20
- else if (diff <= -60 * 60) return "green";
21
- else if (diff <= -60) return "yellowgreen";
22
-
23
- // Expiration Time
24
- else if (diff <= 60) return "orange";
25
- else if (diff <= 60 * 10) return "yellowgreen";
26
- else if (diff <= 60 * 60) return "green";
27
- else return "brightgreen";
28
- };
29
-
30
30
  const params = new URLSearchParams();
31
- params.set("color", color());
31
+ params.set("color", dateBadgeColor(diff));
32
32
  if (label) params.set("label", label);
33
33
  if (logo) params.set("logo", logo);
34
34
 
package/Badges/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import Badge from "./Badge";
2
2
  import Branch from "./Branch";
3
3
  import Commit from "./Commit";
4
- import Date from "./Date";
4
+ import Date, { dateBadgeColor } from "./Date";
5
5
  import Dependency from "./Dependency";
6
6
  import Gem from "./Gem";
7
7
  import Npm from "./Npm";
@@ -14,7 +14,7 @@ import Tag from "./Tag";
14
14
  export { default as Badge } from "./Badge";
15
15
  export { default as BranchBadge } from "./Branch";
16
16
  export { default as CommitBadge } from "./Commit";
17
- export { default as DateBadge } from "./Date";
17
+ export { default as DateBadge, dateBadgeColor } from "./Date";
18
18
  export { default as DependencyBadge } from "./Dependency";
19
19
  export { default as GemBadge } from "./Gem";
20
20
  export { default as NpmBadge } from "./Npm";
@@ -39,4 +39,5 @@ export default {
39
39
  Repo,
40
40
  Suite,
41
41
  Tag,
42
+ dateBadgeColor,
42
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unitedstatespowersquadrons/components",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "USPS shared React components library",
5
5
  "main": "index.tsx",
6
6
  "scripts": {