Skip to content

Commit 6f73f90

Browse files
committed
Activity log chips styling and group move renderer updates
1 parent dd9eb5a commit 6f73f90

File tree

3 files changed

+30
-33
lines changed

3 files changed

+30
-33
lines changed

apps/web/ui/activity-logs/activity-entry-chips.tsx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getResourceColorData, RAINBOW_CONIC_GRADIENT } from "@/ui/colors";
33
import { Bolt } from "@dub/ui";
44
import { cn, OG_AVATAR_URL } from "@dub/utils";
55
import { ReactNode } from "react";
6-
import { ActorType, getActorType } from "./activity-log-registry";
6+
import { getActorType } from "./activity-log-registry";
77

88
interface GroupPillProps extends Pick<GroupProps, "name" | "color"> {}
99

@@ -16,13 +16,17 @@ interface UserChipProps {
1616
user: NonNullable<ActivityLog["user"]>;
1717
}
1818

19+
interface ActorChipProps {
20+
log: ActivityLog;
21+
}
22+
1923
export function GroupPill({ name, color }: GroupPillProps) {
2024
const colorClassName = color
2125
? getResourceColorData(color)?.groupVariants
2226
: undefined;
2327

2428
return (
25-
<span className="inline-flex items-center gap-1.5 rounded-md bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
29+
<span className="inline-flex items-center gap-1 rounded-lg bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
2630
<span
2731
className={cn("size-2.5 shrink-0 rounded-full", colorClassName)}
2832
{...(!colorClassName && {
@@ -38,20 +42,16 @@ export function GroupPill({ name, color }: GroupPillProps) {
3842

3943
export function SourcePill({ icon, label }: SourcePillProps) {
4044
return (
41-
<span className="inline-flex items-center gap-1.5 rounded-md bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
42-
{icon && (
43-
<span className="flex size-3.5 items-center justify-center text-neutral-500">
44-
{icon}
45-
</span>
46-
)}
45+
<span className="inline-flex items-center gap-1 rounded-lg bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
46+
{icon && <span className="size-2.5 shrink-0 rounded-full">{icon}</span>}
4747
{label}
4848
</span>
4949
);
5050
}
5151

5252
export function UserChip({ user }: UserChipProps) {
5353
return (
54-
<span className="inline-flex items-center gap-1.5 rounded-md bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
54+
<span className="inline-flex items-center gap-1 rounded-lg bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
5555
<img
5656
src={user.image || `${OG_AVATAR_URL}${user.id}`}
5757
alt={`${user.name || user.email || "User"}`}
@@ -64,17 +64,13 @@ export function UserChip({ user }: UserChipProps) {
6464

6565
export function SystemChip() {
6666
return (
67-
<span className="inline-flex items-center gap-1.5 rounded-md bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
67+
<span className="inline-flex items-center gap-1 rounded-lg bg-neutral-100 px-2 py-0.5 text-sm font-medium text-neutral-700">
6868
<Bolt className="size-3 text-neutral-500" />
6969
System
7070
</span>
7171
);
7272
}
7373

74-
interface ActorChipProps {
75-
log: ActivityLog;
76-
}
77-
7874
export function ActorChip({ log }: ActorChipProps) {
7975
const actorType = getActorType(log);
8076

@@ -84,7 +80,3 @@ export function ActorChip({ log }: ActorChipProps) {
8480

8581
return <SystemChip />;
8682
}
87-
88-
export function getActorPreposition(actorType: ActorType): string {
89-
return "by";
90-
}

apps/web/ui/activity-logs/activity-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function ActivityItem({ log, isLast = false }: ActivityItemProps) {
3737
</div>
3838

3939
<div className="flex min-w-0 flex-1 flex-col gap-1 pb-6">
40-
<div className="flex flex-wrap items-center gap-1 text-sm text-neutral-700">
40+
<div className="flex flex-wrap items-center gap-1.5 text-sm text-neutral-700">
4141
<Renderer log={log} />
4242
</div>
4343

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import useGroups from "@/lib/swr/use-groups";
22
import { ActivityLog, GroupProps } from "@/lib/types";
33
import { Bolt } from "@dub/ui";
4+
import { ReactNode } from "react";
45
import { GroupPill, SourcePill, UserChip } from "../activity-entry-chips";
56

67
interface GroupChangeSet {
78
old: Pick<GroupProps, "id" | "name">;
89
new: Pick<GroupProps, "id" | "name">;
910
}
1011

12+
function Label({ children }: { children: ReactNode }) {
13+
return (
14+
<span className="text-sm font-medium text-neutral-800">{children}</span>
15+
);
16+
}
17+
1118
export function PartnerGroupChangedRenderer({ log }: { log: ActivityLog }) {
1219
const { groups } = useGroups();
1320

@@ -21,23 +28,21 @@ export function PartnerGroupChangedRenderer({ log }: { log: ActivityLog }) {
2128
const newGroupColor =
2229
groups?.find((g) => g.id === newGroup.id)?.color ?? null;
2330

24-
if (log.user) {
25-
return (
26-
<>
27-
<span>Moved to</span>
28-
<GroupPill name={newGroup.name} color={newGroupColor} />
29-
<span>by</span>
30-
<UserChip user={log.user} />
31-
</>
32-
);
33-
}
34-
3531
return (
3632
<>
37-
<span>Moved to</span>
33+
<Label>Moved to</Label>
3834
<GroupPill name={newGroup.name} color={newGroupColor} />
39-
<span>automatically by</span>
40-
<SourcePill icon={<Bolt className="size-3" />} label="Group move" />
35+
{log.user ? (
36+
<>
37+
<Label>by</Label>
38+
<UserChip user={log.user} />
39+
</>
40+
) : (
41+
<>
42+
<Label>automatically by</Label>
43+
<SourcePill icon={<Bolt className="size-3" />} label="Group move" />
44+
</>
45+
)}
4146
</>
4247
);
4348
}

0 commit comments

Comments
 (0)