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.

start

Sara Vieira6e37ef402d0b
diff --git a/apps/designer/app/designer/designer.tsx b/apps/designer/app/designer/designer.tsx
index 43b14a34b8..ecdb0f61a5 100644
--- a/apps/designer/app/designer/designer.tsx
+++ b/apps/designer/app/designer/designer.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useState } from "react";
+import { useCallback, useEffect, useState } from "react";
import { DndProvider } from "react-dnd";
import { TouchBackend } from "react-dnd-touch-backend";
import { useSubscribe, usePublish } from "@webstudio-is/react-sdk";
@@ -34,6 +34,14 @@ import { usePublishShortcuts } from "./shared/shortcuts";
import { type SyncStatus } from "~/shared/sync";
import { useIsPreviewMode, useRootInstance } from "~/shared/nano-states";
import { useSubscribeClientSetting } from "./shared/client-settings";
+import toast from "react-hot-toast/headless";
+import {
+ AngleIcon,
+ CheckIcon,
+ Cross1Icon,
+ ExclamationTriangleIcon,
+ TriangleDownIcon,
+} from "@radix-ui/react-icons";
export const links = () => {
return [
@@ -199,6 +207,18 @@ export const Designer = ({ config, project, assets }: DesignerProps) => {
[publishRef, onRefReadCanvasWidth, onRefReadCanvas]
);
+ useEffect(() => {
+ window.setTimeout(() => {
+ toast.success("Hiiiii, I am a success toast");
+ }, 2500);
+ window.setTimeout(() => {
+ toast.error("Hi am an error");
+ }, 3000);
+ window.setTimeout(() => {
+ toast("Hi I am a message");
+ }, 3500);
+ }, []);
+
return (
<DndProvider backend={TouchBackend} options={dndOptions}>
<ChromeWrapper isPreviewMode={isPreviewMode}>
@@ -208,6 +228,7 @@ export const Designer = ({ config, project, assets }: DesignerProps) => {
project={project}
publish={publish}
/>
+
<Main>
<Workspace onTransitionEnd={onTransitionEnd} publish={publish}>
<CanvasIframe
diff --git a/apps/designer/app/designer/features/workspace/workspace.tsx b/apps/designer/app/designer/features/workspace/workspace.tsx
index 916e0f0332..661e1d83c3 100644
--- a/apps/designer/app/designer/features/workspace/workspace.tsx
+++ b/apps/designer/app/designer/features/workspace/workspace.tsx
@@ -1,3 +1,4 @@
+import { Notifications } from "~/shared/design-system/components/toast";
import { Box, Flex } from "~/shared/design-system";
import { useCanvasWidth, useZoom } from "~/designer/shared/nano-states";
import { CanvasTools } from "./canvas-tools";
@@ -9,6 +10,7 @@ const workspaceStyle = {
// scroll behaviour should be derived from the iframe
overflow: "hidden",
scrollbarGutter: "stable",
+ position: "relative",
};
const zoomStyle = {
@@ -55,6 +57,7 @@ export const Workspace = ({
<CanvasTools publish={publish} />
</Box>
</Flex>
+ <Notifications />
</Box>
);
};
diff --git a/apps/designer/app/shared/design-system/components/toast.tsx b/apps/designer/app/shared/design-system/components/toast.tsx
new file mode 100644
index 0000000000..2c93de273c
--- /dev/null
+++ b/apps/designer/app/shared/design-system/components/toast.tsx
@@ -0,0 +1,115 @@
+import { styled } from "@stitches/react";
+import { slate } from "@radix-ui/colors";
+import * as ToastPrimitive from "@radix-ui/react-toast";
+import { useToaster } from "react-hot-toast/headless";
+import { keyframes } from "../stitches.config";
+import { CheckIcon, Cross1Icon } from "@radix-ui/react-icons";
+
+const VIEWPORT_PADDING = 10;
+
+const hide = keyframes({
+ "0%": { opacity: 1 },
+ "100%": { opacity: 0 },
+});
+
+const slideIn = keyframes({
+ from: { transform: `translateY(calc(0px - ${VIEWPORT_PADDING}px))` },
+ to: { transform: "translateY(0)" },
+});
+
+const swipeOut = keyframes({
+ from: { transform: "translateX(var(--radix-toast-swipe-end-x))" },
+ to: { transform: `translateX(calc(100% + ${VIEWPORT_PADDING}px))` },
+});
+
+const StyledViewport = styled(ToastPrimitive.Viewport, {
+ position: "absolute",
+ top: 0,
+ right: 0,
+ display: "flex",
+ flexDirection: "column",
+ padding: VIEWPORT_PADDING,
+ gap: VIEWPORT_PADDING,
+ minWidth: 200,
+ width: "auto",
+ maxWidth: "100vw",
+ margin: 0,
+ listStyle: "none",
+ zIndex: 2147483649,
+ outline: "none",
+});
+
+const StyledToast = styled(ToastPrimitive.Root, {
+ borderRadius: 6,
+ boxShadow:
+ "hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
+ padding: 15,
+ display: "flex",
+ gap: 15,
+ alignItems: "center",
+ color: slate.slate12,
+ fontWeight: 500,
+ fontSize: 15,
+
+ "@media (prefers-reduced-motion: no-preference)": {
+ '&[data-state="open"]': {
+ animation: `${slideIn} 250ms cubic-bezier(0.16, 1, 0.3, 1)`,
+ },
+ '&[data-state="closed"]': {
+ animation: `${hide} 100ms ease-in`,
+ },
+ '&[data-swipe="move"]': {
+ transform: "translateX(var(--radix-toast-swipe-move-x))",
+ },
+ '&[data-swipe="cancel"]': {
+ transform: "translateX(0)",
+ transition: "transform 200ms ease-out",
+ },
+ '&[data-swipe="end"]': {
+ animation: `${swipeOut} 100ms ease-out`,
+ },
+ },
+ variants: {
+ variant: {
+ error: {
+ backgroundColor: "red",
+ color: "white",
+ },
+ success: {
+ backgroundColor: "green",
+ },
+ blank: {
+ background: "white",
+ },
+ custom: {},
+ loading: {},
+ },
+ },
+});
+
+const StyledTitle = styled(ToastPrimitive.Title, {
+ marginBottom: 5,
+});
+
+export const Notifications = () => {
+ const { toasts, handlers } = useToaster();
+ const { startPause, endPause } = handlers;
+
+ return (
+ <ToastPrimitive.ToastProvider>
+ {toasts.map((toast) => (
+ <StyledToast
+ variant={toast.type}
+ key={toast.id}
+ onMouseEnter={startPause}
+ onMouseLeave={endPause}
+ >
+ {toast.type === "success" && <CheckIcon />}
+ {toast.type === "error" && <Cross1Icon />}
+ <StyledTitle>{toast.message}</StyledTitle>
+ </StyledToast>
+ ))}
+ <StyledViewport />
+ </ToastPrimitive.ToastProvider>
+ );
+};
diff --git a/apps/designer/package.json b/apps/designer/package.json
index 928940c399..3669f44eeb 100644
--- a/apps/designer/package.json
+++ b/apps/designer/package.json
@@ -41,6 +41,7 @@
"@radix-ui/react-slider": "^0.1.4",
"@radix-ui/react-switch": "^0.1.5",
"@radix-ui/react-tabs": "^0.1.5",
+ "@radix-ui/react-toast": "^1.0.0",
"@radix-ui/react-toggle": "^0.1.4",
"@radix-ui/react-toggle-group": "^0.1.5",
"@radix-ui/react-tooltip": "^0.1.7",
@@ -54,8 +55,8 @@
"@stitches/react": "^1.2.7",
"@vercel/node": "^2.4.1",
"@webstudio-is/asset-uploader": "*",
- "@webstudio-is/react-sdk": "*",
"@webstudio-is/prisma-client": "*",
+ "@webstudio-is/react-sdk": "*",
"bson-objectid": "^2.0.2",
"camelcase": "^6.3.0",
"debug": "^4.3.4",
@@ -80,6 +81,7 @@
"react-dnd-touch-backend": "^15.1.1",
"react-dom": "^17.0.2",
"react-error-boundary": "^3.1.4",
+ "react-hot-toast": "^2.3.0",
"react-hotkeys-hook": "^3.4.4",
"react-nano-state": "^0.4.0",
"react-router-dom": "^6.2.2",
diff --git a/yarn.lock b/yarn.lock
index f89a7fbd79..3538589f7e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2752,6 +2752,13 @@
dependencies:
"@babel/runtime" "^7.13.10"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/primitive/-/primitive-1.0.0.tgz#e1d8ef30b10ea10e69c76e896f608d9276352253"
+ integrity sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+
"@radix-ui/react-accessible-icon@^0.1.4":
version "0.1.4"
resolved "https://registry.yarnpkg.com/@radix-ui/react-accessible-icon/-/react-accessible-icon-0.1.4.tgz#bdbf1e3226a0e9e7778b68728b175bdc532b720c"
@@ -2857,6 +2864,17 @@
"@radix-ui/react-primitive" "0.1.4"
"@radix-ui/react-slot" "0.1.2"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-collection/-/react-collection-1.0.0.tgz#0ec4c72fabd35a03b5787075ac799e3b17ca5710"
+ integrity sha512-8i1pf5dKjnq90Z8udnnXKzdCEV3/FYrfw0n/b6NvB6piXEn3fO1bOh7HBcpG8XrnIXzxlYu2oCcR38QpyLS/mg==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-compose-refs" "1.0.0"
+ "@radix-ui/react-context" "1.0.0"
+ "@radix-ui/react-primitive" "1.0.0"
+ "@radix-ui/react-slot" "1.0.0"
+
"@radix-ui/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-0.1.0.tgz#cff6e780a0f73778b976acff2c2a5b6551caab95"
@@ -2931,6 +2949,18 @@
"@radix-ui/react-use-callback-ref" "0.1.0"
"@radix-ui/react-use-escape-keydown" "0.1.0"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.0.0.tgz#35b7826fa262fd84370faef310e627161dffa76b"
+ integrity sha512-n7kDRfx+LB1zLueRDvZ1Pd0bxdJWDUZNQ/GWoxDn2prnuJKRdxsjulejX/ePkOsLi2tTm6P24mDqlMSgQpsT6g==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/primitive" "1.0.0"
+ "@radix-ui/react-compose-refs" "1.0.0"
+ "@radix-ui/react-primitive" "1.0.0"
+ "@radix-ui/react-use-callback-ref" "1.0.0"
+ "@radix-ui/react-use-escape-keydown" "1.0.0"
+
"@radix-ui/react-dropdown-menu@^0.1.6":
version "0.1.6"
resolved "https://registry.yarnpkg.com/@radix-ui/react-dropdown-menu/-/react-dropdown-menu-0.1.6.tgz#3203229788cd57e552c9f19dcc7008e2b545919c"
@@ -3071,6 +3101,14 @@
"@radix-ui/react-primitive" "0.1.4"
"@radix-ui/react-use-layout-effect" "0.1.0"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-portal/-/react-portal-1.0.0.tgz#7220b66743394fabb50c55cb32381395cc4a276b"
+ integrity sha512-a8qyFO/Xb99d8wQdu4o7qnigNjTPG123uADNecz0eX4usnQEj7o+cG4ZX4zkqq98NYekT7UoEQIjxBNWIFuqTA==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-primitive" "1.0.0"
+
"@radix-ui/[email protected]":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@radix-ui/react-presence/-/react-presence-0.1.2.tgz#9f11cce3df73cf65bc348e8b76d891f0d54c1fe3"
@@ -3080,6 +3118,15 @@
"@radix-ui/react-compose-refs" "0.1.0"
"@radix-ui/react-use-layout-effect" "0.1.0"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-presence/-/react-presence-1.0.0.tgz#814fe46df11f9a468808a6010e3f3ca7e0b2e84a"
+ integrity sha512-A+6XEvN01NfVWiKu38ybawfHsBjWum42MRPnEuqPsBZ4eV7e/7K321B5VgYMPv3Xx5An6o1/l9ZuDBgmcmWK3w==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-compose-refs" "1.0.0"
+ "@radix-ui/react-use-layout-effect" "1.0.0"
+
"@radix-ui/[email protected]":
version "0.1.4"
resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-0.1.4.tgz#6c233cf08b0cb87fecd107e9efecb3f21861edc1"
@@ -3232,6 +3279,25 @@
"@radix-ui/react-roving-focus" "0.1.5"
"@radix-ui/react-use-controllable-state" "0.1.0"
+"@radix-ui/react-toast@^1.0.0":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-toast/-/react-toast-1.0.0.tgz#0d808e7f13376ddc74c0dbb7a4ff1c0602778ae2"
+ integrity sha512-mdoF6rahgushdev0OX+9a7JKoH0xZAZBo2Ktf/s779S7EnkZeL3/MFiRIV5LpRP5CtASmfdSD3FLnEvG1RHRtQ==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/primitive" "1.0.0"
+ "@radix-ui/react-collection" "1.0.0"
+ "@radix-ui/react-compose-refs" "1.0.0"
+ "@radix-ui/react-context" "1.0.0"
+ "@radix-ui/react-dismissable-layer" "1.0.0"
+ "@radix-ui/react-portal" "1.0.0"
+ "@radix-ui/react-presence" "1.0.0"
+ "@radix-ui/react-primitive" "1.0.0"
+ "@radix-ui/react-use-callback-ref" "1.0.0"
+ "@radix-ui/react-use-controllable-state" "1.0.0"
+ "@radix-ui/react-use-layout-effect" "1.0.0"
+ "@radix-ui/react-visually-hidden" "1.0.0"
+
"@radix-ui/react-toggle-group@^0.1.5":
version "0.1.5"
resolved "https://registry.yarnpkg.com/@radix-ui/react-toggle-group/-/react-toggle-group-0.1.5.tgz#9e4d65e22c4fc0ba3a42fbc8d5496c430e5e9852"
@@ -3291,6 +3357,13 @@
dependencies:
"@babel/runtime" "^7.13.10"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.0.tgz#9e7b8b6b4946fe3cbe8f748c82a2cce54e7b6a90"
+ integrity sha512-GZtyzoHz95Rhs6S63D2t/eqvdFCm7I+yHMLVQheKM7nBD8mbZIt+ct1jz4536MDnaOGKIxynJ8eHTkVGVVkoTg==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+
"@radix-ui/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-0.1.0.tgz#4fced164acfc69a4e34fb9d193afdab973a55de1"
@@ -3299,6 +3372,14 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-use-callback-ref" "0.1.0"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.0.0.tgz#a64deaafbbc52d5d407afaa22d493d687c538b7f"
+ integrity sha512-FohDoZvk3mEXh9AWAVyRTYR4Sq7/gavuofglmiXB2g1aKyboUD4YtgWxKj8O5n+Uak52gXQ4wKz5IFST4vtJHg==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-use-callback-ref" "1.0.0"
+
"@radix-ui/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-direction/-/react-use-direction-0.1.0.tgz#97ac1d52e497c974389e7988f809238ed72e7df7"
@@ -3314,6 +3395,14 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-use-callback-ref" "0.1.0"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-use-escape-keydown/-/react-use-escape-keydown-1.0.0.tgz#aef375db4736b9de38a5a679f6f49b45a060e5d1"
+ integrity sha512-JwfBCUIfhXRxKExgIqGa4CQsiMemo1Xt0W/B4ei3fpzpvPENKpMKQ8mZSB6Acj3ebrAEgi2xiQvcI1PAAodvyg==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-use-callback-ref" "1.0.0"
+
"@radix-ui/[email protected]", "@radix-ui/react-use-layout-effect@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-0.1.0.tgz#ebf71bd6d2825de8f1fbb984abf2293823f0f223"
@@ -3374,6 +3463,14 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-primitive" "0.1.4"
+"@radix-ui/[email protected]":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-visually-hidden/-/react-visually-hidden-1.0.0.tgz#4d69d7e3b6d21ee4678ed6de5215dcd068394401"
+ integrity sha512-MwAhMdX+n6S4InwRKSnpUsp+lLkYG6izQF56ul6guSX2mBBLOMV9Frx7xJlkEe2GjKLzbNuHhaCS6e5gopmZNA==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-primitive" "1.0.0"
+
"@radix-ui/[email protected]":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-0.1.1.tgz#95b5ba51f469bea6b1b841e2d427e17e37d38419"
@@ -10050,6 +10147,11 @@ globby@^9.2.0:
pify "^4.0.1"
slash "^2.0.0"
+goober@^2.1.10:
+ version "2.1.10"
+ resolved "https://registry.yarnpkg.com/goober/-/goober-2.1.10.tgz#058def43ba1e3b06f973dbb372a4978aa42f1049"
+ integrity sha512-7PpuQMH10jaTWm33sQgBQvz45pHR8N4l3Cu3WMGEWmHShAcTuuP7I+5/DwKo39fwti5A80WAjvqgz6SSlgWmGA==
+
got@^11.0.0:
version "11.8.5"
resolved "https://registry.yarnpkg.com/got/-/got-11.8.5.tgz#ce77d045136de56e8f024bebb82ea349bc730046"
@@ -14624,6 +14726,13 @@ react-error-boundary@^3.1.0, react-error-boundary@^3.1.4:
dependencies:
"@babel/runtime" "^7.12.5"
+react-hot-toast@^2.3.0:
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/react-hot-toast/-/react-hot-toast-2.3.0.tgz#70b3d183ac2a4afb6b17cda4a7f4cfe02e730415"
+ integrity sha512-/RxV+bfjld7tSJR1SCLzMAXgFuNW7fCpK6+vbYqfmbGSWcqTMz2rizrvfWKvtcPH5HK0NqxmBaC5SrAy1F42zA==
+ dependencies:
+ goober "^2.1.10"
+
react-hotkeys-hook@^3.4.4:
version "3.4.6"
resolved "https://registry.yarnpkg.com/react-hotkeys-hook/-/react-hotkeys-hook-3.4.6.tgz#21eda8e97121583a14056479e3eea9e51d2e2a69"