Skip to content

Commit aa8a720

Browse files
authored
chore: Reuse help menu (#4769)
## Description <img width="389" alt="image" src="https://github.com/user-attachments/assets/4e011ab6-5f39-4c38-84a5-96b4ad75934e" /> 1. Added central place for all help links 1. Added same thing to the menu 1. Deemphasize github discussions, it works better with discord for everything ## Steps for reproduction 1. click button 4. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent b3e2604 commit aa8a720

File tree

4 files changed

+86
-110
lines changed

4 files changed

+86
-110
lines changed

apps/builder/app/builder/features/help/help-center.tsx

+20-68
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@ import {
77
rawTheme,
88
theme,
99
} from "@webstudio-is/design-system";
10-
import {
11-
BugIcon,
12-
ContentIcon,
13-
DiscordIcon,
14-
GithubIcon,
15-
LifeBuoyIcon,
16-
YoutubeIcon,
17-
} from "@webstudio-is/icons";
1810
import { type ComponentProps } from "react";
1911
import { $remoteDialog } from "../../shared/nano-states";
12+
import { help } from "~/shared/help";
2013

2114
export const HelpCenter = ({
2215
children,
@@ -43,66 +36,25 @@ export const HelpCenter = ({
4336
css={{ padding: theme.spacing[5] }}
4437
gap="2"
4538
>
46-
<Button
47-
type="button"
48-
prefix={<LifeBuoyIcon />}
49-
css={{ justifyContent: "start" }}
50-
color="ghost"
51-
onClick={() => {
52-
$remoteDialog.set({
53-
title: "Support Hub",
54-
url: "https://help.webstudio.is/",
55-
});
56-
}}
57-
>
58-
Support Hub
59-
</Button>
60-
<Button
61-
formAction="https://wstd.us/101"
62-
name="list"
63-
value="PL4vVqpngzeT4sDlanyPe99dYl8BgUYCac"
64-
prefix={<YoutubeIcon />}
65-
color="ghost"
66-
css={{ justifyContent: "start" }}
67-
>
68-
Learn with videos
69-
</Button>
70-
<Button
71-
formAction="https://docs.webstudio.is/"
72-
prefix={<ContentIcon />}
73-
color="ghost"
74-
css={{ justifyContent: "start" }}
75-
>
76-
Learn from docs
77-
</Button>
78-
<Button
79-
formAction="https://wstd.us/community"
80-
prefix={<DiscordIcon />}
81-
color="ghost"
82-
css={{ justifyContent: "start" }}
83-
>
84-
Join the Community
85-
</Button>
86-
<Button
87-
formAction="https://github.com/webstudio-is/webstudio-community/discussions"
88-
prefix={<GithubIcon fill="currentColor" />}
89-
color="ghost"
90-
css={{ justifyContent: "start" }}
91-
>
92-
Discuss on GitHub
93-
</Button>
94-
<Button
95-
prefix={<BugIcon />}
96-
color="ghost"
97-
onClick={() => {
98-
window.open(
99-
"https://github.com/webstudio-is/webstudio-community/discussions/new?category=q-a&labels=bug&title=[Bug]"
100-
);
101-
}}
102-
css={{ justifyContent: "start" }}
103-
>
104-
Report a bug
105-
</Button>
39+
{help.map((item) => (
40+
<Button
41+
key={item.url}
42+
prefix={item.icon}
43+
css={{ justifyContent: "start" }}
44+
color="ghost"
45+
formAction={item.url}
46+
onClick={() => {
47+
if ("target" in item && item.target === "embed") {
48+
$remoteDialog.set({
49+
title: item.label,
50+
url: item.url,
51+
});
52+
}
53+
}}
54+
>
55+
{item.label}
56+
</Button>
57+
))}
10658
</Flex>
10759
</PopoverContent>
10860
</Popover>

apps/builder/app/builder/features/topbar/menu/menu.tsx

+28-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
$isCloneDialogOpen,
2020
$isShareDialogOpen,
2121
$publishDialog,
22+
$remoteDialog,
2223
} from "~/builder/shared/nano-states";
2324
import { cloneProjectUrl, dashboardUrl } from "~/shared/router-utils";
2425
import {
@@ -33,6 +34,7 @@ import { MenuButton } from "./menu-button";
3334
import { $openProjectSettings } from "~/shared/nano-states/project-settings";
3435
import { UpgradeIcon } from "@webstudio-is/icons";
3536
import { getSetting, setSetting } from "~/builder/shared/client-settings";
37+
import { help } from "~/shared/help";
3638

3739
const ViewMenuItem = () => {
3840
const navigatorLayout = getSetting("navigatorLayout");
@@ -79,7 +81,7 @@ export const Menu = () => {
7981
const cloneIsExternal = authToken !== undefined;
8082

8183
return (
82-
<DropdownMenu>
84+
<DropdownMenu modal={false}>
8385
<MenuButton />
8486
<DropdownMenuPortal>
8587
<DropdownMenuContent
@@ -262,13 +264,31 @@ export const Menu = () => {
262264
>
263265
Keyboard shortcuts
264266
</DropdownMenuItem>
265-
<DropdownMenuItem
266-
onSelect={() => {
267-
window.open("https://docs.webstudio.is");
268-
}}
269-
>
270-
Learn Webstudio
271-
</DropdownMenuItem>
267+
268+
<DropdownMenuSub>
269+
<DropdownMenuSubTrigger>Help</DropdownMenuSubTrigger>
270+
<DropdownMenuSubContent width="regular">
271+
{help.map((item) => (
272+
<DropdownMenuItem
273+
key={item.url}
274+
onSelect={(event) => {
275+
if ("target" in item && item.target === "embed") {
276+
event.preventDefault();
277+
$remoteDialog.set({
278+
title: item.label,
279+
url: item.url,
280+
});
281+
return;
282+
}
283+
window.open(item.url);
284+
}}
285+
>
286+
{item.label}
287+
</DropdownMenuItem>
288+
))}
289+
</DropdownMenuSubContent>
290+
</DropdownMenuSub>
291+
272292
{hasProPlan === false && (
273293
<>
274294
<DropdownMenuSeparator />

apps/builder/app/dashboard/dashboard.tsx

+8-34
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ import {
1111
theme,
1212
} from "@webstudio-is/design-system";
1313
import type { DashboardProject } from "@webstudio-is/dashboard";
14-
import {
15-
BodyIcon,
16-
ContentIcon,
17-
DiscordIcon,
18-
ExtensionIcon,
19-
LifeBuoyIcon,
20-
YoutubeIcon,
21-
} from "@webstudio-is/icons";
14+
import { BodyIcon, ExtensionIcon } from "@webstudio-is/icons";
2215
import type { User } from "~/shared/db/user.server";
2316
import type { UserPlanFeatures } from "~/shared/db/user-plan-features.server";
2417
import { NavLink, useLocation, useRevalidator } from "@remix-run/react";
@@ -29,6 +22,7 @@ import { ProfileMenu } from "./profile-menu";
2922
import { Projects } from "./projects/projects";
3023
import { Templates } from "./templates/templates";
3124
import { Header } from "./shared/layout";
25+
import { help } from "~/shared/help";
3226

3327
const globalStyles = globalCss({
3428
body: {
@@ -195,32 +189,12 @@ export const Dashboard = ({
195189
</CollapsibleSection>
196190
<CollapsibleSection label="Help & support" fullWidth>
197191
<NavigationItems
198-
items={[
199-
{
200-
to: "https://wstd.us/101",
201-
target: "_blank",
202-
prefix: <YoutubeIcon />,
203-
children: "Video tutorials",
204-
},
205-
{
206-
to: "https://help.webstudio.is/",
207-
target: "_blank",
208-
prefix: <LifeBuoyIcon />,
209-
children: "Support hub",
210-
},
211-
{
212-
to: "https://docs.webstudio.is",
213-
target: "_blank",
214-
prefix: <ContentIcon />,
215-
children: "Docs",
216-
},
217-
{
218-
to: "https://wstd.us/community",
219-
target: "_blank",
220-
prefix: <DiscordIcon />,
221-
children: "Community",
222-
},
223-
]}
192+
items={help.map((item) => ({
193+
to: item.url,
194+
target: "_blank",
195+
prefix: item.icon,
196+
children: item.label,
197+
}))}
224198
/>
225199
</CollapsibleSection>
226200
</nav>

apps/builder/app/shared/help.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {
2+
ContentIcon,
3+
DiscordIcon,
4+
LifeBuoyIcon,
5+
YoutubeIcon,
6+
} from "@webstudio-is/icons";
7+
8+
export const help = [
9+
{
10+
label: "Support hub",
11+
url: "https://help.webstudio.is/",
12+
icon: <LifeBuoyIcon />,
13+
target: "embed",
14+
},
15+
{
16+
label: "Video tutorials",
17+
url: "https://wstd.us/101",
18+
icon: <YoutubeIcon />,
19+
},
20+
{
21+
label: "Docs",
22+
url: "https://docs.webstudio.is/",
23+
icon: <ContentIcon />,
24+
},
25+
{
26+
label: "Community",
27+
url: "https://wstd.us/community",
28+
icon: <DiscordIcon />,
29+
},
30+
] as const;

0 commit comments

Comments
 (0)