Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

experimental: move address bar to topbar (#2921)

Bogdan Chadkin4f06445e9320
diff --git a/apps/builder/app/builder/features/address-bar.tsx b/apps/builder/app/builder/features/address-bar.tsx
new file mode 100644
index 0000000000..ddcbb4de31
--- /dev/null
+++ b/apps/builder/app/builder/features/address-bar.tsx
@@ -0,0 +1,231 @@
+import { computed } from "nanostores";
+import { useStore } from "@nanostores/react";
+import { useEffect, useId, useState, type ComponentProps } from "react";
+import {
+ Flex,
+ InputField,
+ Tooltip,
+ theme,
+ textVariants,
+ InputErrorsTooltip,
+ ToolbarButton,
+ Popover,
+ PopoverTrigger,
+ PopoverPortal,
+ PopoverContent,
+ IconButton,
+} from "@webstudio-is/design-system";
+import { CheckMarkIcon, CopyIcon, DynamicPageIcon } from "@webstudio-is/icons";
+import {
+ findParentFolderByChildId,
+ ROOT_FOLDER_ID,
+ getPagePath,
+} from "@webstudio-is/sdk";
+import {
+ $dataSourceVariables,
+ $domains,
+ $pages,
+ $project,
+ $selectedPage,
+} from "~/shared/nano-states";
+import env from "~/shared/env";
+import {
+ compilePathnamePattern,
+ tokenizePathnamePattern,
+} from "~/builder/shared/url-pattern";
+
+export const $publishedOrigin = computed(
+ [$project, $domains],
+ (project, domains) => {
+ const customDomain: string | undefined = domains[0];
+ const projectDomain = `${project?.domain}.${
+ env.PUBLISHER_HOST ?? "wstd.work"
+ }`;
+ const domain = customDomain ?? projectDomain;
+ const publishedUrl = new URL(`https://${domain}`);
+ return publishedUrl.origin;
+ }
+);
+
+const $selectedPagePath = computed([$selectedPage, $pages], (page, pages) => {
+ if (pages === undefined || page === undefined) {
+ return "/";
+ }
+ const parentFolder = findParentFolderByChildId(page.id, pages.folders);
+ const parentFolderId = parentFolder?.id ?? ROOT_FOLDER_ID;
+ const foldersPath = getPagePath(parentFolderId, pages);
+ return [foldersPath, page?.path ?? ""]
+ .filter(Boolean)
+ .join("/")
+ .replace(/\/+/g, "/");
+});
+
+type PathParams = Record<string, string>;
+
+const $selectedPagePathParams = computed(
+ [$selectedPage, $dataSourceVariables],
+ (selectedPage, dataSourceVariables) => {
+ if (selectedPage?.pathParamsDataSourceId === undefined) {
+ return {};
+ }
+ const pathParams = dataSourceVariables.get(
+ selectedPage?.pathParamsDataSourceId
+ ) as undefined | PathParams;
+ return pathParams;
+ }
+);
+
+const updatePathParam = (name: string, value: string) => {
+ const pathParams = $selectedPagePathParams.get();
+ const path = $selectedPagePath.get();
+ const tokens = tokenizePathnamePattern(path);
+ // delete stale fields
+ const newParams: PathParams = {};
+ for (const token of tokens) {
+ if (token.type === "param") {
+ newParams[token.name] = pathParams?.[token.name] ?? "";
+ }
+ }
+ newParams[name] = value;
+ const page = $selectedPage.get();
+ if (page?.pathParamsDataSourceId) {
+ const dataSourceVariables = new Map($dataSourceVariables.get());
+ dataSourceVariables.set(page.pathParamsDataSourceId, newParams);
+ $dataSourceVariables.set(dataSourceVariables);
+ }
+};
+
+const useCopyUrl = (pageUrl: string) => {
+ const [copyState, setCopyState] = useState<"copy" | "copied">("copy");
+ // reset copied state after 2 seconds
+ useEffect(() => {
+ if (copyState === "copied") {
+ const timeoutId = setTimeout(() => {
+ setCopyState("copy");
+ }, 2000);
+ return () => {
+ clearTimeout(timeoutId);
+ };
+ }
+ }, [copyState]);
+ let copyIcon = <CopyIcon />;
+ if (copyState === "copied") {
+ copyIcon = <CheckMarkIcon />;
+ }
+ const onClick = () => {
+ navigator.clipboard.writeText(pageUrl);
+ setCopyState("copied");
+ };
+ return {
+ tooltipProps: {
+ // keep tooltip open when user just copied
+ open: copyState === "copied" ? true : undefined,
+ content: copyState === "copied" ? "Copied" : `Copy ${pageUrl}`,
+ } satisfies Partial<ComponentProps<typeof Tooltip>>,
+ buttonProps: {
+ onClick,
+ children: copyIcon,
+ } satisfies Partial<ComponentProps<"button">>,
+ };
+};
+
+const AddressBar = () => {
+ const id = useId();
+ const publishedOrigin = useStore($publishedOrigin);
+ const path = useStore($selectedPagePath);
+ const pathParams = useStore($selectedPagePathParams);
+ const tokens = tokenizePathnamePattern(path);
+ const compiledPath = compilePathnamePattern(tokens, pathParams ?? {});
+ const { tooltipProps, buttonProps } = useCopyUrl(
+ `${publishedOrigin}${compiledPath}`
+ );
+
+ const errors = new Map<string, string>();
+ for (const token of tokens) {
+ if (token.type === "param") {
+ const value = (pathParams?.[token.name] ?? "").trim();
+ if (value === "" && token.optional === false) {
+ errors.set(token.name, `"${token.name}" is required`);
+ }
+ if (value.includes("/") && token.splat === false) {
+ errors.set(
+ token.name,
+ `"${token.name}" should be splat parameter to contain slashes`
+ );
+ }
+ }
+ }
+
+ return (
+ <InputErrorsTooltip errors={Array.from(errors.values())}>
+ <Flex gap={1} css={{ padding: theme.spacing[5] }}>
+ <Flex align="center" gap={1} css={textVariants.mono}>
+ {tokens.map((token, index) => {
+ if (token.type === "fragment") {
+ return token.value;
+ }
+ if (token.type === "param") {
+ return (
+ <InputField
+ key={index}
+ fieldSizing="content"
+ css={{ minWidth: theme.spacing[15] }}
+ color={errors.has(token.name) ? "error" : undefined}
+ id={`${id}-${token.name}`}
+ placeholder={token.name}
+ value={pathParams?.[token.name] ?? ""}
+ onChange={(event) =>
+ updatePathParam(token.name, event.target.value)
+ }
+ />
+ );
+ }
+ token satisfies never;
+ })}
+ </Flex>
+
+ <Tooltip {...tooltipProps}>
+ <IconButton {...buttonProps} disabled={errors.size > 0} />
+ </Tooltip>
+ </Flex>
+ </InputErrorsTooltip>
+ );
+};
+
+export const AddressBarPopover = () => {
+ const [isOpen, setIsOpen] = useState(false);
+ const path = useStore($selectedPagePath);
+ const tokens = tokenizePathnamePattern(path);
+ const publishedOrigin = useStore($publishedOrigin);
+ const { tooltipProps, buttonProps } = useCopyUrl(`${publishedOrigin}${path}`);
+ if (tokens.length === 1) {
+ return (
+ <Tooltip {...tooltipProps}>
+ <ToolbarButton
+ {...buttonProps}
+ aria-label="Copy page URL"
+ tabIndex={0}
+ />
+ </Tooltip>
+ );
+ }
+ return (
+ <Popover open={isOpen} onOpenChange={setIsOpen}>
+ <PopoverTrigger asChild>
+ <ToolbarButton aria-label="Toggle dynamic page address" tabIndex={0}>
+ <DynamicPageIcon />
+ </ToolbarButton>
+ </PopoverTrigger>
+ <PopoverPortal>
+ <PopoverContent
+ css={{ zIndex: theme.zIndices[1], padding: 0 }}
+ sideOffset={0}
+ collisionPadding={4}
+ align="start"
+ >
+ <AddressBar />
+ </PopoverContent>
+ </PopoverPortal>
+ </Popover>
+ );
+};
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/address-bar.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/address-bar.tsx
deleted file mode 100644
index 242fd3f9b3..0000000000
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/address-bar.tsx
+++ /dev/null
@@ -1,251 +0,0 @@
-import { computed } from "nanostores";
-import { useStore } from "@nanostores/react";
-import { useEffect, useId, useState } from "react";
-import {
- Button,
- Flex,
- Grid,
- InputField,
- Label,
- Tooltip,
- theme,
- textVariants,
- InputErrorsTooltip,
-} from "@webstudio-is/design-system";
-import { CheckMarkIcon, CopyIcon, LinkIcon } from "@webstudio-is/icons";
-import type { DataSource } from "@webstudio-is/sdk";
-import { $dataSourceVariables, $domains, $project } from "~/shared/nano-states";
-import env from "~/shared/env";
-import {
- compilePathnamePattern,
- parsePathnamePattern,
- tokenizePathnamePattern,
-} from "./url-pattern";
-import { $userPlanFeatures } from "~/builder/shared/nano-states";
-
-const $publishedOrigin = computed([$project, $domains], (project, domains) => {
- const customDomain: string | undefined = domains[0];
- const projectDomain = `${project?.domain}.${
- env.PUBLISHER_HOST ?? "wstd.work"
- }`;
- const domain = customDomain ?? projectDomain;
- const publishedUrl = new URL(`https://${domain}`);
- return publishedUrl.origin;
-});
-
-type PathParams = Record<string, string>;
-
-export type AddressBarApi = {
- path: string;
- pathParams: PathParams;
- pageUrl: string;
- updatePathParam: (name: string, value: string) => void;
- savePathParams: () => void;
-};
-
-const setPathParams = (
- dataSourceId: DataSource["id"],
- newParams: PathParams
-) => {
- const dataSourceVariables = new Map($dataSourceVariables.get());
- dataSourceVariables.set(dataSourceId, newParams);
- $dataSourceVariables.set(dataSourceVariables);
-};
-
-export const useAddressBar = ({
- path,
- dataSourceId,
-}: {
- path: string;
- dataSourceId?: string;
-}): AddressBarApi => {
- const pathParamNames = parsePathnamePattern(path);
- const [localParams, setLocalParams] = useState<PathParams>({});
- const dataSourceVariables = useStore($dataSourceVariables);
- const storedParams =
- dataSourceId === undefined
- ? undefined
- : (dataSourceVariables.get(dataSourceId) as Record<string, string>);
- const pathParams = storedParams ?? localParams;
-
- const publishedOrigin = useStore($publishedOrigin);
- const tokens = tokenizePathnamePattern(path);
- const compiledPath = compilePathnamePattern(tokens, pathParams);
- const pageUrl = `${publishedOrigin}${compiledPath}`;
-
- const updatePathParam: AddressBarApi["updatePathParam"] = (name, value) => {
- // delete stale fields
- const newParams: Record<string, string> = {};
- for (const name of pathParamNames) {
- newParams[name] = pathParams[name] ?? "";
- }
- newParams[name] = value;
- setLocalParams(newParams);
- if (dataSourceId) {
- setPathParams(dataSourceId, newParams);
- }
- };
-
- const savePathParams: AddressBarApi["savePathParams"] = () => {
- const newParams: Record<string, string> = {};
- for (const name of pathParamNames) {
- newParams[name] = pathParams[name] ?? "";
- }
- if (dataSourceId) {
- setPathParams(dataSourceId, newParams);
- }
- };
-
- return {
- path,
- pathParams,
- pageUrl,
- updatePathParam,
- savePathParams,
- };
-};
-
-const CopyPageUrl = ({
- pageUrl,
- disabled,
-}: {
- pageUrl: string;
- disabled: boolean;
-}) => {
- const [copyState, setCopyState] = useState<"copy" | "copied">("copy");
-
- // reset copied state after 2 seconds
- useEffect(() => {
- if (copyState === "copied") {
- const timeoutId = setTimeout(() => {
- setCopyState("copy");
- }, 2000);
- return () => {
- clearTimeout(timeoutId);
- };
- }
- }, [copyState]);
-
- let copyIcon = (
- <>
- <LinkIcon
- style={{ display: "var(--ws-address-bar-link-icon-display, block)" }}
- />
- <CopyIcon
- style={{ display: "var(--ws-address-bar-copy-icon-display, none)" }}
- />
- </>
- );
- if (copyState === "copied") {
- copyIcon = <CheckMarkIcon />;
- }
-
- const parsed = new URL(pageUrl);
- const pageDomainAndPath = `${parsed.host}${parsed.pathname}`;
-
- return (
- <Tooltip
- // keep tooltip open when user just copied
- open={copyState === "copied" ? true : undefined}
- content={copyState === "copied" ? "Copied" : "Click to copy"}
- >
- <Button
- color="ghost"
- type="button"
- disabled={disabled}
- onClick={() => {
- navigator.clipboard.writeText(pageUrl);
- setCopyState("copied");
- }}
- prefix={copyIcon}
- css={{
- justifySelf: "start",
- "&:hover": {
- "--ws-address-bar-link-icon-display": "none",
- "--ws-address-bar-copy-icon-display": "block",
- },
- }}
- >
- {pageDomainAndPath}
- </Button>
- </Tooltip>
- );
-};
-
-export const AddressBar = ({ addressBar }: { addressBar: AddressBarApi }) => {
- const { path, pathParams, pageUrl, updatePathParam } = addressBar;
- const id = useId();
- const { allowDynamicData } = useStore($userPlanFeatures);
-
- const tokens = tokenizePathnamePattern(path);
- const hasParams = tokens.length > 1;
-
- const errors = new Map<string, string>();
- for (const token of tokens) {
- if (token.type === "param") {
- const value = (pathParams[token.name] ?? "").trim();
- if (value === "" && token.optional === false) {
- errors.set(token.name, `"${token.name}" is required`);
- }
- if (value.includes("/") && token.splat === false) {
- errors.set(
- token.name,
- `"${token.name}" should be splat parameter to contain slashes`
- );
- }
- }
- }
-
- return (
- <Grid gap={1}>
- {allowDynamicData && hasParams && (
- <>
- <Label htmlFor={id}>Address Bar</Label>
- <InputErrorsTooltip errors={Array.from(errors.values())}>
- <Flex
- align="center"
- css={{
- padding: theme.spacing[5],
- // background: theme.colors.white,
- borderRadius: theme.borderRadius[4],
- border: `1px solid ${theme.colors.borderMain}`,
- ...textVariants.mono,
- }}
- >
- {tokens.map((token, index) => {
- if (token.type === "fragment") {
- return token.value;
- }
- if (token.type === "param") {
- return (
- <InputField
- key={index}
- fieldSizing="content"
- css={{
- margin: `0 ${theme.spacing[3]}`,
- minWidth: theme.spacing[15],
- }}
- color={errors.has(token.name) ? "error" : undefined}
- id={`${id}-${token.name}`}
- placeholder={token.name}
- value={pathParams[token.name] ?? ""}
- onChange={(event) =>
- updatePathParam(token.name, event.target.value)
- }
- />
- );
- }
- token satisfies never;
- })}
- </Flex>
- </InputErrorsTooltip>
- </>
- )}
-
- <CopyPageUrl
- pageUrl={pageUrl}
- disabled={errors.size > 0 || (allowDynamicData === false && hasParams)}
- />
- </Grid>
- );
-};
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/custom-metadata.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/custom-metadata.tsx
index bda9772894..615b30e9d2 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/custom-metadata.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/custom-metadata.tsx
@@ -193,7 +193,7 @@ export const CustomMetadata = (props: CustomMetadataProps) => {
onClick={() => {
const newCustomMetas = [
...props.customMetas,
- { property: "", content: "" },
+ { property: "", content: `""` },
];
props.onChange(newCustomMetas);
}}
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx
index 40f0ad113a..2ad9bbe52f 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/page-settings.tsx
@@ -19,6 +19,7 @@ import {
ROOT_FOLDER_ID,
findParentFolderByChildId,
ProjectNewRedirectPath,
+ DataSource,
} from "@webstudio-is/sdk";
import {
theme,
@@ -59,6 +60,7 @@ import {
$selectedInstanceSelector,
$dataSources,
computeExpression,
+ $dataSourceVariables,
} from "~/shared/nano-states";
import {
BindingControl,
@@ -74,7 +76,12 @@ import { SocialPreview } from "./social-preview";
// @todo should be moved to shared because features should not depend on features
import { useEffectEvent } from "~/builder/features/ai/hooks/effect-event";
import { CustomMetadata } from "./custom-metadata";
-import { parsePathnamePattern, validatePathnamePattern } from "./url-pattern";
+import {
+ compilePathnamePattern,
+ parsePathnamePattern,
+ tokenizePathnamePattern,
+ validatePathnamePattern,
+} from "~/builder/shared/url-pattern";
import {
registerFolderChildMutable,
deletePageMutable,
@@ -82,7 +89,7 @@ import {
duplicatePage,
} from "./page-utils";
import { Form } from "./form";
-import { AddressBar, useAddressBar, type AddressBarApi } from "./address-bar";
+import { $publishedOrigin } from "~/builder/features/address-bar";
import { $userPlanFeatures } from "~/builder/shared/nano-states";
import type { UserPlanFeatures } from "~/shared/db/user-plan-features.server";
@@ -486,14 +493,42 @@ const RedirectField = ({
);
};
+const usePageUrl = (
+ values: Values,
+ pathParamsDataSourceId?: DataSource["id"]
+) => {
+ const pages = useStore($pages);
+ const foldersPath =
+ pages === undefined ? "" : getPagePath(values.parentFolderId, pages);
+ const path = [foldersPath, values.path]
+ .filter(Boolean)
+ .join("/")
+ .replace(/\/+/g, "/");
+
+ const dataSourceVariables = useStore($dataSourceVariables);
+ const storedParams =
+ pathParamsDataSourceId === undefined
+ ? undefined
+ : (dataSourceVariables.get(pathParamsDataSourceId) as Record<
+ string,
+ string
+ >);
+ const pathParams = storedParams ?? {};
+
+ const publishedOrigin = useStore($publishedOrigin);
+ const tokens = tokenizePathnamePattern(path);
+ const compiledPath = compilePathnamePattern(tokens, pathParams);
+ return `${publishedOrigin}${compiledPath}`;
+};
+
const FormFields = ({
- addressBar,
+ pathParamsDataSourceId,
autoSelect,
errors,
values,
onChange,
}: {
- addressBar: AddressBarApi;
+ pathParamsDataSourceId?: DataSource["id"];
autoSelect?: boolean;
errors: Errors;
values: Values;
@@ -511,6 +546,8 @@ const FormFields = ({
const pages = useStore($pages);
const { variableValues, scope, aliases } = useStore($pageRootScope);
+ const pageUrl = usePageUrl(values, pathParamsDataSourceId);
+
if (pages === undefined) {
return;
}
@@ -613,7 +650,6 @@ const FormFields = ({
onChange={(value) => onChange({ field: "path", value })}
/>
)}
- <AddressBar addressBar={addressBar} />
{isFeatureEnabled("cms") && (
<StatusField
@@ -681,7 +717,7 @@ const FormFields = ({
<SearchPreview
siteName={pages?.meta?.siteName ?? ""}
faviconUrl={faviconUrl}
- pageUrl={addressBar.pageUrl}
+ pageUrl={pageUrl}
titleLink={title}
snippet={description}
/>
@@ -932,7 +968,7 @@ const FormFields = ({
? socialImageAsset.name
: socialImageUrl
}
- ogUrl={addressBar.pageUrl}
+ ogUrl={pageUrl}
ogTitle={title}
ogDescription={description}
/>
@@ -1008,20 +1044,12 @@ export const NewPageSettings = ({
variableValues,
userPlanFeatures
);
- const foldersPath =
- pages === undefined ? "" : getPagePath(values.parentFolderId, pages);
- const addressBar = useAddressBar({
- path: [foldersPath, values.path]
- .filter(Boolean)
- .join("/")
- .replace(/\/+/g, "/"),
- });
const handleSubmit = () => {
if (Object.keys(errors).length === 0) {
const pageId = nanoid();
createPage(pageId, values);
- updatePage(pageId, values, addressBar);
+ updatePage(pageId, values);
onSuccess(pageId);
}
};
@@ -1034,7 +1062,6 @@ export const NewPageSettings = ({
>
<FormFields
autoSelect
- addressBar={addressBar}
errors={errors}
values={values}
onChange={(val) => {
@@ -1131,11 +1158,7 @@ const createPage = (pageId: Page["id"], values: Values) => {
);
};
-const updatePage = (
- pageId: Page["id"],
- values: Partial<Values>,
- addressBar: AddressBarApi
-) => {
+const updatePage = (pageId: Page["id"], values: Partial<Values>) => {
const updatePageMutable = (
page: Page,
values: Partial<Values>,
@@ -1241,7 +1264,6 @@ const updatePage = (
}
}
);
- addressBar.savePathParams();
};
export const PageSettings = ({
@@ -1277,15 +1299,6 @@ export const PageSettings = ({
variableValues,
userPlanFeatures
);
- const foldersPath =
- pages === undefined ? "" : getPagePath(values.parentFolderId, pages);
- const addressBar = useAddressBar({
- path: [foldersPath, values.path]
- .filter(Boolean)
- .join("/")
- .replace(/\/+/g, "/"),
- dataSourceId: page?.pathParamsDataSourceId,
- });
const debouncedFn = useEffectEvent(() => {
if (
@@ -1295,7 +1308,7 @@ export const PageSettings = ({
return;
}
- updatePage(pageId, unsavedValues, addressBar);
+ updatePage(pageId, unsavedValues);
setUnsavedValues({});
});
@@ -1320,7 +1333,7 @@ export const PageSettings = ({
) {
return;
}
- updatePage(pageId, unsavedValues, addressBar);
+ updatePage(pageId, unsavedValues);
});
const hanldeDelete = () => {
@@ -1346,7 +1359,7 @@ export const PageSettings = ({
}}
>
<FormFields
- addressBar={addressBar}
+ pathParamsDataSourceId={page.pathParamsDataSourceId}
errors={errors}
values={values}
onChange={handleChange}
diff --git a/apps/builder/app/builder/features/topbar/topbar.tsx b/apps/builder/app/builder/features/topbar/topbar.tsx
index dfa7d67f79..b10913996c 100644
--- a/apps/builder/app/builder/features/topbar/topbar.tsx
+++ b/apps/builder/app/builder/features/topbar/topbar.tsx
@@ -9,7 +9,7 @@ import {
Text,
} from "@webstudio-is/design-system";
import type { Project } from "@webstudio-is/project";
-import { $selectedPage } from "~/shared/nano-states";
+import { $pages, $selectedPage } from "~/shared/nano-states";
import { PreviewButton } from "./preview";
import { ShareButton } from "./share";
import { PublishButton } from "./publish";
@@ -21,6 +21,7 @@ import {
} from "../breakpoints";
import { ViewMode } from "./view-mode";
import { $activeSidebarPanel } from "~/builder/shared/nano-states";
+import { AddressBarPopover } from "../address-bar";
const PagesButton = () => {
const page = useStore($selectedPage);
@@ -63,20 +64,30 @@ type TopbarProps = {
};
export const Topbar = ({ gridArea, project, hasProPlan }: TopbarProps) => {
+ const pages = useStore($pages);
return (
<nav className={topbarContainerStyle({ css: { gridArea } })}>
<Flex grow={false} shrink={false}>
<Menu />
</Flex>
- <Flex align="center">
- <PagesButton />
- </Flex>
- <Flex css={{ minWidth: theme.spacing[23] }}>
- <BreakpointsPopover />
- </Flex>
- <Flex grow align="center" justify="center">
- <BreakpointsSelectorContainer />
- </Flex>
+
+ {/* prevent rendering when data is not loaded */}
+ {pages && (
+ <>
+ <Flex align="center">
+ <PagesButton />
+ <AddressBarPopover />
+ </Flex>
+ <Flex css={{ minWidth: theme.spacing[23] }}>
+ <BreakpointsPopover />
+ </Flex>
+ <Flex grow></Flex>
+ <Flex align="center" justify="center">
+ <BreakpointsSelectorContainer />
+ </Flex>
+ </>
+ )}
+ <Flex grow></Flex>
<Toolbar>
<ToolbarToggleGroup
type="single"
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/url-pattern.test.ts b/apps/builder/app/builder/shared/url-pattern.test.ts
similarity index 94%
rename from apps/builder/app/builder/features/sidebar-left/panels/pages/url-pattern.test.ts
rename to apps/builder/app/builder/shared/url-pattern.test.ts
index be378378ad..f1a11025d3 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/url-pattern.test.ts
+++ b/apps/builder/app/builder/shared/url-pattern.test.ts
@@ -56,6 +56,21 @@ test("tokenize pathname without params", () => {
]);
});
+test("tokenize empty pathname", () => {
+ expect(tokenizePathnamePattern("")).toEqual([
+ { type: "fragment", value: "" },
+ ]);
+});
+
+test("compile pathname pattern with named values", () => {
+ expect(
+ compilePathnamePattern(tokenizePathnamePattern("/blog/:id/:date"), {
+ id: "my-id",
+ date: "my-date",
+ })
+ ).toEqual("/blog/my-id/my-date");
+});
+
test("compile pathname pattern with named values", () => {
expect(
compilePathnamePattern(tokenizePathnamePattern("/blog/:id/:date"), {
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/url-pattern.ts b/apps/builder/app/builder/shared/url-pattern.ts
similarity index 98%
rename from apps/builder/app/builder/features/sidebar-left/panels/pages/url-pattern.ts
rename to apps/builder/app/builder/shared/url-pattern.ts
index 3750a26e67..4ea07c6562 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/url-pattern.ts
+++ b/apps/builder/app/builder/shared/url-pattern.ts
@@ -59,7 +59,7 @@ export const tokenizePathnamePattern = (pathname: string) => {
});
}
}
- if (lastCursor < pathname.length) {
+ if (lastCursor < pathname.length || tokens.length === 0) {
tokens.push({
type: "fragment",
value: pathname.slice(lastCursor),
diff --git a/packages/icons/icons/dynamic-page.svg b/packages/icons/icons/dynamic-page.svg
new file mode 100644
index 0000000000..423160f812
--- /dev/null
+++ b/packages/icons/icons/dynamic-page.svg
@@ -0,0 +1,4 @@
+<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8.54999 2.30826C8.44266 2.30149 8.28373 2.30005 8.00705 2.30005H6.07999C5.56522 2.30005 5.21823 2.30055 4.95068 2.32241C4.69073 2.34365 4.56352 2.38176 4.4779 2.42539C4.26151 2.53564 4.08559 2.71157 3.97533 2.92796C3.93171 3.01357 3.89359 3.14078 3.87235 3.40074C3.85049 3.66828 3.84999 4.01527 3.84999 4.53005V5.77005C3.84999 6.28482 3.85049 8.63181 3.87235 8.89935C3.89359 9.15931 3.93171 9.28652 3.97533 9.37213C4.08559 9.58852 4.26151 9.76445 4.4779 9.8747C4.56352 9.91833 4.69073 9.95644 4.95068 9.97768C5.21823 9.99954 5.56522 10 6.07999 10H9.91999C10.4348 10 10.7817 9.99954 11.0493 9.97768C11.3093 9.95644 11.4365 9.91833 11.5221 9.8747C11.7385 9.76445 11.9144 9.58852 12.0246 9.37213C12.0683 9.28652 12.1064 9.15931 12.1276 8.89935C12.1495 8.63181 12.15 6.28482 12.15 5.77005V8.44298C12.15 8.1663 12.1485 6.00738 12.1418 5.90005L10.1399 5.90005C9.98934 5.90007 9.83998 5.90009 9.71298 5.88971C9.57273 5.87825 9.40358 5.85097 9.2325 5.7638C8.9973 5.64396 8.80607 5.45274 8.68623 5.21753C8.59906 5.04646 8.57178 4.8773 8.56032 4.73706C8.54995 4.61006 8.54997 4.4607 8.54999 4.31018L8.54999 2.30826ZM9.4535 1.21301C9.31609 1.15165 9.17311 1.10298 9.02635 1.06774C8.74276 0.999656 8.44909 0.999816 8.07097 1.00002C8.04993 1.00003 8.02863 1.00005 8.00705 1.00005L6.05346 1.00004C5.57198 1.00004 5.1716 1.00003 4.84482 1.02673C4.50447 1.05454 4.18714 1.11451 3.88771 1.26708C3.42671 1.50197 3.05191 1.87677 2.81702 2.33777C2.66446 2.63719 2.60448 2.95453 2.57667 3.29488C2.54997 3.62166 2.54998 4.02204 2.54999 4.50351V5.79658C2.54998 6.27805 2.54997 8.67843 2.57667 9.00521C2.60448 9.34556 2.66446 9.6629 2.81702 9.96232C3.05191 10.4233 3.42671 10.7981 3.88771 11.033C4.18714 11.1856 4.50447 11.2456 4.84482 11.2734C5.1716 11.3001 5.57198 11.3001 6.05346 11.3H7.99999H9.94652C10.428 11.3001 10.8284 11.3001 11.1552 11.2734C11.4955 11.2456 11.8128 11.1856 12.1123 11.033C12.5733 10.7981 12.9481 10.4233 13.183 9.96232C13.3355 9.6629 13.3955 9.34556 13.4233 9.00521C13.45 8.67843 13.45 6.27805 13.45 5.79657V8.44298C13.45 8.4214 13.45 8.4001 13.45 8.37906C13.4502 8.00094 13.4504 5.70727 13.3823 5.42369C13.3471 5.27691 13.2984 5.13392 13.237 4.9965C13.2327 4.98624 13.228 4.97611 13.2232 4.96612C13.1834 4.88018 13.1386 4.79649 13.089 4.71551C12.9366 4.46684 12.7288 4.25929 12.4613 3.99206C12.4464 3.9772 12.4313 3.96215 12.4161 3.94689L10.5031 2.03396C10.4879 2.0187 10.4728 2.00363 10.458 1.98875C10.1907 1.72123 9.98319 1.51346 9.73453 1.36108C9.65355 1.31146 9.56988 1.26666 9.48395 1.22686C9.47394 1.22199 9.46379 1.21737 9.4535 1.21301ZM9.84999 3.21928V4.29005C9.84999 4.44006 9.85034 4.53107 9.85372 4.59631C9.91896 4.59969 10.01 4.60005 10.16 4.60005H11.2308L9.84999 3.21928Z" />
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8 11C8.64999 11 8.65001 11.141 8.65001 11.5V11.9032C9.06921 12.0761 9.4044 12.4113 9.57733 12.8305H12.75C13.109 12.8305 13.4 13.1215 13.4 13.4805C13.4 13.8395 13.109 14.1305 12.75 14.1305H9.57733C9.32175 14.75 8.7118 15.1861 8.00001 15.1861C7.28822 15.1861 6.67827 14.75 6.42269 14.1305H3.25001C2.89103 14.1305 2.60001 13.8395 2.60001 13.4805C2.60001 13.1215 2.89103 12.8305 3.25001 12.8305H6.42269C6.59562 12.4113 6.93081 12.0761 7.35001 11.9032C7.35001 11.9032 7.35001 11.859 7.35001 11.5C7.35001 11.141 7.35001 11 8 11ZM8.00001 13.075C7.77603 13.075 7.59446 13.2565 7.59446 13.4805C7.59446 13.7045 7.77603 13.8861 8.00001 13.8861C8.22399 13.8861 8.40557 13.7045 8.40557 13.4805C8.40557 13.2565 8.22399 13.075 8.00001 13.075Z" />
+</svg>
diff --git a/packages/icons/src/__generated__/dynamic-page.tsx b/packages/icons/src/__generated__/dynamic-page.tsx
new file mode 100644
index 0000000000..70dd4bafb8
--- /dev/null
+++ b/packages/icons/src/__generated__/dynamic-page.tsx
@@ -0,0 +1,15 @@
+// Generated from icons/dynamic-page.svg
+
+import { forwardRef } from "react";
+import type { IconProps } from "../types";
+
+// prettier-ignore
+export const DynamicPageIcon = forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", size = 16, ...props }, forwardedRef) => {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width={size} height={size} fill={color} {...props} ref={forwardedRef}><path fillRule="evenodd" d="M8.55 2.308a9.96 9.96 0 0 0-.543-.008H6.08c-.515 0-.862 0-1.13.022-.26.022-.386.06-.472.103a1.15 1.15 0 0 0-.503.503c-.043.086-.081.213-.103.473-.022.267-.022.614-.022 1.13v1.24c0 .514 0 2.86.022 3.128.022.26.06.388.103.473.11.217.287.392.503.503.086.043.213.081.473.103.267.022.614.022 1.129.022h3.84c.515 0 .862 0 1.13-.022.26-.022.386-.06.472-.103a1.15 1.15 0 0 0 .503-.503c.043-.085.081-.213.103-.473.021-.267.022-2.614.022-3.129v2.673c0-.277-.002-2.436-.008-2.543H10.14c-.15 0-.3 0-.427-.01a1.263 1.263 0 0 1-.48-.126 1.25 1.25 0 0 1-.547-.546 1.263 1.263 0 0 1-.126-.48c-.01-.128-.01-.277-.01-.428V2.308Zm.903-1.095a2.451 2.451 0 0 0-.427-.145C8.743 1 8.45 1 8.071 1H6.053c-.481 0-.881 0-1.208.027-.34.028-.658.088-.957.24a2.45 2.45 0 0 0-1.071 1.07c-.153.3-.213.618-.24.958-.027.327-.027.727-.027 1.209v1.293c0 .481 0 2.881.027 3.208.027.34.087.658.24.957.235.461.61.836 1.07 1.071.3.153.617.213.958.24.327.027.727.027 1.208.027h3.894c.481 0 .881 0 1.208-.027.34-.027.658-.087.957-.24a2.45 2.45 0 0 0 1.071-1.07c.152-.3.213-.617.24-.958.027-.327.027-2.727.027-3.208v2.646-.064c0-.378 0-2.672-.068-2.955a2.445 2.445 0 0 0-.293-.708c-.152-.25-.36-.457-.628-.724l-.045-.045-1.913-1.913-.045-.045c-.267-.268-.475-.476-.723-.628a2.452 2.452 0 0 0-.281-.148Zm.397 2.006V4.29c0 .15 0 .241.004.306.065.004.156.004.306.004h1.07L9.85 3.22Z" clipRule="evenodd" /><path fillRule="evenodd" d="M8 11c.65 0 .65.141.65.5v.403c.42.173.754.508.927.928h3.173a.65.65 0 1 1 0 1.3H9.577a1.706 1.706 0 0 1-3.154 0H3.25a.65.65 0 1 1 0-1.3h3.173c.173-.42.508-.755.927-.928V11.5c0-.359 0-.5.65-.5Zm0 2.075a.405.405 0 1 0 0 .811.405.405 0 0 0 0-.811Z" clipRule="evenodd" /></svg>
+ );
+ }
+);
+
+DynamicPageIcon.displayName = "DynamicPageIcon";
diff --git a/packages/icons/src/__generated__/index.ts b/packages/icons/src/__generated__/index.ts
index 8bcaa71bae..be7967912c 100644
--- a/packages/icons/src/__generated__/index.ts
+++ b/packages/icons/src/__generated__/index.ts
@@ -82,6 +82,7 @@ export * from "./div";
export * from "./dot";
export * from "./dotted-border";
export * from "./drag-handle";
+export * from "./dynamic-page";
export * from "./email";
export * from "./embed";
export * from "./external-link";
diff --git a/packages/icons/src/__generated__/svg/dynamic-page.ts b/packages/icons/src/__generated__/svg/dynamic-page.ts
new file mode 100644
index 0000000000..fdea3fe5c8
--- /dev/null
+++ b/packages/icons/src/__generated__/svg/dynamic-page.ts
@@ -0,0 +1 @@
+export const DynamicPageIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" width="100%" height="100%" style="display: block;"><path fill-rule="evenodd" d="M8.55 2.308a9.96 9.96 0 0 0-.543-.008H6.08c-.515 0-.862 0-1.13.022-.26.022-.386.06-.472.103a1.15 1.15 0 0 0-.503.503c-.043.086-.081.213-.103.473-.022.267-.022.614-.022 1.13v1.24c0 .514 0 2.86.022 3.128.022.26.06.388.103.473.11.217.287.392.503.503.086.043.213.081.473.103.267.022.614.022 1.129.022h3.84c.515 0 .862 0 1.13-.022.26-.022.386-.06.472-.103a1.15 1.15 0 0 0 .503-.503c.043-.085.081-.213.103-.473.021-.267.022-2.614.022-3.129v2.673c0-.277-.002-2.436-.008-2.543H10.14c-.15 0-.3 0-.427-.01a1.263 1.263 0 0 1-.48-.126 1.25 1.25 0 0 1-.547-.546 1.263 1.263 0 0 1-.126-.48c-.01-.128-.01-.277-.01-.428V2.308Zm.903-1.095a2.451 2.451 0 0 0-.427-.145C8.743 1 8.45 1 8.071 1H6.053c-.481 0-.881 0-1.208.027-.34.028-.658.088-.957.24a2.45 2.45 0 0 0-1.071 1.07c-.153.3-.213.618-.24.958-.027.327-.027.727-.027 1.209v1.293c0 .481 0 2.881.027 3.208.027.34.087.658.24.957.235.461.61.836 1.07 1.071.3.153.617.213.958.24.327.027.727.027 1.208.027h3.894c.481 0 .881 0 1.208-.027.34-.027.658-.087.957-.24a2.45 2.45 0 0 0 1.071-1.07c.152-.3.213-.617.24-.958.027-.327.027-2.727.027-3.208v2.646-.064c0-.378 0-2.672-.068-2.955a2.445 2.445 0 0 0-.293-.708c-.152-.25-.36-.457-.628-.724l-.045-.045-1.913-1.913-.045-.045c-.267-.268-.475-.476-.723-.628a2.452 2.452 0 0 0-.281-.148Zm.397 2.006V4.29c0 .15 0 .241.004.306.065.004.156.004.306.004h1.07L9.85 3.22Z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M8 11c.65 0 .65.141.65.5v.403c.42.173.754.508.927.928h3.173a.65.65 0 1 1 0 1.3H9.577a1.706 1.706 0 0 1-3.154 0H3.25a.65.65 0 1 1 0-1.3h3.173c.173-.42.508-.755.927-.928V11.5c0-.359 0-.5.65-.5Zm0 2.075a.405.405 0 1 0 0 .811.405.405 0 0 0 0-.811Z" clip-rule="evenodd"/></svg>`;
diff --git a/packages/icons/src/__generated__/svg/index.ts b/packages/icons/src/__generated__/svg/index.ts
index c894ba2fc1..1a8359c51e 100644
--- a/packages/icons/src/__generated__/svg/index.ts
+++ b/packages/icons/src/__generated__/svg/index.ts
@@ -82,6 +82,7 @@ export { DivIcon } from "./div";
export { DotIcon } from "./dot";
export { DottedBorderIcon } from "./dotted-border";
export { DragHandleIcon } from "./drag-handle";
+export { DynamicPageIcon } from "./dynamic-page";
export { EmailIcon } from "./email";
export { EmbedIcon } from "./embed";
export { ExternalLinkIcon } from "./external-link";