-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fullscreen-preview
- Loading branch information
Showing
226 changed files
with
3,461 additions
and
3,896 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { z } from "zod"; | ||
import { useId, useState } from "react"; | ||
import { useStore } from "@nanostores/react"; | ||
import { | ||
Grid, | ||
|
@@ -10,16 +12,21 @@ import { | |
CheckboxAndLabel, | ||
Checkbox, | ||
css, | ||
Flex, | ||
Tooltip, | ||
InputErrorsTooltip, | ||
ProBadge, | ||
} from "@webstudio-is/design-system"; | ||
import { InfoCircleIcon } from "@webstudio-is/icons"; | ||
import { ImageControl } from "./image-control"; | ||
import { $assets, $imageLoader, $pages } from "~/shared/nano-states"; | ||
import { Image } from "@webstudio-is/image"; | ||
import { useIds } from "~/shared/form-utils"; | ||
import type { ProjectMeta, CompilerSettings } from "@webstudio-is/sdk"; | ||
import { useState } from "react"; | ||
import { $assets, $imageLoader, $pages } from "~/shared/nano-states"; | ||
import { useIds } from "~/shared/form-utils"; | ||
import { serverSyncStore } from "~/shared/sync"; | ||
import { sectionSpacing } from "./utils"; | ||
import { CodeEditor } from "~/builder/shared/code-editor"; | ||
import { $userPlanFeatures } from "~/builder/shared/nano-states"; | ||
|
||
const imgStyle = css({ | ||
width: 72, | ||
|
@@ -32,15 +39,25 @@ const imgStyle = css({ | |
|
||
const defaultMetaSettings: ProjectMeta = { | ||
siteName: "", | ||
contactEmail: "", | ||
faviconAssetId: "", | ||
code: "", | ||
}; | ||
|
||
const Email = z.string().email(); | ||
|
||
export const SectionGeneral = () => { | ||
const { allowContactEmail } = useStore($userPlanFeatures); | ||
const [meta, setMeta] = useState( | ||
() => $pages.get()?.meta ?? defaultMetaSettings | ||
); | ||
const ids = useIds(["siteName"]); | ||
const siteNameId = useId(); | ||
const contactEmailId = useId(); | ||
const contactEmailError = | ||
(meta.contactEmail ?? "").trim().length === 0 || | ||
Email.safeParse(meta.contactEmail).success | ||
? undefined | ||
: "Contact email is invalid."; | ||
const assets = useStore($assets); | ||
const asset = assets.get(meta.faviconAssetId ?? ""); | ||
const favIconUrl = asset ? `${asset.name}` : undefined; | ||
|
@@ -65,21 +82,59 @@ export const SectionGeneral = () => { | |
}; | ||
|
||
return ( | ||
<> | ||
<Grid gap={2}> | ||
<Text variant="titles" css={sectionSpacing}> | ||
General | ||
</Text> | ||
|
||
<Grid gap={1} css={sectionSpacing}> | ||
<Text variant="titles">General</Text> | ||
<Label htmlFor={ids.siteName}>Site Name</Label> | ||
<Flex gap={1} align="center"> | ||
<Label htmlFor={siteNameId}>Site Name</Label> | ||
<Tooltip | ||
variant="wrapped" | ||
content="Used in search results and social previews." | ||
> | ||
<InfoCircleIcon tabIndex={0} /> | ||
</Tooltip> | ||
</Flex> | ||
<InputField | ||
id={ids.siteName} | ||
id={siteNameId} | ||
placeholder="Current Site Name" | ||
autoFocus={true} | ||
value={meta.siteName ?? ""} | ||
onChange={(event) => { | ||
handleSave("siteName")(event.target.value); | ||
}} | ||
placeholder="Current Site Name" | ||
autoFocus | ||
/> | ||
</Grid> | ||
|
||
<Grid gap={1} css={sectionSpacing}> | ||
<Flex gap={1} align="center"> | ||
<Label htmlFor={contactEmailId}>Contact Email</Label> | ||
<Tooltip | ||
variant="wrapped" | ||
content="Used as the email recipient when submitting a webhook form without an action." | ||
> | ||
<InfoCircleIcon tabIndex={0} /> | ||
</Tooltip> | ||
{allowContactEmail === false && <ProBadge>Pro</ProBadge>} | ||
</Flex> | ||
<InputErrorsTooltip | ||
errors={contactEmailError ? [contactEmailError] : undefined} | ||
> | ||
<InputField | ||
id={contactEmailId} | ||
color={contactEmailError ? "error" : undefined} | ||
placeholder="[email protected]" | ||
disabled={allowContactEmail === false} | ||
value={meta.contactEmail ?? ""} | ||
onChange={(event) => { | ||
handleSave("contactEmail")(event.target.value); | ||
}} | ||
/> | ||
</InputErrorsTooltip> | ||
</Grid> | ||
|
||
<Separator /> | ||
|
||
<Grid gap={2} css={sectionSpacing}> | ||
|
@@ -118,7 +173,7 @@ export const SectionGeneral = () => { | |
<Separator /> | ||
|
||
<CompilerSection /> | ||
</> | ||
</Grid> | ||
); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.