Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions desktop/src/features/sidebar/ui/CommunityRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function CommunityButton({
dragAttributes?: React.HTMLAttributes<HTMLElement>;
isDragging?: boolean;
}) {
const { mentionCount, showBadge, showDot, pending, badgeLabel } =
const { mentionCount, showBadge, showDot, badgeLabel } =
communityRailIndicators(unread);

const tooltipLabel = showBadge
Expand Down Expand Up @@ -135,11 +135,8 @@ function CommunityButton({
>
<span
className={cn(
"flex h-9 w-9 items-center justify-center overflow-hidden rounded-2xl text-xs font-semibold transition-all",
isActive
? "rounded-xl bg-primary text-primary-foreground"
: "bg-sidebar-accent/60 text-sidebar-foreground/80 hover:rounded-xl hover:bg-primary/80 hover:text-primary-foreground",
pending && !isActive && "opacity-60",
"flex h-9 w-9 items-center justify-center overflow-hidden rounded-xl bg-sidebar-accent/60 text-xs font-semibold text-sidebar-foreground/80 outline-2 outline-offset-2 outline-primary/0 transition-[outline-color]",
isActive ? "outline-primary" : "hover:outline-primary/50",
)}
>
{iconUrl ? (
Expand Down Expand Up @@ -172,7 +169,9 @@ function CommunityButton({
</button>
</ContextMenuTrigger>
</TooltipTrigger>
<TooltipContent side="right">{tooltipLabel}</TooltipContent>
<TooltipContent side="right" sideOffset={8}>
{tooltipLabel}
</TooltipContent>
</Tooltip>
<ContextMenuContent data-testid={`community-rail-menu-${community.id}`}>
{menu}
Expand Down Expand Up @@ -368,7 +367,7 @@ export function CommunityRail({
return (
<nav
aria-label="Communities"
className="relative z-0 flex w-14 shrink-0 flex-col items-center gap-2 overflow-y-auto bg-sidebar px-2.5 pb-5 pt-[calc(var(--buzz-top-chrome-height,40px)+7px)]"
className="relative z-0 flex w-14 shrink-0 flex-col items-center gap-2.5 overflow-y-auto bg-sidebar px-2.5 pb-5 pt-[calc(var(--buzz-top-chrome-height,40px)+7px)]"
data-testid="community-rail"
>
<DndContext
Expand Down Expand Up @@ -418,7 +417,9 @@ export function CommunityRail({
<Plus className="h-4 w-4" />
</button>
</TooltipTrigger>
<TooltipContent side="right">Add community</TooltipContent>
<TooltipContent side="right" sideOffset={8}>
Add community
</TooltipContent>
</Tooltip>
<EditCommunityDialog
onOpenChange={(open) => {
Expand Down
46 changes: 46 additions & 0 deletions desktop/tests/e2e/community-rail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,52 @@ test.describe("community rail", () => {
"opacity",
"1",
);
await expect(buttonB.locator(":scope > span").first()).toHaveCSS(
"opacity",
"1",
);
const [activeStyle, inactiveStyle] = await Promise.all(
[buttonA, buttonB].map((button) =>
button
.locator(":scope > span")
.first()
.evaluate((element) => {
const style = getComputedStyle(element);
return {
backgroundColor: style.backgroundColor,
borderRadius: style.borderRadius,
color: style.color,
outlineStyle: style.outlineStyle,
outlineWidth: style.outlineWidth,
};
}),
),
);
expect(activeStyle.backgroundColor).toBe(inactiveStyle.backgroundColor);
expect(activeStyle.borderRadius).toBe(inactiveStyle.borderRadius);
expect(activeStyle.borderRadius).toBe("12px");
expect(activeStyle.color).toBe(inactiveStyle.color);
expect(activeStyle.outlineStyle).toBe("solid");
expect(activeStyle.outlineWidth).toBe("2px");
expect(inactiveStyle.outlineStyle).toBe("solid");
expect(inactiveStyle.outlineWidth).toBe("2px");

const inactiveIcon = buttonB.locator(":scope > span").first();
await buttonB.hover();
await expect(inactiveIcon).toHaveCSS("outline-width", "2px");
const hoverStyle = await inactiveIcon.evaluate((element) => {
const style = getComputedStyle(element);
return {
backgroundColor: style.backgroundColor,
borderRadius: style.borderRadius,
color: style.color,
outlineStyle: style.outlineStyle,
};
});
expect(hoverStyle.backgroundColor).toBe(inactiveStyle.backgroundColor);
expect(hoverStyle.borderRadius).toBe(inactiveStyle.borderRadius);
expect(hoverStyle.color).toBe(inactiveStyle.color);
expect(hoverStyle.outlineStyle).toBe("solid");

// The add-community affordance lives at the bottom of the rail.
await expect(page.getByTestId("community-rail-add")).toBeVisible();
Expand Down
Loading