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

Commit a93cf72

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

4 files changed

Lines changed: 11 additions & 34 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
@@ -114,19 +114,6 @@ describe("ChannelsList", () => {
114114
renderList();
115115
expect(screen.getByText("Channels")).toBeTruthy();
116116
});
117-
118-
it("shows section icons and the caret for the current state", async () => {
119-
const user = userEvent.setup();
120-
renderList();
121-
122-
expect(screen.getByTestId("starred-section-icon")).toBeTruthy();
123-
expect(screen.getByTestId("spaces-section-icon")).toBeTruthy();
124-
expect(screen.getByTestId("channels:all-caret-down")).toBeTruthy();
125-
126-
await user.click(screen.getByText("Spaces"));
127-
128-
expect(screen.getByTestId("channels:all-caret-right")).toBeTruthy();
129-
});
130117
});
131118

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

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ function ChannelSection({
558558
// the "me" folder is the bridge that keeps the folder-keyed surfaces
559559
// (CONTEXT.md, artifacts) routable, created lazily on first open.
560560
function PersonalChannelRow({ hotkeySlot }: { hotkeySlot?: number }) {
561-
const spacesLayout = useChannelsLayout();
562561
const navigate = useNavigate();
563562
const pathname = useRouterState({ select: (s) => s.location.pathname });
564563
const setCurrentChannel = useCurrentChannelStore((s) => s.setCurrentChannel);
@@ -635,7 +634,6 @@ function PersonalChannelRow({ hotkeySlot }: { hotkeySlot?: number }) {
635634
>
636635
{channelGlyph(PERSONAL_CHANNEL_NAME, {
637636
size: 14,
638-
space: spacesLayout,
639637
weight: isUnread ? "bold" : undefined,
640638
className: cn(
641639
"shrink-0",
@@ -733,7 +731,7 @@ function ChannelGroup({
733731
sectionId: string;
734732
label: string;
735733
className?: string;
736-
/** Layout-only: rows sit at the label's level instead of indented under it. */
734+
/** Layout-only: removes the legacy tree indent; rows apply their own inset. */
737735
flat?: boolean;
738736
icon: ReactNode;
739737
children: ReactNode;
@@ -766,13 +764,11 @@ function ChannelGroup({
766764
{isOpen ? (
767765
<CaretDownIcon
768766
size={14}
769-
data-testid={`${sectionId}-caret-down`}
770767
className="hidden group-hover/group-trigger:block group-focus-visible/group-trigger:block"
771768
/>
772769
) : (
773770
<CaretRightIcon
774771
size={14}
775-
data-testid={`${sectionId}-caret-right`}
776772
className="hidden group-hover/group-trigger:block group-focus-visible/group-trigger:block"
777773
/>
778774
)}
@@ -881,9 +877,7 @@ export function ChannelsList() {
881877
sectionId={STARRED_SECTION_ID}
882878
label="Starred"
883879
flat={channelsLayout}
884-
icon={
885-
<StarIcon size={14} data-testid="starred-section-icon" />
886-
}
880+
icon={<StarIcon size={14} />}
887881
>
888882
{starred.map((channel) => (
889883
<ChannelSection
@@ -902,10 +896,7 @@ export function ChannelsList() {
902896
flat={channelsLayout}
903897
icon={
904898
channelsLayout ? (
905-
<CubeFocusIcon
906-
size={14}
907-
data-testid="spaces-section-icon"
908-
/>
899+
<CubeFocusIcon size={14} />
909900
) : (
910901
<HashIcon size={14} />
911902
)

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)