Skip to content

Commit 7889513

Browse files
authored
feat: Open the page settings in one click or key press from the top bar (#4126)
## Description I noticed people are annoyed by the need to click the pages first, then find the right page and click settings in webflow https://x.com/thepixelgeek/status/1833583918756597875 While this is an advanced need and bloating the UI is not very good, there must be a way to do this, so I added a modifier. Now you can hold alt/option modifier + click or enter on page button in the top bar and its going to open the navigator and Demo: https://share.descript.com/view/mzqZLue17q7 Todo - [ ] add this shortcut to shortcuts doc ## Steps for reproduction 1. click button 2. 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: 5de6) - [ ] 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 30981bd commit 7889513

File tree

7 files changed

+46
-34
lines changed

7 files changed

+46
-34
lines changed

apps/builder/app/builder/features/sidebar-left/panels/pages/page-utils.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import {
1616
toTreeData,
1717
filterSelfAndChildren,
1818
getExistingRoutePaths,
19-
$editingPagesItemId,
2019
$pageRootScope,
2120
isPathAvailable,
2221
} from "./page-utils";
2322
import {
2423
$dataSourceVariables,
2524
$dataSources,
25+
$editingPageId,
2626
$pages,
2727
$resourceValues,
2828
$selectedPageId,
@@ -585,7 +585,7 @@ test("page root scope should rely on editing page", () => {
585585
});
586586
$pages.set(pages);
587587
$selectedPageId.set("homePageId");
588-
$editingPagesItemId.set("pageId");
588+
$editingPageId.set("pageId");
589589
$dataSources.set(
590590
toMap([
591591
{
@@ -619,7 +619,7 @@ test("page root scope should use variable and resource values", () => {
619619
systemDataSourceId: "system",
620620
})
621621
);
622-
$editingPagesItemId.set("homePageId");
622+
$editingPageId.set("homePageId");
623623
$dataSources.set(
624624
toMap([
625625
{
@@ -666,7 +666,7 @@ test("page root scope should prefill default system variable value", () => {
666666
systemDataSourceId: "systemId",
667667
})
668668
);
669-
$editingPagesItemId.set("homePageId");
669+
$editingPageId.set("homePageId");
670670
$dataSources.set(
671671
toMap([
672672
{

apps/builder/app/builder/features/sidebar-left/panels/pages/page-utils.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { atom, computed } from "nanostores";
1+
import { computed } from "nanostores";
22
import { createRootFolder } from "@webstudio-is/project-build";
33
import {
44
type Page,
@@ -21,6 +21,7 @@ import {
2121
import {
2222
$dataSourceVariables,
2323
$dataSources,
24+
$editingPageId,
2425
$pages,
2526
$publishedOrigin,
2627
$resourceValues,
@@ -328,15 +329,13 @@ export const getExistingRoutePaths = (pages?: Pages): Set<string> => {
328329
return paths;
329330
};
330331

331-
export const $editingPagesItemId = atom<undefined | Page["id"]>();
332-
333332
const $editingPage = computed(
334-
[$editingPagesItemId, $pages],
335-
(editingPagesItemId, pages) => {
336-
if (editingPagesItemId === undefined || pages === undefined) {
333+
[$editingPageId, $pages],
334+
(editingPageId, pages) => {
335+
if (editingPageId === undefined || pages === undefined) {
337336
return;
338337
}
339-
return findPageByIdOrPath(editingPagesItemId, pages);
338+
return findPageByIdOrPath(editingPageId, pages);
340339
}
341340
);
342341

apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ import type { TabContentProps } from "../../types";
2525
import { CloseButton, Header, Root } from "../../shared/panel";
2626
import { ExtendedPanel } from "../../shared/extended-panel";
2727
import { NewPageSettings, PageSettings } from "./page-settings";
28-
import { $pages, $selectedPageId } from "~/shared/nano-states";
28+
import { $editingPageId, $pages, $selectedPageId } from "~/shared/nano-states";
2929
import { switchPage } from "~/shared/pages";
3030
import {
31-
$editingPagesItemId,
3231
getAllChildrenAndSelf,
3332
reparentOrphansMutable,
3433
toTreeData,
@@ -364,7 +363,7 @@ const FolderEditor = ({
364363

365364
export const TabContent = ({ onSetActiveTab }: TabContentProps) => {
366365
const currentPageId = useStore($selectedPageId);
367-
const editingItemId = useStore($editingPagesItemId);
366+
const editingItemId = useStore($editingPageId);
368367
const pages = useStore($pages);
369368

370369
if (currentPageId === undefined || pages === undefined) {
@@ -376,12 +375,12 @@ export const TabContent = ({ onSetActiveTab }: TabContentProps) => {
376375
<PagesPanel
377376
onClose={() => onSetActiveTab("none")}
378377
onCreateNewFolder={() => {
379-
$editingPagesItemId.set(
378+
$editingPageId.set(
380379
editingItemId === newFolderId ? undefined : newFolderId
381380
);
382381
}}
383382
onCreateNewPage={() =>
384-
$editingPagesItemId.set(
383+
$editingPageId.set(
385384
editingItemId === newPageId ? undefined : newPageId
386385
)
387386
}
@@ -393,7 +392,7 @@ export const TabContent = ({ onSetActiveTab }: TabContentProps) => {
393392
onSetActiveTab("none");
394393
}}
395394
selectedPageId={currentPageId}
396-
onEdit={$editingPagesItemId.set}
395+
onEdit={$editingPageId.set}
397396
editingItemId={editingItemId}
398397
/>
399398

@@ -403,12 +402,12 @@ export const TabContent = ({ onSetActiveTab }: TabContentProps) => {
403402
{isFolder(editingItemId, pages.folders) ? (
404403
<FolderEditor
405404
editingFolderId={editingItemId}
406-
setEditingFolderId={$editingPagesItemId.set}
405+
setEditingFolderId={$editingPageId.set}
407406
/>
408407
) : (
409408
<PageEditor
410409
editingPageId={editingItemId}
411-
setEditingPageId={$editingPagesItemId.set}
410+
setEditingPageId={$editingPageId.set}
412411
/>
413412
)}
414413
</>

apps/builder/app/builder/features/style-panel/property-label.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const PropertyInfo = ({
157157
<ResetIcon />
158158
</Flex>
159159
}
160-
suffix={<Kbd value={["option", "click"]} />}
160+
suffix={<Kbd value={["option", "click"]} color="moreSubtle" />}
161161
css={{ gridTemplateColumns: "2fr 3fr 1fr" }}
162162
onClick={onReset}
163163
>

apps/builder/app/builder/features/style-panel/shared/property-name.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export const TooltipContent = ({
274274
<ResetIcon />
275275
</Flex>
276276
}
277-
suffix={<Kbd value={["option", "click"]} />}
277+
suffix={<Kbd value={["option", "click"]} color="moreSubtle" />}
278278
css={{ gridTemplateColumns: "2fr 3fr 1fr" }}
279279
onClick={onReset}
280280
>

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

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import {
88
ToolbarButton,
99
Text,
1010
type CSS,
11+
Tooltip,
12+
Kbd,
1113
} from "@webstudio-is/design-system";
1214
import type { Project } from "@webstudio-is/project";
13-
import { $pages, $selectedPage } from "~/shared/nano-states";
15+
import { $editingPageId, $pages, $selectedPage } from "~/shared/nano-states";
1416
import { PreviewButton } from "./preview";
1517
import { ShareButton } from "./share";
1618
import { PublishButton } from "./publish";
@@ -33,19 +35,29 @@ const PagesButton = () => {
3335
}
3436

3537
return (
36-
<ToolbarButton
37-
css={{
38-
px: theme.spacing[9],
39-
maxWidth: theme.spacing[24],
40-
}}
41-
aria-label="Toggle Pages"
42-
onClick={() => {
43-
toggleActiveSidebarPanel("pages");
44-
}}
45-
tabIndex={0}
38+
<Tooltip
39+
content={
40+
<Text>
41+
{"Pages or page settings "}
42+
<Kbd value={["option", "click"]} color="moreSubtle" />
43+
</Text>
44+
}
4645
>
47-
<Text truncate>{page.name}</Text>
48-
</ToolbarButton>
46+
<ToolbarButton
47+
css={{
48+
px: theme.spacing[9],
49+
maxWidth: theme.spacing[24],
50+
}}
51+
aria-label="Toggle Pages"
52+
onClick={(event) => {
53+
$editingPageId.set(event.altKey ? page.id : undefined);
54+
toggleActiveSidebarPanel("pages");
55+
}}
56+
tabIndex={0}
57+
>
58+
<Text truncate>{page.name}</Text>
59+
</ToolbarButton>
60+
</Tooltip>
4961
);
5062
};
5163

apps/builder/app/shared/nano-states/pages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ export const $selectedPage = computed(
1515
return findPageByIdOrPath(selectedPageId, pages);
1616
}
1717
);
18+
19+
export const $editingPageId = atom<undefined | Page["id"]>();

0 commit comments

Comments
 (0)