Skip to content
Open
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
9 changes: 8 additions & 1 deletion desktop/src/features/sidebar/ui/CommunityRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,17 @@ function CommunityButton({
{...dragAttributes}
{...dragListeners}
>
{isActive ? (
<span
aria-hidden="true"
className="absolute -left-2.5 h-5 w-1 rounded-r-full bg-primary"
data-testid={`community-rail-active-${community.id}`}
/>
) : null}
<span
className={cn(
"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",
!isActive && "hover:outline-primary/50",
)}
>
{iconUrl ? (
Expand Down
20 changes: 15 additions & 5 deletions desktop/tests/e2e/community-rail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,37 @@ test.describe("community rail", () => {
await expect(buttonA).toBeVisible();
await expect(buttonB).toBeVisible();

// The active community is marked via aria-current.
// The active community is marked semantically and with a persistent rail.
await expect(buttonA).toHaveAttribute("aria-current", "true");
await expect(buttonB).not.toHaveAttribute("aria-current", "true");
await expect(buttonA.locator(":scope > span").first()).toHaveCSS(
"opacity",
"1",
const activeIndicator = page.getByTestId(
`community-rail-active-${COMMUNITY_A.id}`,
);
await expect(activeIndicator).toBeVisible();
await expect(
page.getByTestId(`community-rail-active-${COMMUNITY_B.id}`),
).toHaveCount(0);
await expect(activeIndicator).toHaveCSS("height", "20px");
await expect(activeIndicator).toHaveCSS("width", "4px");
await expect(
buttonA.locator(":scope > span:not([data-testid])").first(),
).toHaveCSS("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")
.locator(":scope > span:not([data-testid])")
.first()
.evaluate((element) => {
const style = getComputedStyle(element);
return {
backgroundColor: style.backgroundColor,
borderRadius: style.borderRadius,
color: style.color,
outlineColor: style.outlineColor,
outlineStyle: style.outlineStyle,
outlineWidth: style.outlineWidth,
};
Expand All @@ -98,6 +107,7 @@ test.describe("community rail", () => {
expect(activeStyle.borderRadius).toBe(inactiveStyle.borderRadius);
expect(activeStyle.borderRadius).toBe("12px");
expect(activeStyle.color).toBe(inactiveStyle.color);
expect(activeStyle.outlineColor).toBe(inactiveStyle.outlineColor);
expect(activeStyle.outlineStyle).toBe("solid");
expect(activeStyle.outlineWidth).toBe("2px");
expect(inactiveStyle.outlineStyle).toBe("solid");
Expand Down
Loading