Skip to content

Commit ec9c07d

Browse files
committed
Refactoring types
1 parent 7ab2a12 commit ec9c07d

File tree

2 files changed

+8
-43
lines changed

2 files changed

+8
-43
lines changed

src/helpers/index.ts

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,12 @@ dayjs.extend(weekday);
66
dayjs.extend(customParseFormat);
77

88
import { DATE_FORMAT, LANGUAGE } from "../constants";
9+
import { WeekStringType } from "../types";
910

1011
export function classNames(...classes: (false | null | undefined | string)[]) {
1112
return classes.filter(Boolean).join(" ");
1213
}
1314

14-
export function getTextColorByPrimaryColor(color: string) {
15-
switch (color) {
16-
case "blue":
17-
return "text-blue-500";
18-
case "orange":
19-
return "text-orange-500";
20-
case "yellow":
21-
return "text-yellow-500";
22-
case "red":
23-
return "text-red-500";
24-
case "purple":
25-
return "text-purple-500";
26-
case "amber":
27-
return "text-amber-500";
28-
case "lime":
29-
return "text-lime-500";
30-
case "green":
31-
return "text-green-500";
32-
case "emerald":
33-
return "text-emerald-500";
34-
case "teal":
35-
return "text-teal-500";
36-
case "cyan":
37-
return "text-cyan-500";
38-
case "sky":
39-
return "text-sky-500";
40-
case "indigo":
41-
return "text-indigo-500";
42-
case "violet":
43-
return "text-violet-500";
44-
case "fuchsia":
45-
return "text-fuchsia-500";
46-
case "pink":
47-
return "text-pink-500";
48-
case "rose":
49-
return "text-rose-500";
50-
default:
51-
return "";
52-
}
53-
}
54-
5515
export function generateArrayNumber(start = 0, end = 0) {
5616
const array = [];
5717
for (let i = start; i <= end; i++) {
@@ -148,7 +108,10 @@ export function generateWeekdayStringsArray() {
148108
return weekdays;
149109
}
150110

151-
export function getNumberOfDay(dayString: string, startWeekOn?: string | null | undefined): number {
111+
export function getNumberOfDay(
112+
dayString: string,
113+
startWeekOn?: WeekStringType | null | undefined
114+
): number {
152115
let number = 0;
153116

154117
let startDateModifier = 0;

src/types/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export type ClassNamesTypeProp = {
5353

5454
export type PopoverDirectionType = "up" | "down";
5555

56+
export type WeekStringType = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
57+
5658
export interface DatepickerType {
5759
primaryColor?: ColorKeys;
5860
value: DateValueType;
@@ -81,7 +83,7 @@ export interface DatepickerType {
8183
maxDate?: Date | null;
8284
dateLooking?: "forward" | "backward" | "middle";
8385
disabledDates?: DateRangeType[] | null;
84-
startWeekOn?: string | null;
86+
startWeekOn?: WeekStringType | null;
8587
popoverDirection?: PopoverDirectionType;
8688
required?: boolean;
8789
}

0 commit comments

Comments
 (0)