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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
feat: Toasts redesign (#3662)
Ivan Starkov228122f087ea
diff --git a/apps/builder/app/builder/shared/assets/use-assets.tsx b/apps/builder/app/builder/shared/assets/use-assets.tsxindex 574b7b3632..cbbd6de89f 100644--- a/apps/builder/app/builder/shared/assets/use-assets.tsx+++ b/apps/builder/app/builder/shared/assets/use-assets.tsx@@ -3,7 +3,7 @@ import { useStore } from "@nanostores/react";import warnOnce from "warn-once";import type { Asset } from "@webstudio-is/sdk";import type { AssetType } from "@webstudio-is/asset-uploader";-import { Box, Grid, toast, Text } from "@webstudio-is/design-system";+import { Box, toast, css, theme } from "@webstudio-is/design-system";import { sanitizeS3Key } from "@webstudio-is/asset-uploader";import { restAssetsUploadPath, restAssetsPath } from "~/shared/router-utils";import type {@@ -29,8 +29,9 @@ import {getSha256HashOfFile,uploadingFileDataToAsset,} from "./asset-utils";-import { Image } from "../image-manager/image";+import { Image } from "@webstudio-is/image";import invariant from "tiny-invariant";+import { $imageLoader } from "~/shared/nano-states";export const deleteAssets = (assetIds: Asset["id"][]) => {serverSyncStore.createTransaction([$assets], (assets) => {@@ -238,43 +239,23 @@ const handleAfterSubmit = (safeSetAsset({ ...uploadedAsset, id: assetId }, projectId);};-const ToastMessage = ({- assetId,- objectURL,- children,- title,-}: {- assetId: string;- objectURL: string;- children: string;- title: string;-}) => {+const imageWidth = css({+ maxWidth: "100%",+});++const ToastImageInfo = ({ objectURL }: { objectURL: string }) => {+ const imageLoader = useStore($imageLoader);+return (- <Grid- css={{- gridTemplateColumns: "20% 1fr",- }}- gap={2}- >+ <Box css={{ width: theme.spacing[18] }}><Image- alt={children}- objectURL={objectURL}- name={""}- assetId={assetId}+ className={imageWidth()}+ src={objectURL}+ optimize={false}width={64}+ loader={imageLoader}/>- <Grid>- <Text variant={"titles"}>{title}</Text>- <Box- css={{- whiteSpace: "pre-wrap",- wordBreak: "break-word",- }}- >- {children}- </Box>- </Grid>- </Grid>+ </Box>);};@@ -309,15 +290,9 @@ const processUpload = async (const assetId = fileData.assetId;if ($assets.get().has(assetId)) {- toast.warn(- <ToastMessage- title="Info"- assetId={assetId}- objectURL={fileData.objectURL}- >- Asset already exists- </ToastMessage>- );+ toast.info("Asset already exists", {+ icon: <ToastImageInfo objectURL={fileData.objectURL} />,+ });deleteUploadingFileData(assetId);continue;@@ -335,15 +310,9 @@ const processUpload = async (},onError: (error) => {deleteUploadingFileData(assetId);- toast.error(- <ToastMessage- title="Error"- assetId={assetId}- objectURL={fileData.objectURL}- >- {error}- </ToastMessage>- );+ toast.error(error, {+ icon: <ToastImageInfo objectURL={fileData.objectURL} />,+ });safeDeleteAssets([assetId], projectId);},@@ -393,16 +362,9 @@ export async function uploadAssets(if (uniqFilesDataMap.has(existingAssetId)) {const fileData = uniqFilesDataMap.get(existingAssetId)!;uniqFilesDataMap.delete(existingAssetId);-- toast.warn(- <ToastMessage- title="Info"- assetId={fileData.assetId}- objectURL={fileData.objectURL}- >- Asset already exists- </ToastMessage>- );+ toast.info("Asset already exists", {+ icon: <ToastImageInfo objectURL={fileData.objectURL} />,+ });}}diff --git a/packages/design-system/package.json b/packages/design-system/package.jsonindex 772bda23ad..e7724b64ba 100644--- a/packages/design-system/package.json+++ b/packages/design-system/package.json@@ -17,6 +17,7 @@"@types/react-dom": "^18.2.25","@webstudio-is/jest-config": "workspace:*","@webstudio-is/tsconfig": "workspace:*",+ "@webstudio-is/image": "workspace:*","react": "18.3.0-canary-14898b6a9-20240318","react-dom": "18.3.0-canary-14898b6a9-20240318","typescript": "5.5.2",diff --git a/packages/design-system/src/components/toast.stories.tsx b/packages/design-system/src/components/toast.stories.tsxnew file mode 100644index 0000000000..83f9baa037--- /dev/null+++ b/packages/design-system/src/components/toast.stories.tsx@@ -0,0 +1,214 @@+import { Toast, Toaster, toast } from "./toast";+import { StorySection, StoryGrid } from "./storybook";+import { Button } from "./button";+import { Image } from "@webstudio-is/image";+import { Box } from "./box";+import { css, theme } from "../stitches.config";+import { AlertCircleIcon } from "@webstudio-is/icons";++export default {+ title: "Library/Toast",+};++const svgString = `+<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"+ width="800px" height="800px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">+<g>+ <path fill="#231F20" d="M60,0H4C1.789,0,0,1.789,0,4v56c0,2.211,1.789,4,4,4h56c2.211,0,4-1.789,4-4V4C64,1.789,62.211,0,60,0z+ M62,60c0,1.104-0.896,2-2,2H4c-1.104,0-2-0.896-2-2v-2.801l14.603-14.603c0.781-0.781,2.047-0.781,2.828,0+ c0,0,6.197,6.198,7.15,7.15c0.953,0.953,1.88,0.95,2.829,0s17.171-17.171,17.171-17.171c0.781-0.781,2.047-0.781,2.828,0L62,45.167+ V60z M62,42.338L50.823,31.161c-1.563-1.563-4.093-1.563-5.656,0L27.996,48.332l-7.151-7.15c-1.563-1.563-4.093-1.563-5.656,0+ L2,54.37V4c0-1.104,0.896-2,2-2h56c1.104,0,2,0.896,2,2V42.338z"/>+ <path fill="#231F20" d="M28.999,17h-2.998c-0.024,0-0.044,0.012-0.068,0.014c-0.181-1.469-0.76-2.812-1.626-3.924+ c0.018-0.016,0.041-0.021,0.059-0.039l2.121-2.121c0.392-0.391,0.391-1.023,0-1.414c-0.392-0.391-1.023-0.391-1.416,0l-2.12,2.12+ c-0.018,0.018-0.023,0.04-0.039,0.059c-1.111-0.867-2.454-1.446-3.924-1.627c0.002-0.022,0.014-0.044,0.014-0.067l0.001-3+ c0-0.553-0.449-1-1-1C17.448,6.001,17.001,6.447,17,7.002V10c0,0.023,0.012,0.045,0.014,0.067c-1.47,0.181-2.813,0.76-3.925,1.626+ c-0.016-0.018-0.021-0.041-0.038-0.058L10.93,9.515c-0.391-0.392-1.023-0.391-1.414,0c-0.391,0.392-0.392,1.023,0,1.415+ l2.121,2.121c0.017,0.017,0.04,0.022,0.058,0.038c-0.867,1.111-1.446,2.456-1.627,3.925C10.044,17.012,10.023,17,10,17H7+ c-0.553,0-1,0.447-1,1s0.447,1,1,1h3c0.023,0,0.044-0.012,0.067-0.014c0.181,1.47,0.76,2.813,1.627,3.925+ c-0.019,0.016-0.041,0.021-0.059,0.039l-2.121,2.12c-0.392,0.392-0.392,1.025,0,1.414c0.392,0.393,1.022,0.391,1.416,0.002+ l2.12-2.121c0.018-0.018,0.023-0.041,0.039-0.059c1.111,0.866,2.454,1.445,3.924,1.626C17.012,25.957,17,25.977,17,26.002+ L16.999,29c0,0.554,0.448,1.002,1,1c0.554,0,1-0.447,1.003-1l-0.001-2.998c0-0.025-0.012-0.045-0.014-0.069+ c1.469-0.181,2.812-0.76,3.924-1.627c0.016,0.019,0.021,0.042,0.039,0.06l2.12,2.121c0.392,0.393,1.025,0.391,1.414,0+ c0.392-0.392,0.391-1.023,0.001-1.416l-2.12-2.12c-0.018-0.018-0.041-0.023-0.06-0.039c0.867-1.111,1.446-2.455,1.627-3.924+ c0.024,0.002,0.044,0.014,0.068,0.014L29,19.002c0.554,0,1.001-0.448,1-1C30,17.448,29.553,17.002,28.999,17z M18,24+ c-3.313,0-6-2.687-6-6s2.687-6,6-6s6,2.687,6,6S21.313,24,18,24z"/>+</g>+</svg>`;++// Step 2: Convert the SVG string to a Blob+const svgBlob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });++// Step 3: Generate the Object URL+const objectURL = URL.createObjectURL(svgBlob);++const imageWidth = css({+ maxWidth: "100%",+});++const ImageIcon = () => (+ <Box css={{ width: theme.spacing[18] }}>+ <Image+ className={imageWidth()}+ src={objectURL}+ optimize={false}+ width={64}+ loader={() => ""}+ />+ </Box>+);++const texts = [+ `We are what repeatedly do. Excellence is not an act but a habit.`,+ `We are what repeatedly do. Excellence is not an act but a habit.`,+ `We are what repeatedly do. Excellence is not an act but a habit. We are what repeatedly do. Excellence is not an act but a habit. We are what repeatedly do. Excellence is not an act but a habit.`,+ `Asset already exists`,+];++export const Design = () => {+ return (+ <>+ <StorySection title="Toast Design">+ <StoryGrid>+ <Toast>1. We are what repeatedly do.</Toast>++ <Toast>+ 2. We are what repeatedly do. Excellence is not an act but a habit.+ </Toast>++ <Toast>+ 3. We are what repeatedly do. We are what repeatedly do. Excellence+ is not an act but a habit.+ </Toast>++ <Toast>+ 3. We are what repeatedly do. We are what repeatedly do. Excellence+ is not an act but a habit. We are what+ </Toast>++ <Toast>+ 4. We are what repeatedly do. We are what repeatedly do. We are what+ repeatedly do. Excellence is not an act but a habit.+ </Toast>++ <Toast>+ 5. We are what repeatedly do. We are what repeatedly do. We are what+ repeatedly do. We are what repeatedly do. Excellence is not an act+ but a habit.+ </Toast>++ <Toast>+ 6. We are what repeatedly do. We are what repeatedly do. We are what+ repeatedly do. We are what repeatedly do. We are what repeatedly do.+ Excellence is not an act but a habit.+ </Toast>++ <Toast variant="warning">+ We are what repeatedly do. Excellence is not an act but a habit.+ </Toast>++ <Toast variant="error">+ We are what repeatedly do. Excellence is not an act but a habit. We+ are what repeatedly do. Excellence is not an act but a habit. We are+ what repeatedly do. Excellence is not an act but a habit.+ </Toast>+ <Toast variant="success">+ We are what repeatedly do. Excellence is not an act but a habit. We+ are what repeatedly do. Excellence is not an act but a habit. We are+ what repeatedly do. Excellence is not an act but a habit.+ </Toast>+ </StoryGrid>+ </StorySection>++ <StorySection title="Toast With Icon Design">+ <StoryGrid>+ <Toast icon={<AlertCircleIcon size={24} />}>+ We are what repeatedly do. Excellence is not an act but a habit.+ </Toast>++ <Toast icon={<AlertCircleIcon size={24} />} variant="warning">+ We are what repeatedly do. Excellence is not an act but a habit.+ </Toast>++ <Toast icon={<AlertCircleIcon size={24} />} variant="error">+ We are what repeatedly do. Excellence is not an act but a habit. We+ are what repeatedly do. Excellence is not an act but a habit. We are+ what repeatedly do. Excellence is not an act but a habit.+ </Toast>++ <Toast variant="success" icon={<AlertCircleIcon size={24} />}>+ We are what repeatedly do. Excellence is not an act but a habit. We+ are what repeatedly do. Excellence is not an act but a habit. We are+ what repeatedly do. Excellence is not an act but a habit.+ </Toast>++ <Toast icon={<ImageIcon />}>Asset already exists</Toast>+ </StoryGrid>+ </StorySection>++ <StorySection title="Very long Toast">+ <StoryGrid>+ <Toast icon={<AlertCircleIcon size={24} />}>+ {"We are what repeatedly do. Excellence is not an act but a habit.".repeat(+ 100+ )}+ </Toast>+ </StoryGrid>+ </StorySection>+ </>+ );+};+Design.storyName = "Toast Design";++let counter = 0;+export const InAction = () => {+ return (+ <StorySection title="Toast In Action">+ <StoryGrid css={{ width: 300 }}>+ <Toaster />+ <Button+ onClick={() => {+ toast.error(texts[++counter % texts.length], { duration: 5000 });+ }}+ >+ Show Error Toast+ </Button>+ <Button+ onClick={() => {+ toast.warn(texts[++counter % texts.length], { duration: 5000 });+ }}+ >+ Show Warn Toast+ </Button>+ <Button+ onClick={() => {+ toast.info(texts[++counter % texts.length], { duration: 5000 });+ }}+ >+ Show Info Toast+ </Button>++ <Button+ onClick={() => {+ toast.error(texts[++counter % texts.length], {+ duration: 5000,+ icon: <ImageIcon />,+ });+ }}+ >+ Show Error Image Toast+ </Button>+ <Button+ onClick={() => {+ toast.info(texts[++counter % texts.length], {+ duration: 5000,+ icon: <ImageIcon />,+ });+ }}+ >+ Show Info Image Toast+ </Button>+ </StoryGrid>+ </StorySection>+ );+};diff --git a/packages/design-system/src/components/toast.tsx b/packages/design-system/src/components/toast.tsxindex e400be48a8..352af45b9d 100644--- a/packages/design-system/src/components/toast.tsx+++ b/packages/design-system/src/components/toast.tsx@@ -1,11 +1,22 @@import * as ToastPrimitive from "@radix-ui/react-toast";-import hotToast, { resolveValue, useToaster } from "react-hot-toast/headless";-import { keyframes, styled } from "../stitches.config";-import { InfoCircleIcon } from "@webstudio-is/icons";+import hotToast, {+ resolveValue,+ useToaster,+ type Toast as HotToast,+ type ToastOptions,+} from "react-hot-toast/headless";+import { keyframes, rawTheme, styled, type CSS } from "../stitches.config";import { Box } from "./box";import { theme } from "../stitches.config";+import { Grid } from "./grid";-const VIEWPORT_PADDING = theme.spacing[2];+import { Text } from "./text";+import { Flex } from "./flex";+import { Tooltip } from "./tooltip";+import { Button } from "./button";+import { CopyIcon, LargeXIcon } from "@webstudio-is/icons";++const ANIMATION_SLIDE_LENGTH = 30;const hide = keyframes({"0%": { opacity: 1 },@@ -13,13 +24,13 @@ const hide = keyframes({});const slideIn = keyframes({- from: { transform: `translateY(calc(0px - ${VIEWPORT_PADDING}px))` },+ from: { transform: `translateY(calc(0px + ${ANIMATION_SLIDE_LENGTH}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))` },+ to: { transform: `translateX(calc(100% + ${ANIMATION_SLIDE_LENGTH}px))` },});const StyledViewport = styled(ToastPrimitive.Viewport, {@@ -28,31 +39,17 @@ const StyledViewport = styled(ToastPrimitive.Viewport, {right: 0,display: "flex",flexDirection: "column",- padding: VIEWPORT_PADDING,- gap: VIEWPORT_PADDING,+ padding: theme.spacing[5],+ gap: theme.spacing[5],minWidth: 200,width: "auto",maxWidth: "100vw",margin: 0,listStyle: "none",- zIndex: theme.zIndices.max,outline: "none",});-const StyledToast = styled(ToastPrimitive.Root, {- borderRadius: 6,- boxShadow: "0px 2px 7px rgba(0, 0, 0, 0.1), 0px 5px 17px rgba(0, 0, 0, 0.15)",- padding: theme.spacing[9],- display: "flex",- maxWidth: 250,- gap: theme.spacing[9],- alignItems: "center",- color: theme.colors.hiContrast,- fontWeight: 500,- fontSize: theme.deprecatedFontSize[3],- WebkitFontSmoothing: "antialiased",- background: theme.colors.backgroundPanel,-+const AnimatedToast = styled(ToastPrimitive.Root, {"@media (prefers-reduced-motion: no-preference)": {'&[data-state="open"]': {animation: `${slideIn} 250ms cubic-bezier(0.16, 1, 0.3, 1)`,@@ -71,67 +68,322 @@ const StyledToast = styled(ToastPrimitive.Root, {animation: `${swipeOut} 150ms ease-out`,},},+});++const borderAccentBackgroundColor = "--ws-toast-border-accent-background-color";+const backgroundColor = "--ws-toast-background-color";+const borderColor = "--ws-toast-border-color";+const iconColor = "--ws-toast-icon-color";++const ToastVariants = styled("div", {+ [borderAccentBackgroundColor]: theme.colors.foregroundMain,+ [backgroundColor]: theme.colors.backgroundNeutralNotification,+ [borderColor]: theme.colors.borderNeutral,+ [iconColor]: theme.colors.foregroundMain,+variants: {variant: {+ neutral: {},+ warning: {+ [backgroundColor]: theme.colors.backgroundAlertNotification,+ [borderAccentBackgroundColor]: theme.colors.backgroundAlertMain,+ [borderColor]: theme.colors.backgroundAlertMain,+ [iconColor]: theme.colors.backgroundAlertMain,+ },error: {- background: theme.colors.red9,- color: theme.colors.loContrast,+ [backgroundColor]: theme.colors.backgroundDestructiveNotification,+ [borderAccentBackgroundColor]: theme.colors.backgroundDestructiveMain,+ [borderColor]: theme.colors.backgroundDestructiveMain,+ [iconColor]: theme.colors.foregroundDestructive,},success: {- background: theme.colors.green10,- color: theme.colors.loContrast,- },- blank: {- background: theme.colors.blue11,- color: theme.colors.loContrast,+ [backgroundColor]: theme.colors.backgroundSuccessNotification,+ [borderAccentBackgroundColor]: theme.colors.backgroundSuccessMain,+ [borderColor]: theme.colors.backgroundSuccessMain,+ [iconColor]: theme.colors.foregroundSuccess,},- custom: {},- loading: {},},},});+type ToastVariant = React.ComponentProps<typeof ToastVariants>["variant"];++const cssVar = (name: string) => `var(${name})`;++const InternalToast = ({+ children,+ variant,+ icon,+ sideButtons,+}: {+ children: React.ReactNode;+ variant?: ToastVariant;+ icon?: React.ReactNode;+ sideButtons: React.ReactNode;+}) => {+ return (+ <ToastVariants variant={variant}>+ <Grid+ css={{+ display: "grid",+ gridTemplateColumns: "8px 1fr",+ }}+ >+ <Box+ css={{+ backgroundColor: cssVar(borderAccentBackgroundColor),+ borderTopLeftRadius: theme.borderRadius[5],+ borderBottomLeftRadius: theme.borderRadius[5],+ }}+ ></Box>+ <Grid+ gap={"3"}+ align={"center"}+ css={{+ backgroundColor: cssVar(backgroundColor),+ padding: theme.spacing[9],+ gridTemplateColumns: icon ? "auto 1fr auto" : "1fr auto",+ borderBottomRightRadius: theme.borderRadius[5],+ borderTopRightRadius: theme.borderRadius[5],+ border: `1px solid ${cssVar(borderColor)}`,+ borderLeft: "none",+ }}+ >+ <Box+ css={{+ color: cssVar(iconColor),+ display: icon ? "contents" : "none",+ }}+ >+ {icon}+ </Box>++ <Grid gap={"1"}>+ <ToastPrimitive.Description asChild>+ <Text+ css={{+ whiteSpace: "pre-wrap",+ wordBreak: "break-word",+ display: "-webkit-box",+ "-webkit-line-clamp": 20,+ "-webkit-box-orient": "vertical",+ overflow: "hidden",+ textOverflow: "ellipsis",+ }}+ variant={"labelsSentenceCase"}+ >+ {children}+ </Text>+ </ToastPrimitive.Description>+ </Grid>++ {sideButtons}+ </Grid>+ </Grid>+ </ToastVariants>+ );+};++export const Toast = ({+ children,+ variant,+ icon,+ onClose,+ onCopy,+}: {+ onClose?: () => void;+ onCopy?: () => void;+ children: React.ReactNode;+ variant?: ToastVariant;+ icon?: React.ReactNode;+}) => {+ const sideButtons = (css: CSS) => (+ <Flex css={css} wrap="wrapReverse">+ <Tooltip content={"Copy to clipboard"}>+ <Button+ css={{+ "&[data-state=auto]:hover": {+ background: "rgba(0, 0, 0, 0.07)",+ },+ "&[data-state=auto]:active": {+ background: "rgba(0, 0, 0, 0.04)",+ },+ }}+ color="ghost"+ onClick={() => {+ onCopy?.();+ }}+ prefix={<CopyIcon />}+ ></Button>+ </Tooltip>+ <Tooltip content={"Close"}>+ <Button+ css={{+ "&[data-state=auto]:hover": {+ background: "rgba(0, 0, 0, 0.07)",+ },+ "&[data-state=auto]:active": {+ background: "rgba(0, 0, 0, 0.04)",+ },+ }}+ color="ghost"+ onClick={() => {+ onClose?.();+ }}+ prefix={<LargeXIcon />}+ ></Button>+ </Tooltip>+ </Flex>+ );++ const buttonSize = Number.parseFloat(rawTheme.spacing[12]);+ // Change the side button layout to vertical at a specific container size.+ const layoutThreshold = `90px`;++ /**+ * Using `container-type: size` enables the @container (min-height) media query.+ * This applies layout, style, and size containment to the container,+ * meaning the element's size is computed in isolation, ignoring its child elements.+ * We use `visibility: hidden` elements to set the container's size,+ * placing all elements inside the same grid cell.+ */+ return (+ <Grid+ css={{+ width: theme.spacing[33],+ }}+ >+ {/* Toast with a horizontal layout for side buttons */}+ <Box+ css={{+ gridColumn: "1",+ gridRow: "1",+ // Vertical button layout is applied after this height, so it must not affect the container height.+ maxHeight: layoutThreshold,+ overflow: "hidden",+ // Element is used to set the container size.+ visibility: "hidden",+ }}+ >+ <InternalToast+ variant={variant}+ icon={icon}+ sideButtons={sideButtons({})}+ >+ {children}+ </InternalToast>+ </Box>++ {/* Toast with a vertical layout for side buttons. */}+ <Box+ css={{+ gridColumn: "1",+ gridRow: "1",+ // Element is used to set the container size.+ visibility: "hidden",+ }}+ >+ <InternalToast+ variant={variant}+ icon={icon}+ sideButtons={sideButtons({+ width: "min-content",+ // Ensure buttons do not affect the container height; only the content should.+ maxHeight: buttonSize,+ })}+ >+ {children}+ </InternalToast>+ </Box>++ {/* Container with Toast */}+ <Grid+ css={{+ gridColumn: "1",+ gridRow: "1",+ containerType: "size",+ }}+ >+ <InternalToast+ variant={variant}+ icon={+ icon ? (+ <Box+ css={{+ [`@container (min-height: ${layoutThreshold})`]: {+ alignSelf: "start",+ },+ }}+ >+ {icon}+ </Box>+ ) : undefined+ }+ sideButtons={sideButtons({+ [`@container (min-height: ${layoutThreshold})`]: {+ width: "min-content",+ alignSelf: "start",+ },+ })}+ >+ {children}+ </InternalToast>+ </Grid>+ </Grid>+ );+};++const mapToVariant: Record<HotToast["type"], ToastVariant> = {+ success: "success",+ error: "error",+ loading: "neutral",+ blank: "neutral",+ custom: "warning",+};+export const Toaster = () => {const { toasts, handlers } = useToaster();const { startPause, endPause } = handlers;return (<ToastPrimitive.ToastProvider>- {toasts.map((toastData) => (- <StyledToast- variant={toastData.type}- key={toastData.id}- onMouseEnter={startPause}- onMouseLeave={endPause}- onClick={() => {- hotToast.remove(toastData.id);- }}- >- {toastData.type === "blank" && (- <Box- css={{- svg: {- width: theme.spacing[11],- height: theme.spacing[11],- },+ {toasts.map((toastData) => {+ const toastVariant = mapToVariant[toastData.type];+ const children = resolveValue(toastData.message, toastData);++ return (+ <AnimatedToast+ key={toastData.id}+ onMouseEnter={startPause}+ onMouseLeave={endPause}+ duration={toastData.duration}+ >+ <Toast+ variant={toastVariant}+ onClose={() => {+ hotToast.remove(toastData.id);}}+ onCopy={() => {+ navigator.clipboard.writeText(children?.toString() ?? "");+ }}+ icon={toastData.icon}>- <InfoCircleIcon />- </Box>- )}- <ToastPrimitive.Title>- {resolveValue(toastData.message, toastData)}- </ToastPrimitive.Title>- </StyledToast>- ))}+ {children}+ </Toast>+ </AnimatedToast>+ );+ })}<StyledViewport /></ToastPrimitive.ToastProvider>);};+type Options = Pick<ToastOptions, "duration" | "id" | "icon">;+export const toast = {- info: hotToast,- error: hotToast.error,- success: hotToast.success,- warn: hotToast.custom,+ info: (value: string, options?: Options) => hotToast(value, options),+ error: (value: string, options?: Options) => hotToast.error(value, options),+ warn: (value: string, options?: Options) => hotToast.custom(value, options),+ success: (value: string, options?: Options) =>+ hotToast.success(value, options),};diff --git a/packages/icons/icons/alert-circle.svg b/packages/icons/icons/alert-circle.svgnew file mode 100644index 0000000000..8ecde34ecf--- /dev/null+++ b/packages/icons/icons/alert-circle.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="m11.28 1.023-.56.06A10.685 10.685 0 0 0 7.18 2.12c-1.135.551-1.987 1.165-2.942 2.119-.961.959-1.595 1.841-2.141 2.981C.301 10.968.728 15.286 3.226 18.633c.475.636 1.527 1.683 2.174 2.164 3.964 2.948 9.266 2.937 13.237-.027.609-.454 1.679-1.524 2.133-2.133 2.974-3.985 2.974-9.289 0-13.274-.454-.608-1.523-1.677-2.13-2.128-1.595-1.186-3.275-1.875-5.217-2.139C13 1.038 11.574.99 11.28 1.023m2.04 2.078c2.563.387 4.804 1.83 6.24 4.019.303.463.743 1.359.932 1.9.346.993.485 1.845.485 2.98 0 1.493-.257 2.621-.897 3.94-.705 1.454-1.769 2.667-3.153 3.592-.789.528-2.051 1.056-3.019 1.265a9.053 9.053 0 0 1-7.538-1.778c-1.513-1.212-2.648-2.99-3.103-4.859-.186-.763-.244-1.272-.244-2.16 0-1.493.257-2.621.897-3.94a8.983 8.983 0 0 1 5.24-4.594c.705-.233 1.272-.348 2.18-.442.322-.033 1.571.015 1.98.077m-1.625 3.956a1.04 1.04 0 0 0-.567.459l-.108.184v4.606l.121.197c.068.11.205.253.311.325.471.316 1.102.171 1.407-.325l.121-.197V7.7l-.108-.184a1.005 1.005 0 0 0-1.177-.459m0 7.998a1.05 1.05 0 0 0-.567.461c-.091.156-.108.23-.108.484 0 .257.016.327.113.492.518.882 1.865.526 1.865-.492a.994.994 0 0 0-.535-.888 1.17 1.17 0 0 0-.768-.057" fill-rule="evenodd" /></svg>\ No newline at end of filediff --git a/packages/icons/src/__generated__/components.tsx b/packages/icons/src/__generated__/components.tsxindex e16d1a0a5c..da9f5309ad 100644--- a/packages/icons/src/__generated__/components.tsx+++ b/packages/icons/src/__generated__/components.tsx@@ -617,6 +617,28 @@ export const AiIcon = forwardRef<SVGSVGElement, IconProps>();AiIcon.displayName = "AiIcon";+export const AlertCircleIcon = forwardRef<SVGSVGElement, IconProps>(+ ({ color = "currentColor", size = 16, ...props }, forwardedRef) => {+ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24"+ width={size}+ height={size}+ fill={color}+ {...props}+ ref={forwardedRef}+ >+ <path+ fillRule="evenodd"+ d="m11.28 1.023-.56.06A10.685 10.685 0 0 0 7.18 2.12c-1.135.551-1.987 1.165-2.942 2.119-.961.959-1.595 1.841-2.141 2.981C.301 10.968.728 15.286 3.226 18.633c.475.636 1.527 1.683 2.174 2.164 3.964 2.948 9.266 2.937 13.237-.027.609-.454 1.679-1.524 2.133-2.133 2.974-3.985 2.974-9.289 0-13.274-.454-.608-1.523-1.677-2.13-2.128-1.595-1.186-3.275-1.875-5.217-2.139C13 1.038 11.574.99 11.28 1.023m2.04 2.078c2.563.387 4.804 1.83 6.24 4.019.303.463.743 1.359.932 1.9.346.993.485 1.845.485 2.98 0 1.493-.257 2.621-.897 3.94-.705 1.454-1.769 2.667-3.153 3.592-.789.528-2.051 1.056-3.019 1.265a9.053 9.053 0 0 1-7.538-1.778c-1.513-1.212-2.648-2.99-3.103-4.859-.186-.763-.244-1.272-.244-2.16 0-1.493.257-2.621.897-3.94a8.983 8.983 0 0 1 5.24-4.594c.705-.233 1.272-.348 2.18-.442.322-.033 1.571.015 1.98.077m-1.625 3.956a1.04 1.04 0 0 0-.567.459l-.108.184v4.606l.121.197c.068.11.205.253.311.325.471.316 1.102.171 1.407-.325l.121-.197V7.7l-.108-.184a1.005 1.005 0 0 0-1.177-.459m0 7.998a1.05 1.05 0 0 0-.567.461c-.091.156-.108.23-.108.484 0 .257.016.327.113.492.518.882 1.865.526 1.865-.492a.994.994 0 0 0-.535-.888 1.17 1.17 0 0 0-.768-.057"+ />+ </svg>+ );+ }+);+AlertCircleIcon.displayName = "AlertCircleIcon";+export const AlertIcon = forwardRef<SVGSVGElement, IconProps>(({ color = "currentColor", size = 16, ...props }, forwardedRef) => {return (diff --git a/packages/icons/src/__generated__/svg.ts b/packages/icons/src/__generated__/svg.tsindex 1dd04f9723..e4379f7c75 100644--- a/packages/icons/src/__generated__/svg.ts+++ b/packages/icons/src/__generated__/svg.ts@@ -40,6 +40,8 @@ export const AiLoadingIcon = `<svg xmlns="http://www.w3.org/2000/svg" id="evA4hIexport const AiIcon = `<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="M3.04 12.326a1.1 1.1 0 0 1-2.134-.534l1.513-6.05a3.663 3.663 0 0 1 7.108 0l1.159 4.634c.085.34.399.584.749.584a.78.78 0 0 0 .772-.773V4.06a1.1 1.1 0 0 1 2.2 0v6.128c0 1.618-1.355 2.973-2.972 2.973a2.996 2.996 0 0 1-2.883-2.25l-1.16-4.636a1.464 1.464 0 0 0-2.84 0L3.04 12.326Z" clip-rule="evenodd"/></svg>`;+export const AlertCircleIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="100%" height="100%" style="display: block;"><path fill-rule="evenodd" d="m11.28 1.023-.56.06A10.685 10.685 0 0 0 7.18 2.12c-1.135.551-1.987 1.165-2.942 2.119-.961.959-1.595 1.841-2.141 2.981C.301 10.968.728 15.286 3.226 18.633c.475.636 1.527 1.683 2.174 2.164 3.964 2.948 9.266 2.937 13.237-.027.609-.454 1.679-1.524 2.133-2.133 2.974-3.985 2.974-9.289 0-13.274-.454-.608-1.523-1.677-2.13-2.128-1.595-1.186-3.275-1.875-5.217-2.139C13 1.038 11.574.99 11.28 1.023m2.04 2.078c2.563.387 4.804 1.83 6.24 4.019.303.463.743 1.359.932 1.9.346.993.485 1.845.485 2.98 0 1.493-.257 2.621-.897 3.94-.705 1.454-1.769 2.667-3.153 3.592-.789.528-2.051 1.056-3.019 1.265a9.053 9.053 0 0 1-7.538-1.778c-1.513-1.212-2.648-2.99-3.103-4.859-.186-.763-.244-1.272-.244-2.16 0-1.493.257-2.621.897-3.94a8.983 8.983 0 0 1 5.24-4.594c.705-.233 1.272-.348 2.18-.442.322-.033 1.571.015 1.98.077m-1.625 3.956a1.04 1.04 0 0 0-.567.459l-.108.184v4.606l.121.197c.068.11.205.253.311.325.471.316 1.102.171 1.407-.325l.121-.197V7.7l-.108-.184a1.005 1.005 0 0 0-1.177-.459m0 7.998a1.05 1.05 0 0 0-.567.461c-.091.156-.108.23-.108.484 0 .257.016.327.113.492.518.882 1.865.526 1.865-.492a.994.994 0 0 0-.535-.888 1.17 1.17 0 0 0-.768-.057"/></svg>`;+export const AlertIcon = `<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="M6.3 2.354c.746-1.325 2.654-1.325 3.4 0l5.276 9.38c.732 1.3-.208 2.905-1.699 2.905H2.723c-1.491 0-2.43-1.606-1.7-2.906l5.278-9.379Zm2.267.638a.65.65 0 0 0-1.133 0L2.157 12.37a.65.65 0 0 0 .566.968h10.554a.65.65 0 0 0 .566-.968L8.567 2.99Z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M8 5.34a.65.65 0 0 1 .65.65v2.66a.65.65 0 0 1-1.3 0V5.99A.65.65 0 0 1 8 5.34ZM7.2 11.323a.8.8 0 0 1 .8-.8h.007a.8.8 0 0 1 0 1.6H8a.8.8 0 0 1-.8-.8Z" clip-rule="evenodd"/></svg>`;export const ArrowDownIcon = `<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="M3.434 8.434a.8.8 0 0 1 1.132 0L7.2 11.07V3a.8.8 0 1 1 1.6 0v8.069l2.634-2.635a.8.8 0 0 1 1.132 1.132l-4 4a.8.8 0 0 1-1.132 0l-4-4a.8.8 0 0 1 0-1.132Z" clip-rule="evenodd"/></svg>`;diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 0608a7ce18..6d81dbd347 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1326,6 +1326,9 @@ importers:'@types/react-dom':specifier: ^18.2.25version: 18.2.25+ '@webstudio-is/image':+ specifier: workspace:*+ version: link:../image'@webstudio-is/jest-config':specifier: workspace:*version: link:../jest-config