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.

feat: Add SiteSettings Dialog (#2527)

Ivan Starkov6f3adf1cc40d
diff --git a/apps/builder/app/builder/builder.tsx b/apps/builder/app/builder/builder.tsx
index 7e3553249f..d0a30ddf1b 100644
--- a/apps/builder/app/builder/builder.tsx
+++ b/apps/builder/app/builder/builder.tsx
@@ -45,6 +45,7 @@ import { useSyncPageUrl } from "~/shared/pages";
import { useMount } from "~/shared/hook-utils/use-mount";
import { subscribeCommands } from "~/builder/shared/commands";
import { AiCommandBar } from "./features/ai/ai-command-bar";
+import { SiteSettings } from "./features/seo/site-settings";
registerContainers();
@@ -298,6 +299,7 @@ export const Builder = ({
return (
<TooltipProvider>
<ChromeWrapper isPreviewMode={isPreviewMode}>
+ <SiteSettings />
<Topbar gridArea="header" project={project} />
<Main>
<Workspace
diff --git a/apps/builder/app/builder/features/seo/image-control.tsx b/apps/builder/app/builder/features/seo/image-control.tsx
new file mode 100644
index 0000000000..caf0693d38
--- /dev/null
+++ b/apps/builder/app/builder/features/seo/image-control.tsx
@@ -0,0 +1,25 @@
+import { FloatingPanel } from "~/builder/shared/floating-panel";
+import { ImageManager } from "~/builder/shared/image-manager";
+import type { ReactElement } from "react";
+
+export const ImageControl = (props: {
+ assetId: string;
+ onAssetIdChange: (assetId: string) => void;
+ children: ReactElement;
+}) => {
+ return (
+ <FloatingPanel
+ title="Images"
+ zIndex={1}
+ content={
+ <ImageManager
+ onChange={(asset) => {
+ props.onAssetIdChange(asset.id);
+ }}
+ />
+ }
+ >
+ {props.children}
+ </FloatingPanel>
+ );
+};
diff --git a/apps/builder/app/builder/features/seo/site-settings.stories.tsx b/apps/builder/app/builder/features/seo/site-settings.stories.tsx
new file mode 100644
index 0000000000..ed1f04f0f4
--- /dev/null
+++ b/apps/builder/app/builder/features/seo/site-settings.stories.tsx
@@ -0,0 +1,12 @@
+import { $isSiteSettigsOpen } from "~/shared/nano-states/seo";
+import { SiteSettings } from "./site-settings";
+
+export default {
+ component: SiteSettings,
+};
+
+$isSiteSettigsOpen.set(true);
+
+export const SiteSettingsExample = () => {
+ return <SiteSettings />;
+};
diff --git a/apps/builder/app/builder/features/seo/site-settings.tsx b/apps/builder/app/builder/features/seo/site-settings.tsx
new file mode 100644
index 0000000000..8cfab74fd9
--- /dev/null
+++ b/apps/builder/app/builder/features/seo/site-settings.tsx
@@ -0,0 +1,210 @@
+import { useStore } from "@nanostores/react";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ Grid,
+ InputField,
+ Label,
+ theme,
+ Text,
+ TextArea,
+ Separator,
+ Button,
+ css,
+} from "@webstudio-is/design-system";
+import { useEffect, useState } from "react";
+import { $isSiteSettigsOpen } from "~/shared/nano-states/seo";
+import { ImageControl } from "./image-control";
+import { assetsStore, pagesStore } from "~/shared/nano-states";
+import env from "~/shared/env";
+import { Image, createImageLoader } from "@webstudio-is/image";
+import { useIds } from "~/shared/form-utils";
+import { serverSyncStore } from "~/shared/sync";
+import { useEffectEvent } from "../ai/hooks/effect-event";
+import type { Pages } from "@webstudio-is/sdk";
+
+type Value = Pages["meta"];
+
+type Props = {
+ value: Value;
+ onChange: (value: Value) => void;
+};
+
+const imgStyle = css({
+ width: 72,
+ height: 72,
+ borderRadius: theme.borderRadius[4],
+ borderWidth: 1,
+ borderStyle: "solid",
+ borderColor: theme.colors.borderMain,
+});
+
+const SiteSettingsContent = (props: Props) => {
+ const ids = useIds(["siteName", "favicon", "code"]);
+ const handleChange =
+ <T extends keyof Value>(name: T) =>
+ (val: Value[T]) => {
+ props.onChange({
+ ...props.value,
+ [name]: val,
+ });
+ };
+
+ const assets = useStore(assetsStore);
+ const asset = assets.get(props.value.faviconAssetId ?? "");
+
+ const favIconUrl = asset ? `${asset.name}` : undefined;
+
+ const imageLoader = createImageLoader({
+ imageBaseUrl: env.ASSET_BASE_URL,
+ });
+
+ return (
+ <Grid
+ gap={2}
+ css={{
+ my: theme.spacing[5],
+ }}
+ >
+ <Grid
+ gap={1}
+ css={{
+ width: theme.spacing[34],
+ mx: theme.spacing[5],
+ px: theme.spacing[5],
+ }}
+ >
+ <Label htmlFor={ids.siteName}>Site Name</Label>
+ <InputField
+ id={ids.siteName}
+ value={props.value.siteName ?? ""}
+ onChange={(event) => handleChange("siteName")(event.target.value)}
+ placeholder="Current Site Name"
+ name="Name"
+ autoFocus
+ />
+ </Grid>
+
+ <Separator />
+
+ <Grid gap={2} css={{ mx: theme.spacing[5], px: theme.spacing[5] }}>
+ <Label htmlFor={ids.favicon} sectionTitle>
+ Favicon
+ </Label>
+ <Grid flow="column" gap={3}>
+ <Image
+ width={72}
+ height={72}
+ className={imgStyle()}
+ src={favIconUrl}
+ loader={imageLoader}
+ />
+
+ <Grid gap={2}>
+ <Text color="subtle">
+ Upload a 32 x 32 px image to display in browser tabs.
+ </Text>
+ <ImageControl
+ assetId={props.value.faviconAssetId ?? ""}
+ onAssetIdChange={handleChange("faviconAssetId")}
+ >
+ <Button id={ids.favicon} css={{ justifySelf: "start" }}>
+ Upload
+ </Button>
+ </ImageControl>
+ </Grid>
+ </Grid>
+ </Grid>
+
+ <Separator />
+
+ <Grid gap={2} css={{ mx: theme.spacing[5], px: theme.spacing[5] }}>
+ <Label htmlFor={ids.code} sectionTitle>
+ Custom Code
+ </Label>
+ <Text color="subtle">
+ Custom code and scripts will be added at the end of the &lt;head&gt;
+ tag to every page across the published site.
+ </Text>
+ <TextArea
+ id={ids.code}
+ rows={5}
+ autoGrow
+ maxRows={10}
+ value={props.value.code ?? ""}
+ onChange={handleChange("code")}
+ />
+ </Grid>
+ <div />
+ </Grid>
+ );
+};
+
+const SiteSettingsView = () => {
+ const [value, setValue] = useState(
+ pagesStore.get()?.meta ?? {
+ siteName: "",
+ faviconAssetId: "",
+ code: "",
+ }
+ );
+
+ const isOpen = useStore($isSiteSettigsOpen);
+
+ const handleSave = useEffectEvent(() => {
+ serverSyncStore.createTransaction([pagesStore], (pages) => {
+ if (pages === undefined) {
+ return;
+ }
+
+ pages.meta = value;
+ });
+ });
+
+ return (
+ <Dialog
+ open={isOpen}
+ onOpenChange={(isOpen) => {
+ handleSave();
+ $isSiteSettigsOpen.set(isOpen);
+ }}
+ >
+ <DialogContent
+ onBlur={handleSave}
+ // Left Aside panels (e.g., Pages, Components) use zIndex: theme.zIndices[1].
+ // For a dialog to appear above these panels, both overlay and content should also have zIndex: theme.zIndices[1].
+ css={{
+ zIndex: theme.zIndices[1],
+ }}
+ overlayCss={{
+ zIndex: theme.zIndices[1],
+ }}
+ >
+ <SiteSettingsContent value={value} onChange={setValue} />
+ {/* Title is at the end intentionally,
+ * to make the close button last in the tab order
+ */}
+ <DialogTitle>Site Settings</DialogTitle>
+ </DialogContent>
+ </Dialog>
+ );
+};
+
+export const SiteSettings = () => {
+ const [settingDialogLazyOpen, setSettingDialogLazyOpen] = useState(false);
+
+ useEffect(() => {
+ return $isSiteSettigsOpen.subscribe((isOpen) => {
+ if (isOpen) {
+ setSettingDialogLazyOpen(true);
+ }
+ });
+ }, []);
+
+ if (settingDialogLazyOpen === false) {
+ return null;
+ }
+
+ return <SiteSettingsView />;
+};
diff --git a/apps/builder/app/builder/features/settings-panel/props-section/props-section.stories.tsx b/apps/builder/app/builder/features/settings-panel/props-section/props-section.stories.tsx
index 0066bcf00e..3d0d532d2b 100644
--- a/apps/builder/app/builder/features/settings-panel/props-section/props-section.stories.tsx
+++ b/apps/builder/app/builder/features/settings-panel/props-section/props-section.stories.tsx
@@ -34,6 +34,7 @@ const page = (name: string, path: string) => ({
});
pagesStore.set({
+ meta: {},
homePage: page("Home", "/"),
pages: [
page("About", "/about"),
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/image-info.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/image-info.tsx
new file mode 100644
index 0000000000..737199a4d1
--- /dev/null
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/image-info.tsx
@@ -0,0 +1,59 @@
+import { IconButton, Text, Grid, theme } from "@webstudio-is/design-system";
+import {
+ AspectRatioIcon,
+ DeleteIcon,
+ DimensionsIcon,
+ ImageIcon,
+} from "@webstudio-is/icons";
+import type { ImageAsset } from "@webstudio-is/sdk";
+import { getFormattedAspectRatio } from "~/builder/shared/image-manager/utils";
+
+type ImageInfoProps = {
+ asset: ImageAsset;
+ onDelete: () => void;
+};
+
+export const ImageInfo = ({ asset, onDelete }: ImageInfoProps) => {
+ return (
+ <Grid gap={1} flow={"column"} align={"center"} justify={"start"}>
+ <Grid
+ gap={2}
+ flow={"column"}
+ align={"center"}
+ justify={"start"}
+ css={{
+ borderRadius: theme.borderRadius[4],
+ border: `1px solid ${theme.colors.borderMain}`,
+ backgroundColor: theme.colors.white,
+ padding: theme.spacing[4],
+ justifySelf: "start",
+ pr: theme.spacing[5],
+ }}
+ >
+ <Grid flow={"column"} gap={1} align={"center"}>
+ <ImageIcon />
+ <Text truncate variant={"labelsTitleCase"}>
+ {asset.name}
+ </Text>
+ </Grid>
+ |
+ <Grid flow={"column"} gap={1} align={"center"}>
+ <DimensionsIcon />
+ <Text variant={"labelsTitleCase"}>
+ {asset.meta.width} x {asset.meta.height} Px
+ </Text>
+ </Grid>
+ |
+ <Grid flow={"column"} gap={1} align={"center"}>
+ <AspectRatioIcon />
+ <Text variant={"labelsTitleCase"}>
+ {getFormattedAspectRatio(asset.meta)}
+ </Text>
+ </Grid>
+ </Grid>
+ <IconButton onClick={onDelete}>
+ <DeleteIcon />
+ </IconButton>
+ </Grid>
+ );
+};
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.stories.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.stories.tsx
index 24145b8707..a59678d248 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.stories.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.stories.tsx
@@ -7,10 +7,10 @@ export const Basic = () => (
<Box css={{ width: 600, margin: 20 }}>
<SearchPreview
pageUrl="https://webstudio.is/blog-webstudios-architecture-an-overview"
- title="Blog: Webstudio's Architecture - an overview"
+ titleLink="Blog: Webstudio's Architecture - an overview"
siteName="Webstudio"
faviconUrl="https://webstudio.is/favicon.ico"
- description="This is an introduction for developers who want to contribute to Webstudio Core. However, it may also be an interesting read for ambitious designers who want to better understand the future of Webstudio and Visual Development."
+ snippet="This is an introduction for developers who want to contribute to Webstudio Core. However, it may also be an interesting read for ambitious designers who want to better understand the future of Webstudio and Visual Development."
/>
</Box>
);
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.tsx
index 79dc266528..d86acb8271 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.tsx
@@ -1,53 +1,53 @@
-import { Flex, Grid } from "@webstudio-is/design-system";
+import { Box, Flex, Grid } from "@webstudio-is/design-system";
import { Image, createImageLoader } from "@webstudio-is/image";
+import { formatUrl, truncateByWords, truncate } from "./social-utils";
+import env from "~/shared/env";
/**
- * Exact google truncation logic is not known, but this is a close approximation
+ * Full description with links https://developers.google.com/search/docs/appearance/visual-elements-gallery
*/
-export const truncateMetaText = (
- description: string,
- maxLength: number = 155
-) => {
- if (description.length <= maxLength) {
- return description;
- }
-
- const ellipsis = "\u00A0...";
- let truncated = description.substring(0, maxLength);
- const lastSpaceIndex = truncated.lastIndexOf(" ");
-
- // If there's a space to truncate at, use it; otherwise, use the max length
- truncated =
- lastSpaceIndex > 0 ? truncated.substring(0, lastSpaceIndex) : truncated;
-
- return `${truncated}${ellipsis}`;
-};
-
-export const truncateUrl = (pageUrl: string, maxLength = 53) => {
- if (pageUrl.length <= maxLength) {
- return pageUrl;
- }
-
- const ellipsis = "...";
- const truncated = pageUrl.substring(0, maxLength);
+type SearchPreviewProps = {
+ /**
+ * https://developers.google.com/search/docs/appearance/site-names
+ * ```html
+ * <script type="application/ld+json">
+ * {
+ * "@context" : "https://schema.org",
+ * "@type" : "WebSite",
+ * "name" : "Example",
+ * "url" : "https://example.com/"
+ * }
+ * </script>
+ * ```
+ */
+ siteName: string;
- return `${truncated}${ellipsis}`;
-};
+ /**
+ * Domain + Visible Url, The URL of the page to preview in search results
+ * or https://developers.google.com/search/docs/appearance/structured-data/breadcrumb
+ */
+ pageUrl: string;
-const formatUrl = (urlString: string) => {
- const url = new URL(urlString);
+ /**
+ * https://developers.google.com/search/docs/appearance/title-link
+ * ```html
+ * <title>Blue title link example</title>
+ * ```
+ */
+ titleLink: string;
- return `${url.origin}${url.pathname.split("/").join(" › ")}`;
-};
+ /**
+ * Snippets are automatically created from page content https://developers.google.com/search/docs/appearance/snippet
+ * sometimes meta description or structured data can be used
+ * ```html
+ * <meta name="description" content="This is the description of the content of the page">
+ * ```
+ */
+ snippet: string;
-type SearchPreviewProps = {
/**
- * The URL of the page to preview in search results
+ * https://developers.google.com/search/docs/appearance/favicon-in-search
*/
- pageUrl: string;
- title: string;
- description: string;
- siteName: string;
faviconUrl: string;
};
@@ -65,9 +65,9 @@ const VerticalThreePointIcon = () => (
</svg>
);
-const loader = createImageLoader({ imageBaseUrl: "" });
-
export const SearchPreview = (props: SearchPreviewProps) => {
+ const loader = createImageLoader({ imageBaseUrl: env.IMAGE_BASE_URL });
+
return (
<Grid
gap={1}
@@ -111,7 +111,7 @@ export const SearchPreview = (props: SearchPreviewProps) => {
whiteSpace: "nowrap",
}}
>
- {truncateMetaText(props.siteName)}
+ {truncate(truncateByWords(props.siteName), 60)}
</Flex>
<Flex
css={{
@@ -122,22 +122,26 @@ export const SearchPreview = (props: SearchPreviewProps) => {
}}
align={"center"}
>
- {/*todo add > instead of / */ formatUrl(truncateUrl(props.pageUrl))}
+ {/*todo add > instead of / */ formatUrl(truncate(props.pageUrl))}
<VerticalThreePointIcon />
</Flex>
</Grid>
</Flex>
<div />
- <Flex
+ <Box
css={{
fontSize: "20px",
fontWeight: 400,
color: "#1a0dab",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ width: "100%",
}}
>
- {truncateMetaText(props.title, 60)}
- </Flex>
- <Flex
+ {truncateByWords(props.titleLink, 60)}
+ </Box>
+ <Box
css={{
lineHeight: 1.58,
fontSize: 14,
@@ -148,8 +152,8 @@ export const SearchPreview = (props: SearchPreviewProps) => {
overflow: "hidden",
}}
>
- {truncateMetaText(props.description)}
- </Flex>
+ {truncateByWords(props.snippet)}
+ </Box>
</Grid>
);
};
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.stories.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.stories.tsx
new file mode 100644
index 0000000000..c20a62f031
--- /dev/null
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.stories.tsx
@@ -0,0 +1,86 @@
+import { pagesStore } from "~/shared/nano-states/pages";
+import { PageSettings } from "./settings";
+
+import { $isSiteSettigsOpen } from "~/shared/nano-states/seo";
+import { Grid, theme } from "@webstudio-is/design-system";
+import { assetsStore, projectStore } from "~/shared/nano-states";
+
+export default {
+ component: PageSettings,
+};
+
+$isSiteSettigsOpen.set(true);
+
+assetsStore.set(
+ new Map([
+ [
+ "imageId",
+ {
+ id: "imageId",
+ type: "image",
+ name: "very-very-very-long-long-image-name.jpg",
+ format: "jpg",
+ size: 100,
+ meta: {
+ width: 2 * 191,
+ height: 2 * 100,
+ },
+ projectId: "projectId",
+ createdAt: `${new Date()}`,
+ description: "image-description",
+ },
+ ],
+ ])
+);
+
+pagesStore.set({
+ meta: {
+ siteName: "Site name",
+ faviconAssetId: "imageId",
+ code: "code",
+ },
+ homePage: {
+ id: "homePageId",
+ title: "Home page title",
+ path: "/home-page-path",
+ name: "home-page-name",
+ meta: {},
+ rootInstanceId: "root-instance-id",
+ },
+ pages: [
+ {
+ id: "pageId",
+ title: "Page title",
+ path: "/page-path",
+ name: "page-name",
+ meta: {},
+ rootInstanceId: "root-instance-id",
+ },
+ ],
+});
+
+projectStore.set({
+ id: "projectId",
+ title: "Project title",
+ createdAt: `${new Date()}`,
+ isDeleted: false,
+ userId: "userId",
+ domain: "new-2x9tcd.wstd.io",
+});
+
+export const PageSettingsEdit = () => {
+ return (
+ <Grid
+ css={{
+ width: theme.spacing[35],
+ margin: "auto",
+ border: `1px solid ${theme.colors.borderMain}`,
+ boxShadow: theme.shadows.menuDropShadow,
+ background: theme.colors.backgroundPanel,
+ borderRadius: theme.borderRadius[4],
+ }}
+ >
+ <PageSettings onClose={() => {}} onDelete={() => {}} pageId="pageId" />
+ </Grid>
+ );
+};
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsx
index 4a391ed208..88ef7560d2 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/settings.tsx
@@ -24,37 +24,62 @@ import {
Box,
Label,
TextArea,
- styled,
- Flex,
InputErrorsTooltip,
Tooltip,
InputField,
+ Grid,
+ Checkbox,
+ Separator,
+ Text,
+ ScrollArea,
} from "@webstudio-is/design-system";
-import { ChevronDoubleLeftIcon, TrashIcon } from "@webstudio-is/icons";
+import {
+ ChevronDoubleLeftIcon,
+ CopyIcon,
+ TrashIcon,
+ CheckMarkIcon,
+ LinkIcon,
+ HomeIcon,
+} from "@webstudio-is/icons";
import { useIds } from "~/shared/form-utils";
import { Header, HeaderSuffixSpacer } from "../../header";
import { deleteInstance } from "~/shared/instance-utils";
import {
+ assetsStore,
instancesStore,
pagesStore,
+ projectStore,
selectedInstanceSelectorStore,
selectedPageIdStore,
} from "~/shared/nano-states";
import { nanoid } from "nanoid";
import { removeByMutable } from "~/shared/array-utils";
import { serverSyncStore } from "~/shared/sync";
+import { SearchPreview } from "./search-preview";
+import { ImageControl } from "~/builder/features/seo/image-control";
+import { ImageInfo } from "./image-info";
+import { SocialPreview } from "./social-preview";
+import { useEffectEvent } from "~/builder/features/ai/hooks/effect-event";
+import { getPublishedUrl } from "~/shared/router-utils";
+
+const fieldDefaultValues = {
+ name: "Untitled",
+ path: "/untitled",
+ title: "Untitled",
+ description: "",
+ isHomePage: false,
+ excludePageFromSearch: false,
+ socialImageAssetId: "",
+};
-const Group = styled(Flex, {
- marginBottom: theme.spacing[9],
- gap: theme.spacing[4],
- defaultVariants: { direction: "column" },
-});
+const fieldNames = Object.keys(
+ fieldDefaultValues
+) as (keyof typeof fieldDefaultValues)[];
-const fieldNames = ["name", "path", "title", "description"] as const;
type FieldName = (typeof fieldNames)[number];
-type Values = {
- [fieldName in FieldName]: string;
-};
+
+type Values = typeof fieldDefaultValues;
+
type Errors = {
[fieldName in FieldName]?: string[];
};
@@ -116,112 +141,347 @@ const validateValues = (
return errors;
};
-const toFormPage = (page?: Page): Values => {
+const toFormPage = (page: Page, isHomePage: boolean): Values => {
return {
- name: page?.name ?? "",
- path: page?.path ?? "",
- title: page?.title ?? "",
- description: page?.meta.description ?? "",
+ name: page.name,
+ path: page.path,
+ title: page.title,
+ description: page.meta.description ?? "",
+ socialImageAssetId: page.meta.socialImageAssetId ?? "",
+ excludePageFromSearch: page.meta.excludePageFromSearch ?? false,
+ isHomePage,
};
};
const autoSelectHandler: FocusEventHandler<HTMLInputElement> = (event) =>
event.target.select();
+const CopyPageDomainAndPathButton = ({
+ pageDomainAndPath,
+}: {
+ pageDomainAndPath: string;
+}) => {
+ const [pathIconState, setPathIconState] = useState<
+ "link" | "copy" | "checkmark"
+ >("link");
+
+ let pathIcon = <CopyIcon />;
+ if (pathIconState === "checkmark") {
+ pathIcon = <CheckMarkIcon />;
+ } else if (pathIconState === "link") {
+ pathIcon = <LinkIcon />;
+ }
+
+ return (
+ <Tooltip
+ content={pathIconState === "checkmark" ? "Copied" : "Click to copy"}
+ >
+ <Button
+ color="ghost"
+ onPointerDown={(event) => {
+ navigator.clipboard.writeText("ddd");
+ setPathIconState("checkmark");
+ // Prevent tooltip to be closed
+ event.stopPropagation();
+ }}
+ prefix={pathIcon}
+ css={{ justifySelf: "start" }}
+ onMouseEnter={() => {
+ setPathIconState("copy");
+ }}
+ onMouseLeave={() => {
+ setPathIconState("link");
+ }}
+ >
+ {pageDomainAndPath}
+ </Button>
+ </Tooltip>
+ );
+};
+
const FormFields = ({
disabled,
autoSelect,
- isHomePage,
errors,
values,
onChange,
}: {
disabled?: boolean;
autoSelect?: boolean;
- isHomePage?: boolean;
errors: Errors;
values: Values;
- onChange: <Name extends FieldName>(event: {
- field: Name;
- value: Values[Name];
- }) => void;
+ onChange: (
+ event: {
+ [K in keyof Values]: {
+ field: K;
+ value: Values[K];
+ };
+ }[keyof Values]
+ ) => void;
}) => {
const fieldIds = useIds(fieldNames);
+ const assets = useStore(assetsStore);
+ const pages = useStore(pagesStore);
+ const socialImageAsset = assets.get(values.socialImageAssetId);
+ const faviconAsset = assets.get(pages?.meta.faviconAssetId ?? "");
+
+ const faviconUrl = faviconAsset?.type === "image" ? faviconAsset.name : "";
+
+ const project = projectStore.get();
+ const publishedUrl = new URL(getPublishedUrl(project?.domain ?? ""));
+
+ const pageDomainAndPath = [publishedUrl.host, values?.path]
+ .filter(Boolean)
+ .join("/")
+ .replace(/\/+/g, "/");
+ const pageUrl = `https://${pageDomainAndPath}`;
+
+ const TOPBAR_HEIGHT = 40;
+ const HEADER_HEIGHT = 40;
+ const FOOTER_HEIGHT = 24;
+ const SCROLL_AREA_DELTA = TOPBAR_HEIGHT + HEADER_HEIGHT + FOOTER_HEIGHT;
return (
- <>
- <Group>
- <Label htmlFor={fieldIds.name}>Page Name</Label>
- <InputErrorsTooltip errors={errors.name}>
- <InputField
- tabIndex={1}
- color={errors.name && "error"}
- id={fieldIds.name}
- autoFocus
- onFocus={autoSelect ? autoSelectHandler : undefined}
- name="name"
- placeholder="About"
- disabled={disabled}
- value={values?.name}
- onChange={(event) => {
- onChange({ field: "name", value: event.target.value });
- }}
- />
- </InputErrorsTooltip>
- </Group>
- {isHomePage !== true && (
- <Group>
- <Label htmlFor={fieldIds.path}>Path</Label>
- <InputErrorsTooltip errors={errors.path}>
- <InputField
- tabIndex={1}
- color={errors.path && "error"}
- id={fieldIds.path}
- name="path"
- placeholder="/about"
- disabled={disabled}
- value={values?.path}
- onChange={(event) => {
- onChange({ field: "path", value: event.target.value });
+ <Grid>
+ <ScrollArea css={{ maxHeight: `calc(100vh - ${SCROLL_AREA_DELTA}px)` }}>
+ {/**
+ * ----------------------========<<<Page props>>>>========----------------------
+ */}
+ <Grid gap={3} css={{ my: theme.spacing[5], mx: theme.spacing[8] }}>
+ <Grid gap={1}>
+ <Label htmlFor={fieldIds.name}>Page Name</Label>
+ <InputErrorsTooltip errors={errors.name}>
+ <InputField
+ tabIndex={1}
+ color={errors.name && "error"}
+ id={fieldIds.name}
+ autoFocus
+ onFocus={autoSelect ? autoSelectHandler : undefined}
+ name="name"
+ placeholder="About"
+ disabled={disabled}
+ value={values.name}
+ onChange={(event) => {
+ onChange({ field: "name", value: event.target.value });
+ }}
+ />
+ </InputErrorsTooltip>
+
+ <Grid flow={"column"} gap={1} justify={"start"} align={"center"}>
+ {values.isHomePage ? (
+ <HomeIcon />
+ ) : (
+ <Checkbox
+ id={fieldIds.isHomePage}
+ onCheckedChange={() => {
+ onChange({ field: "path", value: "" });
+ onChange({
+ field: "isHomePage",
+ value: !values.isHomePage,
+ });
+ }}
+ />
+ )}
+
+ <Label
+ css={{
+ overflowWrap: "anywhere",
+ wordBreak: "break-all",
+ }}
+ htmlFor={fieldIds.isHomePage}
+ >
+ {values.isHomePage
+ ? `“${values.name}” is the home page`
+ : `Make “${values.name}” the home page`}
+ </Label>
+ </Grid>
+ {values.isHomePage === true && (
+ <>
+ <div />
+ <CopyPageDomainAndPathButton
+ pageDomainAndPath={pageDomainAndPath}
+ />
+ </>
+ )}
+ </Grid>
+
+ {values.isHomePage === false && (
+ <Grid gap={1}>
+ <Label htmlFor={fieldIds.path}>Path</Label>
+ <InputErrorsTooltip errors={errors.path}>
+ <InputField
+ tabIndex={1}
+ color={errors.path && "error"}
+ id={fieldIds.path}
+ name="path"
+ placeholder="/about"
+ disabled={disabled}
+ value={values?.path}
+ onChange={(event) => {
+ onChange({ field: "path", value: event.target.value });
+ }}
+ />
+ </InputErrorsTooltip>
+ <CopyPageDomainAndPathButton
+ pageDomainAndPath={pageDomainAndPath}
+ />
+ </Grid>
+ )}
+ </Grid>
+
+ <Separator />
+
+ {/**
+ * ----------------------========<<<Search Results>>>>========----------------------
+ */}
+ <Grid gap={2} css={{ my: theme.spacing[5], mx: theme.spacing[8] }}>
+ <Grid gap={2}>
+ <Label sectionTitle>Search</Label>
+ <Text color="subtle">
+ Optimize the way this page appears in search engine results pages.
+ </Text>
+ <Grid gap={1}>
+ <Label>Search Result Preview</Label>
+ <Box
+ css={{
+ padding: theme.spacing[5],
+ background: theme.colors.white,
+ borderRadius: theme.borderRadius[4],
+ border: `1px solid ${theme.colors.borderMain}`,
+ }}
+ >
+ <Box
+ css={{
+ transformOrigin: "top left",
+ transform: "scale(0.667)",
+ width: 600,
+ height: 80,
+ }}
+ >
+ <SearchPreview
+ siteName={pages?.meta.siteName ?? ""}
+ faviconUrl={faviconUrl}
+ pageUrl={pageUrl}
+ titleLink={values.title}
+ snippet={values.description}
+ />
+ </Box>
+ </Box>
+ </Grid>
+ </Grid>
+
+ <Grid gap={1}>
+ <Label htmlFor={fieldIds.title}>Title</Label>
+ <InputErrorsTooltip errors={errors.title}>
+ <InputField
+ tabIndex={1}
+ color={errors.title && "error"}
+ id={fieldIds.title}
+ name="title"
+ placeholder="My awesome site - About"
+ disabled={disabled}
+ value={values.title}
+ onChange={(event) => {
+ onChange({ field: "title", value: event.target.value });
+ }}
+ />
+ </InputErrorsTooltip>
+ </Grid>
+
+ <Grid gap={1}>
+ <Label htmlFor={fieldIds.description}>Description</Label>
+ <InputErrorsTooltip errors={errors.description}>
+ <TextArea
+ tabIndex={1}
+ state={errors.description && "invalid"}
+ id={fieldIds.description}
+ name="description"
+ disabled={disabled}
+ value={values.description}
+ onChange={(value) => {
+ onChange({ field: "description", value });
+ }}
+ autoGrow
+ maxRows={10}
+ />
+ </InputErrorsTooltip>
+ <Grid flow={"column"} gap={1} justify={"start"} align={"center"}>
+ <Checkbox
+ id={fieldIds.excludePageFromSearch}
+ checked={values.excludePageFromSearch}
+ onCheckedChange={() => {
+ onChange({
+ field: "excludePageFromSearch",
+ value: !values.excludePageFromSearch,
+ });
+ }}
+ />
+
+ <Label htmlFor={fieldIds.excludePageFromSearch}>
+ Exclude this page from search results
+ </Label>
+ </Grid>
+ </Grid>
+ </Grid>
+
+ <Separator />
+
+ {/**
+ * ----------------------========<<<Social Sharing>>>>========----------------------
+ */}
+ <Grid gap={2} css={{ my: theme.spacing[5], mx: theme.spacing[8] }}>
+ <Label htmlFor={fieldIds.socialImageAssetId} sectionTitle>
+ Social Image
+ </Label>
+ <Text color="subtle">
+ This image appears when you share a link to this page on social
+ media sites. If no image is set here, the Social Image set in the
+ Site Settings will be used. The optimal dimensions for the image are
+ 1200x630 px or larger with a 1.91:1 aspect ratio.
+ </Text>
+ <Grid gap={1} flow={"column"}>
+ <ImageControl
+ assetId={values.socialImageAssetId}
+ onAssetIdChange={(socialImageAssetId) =>
+ onChange({
+ field: "socialImageAssetId",
+ value: socialImageAssetId,
+ })
+ }
+ >
+ <Button
+ id={fieldIds.socialImageAssetId}
+ css={{ justifySelf: "start" }}
+ color="neutral"
+ >
+ Choose Image From Assets
+ </Button>
+ </ImageControl>
+ </Grid>
+
+ {socialImageAsset?.type === "image" && (
+ <ImageInfo
+ asset={socialImageAsset}
+ onDelete={() => {
+ onChange({
+ field: "socialImageAssetId",
+ value: "",
+ });
}}
/>
- </InputErrorsTooltip>
- </Group>
- )}
- <Group>
- <Label htmlFor={fieldIds.title}>Title</Label>
- <InputErrorsTooltip errors={errors.title}>
- <InputField
- tabIndex={1}
- color={errors.title && "error"}
- id={fieldIds.title}
- name="title"
- placeholder="My awesome site - About"
- disabled={disabled}
- value={values?.title}
- onChange={(event) => {
- onChange({ field: "title", value: event.target.value });
- }}
- />
- </InputErrorsTooltip>
- </Group>
- <Group>
- <Label htmlFor={fieldIds.description}>Description</Label>
- <InputErrorsTooltip errors={errors.description}>
- <TextArea
- tabIndex={1}
- state={errors.description && "invalid"}
- id={fieldIds.description}
- name="description"
- disabled={disabled}
- value={values?.description}
- onChange={(value) => {
- onChange({ field: "description", value });
- }}
+ )}
+ <div />
+ <SocialPreview
+ asset={
+ socialImageAsset?.type === "image" ? socialImageAsset : undefined
+ }
+ ogUrl={pageUrl}
+ ogTitle={values.title}
+ ogDescription={values.description}
/>
- </InputErrorsTooltip>
- </Group>
- </>
+ </Grid>
+ </ScrollArea>
+ </Grid>
);
};
@@ -261,16 +521,15 @@ export const NewPageSettings = ({
const pages = useStore(pagesStore);
const [values, setValues] = useState<Values>({
- name: "Untitled",
- path: nameToPath(pages, "Untitled"),
- title: "Untitled",
- description: "",
+ ...fieldDefaultValues,
+ path: nameToPath(pages, fieldDefaultValues.name),
});
const errors = validateValues(pages, undefined, values, false);
const handleSubmit = () => {
if (Object.keys(errors).length === 0) {
const pageId = nanoid();
+
serverSyncStore.createTransaction(
[pagesStore, instancesStore],
(pages, instances) => {
@@ -284,10 +543,9 @@ export const NewPageSettings = ({
path: values.path,
title: values.title,
rootInstanceId,
- meta: {
- description: values.description,
- },
+ meta: {},
});
+
instances.set(rootInstanceId, {
type: "instance",
id: rootInstanceId,
@@ -297,6 +555,9 @@ export const NewPageSettings = ({
selectedInstanceSelectorStore.set(undefined);
}
);
+
+ updatePage(pageId, values);
+
onSuccess(pageId);
}
};
@@ -309,15 +570,16 @@ export const NewPageSettings = ({
errors={errors}
disabled={false}
values={values}
- onChange={({ field, value }) => {
+ onChange={(val) => {
setValues((values) => {
- const changes = { [field]: value };
- if (field === "name") {
+ const changes = { [val.field]: val.value };
+
+ if (val.field === "name") {
if (values.path === nameToPath(pages, values.name)) {
- changes.path = nameToPath(pages, value);
+ changes.path = nameToPath(pages, val.value);
}
if (values.title === values.name) {
- changes.title = value;
+ changes.title = val.value;
}
}
return { ...values, ...changes };
@@ -370,7 +632,6 @@ const NewPageSettingsView = ({
<Box
css={{
overflow: "auto",
- padding: `${theme.spacing[5]} ${theme.spacing[9]}`,
}}
>
<form
@@ -398,17 +659,48 @@ const updatePage = (pageId: Page["id"], values: Partial<Values>) => {
if (values.title !== undefined) {
page.title = values.title;
}
+
if (values.description !== undefined) {
page.meta.description = values.description;
}
+
+ if (values.excludePageFromSearch !== undefined) {
+ page.meta.excludePageFromSearch = values.excludePageFromSearch;
+ }
+
+ if (values.socialImageAssetId !== undefined) {
+ page.meta.socialImageAssetId = values.socialImageAssetId;
+ }
};
+
serverSyncStore.createTransaction([pagesStore], (pages) => {
if (pages === undefined) {
return;
}
+
+ // swap home page
+ if (values.isHomePage && pages.homePage.id !== pageId) {
+ const newHomePageIndex = pages.pages.findIndex(
+ (page) => page.id === pageId
+ );
+
+ if (newHomePageIndex === -1) {
+ throw new Error(`Page with id ${pageId} not found`);
+ }
+
+ const tmp = pages.homePage;
+ pages.homePage = pages.pages[newHomePageIndex];
+
+ pages.homePage.path = "";
+ pages.pages[newHomePageIndex] = tmp;
+
+ tmp.path = nameToPath(pages, tmp.name);
+ }
+
if (pages.homePage.id === pageId) {
updatePageMutable(pages.homePage, values);
}
+
for (const page of pages.pages) {
if (page.id === pageId) {
updatePageMutable(page, values);
@@ -455,21 +747,26 @@ export const PageSettings = ({
const [unsavedValues, setUnsavedValues] = useState<Partial<Values>>({});
const values: Values = {
- ...toFormPage(page),
+ ...(page ? toFormPage(page, isHomePage) : fieldDefaultValues),
...unsavedValues,
};
- const errors = validateValues(pages, pageId, values, isHomePage);
- const handleSubmitDebounced = useDebouncedCallback(() => {
+ const errors = validateValues(pages, pageId, values, values.isHomePage);
+
+ const debouncedFn = useEffectEvent(() => {
if (
Object.keys(unsavedValues).length === 0 ||
Object.keys(errors).length !== 0
) {
return;
}
+
updatePage(pageId, unsavedValues);
+
setUnsavedValues({});
- }, 1000);
+ });
+
+ const handleSubmitDebounced = useDebouncedCallback(debouncedFn, 1000);
const handleChange = useCallback(
<Name extends FieldName>(event: { field: Name; value: Values[Name] }) => {
@@ -503,7 +800,6 @@ export const PageSettings = ({
return (
<PageSettingsView
- isHomePage={isHomePage}
onClose={onClose}
onDelete={hanldeDelete}
errors={errors}
@@ -514,12 +810,10 @@ export const PageSettings = ({
};
const PageSettingsView = ({
- isHomePage,
onDelete,
onClose,
...formFieldsProps
}: {
- isHomePage: boolean;
onDelete: () => void;
onClose?: () => void;
} & ComponentProps<typeof FormFields>) => {
@@ -529,7 +823,7 @@ const PageSettingsView = ({
title="Page Settings"
suffix={
<>
- {isHomePage === false && (
+ {formFieldsProps.values.isHomePage === false && (
<Tooltip content="Delete page" side="bottom">
<Button
color="ghost"
@@ -557,7 +851,6 @@ const PageSettingsView = ({
<Box
css={{
overflow: "auto",
- padding: `${theme.spacing[5]} ${theme.spacing[9]}`,
}}
>
<form
@@ -566,7 +859,7 @@ const PageSettingsView = ({
onClose?.();
}}
>
- <FormFields isHomePage={isHomePage} {...formFieldsProps} />
+ <FormFields {...formFieldsProps} />
<input type="submit" hidden />
</form>
</Box>
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/social-preview.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-preview.tsx
new file mode 100644
index 0000000000..161e284609
--- /dev/null
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-preview.tsx
@@ -0,0 +1,101 @@
+import { Box, Grid, Label, css, theme } from "@webstudio-is/design-system";
+import { Image, createImageLoader } from "@webstudio-is/image";
+import type { ImageAsset } from "@webstudio-is/sdk";
+import env from "~/shared/env";
+import { truncateByWords, truncate } from "./social-utils";
+
+type SocialPreviewProps = {
+ asset?: ImageAsset;
+ ogUrl: string;
+ ogTitle: string;
+ ogDescription: string;
+};
+
+const imgStyle = css({
+ objectFit: "cover",
+ borderTopLeftRadius: theme.borderRadius[4],
+ borderTopRightRadius: theme.borderRadius[4],
+ width: "100%",
+ aspectRatio: "1.91 / 1",
+ background: "#DFE3E6",
+ borderBottom: `1px solid ${theme.colors.borderMain}`,
+});
+
+export const SocialPreview = ({
+ asset,
+ ogDescription,
+ ogTitle,
+ ogUrl,
+}: SocialPreviewProps) => {
+ const imageLoader = createImageLoader({
+ imageBaseUrl: env.ASSET_BASE_URL,
+ });
+
+ return (
+ <Grid gap={1}>
+ <Label>Social Sharing Preview</Label>
+
+ <Grid
+ gap={1}
+ css={{
+ borderRadius: theme.borderRadius[4],
+ border: `1px solid ${theme.colors.borderMain}`,
+ backgroundColor: theme.colors.white,
+ }}
+ >
+ <Image
+ src={asset?.type === "image" ? asset.name : undefined}
+ loader={imageLoader}
+ className={imgStyle()}
+ />
+
+ <Grid
+ gap={1}
+ css={{
+ margin: 12,
+ }}
+ >
+ <Box
+ css={{
+ color: "#4D5156",
+ fontFamily: "Arial",
+ fontSize: "12px",
+ lineHeight: "16px",
+ }}
+ >
+ {truncate(ogUrl)}
+ </Box>
+ <Box
+ css={{
+ color: "#18283E",
+ fontFamily: "Arial",
+ fontSize: "14px",
+ fontWeight: 700,
+ lineHeight: "18px",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {truncateByWords(ogTitle, 60)}
+ </Box>
+ <Box
+ css={{
+ color: "#4D5156",
+ fontFamily: "Arial",
+ fontSize: "12px",
+ fontWeight: 400,
+ lineHeight: "16px",
+ "-webkit-line-clamp": 2,
+ display: "-webkit-box",
+ "-webkit-box-orient": "vertical",
+ overflow: "hidden",
+ }}
+ >
+ {truncateByWords(ogDescription)}
+ </Box>
+ </Grid>
+ </Grid>
+ </Grid>
+ );
+};
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.test.ts b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.test.ts
similarity index 88%
rename from apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.test.ts
rename to apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.test.ts
index fdd5dde1d4..9c42893082 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/search-preview.test.ts
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.test.ts
@@ -1,10 +1,10 @@
/* eslint-disable no-irregular-whitespace */
import { expect, test } from "@jest/globals";
-import { truncateMetaText, truncateUrl } from "./search-preview";
+import { truncateByWords, truncate } from "./social-utils";
test("Truncates description", () => {
expect(
- truncateMetaText(
+ truncateByWords(
"Accept everyone around you. Part of being a good person is not being judgmental. You accept everyone, no matter what race, age, sexual orientation, gender identity, or culture they are. Realize that everybody has feelings, every person is valid, and everyone should always be treated with respect.\n\nBe respectful of elderly people. "
)
).toMatchInlineSnapshot(
@@ -14,7 +14,7 @@ test("Truncates description", () => {
test("Truncates description", () => {
expect(
- truncateMetaText(
+ truncateByWords(
"The best way to determine the best balance for you is by learning to check in with your inner compass — and your results. With intentionality and a little creativity, you can recalibrate your expectations and reset your work-home balance.&nbsp"
)
).toMatchInlineSnapshot(
@@ -24,7 +24,7 @@ test("Truncates description", () => {
test("Truncates description", () => {
expect(
- truncateMetaText(
+ truncateByWords(
"The meta description summarizes a page&#8217;s content and presents that to users in the search results. It&#8217;s one of the first things people will likely see when searching for something, so optimizing it is crucial for SEO. It&#8217;s your chance to persuade users to click on "
)
).toMatchInlineSnapshot(
@@ -34,7 +34,7 @@ test("Truncates description", () => {
test("Truncates description", () => {
expect(
- truncateMetaText(
+ truncateByWords(
"A meta description (also known as a “description tag”) is an HTML attribute designed to describe the content of a webpage. Here’s what a meta description looks like in HTML form:"
)
).toMatchInlineSnapshot(
@@ -44,7 +44,7 @@ test("Truncates description", () => {
test("Truncates url", () => {
expect(
- truncateUrl("https://ahrefs.com/writing-tools/meta-description-generator")
+ truncate("https://ahrefs.com/writing-tools/meta-description-generator")
).toMatchInlineSnapshot(
`"https://ahrefs.com/writing-tools/meta-description-gen..."`
);
@@ -52,9 +52,7 @@ test("Truncates url", () => {
test("Truncates url", () => {
expect(
- truncateUrl(
- "https://university.webflow.com›lesson›seo-title-meta-description"
- )
+ truncate("https://university.webflow.com›lesson›seo-title-meta-description")
).toMatchInlineSnapshot(
`"https://university.webflow.com›lesson›seo-title-meta-..."`
);
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.ts b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.ts
new file mode 100644
index 0000000000..e4b1f2251f
--- /dev/null
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.ts
@@ -0,0 +1,38 @@
+/**
+ * Exact google truncation logic is not known, but this is a close approximation
+ */
+export const truncateByWords = (
+ description: string,
+ maxLength: number = 155
+) => {
+ if (description.length <= maxLength) {
+ return description;
+ }
+
+ const ellipsis = "\u00A0...";
+ let truncated = description.substring(0, maxLength);
+ const lastSpaceIndex = truncated.lastIndexOf(" ");
+
+ // If there's a space to truncate at, use it; otherwise, use the max length
+ truncated =
+ lastSpaceIndex > 0 ? truncated.substring(0, lastSpaceIndex) : truncated;
+
+ return `${truncated}${ellipsis}`;
+};
+
+export const truncate = (pageUrl: string, maxLength = 53) => {
+ if (pageUrl.length <= maxLength) {
+ return pageUrl;
+ }
+
+ const ellipsis = "...";
+ const truncated = pageUrl.substring(0, maxLength);
+
+ return `${truncated}${ellipsis}`;
+};
+
+export const formatUrl = (urlString: string) => {
+ const url = new URL(urlString);
+
+ return `${url.origin}${url.pathname.split("/").join(" › ")}`;
+};
diff --git a/apps/builder/app/builder/features/topbar/menu/menu.tsx b/apps/builder/app/builder/features/topbar/menu/menu.tsx
index 747333ad4e..b3b63f257f 100644
--- a/apps/builder/app/builder/features/topbar/menu/menu.tsx
+++ b/apps/builder/app/builder/features/topbar/menu/menu.tsx
@@ -30,6 +30,7 @@ import { dashboardPath } from "~/shared/router-utils";
import { $authPermit } from "~/shared/nano-states";
import { emitCommand } from "~/builder/shared/commands";
import { MenuButton } from "./menu-button";
+import { $isSiteSettigsOpen } from "~/shared/nano-states/seo";
const ThemeMenuItem = () => {
if (isFeatureEnabled("dark") === false) {
@@ -201,6 +202,15 @@ export const Menu = () => {
Publish
</DropdownMenuItem>
</Tooltip>
+ <Tooltip side="right" content={undefined}>
+ <DropdownMenuItem
+ onSelect={() => {
+ $isSiteSettigsOpen.set(true);
+ }}
+ >
+ Site Settings
+ </DropdownMenuItem>
+ </Tooltip>
</DropdownMenuContent>
</DropdownMenuPortal>
</DropdownMenu>
diff --git a/apps/builder/app/builder/shared/floating-panel/floating-panel.tsx b/apps/builder/app/builder/shared/floating-panel/floating-panel.tsx
index 014c85738d..6732802fe7 100644
--- a/apps/builder/app/builder/shared/floating-panel/floating-panel.tsx
+++ b/apps/builder/app/builder/shared/floating-panel/floating-panel.tsx
@@ -58,9 +58,15 @@ type FloatingPanelProps = {
children: JSX.Element;
open?: boolean;
onOpenChange?: (isOpen: boolean) => void;
+ // Left Aside panels (e.g., Pages, Components) use zIndex: theme.zIndices[1].
+ // For a panel to appear above these panels, both overlay and content should also have zIndex: theme.zIndices[1].
+ // After layout is fixed, this prop should be removed.
+ zIndex?: 1;
};
-const contentStyle = css({ width: theme.spacing[30] });
+const contentStyle = css({
+ width: theme.spacing[30],
+});
export const FloatingPanel = ({
title,
@@ -68,6 +74,7 @@ export const FloatingPanel = ({
children,
open,
onOpenChange,
+ zIndex,
}: FloatingPanelProps) => {
const { isOpen, handleOpenChange, triggerRef, sideOffset } = useLogic(
open,
@@ -82,7 +89,9 @@ export const FloatingPanel = ({
sideOffset={sideOffset}
side="left"
align="start"
- className={contentStyle()}
+ className={contentStyle({
+ zIndex: zIndex ? theme.zIndices[zIndex] : undefined,
+ })}
>
{content}
<FloatingPanelPopoverTitle>{title}</FloatingPanelPopoverTitle>
diff --git a/apps/builder/app/shared/copy-paste/plugin-instance.test.ts b/apps/builder/app/shared/copy-paste/plugin-instance.test.ts
index 83f7690c31..8d2407aede 100644
--- a/apps/builder/app/shared/copy-paste/plugin-instance.test.ts
+++ b/apps/builder/app/shared/copy-paste/plugin-instance.test.ts
@@ -31,6 +31,7 @@ registerContainers();
registeredComponentMetasStore.set(new Map(Object.entries(baseComponentMetas)));
projectStore.set({ id: "my-project" } as Project);
pagesStore.set({
+ meta: {},
homePage: { id: "home-page", rootInstanceId: "body0" } as Page,
pages: [],
});
diff --git a/apps/builder/app/shared/nano-states/seo.ts b/apps/builder/app/shared/nano-states/seo.ts
new file mode 100644
index 0000000000..6935a921a4
--- /dev/null
+++ b/apps/builder/app/shared/nano-states/seo.ts
@@ -0,0 +1,3 @@
+import { atom } from "nanostores";
+
+export const $isSiteSettigsOpen = atom<boolean>(false);
diff --git a/packages/design-system/src/components/button.tsx b/packages/design-system/src/components/button.tsx
index 76a410af32..8b255e19e9 100644
--- a/packages/design-system/src/components/button.tsx
+++ b/packages/design-system/src/components/button.tsx
@@ -110,7 +110,8 @@ const StyledButton = styled("button", {
all: "unset",
boxSizing: "border-box",
minWidth: 0,
- display: "inline-flex",
+ display: "inline-grid",
+ gridAutoFlow: "column",
alignItems: "center",
justifyContent: "center",
gap: theme.spacing[2],
diff --git a/packages/design-system/src/components/dialog.tsx b/packages/design-system/src/components/dialog.tsx
index acb3c6f0be..c1c6cf3ad0 100644
--- a/packages/design-system/src/components/dialog.tsx
+++ b/packages/design-system/src/components/dialog.tsx
@@ -26,13 +26,17 @@ export const DialogContent = forwardRef(
children,
className,
css,
+ overlayCss,
...props
- }: ComponentProps<typeof Primitive.Content> & { css?: CSS },
+ }: ComponentProps<typeof Primitive.Content> & {
+ css?: CSS;
+ overlayCss?: CSS;
+ },
forwardedRef: Ref<HTMLDivElement>
) => {
return (
<Primitive.Portal>
- <Primitive.Overlay className={overlayStyle()} />
+ <Primitive.Overlay className={overlayStyle({ css: overlayCss })} />
<Primitive.Content
className={contentStyle({ className, css })}
{...props}
diff --git a/packages/icons/icons/aspect-ratio.svg b/packages/icons/icons/aspect-ratio.svg
new file mode 100644
index 0000000000..4178a5c481
--- /dev/null
+++ b/packages/icons/icons/aspect-ratio.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="17" viewBox="0 0 16 17" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M4.66617 2.31665C4.83882 2.31665 5.00438 2.38534 5.12632 2.50756L7.7902 5.17756C8.04375 5.43169 8.04328 5.84325 7.78914 6.0968C7.53501 6.35035 7.12346 6.34987 6.86991 6.09574L5.31617 4.53844L5.31617 10.3301C5.31617 10.6891 5.60719 10.9801 5.96617 10.9801H11.823L10.2677 9.43063C10.0134 9.17726 10.0126 8.76571 10.266 8.51139C10.5193 8.25707 10.9309 8.2563 11.1852 8.50967L13.8552 11.1697C13.9775 11.2915 14.0463 11.4569 14.0464 11.6295C14.0466 11.8021 13.9781 11.9677 13.8561 12.0898L11.1861 14.7598C10.9322 15.0136 10.5207 15.0136 10.2668 14.7598C10.013 14.5059 10.013 14.0944 10.2668 13.8405L11.8272 12.2801H5.96617C4.88922 12.2801 4.01617 11.4071 4.01617 10.3301L4.01617 4.53844L2.46244 6.09574C2.20889 6.34987 1.79734 6.35035 1.5432 6.0968C1.28907 5.84325 1.2886 5.43169 1.54215 5.17756L4.20603 2.50756C4.32797 2.38534 4.49353 2.31665 4.66617 2.31665Z" />
+</svg>
diff --git a/packages/icons/icons/delete.svg b/packages/icons/icons/delete.svg
new file mode 100644
index 0000000000..25cada50d9
--- /dev/null
+++ b/packages/icons/icons/delete.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+ <path d="M10.755 14.6501H5.24501C4.74501 14.6501 4.26501 14.4601 3.89501 14.1201C3.52501 13.7701 3.30501 13.3101 3.26501 12.8101L2.72501 5.3201H2.66501C2.30501 5.3201 2.01501 5.0301 2.01501 4.6701C2.01501 4.3101 2.30501 4.0201 2.66501 4.0201H5.34501V2.6701C5.34501 2.3201 5.48501 1.9901 5.73501 1.7401C5.98501 1.4901 6.31501 1.3501 6.66501 1.3501H9.33501C9.68501 1.3501 10.015 1.4901 10.265 1.7301C10.515 1.9801 10.655 2.3101 10.655 2.6601V4.0101H13.335C13.695 4.0101 13.985 4.3001 13.985 4.6601C13.985 5.0201 13.695 5.3101 13.335 5.3101H13.275L12.735 12.8001C12.705 13.3001 12.475 13.7701 12.105 14.1101C11.735 14.4501 11.255 14.6401 10.755 14.6401V14.6501ZM4.03501 5.3201L4.56501 12.7201C4.57501 12.8901 4.65501 13.0501 4.78501 13.1701C4.91501 13.2901 5.07501 13.3501 5.25501 13.3501H10.775C10.945 13.3501 11.115 13.2901 11.245 13.1701C11.375 13.0501 11.445 12.8901 11.465 12.7201L11.995 5.3201H4.03501ZM6.65501 4.0201H9.35501V2.6701L6.67501 2.6501V4.0201H6.65501Z" />
+ <path d="M9.33501 11.9801C8.97501 11.9801 8.68501 11.6901 8.68501 11.3301V7.3301C8.68501 6.9701 8.97501 6.6801 9.33501 6.6801C9.69501 6.6801 9.98501 6.9701 9.98501 7.3301V11.3301C9.98501 11.6901 9.69501 11.9801 9.33501 11.9801ZM6.66501 11.9801C6.30501 11.9801 6.01501 11.6901 6.01501 11.3301V7.3301C6.01501 6.9701 6.30501 6.6801 6.66501 6.6801C7.02501 6.6801 7.31501 6.9701 7.31501 7.3301V11.3301C7.31501 11.6901 7.02501 11.9801 6.66501 11.9801Z" />
+</svg>
\ No newline at end of file
diff --git a/packages/icons/icons/dimensions.svg b/packages/icons/icons/dimensions.svg
new file mode 100644
index 0000000000..d279b5dc19
--- /dev/null
+++ b/packages/icons/icons/dimensions.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="17" viewBox="0 0 16 17" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M7.82108 4.06254C7.82149 4.42153 8.11284 4.71221 8.47183 4.7118L10.6717 4.70927L4.40923 10.9717L4.41175 8.77187C4.41216 8.41289 4.12148 8.12154 3.7625 8.12113C3.40351 8.12072 3.11216 8.4114 3.11175 8.77038L3.10742 12.542C3.10722 12.7147 3.17572 12.8803 3.2978 13.0024C3.41988 13.1245 3.58552 13.1929 3.75817 13.1928L7.52979 13.1884C7.88878 13.188 8.17946 12.8967 8.17904 12.5377C8.17863 12.1787 7.88728 11.888 7.5283 11.8884L5.32846 11.8909L11.5909 5.62851L11.5884 7.82835C11.588 8.18733 11.8786 8.47868 12.2376 8.47909C12.5966 8.4795 12.888 8.18882 12.8884 7.82984L12.8927 4.05822C12.8929 3.88557 12.8244 3.71993 12.7023 3.59785C12.5802 3.47577 12.4146 3.40727 12.242 3.40747L8.47033 3.4118C8.11135 3.41221 7.82067 3.70356 7.82108 4.06254Z" />
+</svg>
diff --git a/packages/icons/icons/home.svg b/packages/icons/icons/home.svg
new file mode 100644
index 0000000000..6e3ab5c7aa
--- /dev/null
+++ b/packages/icons/icons/home.svg
@@ -0,0 +1,3 @@
+<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="M7.6559 0.907089C7.88124 0.846075 8.11876 0.846075 8.34411 0.907089C8.60553 0.97787 8.82581 1.15075 9.00433 1.29086C9.02124 1.30414 9.03777 1.31712 9.05393 1.32968L13.5755 4.84644C13.5927 4.85983 13.6098 4.87308 13.6267 4.88623C13.8784 5.08159 14.0978 5.25187 14.2612 5.47281C14.4047 5.66677 14.5116 5.88528 14.5766 6.11759C14.6507 6.38223 14.6504 6.65995 14.65 6.9786C14.65 7.00004 14.65 7.02165 14.65 7.04347V11.8919C14.65 12.2438 14.65 12.5464 14.6297 12.7954C14.6082 13.0579 14.561 13.3177 14.4338 13.5672C14.2437 13.9404 13.9403 14.2438 13.5671 14.4339C13.3176 14.561 13.0579 14.6083 12.7953 14.6298C12.5463 14.6501 12.2437 14.6501 11.8918 14.6501H4.10816C3.75628 14.6501 3.4537 14.6501 3.20467 14.6298C2.94214 14.6083 2.68243 14.561 2.43292 14.4339C2.05973 14.2438 1.75632 13.9404 1.56617 13.5672C1.43904 13.3177 1.39178 13.0579 1.37033 12.7954C1.34998 12.5464 1.34999 12.2438 1.35 11.8919L1.35 7.04347C1.35 7.02165 1.34998 7.00003 1.34996 6.9786C1.34963 6.65995 1.34934 6.38222 1.42341 6.11759C1.48844 5.88527 1.59531 5.66677 1.73876 5.47281C1.90218 5.25187 2.12158 5.08159 2.3733 4.88623C2.39024 4.87308 2.40732 4.85983 2.42453 4.84644L6.94607 1.32968C6.96223 1.31711 6.97877 1.30414 6.99568 1.29086C7.1742 1.15075 7.39448 0.97787 7.6559 0.907089ZM6.65 13.3501H9.35V9.06675C9.35 8.86934 9.3495 8.76038 9.34308 8.68182C9.34236 8.67303 9.34162 8.66552 9.34091 8.65918C9.33457 8.65847 9.32706 8.65773 9.31827 8.65701C9.23971 8.65059 9.13075 8.65009 8.93334 8.65009H7.06667C6.86926 8.65009 6.76029 8.65059 6.68174 8.65701C6.67294 8.65773 6.66544 8.65847 6.6591 8.65918C6.65839 8.66552 6.65765 8.67303 6.65693 8.68182C6.65051 8.76038 6.65 8.86934 6.65 9.06675V13.3501ZM10.65 13.3501L10.65 9.04584C10.65 8.87727 10.65 8.71403 10.6388 8.57596C10.6264 8.42459 10.5973 8.24721 10.5065 8.069C10.3803 7.82125 10.1788 7.61983 9.93109 7.49359C9.75288 7.40279 9.5755 7.37369 9.42413 7.36133C9.28606 7.35005 9.12282 7.35007 8.95425 7.35008H7.04575C6.87718 7.35007 6.71395 7.35005 6.57587 7.36133C6.42451 7.37369 6.24712 7.40279 6.06892 7.49359C5.82117 7.61983 5.61974 7.82125 5.49351 8.069C5.40271 8.24721 5.37361 8.42459 5.36124 8.57596C5.34996 8.71403 5.34998 8.87727 5.35 9.04584L5.35 13.3501H4.13334C3.74924 13.3501 3.50026 13.3496 3.31054 13.3341C3.1284 13.3192 3.05881 13.2938 3.02311 13.2756C2.89453 13.2101 2.79 13.1056 2.72448 12.977C2.70629 12.9413 2.68089 12.8717 2.66601 12.6896C2.65051 12.4998 2.65 12.2508 2.65 11.8668V7.04347C2.65 6.62375 2.65565 6.53819 2.6753 6.46801C2.6977 6.38796 2.73452 6.31268 2.78395 6.24586C2.82729 6.18726 2.89135 6.13027 3.22266 5.87259L7.74419 2.35584C7.86861 2.25907 7.93516 2.20781 7.98588 2.17392C7.99132 2.17029 7.99601 2.16725 8 2.16473C8.00399 2.16725 8.00869 2.17029 8.01413 2.17392C8.06485 2.20781 8.13139 2.25907 8.25581 2.35584L12.7773 5.87259C13.1087 6.13027 13.1727 6.18726 13.2161 6.24586C13.2655 6.31268 13.3023 6.38796 13.3247 6.46801C13.3444 6.53819 13.35 6.62375 13.35 7.04347V11.8668C13.35 12.2508 13.3495 12.4998 13.334 12.6896C13.3191 12.8717 13.2937 12.9413 13.2755 12.977C13.21 13.1056 13.1055 13.2101 12.9769 13.2756C12.9412 13.2938 12.8716 13.3192 12.6895 13.3341C12.4997 13.3496 12.2508 13.3501 11.8667 13.3501H10.65Z" />
+</svg>
diff --git a/packages/icons/src/__generated__/aspect-ratio.tsx b/packages/icons/src/__generated__/aspect-ratio.tsx
new file mode 100644
index 0000000000..4e1294747f
--- /dev/null
+++ b/packages/icons/src/__generated__/aspect-ratio.tsx
@@ -0,0 +1,15 @@
+// Generated from icons/aspect-ratio.svg
+
+import { forwardRef } from "react";
+import type { IconProps } from "../types";
+
+// prettier-ignore
+export const AspectRatioIcon = forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", size = 16, ...props }, forwardedRef) => {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 17" width={size} height={size} fill={color} {...props} ref={forwardedRef}><path fillRule="evenodd" d="M4.666 2.317a.65.65 0 0 1 .46.19l2.664 2.67a.65.65 0 1 1-.92.919L5.316 4.538v5.792c0 .36.291.65.65.65h5.857l-1.555-1.55a.65.65 0 0 1 .917-.92l2.67 2.66a.65.65 0 0 1 .001.92l-2.67 2.67a.65.65 0 0 1-.92-.92l1.561-1.56h-5.86a1.95 1.95 0 0 1-1.95-1.95V4.538L2.461 6.096a.65.65 0 1 1-.92-.918l2.664-2.67a.65.65 0 0 1 .46-.191Z" clipRule="evenodd" /></svg>
+ );
+ }
+);
+
+AspectRatioIcon.displayName = "AspectRatioIcon";
diff --git a/packages/icons/src/__generated__/delete.tsx b/packages/icons/src/__generated__/delete.tsx
new file mode 100644
index 0000000000..ee87ebe38c
--- /dev/null
+++ b/packages/icons/src/__generated__/delete.tsx
@@ -0,0 +1,15 @@
+// Generated from icons/delete.svg
+
+import { forwardRef } from "react";
+import type { IconProps } from "../types";
+
+// prettier-ignore
+export const DeleteIcon = 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 d="M10.755 14.65h-5.51c-.5 0-.98-.19-1.35-.53-.37-.35-.59-.81-.63-1.31l-.54-7.49h-.06c-.36 0-.65-.29-.65-.65 0-.36.29-.65.65-.65h2.68V2.67c0-.35.14-.68.39-.93s.58-.39.93-.39h2.67c.35 0 .68.14.93.38.25.25.39.58.39.93v1.35h2.68c.36 0 .65.29.65.65 0 .36-.29.65-.65.65h-.06l-.54 7.49c-.03.5-.26.97-.63 1.31-.37.34-.85.53-1.35.53v.01Zm-6.72-9.33.53 7.4c.01.17.09.33.22.45s.29.18.47.18h5.52c.17 0 .34-.06.47-.18.13-.12.2-.28.22-.45l.53-7.4h-7.96Zm2.62-1.3h2.7V2.67l-2.68-.02v1.37h-.02Z" /><path d="M9.335 11.98c-.36 0-.65-.29-.65-.65v-4c0-.36.29-.65.65-.65.36 0 .65.29.65.65v4c0 .36-.29.65-.65.65Zm-2.67 0c-.36 0-.65-.29-.65-.65v-4c0-.36.29-.65.65-.65.36 0 .65.29.65.65v4c0 .36-.29.65-.65.65Z" /></svg>
+ );
+ }
+);
+
+DeleteIcon.displayName = "DeleteIcon";
diff --git a/packages/icons/src/__generated__/dimensions.tsx b/packages/icons/src/__generated__/dimensions.tsx
new file mode 100644
index 0000000000..59fdbd35f9
--- /dev/null
+++ b/packages/icons/src/__generated__/dimensions.tsx
@@ -0,0 +1,15 @@
+// Generated from icons/dimensions.svg
+
+import { forwardRef } from "react";
+import type { IconProps } from "../types";
+
+// prettier-ignore
+export const DimensionsIcon = forwardRef<SVGSVGElement, IconProps>(
+ ({ color = "currentColor", size = 16, ...props }, forwardedRef) => {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 17" width={size} height={size} fill={color} {...props} ref={forwardedRef}><path fillRule="evenodd" d="M7.821 4.063c0 .359.292.65.65.649l2.2-.003-6.262 6.263.003-2.2a.65.65 0 0 0-1.3-.002l-.005 3.772a.65.65 0 0 0 .651.65l3.772-.004a.65.65 0 1 0-.002-1.3l-2.2.003 6.263-6.262-.003 2.2a.65.65 0 1 0 1.3 0l.005-3.77a.65.65 0 0 0-.651-.652l-3.772.005a.65.65 0 0 0-.649.65Z" clipRule="evenodd" /></svg>
+ );
+ }
+);
+
+DimensionsIcon.displayName = "DimensionsIcon";
diff --git a/packages/icons/src/__generated__/home.tsx b/packages/icons/src/__generated__/home.tsx
new file mode 100644
index 0000000000..d68428ec56
--- /dev/null
+++ b/packages/icons/src/__generated__/home.tsx
@@ -0,0 +1,15 @@
+// Generated from icons/home.svg
+
+import { forwardRef } from "react";
+import type { IconProps } from "../types";
+
+// prettier-ignore
+export const HomeIcon = 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="M7.656.907c.225-.06.463-.06.688 0 .262.07.482.244.66.384l.05.039 4.521 3.516.052.04c.251.196.47.366.634.587.144.194.25.412.316.645.074.264.073.542.073.86V11.893c0 .352 0 .654-.02.903a2.02 2.02 0 0 1-.196.772c-.19.373-.494.677-.867.867-.25.127-.51.174-.772.196-.249.02-.551.02-.903.02H4.108c-.352 0-.654 0-.903-.02a2.021 2.021 0 0 1-.772-.196 1.983 1.983 0 0 1-.867-.867 2.02 2.02 0 0 1-.196-.772c-.02-.249-.02-.551-.02-.903V6.979c0-.319 0-.597.073-.861.065-.233.172-.451.316-.645.163-.221.383-.391.634-.587l.052-.04L6.946 1.33l.05-.04c.178-.14.398-.312.66-.383ZM6.65 13.35h2.7V9.067a5.468 5.468 0 0 0-.01-.408 5.468 5.468 0 0 0-.408-.01H7.068a5.468 5.468 0 0 0-.408.01 5.466 5.466 0 0 0-.01.408v4.283Zm4 0V9.046c0-.169 0-.332-.011-.47a1.332 1.332 0 0 0-.132-.507 1.317 1.317 0 0 0-.576-.575 1.331 1.331 0 0 0-.507-.133c-.138-.01-.301-.01-.47-.01H7.046c-.169 0-.332 0-.47.01a1.331 1.331 0 0 0-.507.133c-.248.126-.45.327-.575.575-.091.178-.12.356-.133.507-.011.138-.011.301-.011.47v4.304H4.133c-.384 0-.633 0-.822-.016-.183-.015-.252-.04-.288-.058a.683.683 0 0 1-.299-.299c-.018-.036-.043-.105-.058-.287a11.35 11.35 0 0 1-.016-.823V7.043c0-.42.006-.505.025-.575a.683.683 0 0 1 .109-.222c.043-.059.107-.116.439-.373l4.521-3.517A4.86 4.86 0 0 1 8 2.165a4.861 4.861 0 0 1 .256.191l4.521 3.517c.332.257.396.314.44.373.048.067.085.142.108.222.02.07.025.156.025.575v4.824c0 .384 0 .633-.016.823-.015.182-.04.251-.059.287a.683.683 0 0 1-.298.299c-.036.018-.105.043-.287.058-.19.016-.44.016-.823.016H10.65Z" clipRule="evenodd" /></svg>
+ );
+ }
+);
+
+HomeIcon.displayName = "HomeIcon";
diff --git a/packages/icons/src/__generated__/index.ts b/packages/icons/src/__generated__/index.ts
index 2d065f5ae5..43b83c1c64 100644
--- a/packages/icons/src/__generated__/index.ts
+++ b/packages/icons/src/__generated__/index.ts
@@ -22,6 +22,7 @@ export * from "./ai";
export * from "./alert";
export * from "./arrow-down";
export * from "./arrow-right";
+export * from "./aspect-ratio";
export * from "./attachment";
export * from "./auto-scroll";
export * from "./blockquote";
@@ -70,8 +71,10 @@ export * from "./custom-code";
export * from "./dash-border";
export * from "./dash";
export * from "./dashed-border";
+export * from "./delete";
export * from "./description";
export * from "./dialog";
+export * from "./dimensions";
export * from "./discord";
export * from "./div";
export * from "./dot";
@@ -95,6 +98,7 @@ export * from "./hamburger-menu";
export * from "./header";
export * from "./heading";
export * from "./help";
+export * from "./home";
export * from "./image";
export * from "./info";
export * from "./information";
diff --git a/packages/icons/src/__generated__/svg/aspect-ratio.ts b/packages/icons/src/__generated__/svg/aspect-ratio.ts
new file mode 100644
index 0000000000..96411208e1
--- /dev/null
+++ b/packages/icons/src/__generated__/svg/aspect-ratio.ts
@@ -0,0 +1 @@
+export const AspectRatioIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 17" fill="currentColor" width="100%" height="100%" style="display: block;"><path fill-rule="evenodd" d="M4.666 2.317a.65.65 0 0 1 .46.19l2.664 2.67a.65.65 0 1 1-.92.919L5.316 4.538v5.792c0 .36.291.65.65.65h5.857l-1.555-1.55a.65.65 0 0 1 .917-.92l2.67 2.66a.65.65 0 0 1 .001.92l-2.67 2.67a.65.65 0 0 1-.92-.92l1.561-1.56h-5.86a1.95 1.95 0 0 1-1.95-1.95V4.538L2.461 6.096a.65.65 0 1 1-.92-.918l2.664-2.67a.65.65 0 0 1 .46-.191Z" clip-rule="evenodd"/></svg>`;
diff --git a/packages/icons/src/__generated__/svg/delete.ts b/packages/icons/src/__generated__/svg/delete.ts
new file mode 100644
index 0000000000..0536270b63
--- /dev/null
+++ b/packages/icons/src/__generated__/svg/delete.ts
@@ -0,0 +1 @@
+export const DeleteIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" width="100%" height="100%" style="display: block;"><path d="M10.755 14.65h-5.51c-.5 0-.98-.19-1.35-.53-.37-.35-.59-.81-.63-1.31l-.54-7.49h-.06c-.36 0-.65-.29-.65-.65 0-.36.29-.65.65-.65h2.68V2.67c0-.35.14-.68.39-.93s.58-.39.93-.39h2.67c.35 0 .68.14.93.38.25.25.39.58.39.93v1.35h2.68c.36 0 .65.29.65.65 0 .36-.29.65-.65.65h-.06l-.54 7.49c-.03.5-.26.97-.63 1.31-.37.34-.85.53-1.35.53v.01Zm-6.72-9.33.53 7.4c.01.17.09.33.22.45s.29.18.47.18h5.52c.17 0 .34-.06.47-.18.13-.12.2-.28.22-.45l.53-7.4h-7.96Zm2.62-1.3h2.7V2.67l-2.68-.02v1.37h-.02Z"/><path d="M9.335 11.98c-.36 0-.65-.29-.65-.65v-4c0-.36.29-.65.65-.65.36 0 .65.29.65.65v4c0 .36-.29.65-.65.65Zm-2.67 0c-.36 0-.65-.29-.65-.65v-4c0-.36.29-.65.65-.65.36 0 .65.29.65.65v4c0 .36-.29.65-.65.65Z"/></svg>`;
diff --git a/packages/icons/src/__generated__/svg/dimensions.ts b/packages/icons/src/__generated__/svg/dimensions.ts
new file mode 100644
index 0000000000..dbea6b9b5a
--- /dev/null
+++ b/packages/icons/src/__generated__/svg/dimensions.ts
@@ -0,0 +1 @@
+export const DimensionsIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 17" fill="currentColor" width="100%" height="100%" style="display: block;"><path fill-rule="evenodd" d="M7.821 4.063c0 .359.292.65.65.649l2.2-.003-6.262 6.263.003-2.2a.65.65 0 0 0-1.3-.002l-.005 3.772a.65.65 0 0 0 .651.65l3.772-.004a.65.65 0 1 0-.002-1.3l-2.2.003 6.263-6.262-.003 2.2a.65.65 0 1 0 1.3 0l.005-3.77a.65.65 0 0 0-.651-.652l-3.772.005a.65.65 0 0 0-.649.65Z" clip-rule="evenodd"/></svg>`;
diff --git a/packages/icons/src/__generated__/svg/home.ts b/packages/icons/src/__generated__/svg/home.ts
new file mode 100644
index 0000000000..95e440fc14
--- /dev/null
+++ b/packages/icons/src/__generated__/svg/home.ts
@@ -0,0 +1 @@
+export const HomeIcon = `<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="M7.656.907c.225-.06.463-.06.688 0 .262.07.482.244.66.384l.05.039 4.521 3.516.052.04c.251.196.47.366.634.587.144.194.25.412.316.645.074.264.073.542.073.86V11.893c0 .352 0 .654-.02.903a2.02 2.02 0 0 1-.196.772c-.19.373-.494.677-.867.867-.25.127-.51.174-.772.196-.249.02-.551.02-.903.02H4.108c-.352 0-.654 0-.903-.02a2.021 2.021 0 0 1-.772-.196 1.983 1.983 0 0 1-.867-.867 2.02 2.02 0 0 1-.196-.772c-.02-.249-.02-.551-.02-.903V6.979c0-.319 0-.597.073-.861.065-.233.172-.451.316-.645.163-.221.383-.391.634-.587l.052-.04L6.946 1.33l.05-.04c.178-.14.398-.312.66-.383ZM6.65 13.35h2.7V9.067a5.468 5.468 0 0 0-.01-.408 5.468 5.468 0 0 0-.408-.01H7.068a5.468 5.468 0 0 0-.408.01 5.466 5.466 0 0 0-.01.408v4.283Zm4 0V9.046c0-.169 0-.332-.011-.47a1.332 1.332 0 0 0-.132-.507 1.317 1.317 0 0 0-.576-.575 1.331 1.331 0 0 0-.507-.133c-.138-.01-.301-.01-.47-.01H7.046c-.169 0-.332 0-.47.01a1.331 1.331 0 0 0-.507.133c-.248.126-.45.327-.575.575-.091.178-.12.356-.133.507-.011.138-.011.301-.011.47v4.304H4.133c-.384 0-.633 0-.822-.016-.183-.015-.252-.04-.288-.058a.683.683 0 0 1-.299-.299c-.018-.036-.043-.105-.058-.287a11.35 11.35 0 0 1-.016-.823V7.043c0-.42.006-.505.025-.575a.683.683 0 0 1 .109-.222c.043-.059.107-.116.439-.373l4.521-3.517A4.86 4.86 0 0 1 8 2.165a4.861 4.861 0 0 1 .256.191l4.521 3.517c.332.257.396.314.44.373.048.067.085.142.108.222.02.07.025.156.025.575v4.824c0 .384 0 .633-.016.823-.015.182-.04.251-.059.287a.683.683 0 0 1-.298.299c-.036.018-.105.043-.287.058-.19.016-.44.016-.823.016H10.65Z" clip-rule="evenodd"/></svg>`;
diff --git a/packages/icons/src/__generated__/svg/index.ts b/packages/icons/src/__generated__/svg/index.ts
index 9ac4b37e5c..921da7e197 100644
--- a/packages/icons/src/__generated__/svg/index.ts
+++ b/packages/icons/src/__generated__/svg/index.ts
@@ -22,6 +22,7 @@ export { AiIcon } from "./ai";
export { AlertIcon } from "./alert";
export { ArrowDownIcon } from "./arrow-down";
export { ArrowRightIcon } from "./arrow-right";
+export { AspectRatioIcon } from "./aspect-ratio";
export { AttachmentIcon } from "./attachment";
export { AutoScrollIcon } from "./auto-scroll";
export { BlockquoteIcon } from "./blockquote";
@@ -70,8 +71,10 @@ export { CustomCodeIcon } from "./custom-code";
export { DashBorderIcon } from "./dash-border";
export { DashIcon } from "./dash";
export { DashedBorderIcon } from "./dashed-border";
+export { DeleteIcon } from "./delete";
export { DescriptionIcon } from "./description";
export { DialogIcon } from "./dialog";
+export { DimensionsIcon } from "./dimensions";
export { DiscordIcon } from "./discord";
export { DivIcon } from "./div";
export { DotIcon } from "./dot";
@@ -95,6 +98,7 @@ export { HamburgerMenuIcon } from "./hamburger-menu";
export { HeaderIcon } from "./header";
export { HeadingIcon } from "./heading";
export { HelpIcon } from "./help";
+export { HomeIcon } from "./home";
export { ImageIcon } from "./image";
export { InfoIcon } from "./info";
export { InformationIcon } from "./information";
diff --git a/packages/icons/src/aspect-ratio.tsx b/packages/icons/src/aspect-ratio.tsx
deleted file mode 100644
index cd91063786..0000000000
--- a/packages/icons/src/aspect-ratio.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import * as React from "react";
-import type { IconProps } from "./types";
-
-export const AspectRatioIcon = React.forwardRef<SVGSVGElement, IconProps>(
- ({ color = "currentColor", ...props }, forwardedRef) => {
- return (
- <svg
- width={16}
- height={16}
- viewBox="0 0 16 16"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- {...props}
- ref={forwardedRef}
- >
- <path
- d="M10.85 10.503a.625.625 0 100-1.25v1.25zM4.975 3.378a.625.625 0 10-1.25 0h1.25zm-.072 6.394l.275-.561-.275.561zm-.443-.426l.552-.292-.552.292zm6.39-.093H5.972v1.25h4.878v-1.25zM4.975 8.32V3.38h-1.25v4.94h1.25zm.997.934c-.294 0-.478 0-.617-.01a.524.524 0 01-.177-.032l-.55 1.123c.21.102.423.138.63.154.198.016.44.015.714.015v-1.25zM3.725 8.32c0 .262 0 .498.016.693.017.203.056.418.167.627l1.104-.585c0-.001-.004-.008-.009-.028a.803.803 0 01-.017-.12 7.858 7.858 0 01-.011-.587h-1.25zm1.453.892a.37.37 0 01-.166-.157l-1.104.585c.16.303.414.545.72.695l.55-1.123z"
- fill={color}
- />
- <path
- fillRule="evenodd"
- clipRule="evenodd"
- d="M4.349 6.067c.345 0 .625-.28.625-.625V3.466l1.428 1.429a.625.625 0 10.884-.884L4.791 1.515a.625.625 0 00-.884 0L1.412 4.011a.625.625 0 10.884.884l1.428-1.429v1.976c0 .345.28.625.625.625zM7.769 9.878c0 .345.28.625.625.625h1.975l-1.428 1.429a.625.625 0 10.884.883l2.495-2.495a.625.625 0 000-.883L9.825 6.94a.625.625 0 10-.884.884l1.428 1.428H8.394a.625.625 0 00-.625.625z"
- fill={color}
- />
- </svg>
- );
- }
-);
-
-AspectRatioIcon.displayName = "AspectRatioIcon";
diff --git a/packages/icons/src/index.ts b/packages/icons/src/index.ts
index 3fb8a1030d..e0ec25f624 100644
--- a/packages/icons/src/index.ts
+++ b/packages/icons/src/index.ts
@@ -9,7 +9,6 @@ export * from "./justify-items-end";
export * from "./justify-items-space-around";
export * from "./justify-items-space-between";
export * from "./justify-items-start";
-export * from "./aspect-ratio";
export * from "./cloud";
export * from "./trash";
export * from "./size";
diff --git a/packages/image/src/image.tsx b/packages/image/src/image.tsx
index fe92ba02cd..5f0dcd037d 100644
--- a/packages/image/src/image.tsx
+++ b/packages/image/src/image.tsx
@@ -52,19 +52,19 @@ const imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
- <rect width="600" height="600" fill="#CCCCCC" />
+ <rect width="600" height="600" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M450 170H150C141.716 170 135 176.716 135 185V415C135 423.284 141.716 430 150 430H450C458.284 430 465 423.284 465 415V185C465 176.716 458.284 170 450 170ZM150 145C127.909 145 110 162.909 110 185V415C110 437.091 127.909 455 150 455H450C472.091 455 490 437.091 490 415V185C490 162.909 472.091 145 450 145H150Z"
- fill="#A2A2A2"
+ fill="#C1C8CD"
/>
<path
d="M237.135 235.012C237.135 255.723 220.345 272.512 199.635 272.512C178.924 272.512 162.135 255.723 162.135 235.012C162.135 214.301 178.924 197.512 199.635 197.512C220.345 197.512 237.135 214.301 237.135 235.012Z"
- fill="#A2A2A2"
+ fill="#C1C8CD"
/>
<path
d="M160 405V367.205L221.609 306.364L256.552 338.628L358.161 234L440 316.043V405H160Z"
- fill="#A2A2A2"
+ fill="#C1C8CD"
/>
</svg>`)}`;
diff --git a/packages/project-build/src/db/build.ts b/packages/project-build/src/db/build.ts
index c83620c02a..8223c137eb 100644
--- a/packages/project-build/src/db/build.ts
+++ b/packages/project-build/src/db/build.ts
@@ -132,6 +132,7 @@ export const createBuild = async (
const [rootInstanceId] = newInstances[0];
const newPages = Pages.parse({
+ meta: {},
homePage: {
id: nanoid(),
name: "Home",
diff --git a/packages/project-build/src/shared/pages-utils.test.ts b/packages/project-build/src/shared/pages-utils.test.ts
index 6f0ec1c212..41a0c97abd 100644
--- a/packages/project-build/src/shared/pages-utils.test.ts
+++ b/packages/project-build/src/shared/pages-utils.test.ts
@@ -1,8 +1,9 @@
import { describe, test, expect } from "@jest/globals";
-import type { Page } from "@webstudio-is/sdk";
+import type { Page, Pages } from "@webstudio-is/sdk";
import { findPageByIdOrPath } from "./pages-utils";
const pages = {
+ meta: {},
homePage: {
id: "home",
path: "/",
@@ -21,7 +22,7 @@ const pages = {
meta: {},
} satisfies Page,
],
-};
+} satisfies Pages;
describe("Find by id or path", () => {
test("home page by id", () => {
diff --git a/packages/react-sdk/src/generator.test.ts b/packages/react-sdk/src/generator.test.ts
index 4366572925..034b5eb1cb 100644
--- a/packages/react-sdk/src/generator.test.ts
+++ b/packages/react-sdk/src/generator.test.ts
@@ -14,6 +14,7 @@ test("generates forms properties", () => {
expect(
generateUtilsExport({
pages: {
+ meta: {},
homePage: createPage("1"),
pages: [],
},
@@ -65,6 +66,7 @@ test("generates list of pages paths", () => {
expect(
generateUtilsExport({
pages: {
+ meta: {},
homePage: createPage("/path1"),
pages: [createPage("/path2"), createPage("/path3")],
},
diff --git a/packages/sdk/src/schema/pages.ts b/packages/sdk/src/schema/pages.ts
index d03deb02c4..df3f16c975 100644
--- a/packages/sdk/src/schema/pages.ts
+++ b/packages/sdk/src/schema/pages.ts
@@ -17,7 +17,12 @@ const commonPageFields = {
id: z.string(),
name: PageName,
title: PageTitle,
- meta: z.record(z.string(), z.string()),
+ meta: z.object({
+ description: z.string().optional(),
+ title: z.string().optional(),
+ excludePageFromSearch: z.boolean().optional(),
+ socialImageAssetId: z.string().optional(),
+ }),
rootInstanceId: z.string(),
} as const;
@@ -68,18 +73,25 @@ const Page = z.object({
path: PagePath,
});
+const SiteMeta = z
+ .object({
+ siteName: z.string().optional(),
+ faviconAssetId: z.string().optional(),
+ code: z.string().optional(),
+ })
+ .default({});
+
export type Page = z.infer<typeof Page>;
-export const Pages: z.ZodType<{ homePage: Page; pages: Array<Page> }> =
- z.object({
- homePage: HomePage,
- pages: z
- .array(Page)
- .refine(
- (array) =>
- new Set(array.map((page) => page.path)).size === array.length,
- "All paths must be unique"
- ),
- });
+export const Pages = z.object({
+ meta: SiteMeta,
+ homePage: HomePage,
+ pages: z
+ .array(Page)
+ .refine(
+ (array) => new Set(array.map((page) => page.path)).size === array.length,
+ "All paths must be unique"
+ ),
+});
export type Pages = z.infer<typeof Pages>;