Skip to content

Commit

Permalink
tw-merge moved to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
ddimitrov1108 committed Jan 30, 2024
1 parent 8f68f9e commit 9f6e04f
Show file tree
Hide file tree
Showing 31 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion components/forms/formik/CheckboxField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Switch } from "@headlessui/react";
import { IFormInput } from "@/lib/interfaces";
import Label from "./Label";
Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/ColorPickerField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IFormInput } from "@/lib/interfaces";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import Label from "./Label";
import dynamic from "next/dynamic";

Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/DatePickerField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IFormInput } from "@/lib/interfaces";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { format } from "date-fns";
import Label from "./Label";
import dynamic from "next/dynamic";
Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/FormErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { FormikErrors } from "formik";

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";

type Props = {
label: string;
Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/PasswordField.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useEffect, useRef, useState } from "react";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Eye, EyeOff } from "lucide-react";
import { IFormInput } from "@/lib/interfaces";
import dynamic from "next/dynamic";
Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/TaskLabelsSelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Fragment } from "react";
import { Listbox, Transition } from "@headlessui/react";
import { IFormInput } from "@/lib/interfaces";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import getLabels from "@/app/actions/label/getLabels";
import useSWR from "swr";
import Label from "./Label";
Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IFormInput } from "@/lib/interfaces";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import dynamic from "next/dynamic";
import Label from "./Label";

Expand Down
2 changes: 1 addition & 1 deletion components/forms/formik/TextareaField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { IFormInput } from "@/lib/interfaces";
import Label from "./Label";
import dynamic from "next/dynamic";
Expand Down
2 changes: 1 addition & 1 deletion components/navigation/components/NavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { usePathname } from "next/navigation";
import Link from "next/link";

Expand Down
2 changes: 1 addition & 1 deletion components/providers/TaskProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ITask } from "@/lib/interfaces";
import { useState } from "react";
import { TaskContext } from "../context/TaskContext";
import dynamic from "next/dynamic";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { format } from "date-fns";
import { toast } from "sonner";
import useSound from "../hooks/useSound";
Expand Down
2 changes: 1 addition & 1 deletion components/task/AddTaskButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Plus } from "lucide-react";
import Button from "../ui/Button";
import { useContext } from "react";
Expand Down
2 changes: 1 addition & 1 deletion components/task/TaskDetailsContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { X } from "lucide-react";
import ButtonIcon from "../ui/ButtonIcon";
import TaskDetails from "./components/TaskDetails";
Expand Down
2 changes: 1 addition & 1 deletion components/task/components/SortTasksListbox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Listbox, Transition } from "@headlessui/react";
import {
ArrowDown01,
Expand Down
3 changes: 2 additions & 1 deletion components/task/components/Task.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { cn, getDueDateText } from "@/lib/utils";
import cn from "@/lib/cn";
import { getDueDateText } from "@/lib/utils";
import { isPast } from "date-fns";
import { Check, Star, ReceiptText } from "lucide-react";
import React, { useContext, useEffect } from "react";
Expand Down
4 changes: 2 additions & 2 deletions components/ui/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AlertVariants, alert } from "../cva/alert";
import alert, { AlertVariants } from "../cva/alert";
import { AlertOctagon, AlertTriangle, CheckCircle, Info } from "lucide-react";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";

interface Props {
variant: AlertVariants;
Expand Down
2 changes: 1 addition & 1 deletion components/ui/AtSign.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";

interface Props {
className?: string;
Expand Down
4 changes: 2 additions & 2 deletions components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cn } from "@/lib/utils";
import { ButtonVariants, button } from "../cva/button";
import cn from "@/lib/cn";
import button, { ButtonVariants } from "../cva/button";
import Spinner from "./Spinner";

interface Props extends React.ComponentProps<"button"> {
Expand Down
2 changes: 1 addition & 1 deletion components/ui/ButtonIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import Spinner from "./Spinner";

interface Props extends React.ComponentProps<"button"> {
Expand Down
2 changes: 1 addition & 1 deletion components/ui/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";

interface Props extends React.ComponentProps<"button"> {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion components/ui/DisclousureContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Disclosure, Transition } from "@headlessui/react";
import { ChevronDown } from "lucide-react";

Expand Down
2 changes: 1 addition & 1 deletion components/ui/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Menu, Transition } from "@headlessui/react";
import { ChevronDownIcon } from "lucide-react";
import { Fragment } from "react";
Expand Down
2 changes: 1 addition & 1 deletion components/ui/DropdownListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { INavLink } from "@/lib/interfaces";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Menu } from "@headlessui/react";
import Link from "next/link";

Expand Down
2 changes: 1 addition & 1 deletion components/ui/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import { Bell } from "lucide-react";
import Link from "next/link";

Expand Down
2 changes: 1 addition & 1 deletion components/ui/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Dialog, Transition } from "@headlessui/react";
import { Fragment } from "react";
import { X } from "lucide-react";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import ButtonIcon from "./ButtonIcon";

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion components/ui/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";

interface Props {
children: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion components/ui/SideBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { X } from "lucide-react";
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";
import dynamic from "next/dynamic";

const Logo = dynamic(() => import("./Logo"), { loading: () => <span></span> });
Expand Down
2 changes: 1 addition & 1 deletion components/ui/Skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";

interface Props {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion components/ui/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn } from "@/lib/utils";
import cn from "@/lib/cn";

interface Props {
className?: string;
Expand Down
6 changes: 6 additions & 0 deletions lib/cn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { twMerge } from "tailwind-merge";
import { clsx, ClassValue } from "clsx";

export default function cn(...args: ClassValue[]) {
return twMerge(clsx(args));
}
6 changes: 0 additions & 6 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { twMerge } from "tailwind-merge";
import { clsx, ClassValue } from "clsx";
import { validate } from "uuid";
import { format, isToday, isTomorrow } from "date-fns";
import { enUS } from "date-fns/locale";

export function cn(...args: ClassValue[]) {
return twMerge(clsx(args));
}

export const isUUID = (id: string | null | undefined): boolean => {
return !!id && validate(id);
};
Expand Down

0 comments on commit 9f6e04f

Please sign in to comment.