Skip to content

Commit

Permalink
refactor tab component
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarrqureshi committed Dec 17, 2023
1 parent 0e82194 commit a491c18
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
21 changes: 17 additions & 4 deletions src/components/UI/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@ import React, { ReactNode } from "react";

type TagProps = {
children: ReactNode;
colorClass: string;
className?: string;
color: string;
className?: string;
};

export const Tag: React.FC<TagProps> = ({ children,colorClass,className} ) => {
export const Tag: React.FC<TagProps> = ({ children, color, className }) => {
const getColorClass = () => {
switch (color) {
case "red":
return "border-red-400 text-red-400 bg-red-700/20";
case "teal":
return "border-teal-400 text-teal-400 bg-teal-700/20";
case "yellow":
return "border-yellow-400 text-yellow-400 bg-yellow-700/20";

default:
return "border-gray-400 text-gray-400";
}
};
return (
<div
className={`border ${colorClass} ${className} min-w-max flex justify-center items-center rounded-full px-2 max-sm:px-1 max-sm:text-xs`}
className={`border $ ${getColorClass()} min-w-max flex justify-center items-center rounded-full px-2 max-sm:px-1 max-sm:text-xs`}
>
{children}
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/task/Task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export const Task: React.FC<taskProps> = ({
const getColor = () => {
switch (task.priority) {
case "high":
return "border-red-400 text-red-400 bg-red-700/20";
return "red";
case "medium":
return "border-teal-400 text-teal-400 bg-teal-700/20";
return "teal";
case "low":
return "border-yellow-400 text-yellow-400 bg-yellow-700/20";
return "yellow";

default:
return "border-gray-400 text-gray-400";
return "gray";
}
};

Expand Down Expand Up @@ -102,7 +102,7 @@ export const Task: React.FC<taskProps> = ({
id="task-right-block"
className="flex justify-end items-center gap-3 max-sm:gap-2"
>
<Tag className="" colorClass={getColor()}>
<Tag className="" color={getColor()}>
{task.priority}
</Tag>
<div
Expand Down

0 comments on commit a491c18

Please sign in to comment.