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
Merge branch 'main' of github.com:webstudio-is/webstudio-designer into toasts
Sara Vieira04f13f4cb7a1
diff --cc apps/designer/app/designer/designer.tsxindex ecdb0f61a5,fef2db5c3e..18c939efe8--- a/apps/designer/app/designer/designer.tsx+++ b/apps/designer/app/designer/designer.tsx@@@ -34,14 -34,6 +34,7 @@@ import { usePublishShortcuts } from "./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 [diff --cc apps/designer/app/designer/features/workspace/workspace.tsxindex 661e1d83c3,41b0d6a7e3..f1e803b2c0--- a/apps/designer/app/designer/features/workspace/workspace.tsx+++ b/apps/designer/app/designer/features/workspace/workspace.tsx@@@ -1,5 -1,4 +1,4 @@@- import { Notifications } from "~/shared/design-system/components/toast";- import { Box, Flex } from "~/shared/design-system";-import { Box, Flex } from "@webstudio-is/design-system";++import { Box, Flex, Notifications } from "@webstudio-is/design-system";import { useCanvasWidth, useZoom } from "~/designer/shared/nano-states";import { CanvasTools } from "./canvas-tools";import { type Publish } from "@webstudio-is/react-sdk";diff --cc apps/designer/package.jsonindex 3669f44eeb,d723f6bcd9..6223e2c8c6--- a/apps/designer/package.json+++ b/apps/designer/package.json@@@ -55,8 -26,10 +26,10 @@@"@stitches/react": "^1.2.7","@vercel/node": "^2.4.1","@webstudio-is/asset-uploader": "*",- "@webstudio-is/prisma-client": "*",- "@webstudio-is/react-sdk": "*",+ "@webstudio-is/design-system": "*",+ "@webstudio-is/icons": "*",+ "@webstudio-is/prisma-client": "*",+ "@webstudio-is/react-sdk": "*","bson-objectid": "^2.0.2","camelcase": "^6.3.0","debug": "^4.3.4",@@@ -123,6 -96,6 +97,8 @@@"@types/react-dom": "^17.0.9","@types/sharp": "^0.30.4","@types/w3c-css-typed-object-model-level-1": "^20180410.0.4",++ "@webstudio-is/eslint-config-custom": "*",++ "@webstudio-is/tsconfig": "*","babel-loader": "^8.2.5","css-tree": "^2.0.4","dotenv": "^16.0.0",@@@ -134,7 -106,8 +109,6 @@@"prettier": "^2.6.2","react-test-renderer": "^17.0.2","relative-deps": "^1.0.7",- "tsconfig": "*",- "@webstudio-is/eslint-config-custom": "*",- "@webstudio-is/tsconfig": "*","typescript": "4.6.4"},"sideEffects": false,diff --cc apps/designer/tsconfig.jsonindex fbf716785d,4ce92c95f5..f30c095e48--- a/apps/designer/tsconfig.json+++ b/apps/designer/tsconfig.json@@@ -6,6 -5,6 +5,17 @@@"paths": {"~/*": ["app/*"]},-- "baseUrl": "."++ "baseUrl": ".",++ "allowJs": true,++ "forceConsistentCasingInFileNames": true,++ "lib": ["DOM", "DOM.Iterable", "ES2019"],++ "strict": true,++ "target": "ES2019",++ "esModuleInterop": true,++ "isolatedModules": true,++ "jsx": "react-jsx",++ "moduleResolution": "node",++ "noEmit": true,++ "resolveJsonModule": true}}diff --cc packages/design-system/package.jsonindex 0000000000,d181546931..7b782a13f7mode 000000,100644..100644--- a/packages/design-system/package.json+++ b/packages/design-system/package.json@@@ -1,0 -1,72 +1,74 @@@+ {+ "name": "@webstudio-is/design-system",+ "version": "0.1.0",+ "description": "Webstudio Design System",+ "author": "Webstudio <[email protected]>",+ "homepage": "https://webstudio.is",+ "scripts": {+ "dev": "tsup src/index.ts --format esm,cjs --watch --out-dir=lib",+ "build": "rm -fr lib && tsc",+ "typecheck": "tsc --noEmit",+ "lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",+ "checks": "yarn typecheck && yarn lint",+ "storybook:run": "start-storybook -p 6006",+ "storybook:build": "build-storybook"+ },+ "devDependencies": {- "tsup": "^6.1.3",- "typescript": "^4.6.2",+ "@storybook/addon-actions": "^6.5.6",+ "@storybook/addon-essentials": "^6.5.6",+ "@storybook/addon-interactions": "^6.5.6",+ "@storybook/addon-links": "^6.5.6",+ "@storybook/builder-webpack4": "^6.5.6",+ "@storybook/manager-webpack4": "^6.5.6",+ "@storybook/react": "^6.5.6",- "@storybook/testing-library": "^0.0.11"++ "@storybook/testing-library": "^0.0.11",++ "tsup": "^6.1.3",++ "typescript": "^4.6.2"+ },+ "peerDependencies": {+ "react": "^17.0.2",+ "react-dom": "^17.0.2"+ },+ "dependencies": {+ "@radix-ui/colors": "^0.1.8",+ "@radix-ui/react-accessible-icon": "^0.1.4",+ "@radix-ui/react-accordion": "^0.1.6",+ "@radix-ui/react-alert-dialog": "^0.1.7",+ "@radix-ui/react-avatar": "^0.1.4",+ "@radix-ui/react-checkbox": "^0.1.5",+ "@radix-ui/react-collapsible": "^0.1.6",+ "@radix-ui/react-context-menu": "^0.1.6",+ "@radix-ui/react-dialog": "^0.1.7",+ "@radix-ui/react-dropdown-menu": "^0.1.6",+ "@radix-ui/react-id": "^0.1.5",+ "@radix-ui/react-label": "^0.1.5",+ "@radix-ui/react-menu": "^0.1.6",+ "@radix-ui/react-popover": "^0.1.6",+ "@radix-ui/react-popper": "^1.0.0",+ "@radix-ui/react-portal": "^0.1.4",+ "@radix-ui/react-progress": "^0.1.4",+ "@radix-ui/react-radio-group": "^0.1.5",+ "@radix-ui/react-select": "^0.1.1",+ "@radix-ui/react-separator": "^0.1.4",+ "@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": "^1.0.0",+ "@radix-ui/react-use-layout-effect": "^0.1.0",+ "@webstudio-is/icons": "*",- "@webstudio-is/react-sdk": "*"++ "@webstudio-is/react-sdk": "*",++ "react-hot-toast": "^2.3.0"+ },+ "main": "lib/index.js",+ "types": "lib/index.d.ts",+ "files": [+ "lib/*",+ "README.md",+ "!*.test.*"+ ],+ "license": "MIT",+ "private": false+ }diff --cc packages/design-system/src/components/toast.tsxindex 2c93de273c,0000000000..77dae9638amode 100644,000000..100644--- a/packages/design-system/src/components/toast.tsx+++ b/packages/design-system/src/components/toast.tsx@@@ -1,115 -1,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";++import { CheckIcon, Cross1Icon } from "@webstudio-is/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 --cc packages/design-system/src/index.tsindex 9c912df80b,d9fc6e725f..3788a741d5--- a/packages/design-system/src/index.ts+++ b/packages/design-system/src/index.ts@@@ -11,6 -11,6 +11,7 @@@ exporttheme,type CSS,} from "./stitches.config";++export { Notifications } from "./components/toast";export * as Collapsible from "@radix-ui/react-collapsible";export { AccessibleIcon } from "@radix-ui/react-accessible-icon";