Skip to content

Commit

Permalink
fix: activity label color (#2227)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryan610 authored Sep 21, 2023
1 parent e3793f4 commit de9f34c
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions web/components/core/activity.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { useRouter } from "next/router";

import useSWR from "swr";

// services
import issuesService from "services/issues.service";
// icons
import { Icon, Tooltip } from "components/ui";
import { CopyPlus } from "lucide-react";
Expand All @@ -10,6 +14,8 @@ import { renderShortDateWithYearFormat } from "helpers/date-time.helper";
import { capitalizeFirstLetter } from "helpers/string.helper";
// types
import { IIssueActivity } from "types";
// fetch-keys
import { WORKSPACE_LABELS } from "constants/fetch-keys";

const IssueLink = ({ activity }: { activity: IIssueActivity }) => {
const router = useRouter();
Expand Down Expand Up @@ -52,6 +58,26 @@ const UserLink = ({ activity }: { activity: IIssueActivity }) => {
);
};

const LabelPill = ({ labelId }: { labelId: string }) => {
const router = useRouter();
const { workspaceSlug } = router.query;

const { data: labels } = useSWR(
workspaceSlug ? WORKSPACE_LABELS(workspaceSlug.toString()) : null,
workspaceSlug ? () => issuesService.getWorkspaceLabels(workspaceSlug.toString()) : null
);

return (
<span
className="h-1.5 w-1.5 rounded-full"
style={{
backgroundColor: labels?.find((l) => l.id === labelId)?.color ?? "#000000",
}}
aria-hidden="true"
/>
);
};

const activityDetails: {
[key: string]: {
message: (
Expand Down Expand Up @@ -325,14 +351,8 @@ const activityDetails: {
return (
<>
added a new label{" "}
<span className="inline-flex items-center gap-3 rounded-full border border-custom-border-300 px-2 py-0.5 text-xs">
<span
className="h-1.5 w-1.5 rounded-full"
style={{
backgroundColor: "#000000",
}}
aria-hidden="true"
/>
<span className="inline-flex items-center gap-2 rounded-full border border-custom-border-300 px-2 py-0.5 text-xs">
<LabelPill labelId={activity.new_identifier ?? ""} />
<span className="font-medium text-custom-text-100">{activity.new_value}</span>
</span>
{showIssue && (
Expand All @@ -348,13 +368,7 @@ const activityDetails: {
<>
removed the label{" "}
<span className="inline-flex items-center gap-3 rounded-full border border-custom-border-300 px-2 py-0.5 text-xs">
<span
className="h-1.5 w-1.5 rounded-full"
style={{
backgroundColor: "#000000",
}}
aria-hidden="true"
/>
<LabelPill labelId={activity.old_identifier ?? ""} />
<span className="font-medium text-custom-text-100">{activity.old_value}</span>
</span>
{showIssue && (
Expand Down

0 comments on commit de9f34c

Please sign in to comment.