Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit c5de227

Browse files
authored
refactor(spaces): reuse shared channel glyph
Generated-By: PostHog Code Task-Id: 69df779b-b72b-45bc-a11b-3deeff24ad49
1 parent 54104bb commit c5de227

4 files changed

Lines changed: 11 additions & 28 deletions

File tree

packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {
22
BrainIcon,
3-
CubeIcon,
4-
HashIcon,
53
PlugsConnectedIcon,
64
RobotIcon,
75
SquaresFourIcon,
@@ -25,6 +23,7 @@ import {
2523
} from "@posthog/shared";
2624
import { channelSectionFor } from "@posthog/ui/features/canvas/channelSections";
2725
import { iconForTemplate } from "@posthog/ui/features/canvas/components/canvasTemplateIcon";
26+
import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";
2827
import { ensurePersonalChannel } from "@posthog/ui/features/canvas/ensurePersonalChannel";
2928
import {
3029
useChannelMutations,
@@ -514,11 +513,10 @@ export function BrowserTabStrip() {
514513
id: t.id,
515514
label:
516515
meta?.label ?? channel ?? (spacesLayout ? "Space" : "Channel"),
517-
icon: spacesLayout ? (
518-
<CubeIcon size={14} />
519-
) : (
520-
<HashIcon size={14} />
521-
),
516+
icon: channelGlyph(channel ?? undefined, {
517+
size: 14,
518+
space: spacesLayout,
519+
}),
522520
channelName: channel,
523521
// No section meta → the channel's index page.
524522
isChannelHome: !meta,

packages/ui/src/features/canvas/components/ChannelsList.test.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,6 @@ describe("ChannelsList", () => {
125125
renderList();
126126
expect(screen.getByText("Channels")).toBeTruthy();
127127
});
128-
129-
it("shows section icons and the caret for the current state", async () => {
130-
const user = userEvent.setup();
131-
renderList();
132-
133-
expect(screen.getByTestId("starred-section-icon")).toBeTruthy();
134-
expect(screen.getByTestId("spaces-section-icon")).toBeTruthy();
135-
expect(screen.getByTestId("channels:all-caret-down")).toBeTruthy();
136-
137-
await user.click(screen.getByText("Spaces"));
138-
139-
expect(screen.getByTestId("channels:all-caret-right")).toBeTruthy();
140-
});
141128
});
142129

143130
describe("search", () => {

packages/ui/src/features/canvas/components/ChannelsList.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,6 @@ function PersonalChannelRow({ hotkeySlot }: { hotkeySlot?: number }) {
732732
>
733733
{channelGlyph(PERSONAL_CHANNEL_NAME, {
734734
size: 14,
735-
space: spacesLayout,
736735
weight: isUnread ? "bold" : undefined,
737736
className: cn(
738737
"shrink-0",
@@ -831,7 +830,7 @@ function ChannelGroup({
831830
sectionId: string;
832831
label: string;
833832
className?: string;
834-
/** Layout-only: rows sit at the label's level instead of indented under it. */
833+
/** Layout-only: removes the legacy tree indent; rows apply their own inset. */
835834
flat?: boolean;
836835
/**
837836
* Off under the layout: a kept-mounted collapsed row is still an Autocomplete
@@ -870,13 +869,11 @@ function ChannelGroup({
870869
{isOpen ? (
871870
<CaretDownIcon
872871
size={14}
873-
data-testid={`${sectionId}-caret-down`}
874872
className="hidden group-hover/group-trigger:block group-focus-visible/group-trigger:block"
875873
/>
876874
) : (
877875
<CaretRightIcon
878876
size={14}
879-
data-testid={`${sectionId}-caret-right`}
880877
className="hidden group-hover/group-trigger:block group-focus-visible/group-trigger:block"
881878
/>
882879
)}
@@ -1009,7 +1006,7 @@ export function ChannelsList() {
10091006
label="Starred"
10101007
flat={channelsLayout}
10111008
keepMounted={!channelsLayout}
1012-
icon={<StarIcon size={14} data-testid="starred-section-icon" />}
1009+
icon={<StarIcon size={14} />}
10131010
>
10141011
{starred.map((channel) => (
10151012
<ChannelSection
@@ -1029,7 +1026,7 @@ export function ChannelsList() {
10291026
keepMounted={!channelsLayout}
10301027
icon={
10311028
channelsLayout ? (
1032-
<CubeFocusIcon size={14} data-testid="spaces-section-icon" />
1029+
<CubeFocusIcon size={14} />
10331030
) : (
10341031
<HashIcon size={14} />
10351032
)

packages/ui/src/features/canvas/components/RenameChannelModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { CubeIcon, HashIcon, XIcon } from "@phosphor-icons/react";
1+
import { XIcon } from "@phosphor-icons/react";
22
import { validateChannelName } from "@posthog/core/canvas/channelName";
33
import { Button } from "@posthog/quill";
44
import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
5+
import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";
56
import type { Channel } from "@posthog/ui/features/canvas/hooks/useChannels";
67
import { useChannelMutations } from "@posthog/ui/features/canvas/hooks/useChannels";
78
import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
@@ -114,7 +115,7 @@ export function RenameChannelModal({
114115
}}
115116
>
116117
<TextField.Slot>
117-
{spacesLayout ? <CubeIcon size={16} /> : <HashIcon size={16} />}
118+
{channelGlyph(channel.name, { size: 16, space: spacesLayout })}
118119
</TextField.Slot>
119120
<TextField.Slot side="right">
120121
<Text className="text-gray-9 text-sm tabular-nums">

0 commit comments

Comments
 (0)