├── .gitignore ├── src ├── db │ ├── index.ts │ ├── types.ts │ └── instance.ts ├── pubsub │ ├── index.ts │ ├── publish.ts │ └── subscribe.ts ├── stitches │ ├── index.ts │ ├── critical-css.tsx │ ├── css.ts │ ├── to-css.ts │ └── to-css.test.ts ├── tree │ ├── index.ts │ ├── root.ts │ ├── create-elements-tree.tsx │ └── wrapper-component.tsx ├── prisma.server.ts ├── user-props │ ├── index.ts │ ├── schema.ts │ ├── types.ts │ ├── all-user-props.ts │ └── use-user-props.ts ├── css │ ├── index.ts │ ├── breakpoints.ts │ ├── units.ts │ ├── types.ts │ ├── schema.ts │ ├── get-browser-style.ts │ └── categories.ts ├── index.ts ├── components │ ├── index.ts │ ├── bold.tsx │ ├── box.tsx │ ├── form.tsx │ ├── italic.tsx │ ├── heading.tsx │ ├── paragraph.tsx │ ├── text-block.tsx │ ├── link.tsx │ ├── input.tsx │ ├── button.tsx │ ├── form.stories.tsx │ ├── input.stories.tsx │ ├── meta.ts │ ├── link.stories.tsx │ ├── bold.stories.tsx │ ├── button.stories.tsx │ ├── box.stories.tsx │ ├── italic.stories.tsx │ ├── heading.stories.tsx │ ├── text-block.stories.tsx │ ├── paragraph.stories.tsx │ ├── bold.props.json │ └── box.props.json └── arg-types │ └── utils.ts ├── .storybook ├── preview.js └── main.js ├── jest.config.js ├── README.md ├── tsconfig.json ├── .github └── workflow │ └── main.yml ├── LICENSE ├── prisma └── schema.prisma ├── bin ├── generate-arg-types.ts └── mdn-data.ts └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | yarn-error.log 4 | lib 5 | generated -------------------------------------------------------------------------------- /src/db/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./types"; 2 | export * from "./instance"; 3 | -------------------------------------------------------------------------------- /src/pubsub/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./publish"; 2 | export * from "./subscribe"; 3 | -------------------------------------------------------------------------------- /src/stitches/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./to-css"; 2 | export * from "./css"; 3 | export * from "./critical-css"; 4 | -------------------------------------------------------------------------------- /src/tree/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./create-elements-tree"; 2 | export * from "./root"; 3 | export * from "./wrapper-component"; 4 | -------------------------------------------------------------------------------- /src/prisma.server.ts: -------------------------------------------------------------------------------- 1 | export { PrismaClient, Prisma } from "@prisma/client"; 2 | export { PrismaClientKnownRequestError } from "@prisma/client/runtime"; 3 | -------------------------------------------------------------------------------- /src/user-props/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./all-user-props"; 2 | export * from "./use-user-props"; 3 | export * from "./types"; 4 | export * from "./schema"; 5 | -------------------------------------------------------------------------------- /.storybook/preview.js: -------------------------------------------------------------------------------- 1 | export const parameters = { 2 | actions: { argTypesRegex: "^on[A-Z].*" }, 3 | controls: { 4 | matchers: { 5 | color: /(background|color)$/i, 6 | date: /Date$/, 7 | }, 8 | }, 9 | } -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: "node", 3 | testMatch: ["/src/**/*.test.ts"], 4 | transform: { 5 | "^.+\\.tsx?$": "esbuild-jest", 6 | }, 7 | moduleNameMapper: { 8 | "^~/(.*)$": "/src/$1", 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /src/css/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./properties"; 2 | export * from "./units"; 3 | export * from "./types"; 4 | export * from "./get-browser-style"; 5 | export * from "./categories"; 6 | export * from "./keyword-values"; 7 | export * from "./breakpoints"; 8 | export * from "./schema"; 9 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./css"; 2 | export * from "./tree"; 3 | export * from "./stitches"; 4 | export * as components from "./components"; 5 | export * as componentsMeta from "./components/meta"; 6 | export * from "./user-props"; 7 | export * from "./pubsub"; 8 | export * from "./db"; 9 | -------------------------------------------------------------------------------- /src/user-props/schema.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | 3 | export const UserPropSchema = z.object({ 4 | id: z.string(), 5 | prop: z.string(), 6 | value: z.union([z.string(), z.boolean()]), 7 | required: z.optional(z.boolean()), 8 | }); 9 | 10 | export const UserPropsSchema = z.array(UserPropSchema); 11 | -------------------------------------------------------------------------------- /src/components/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./box"; 2 | export * from "./text-block"; 3 | export * from "./heading"; 4 | export * from "./paragraph"; 5 | export * from "./link"; 6 | export * from "./bold"; 7 | export * from "./italic"; 8 | export * from "./button"; 9 | export * from "./input"; 10 | export * from "./form"; 11 | -------------------------------------------------------------------------------- /.storybook/main.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "stories": [ 3 | "../src/**/*.stories.mdx", 4 | "../src/**/*.stories.@(js|jsx|ts|tsx)" 5 | ], 6 | "addons": [ 7 | "@storybook/addon-links", 8 | "@storybook/addon-essentials", 9 | "@storybook/addon-interactions" 10 | ], 11 | "framework": "@storybook/react" 12 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Webstudio SDK 2 | 3 | Webstudio SDK is a TypeScript API that lets you use your Webstudio site or some components in your custom codebase or just render a complete Remix Document. 4 | It is currently under development, but feel free to play with the the current [landing site](https://github.com/webstudio-is/webstudio-landing) 5 | -------------------------------------------------------------------------------- /src/components/bold.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "b"; 4 | 5 | export const Bold = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | >((props, ref) => ); 9 | 10 | Bold.displayName = "Bold"; 11 | -------------------------------------------------------------------------------- /src/components/box.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "div"; 4 | 5 | export const Box = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | >((props, ref) =>
); 9 | 10 | Box.displayName = "Box"; 11 | -------------------------------------------------------------------------------- /src/components/form.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "form"; 4 | 5 | export const Form = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | >((props, ref) =>
); 9 | 10 | Form.displayName = "Form"; 11 | -------------------------------------------------------------------------------- /src/components/italic.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "i"; 4 | 5 | export const Italic = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | >((props, ref) => ); 9 | 10 | Italic.displayName = "Italic"; 11 | -------------------------------------------------------------------------------- /src/components/heading.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "h1"; 4 | 5 | export const Heading = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | >((props, ref) =>

); 9 | 10 | Heading.displayName = "Heading"; 11 | -------------------------------------------------------------------------------- /src/components/paragraph.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "p"; 4 | 5 | export const Paragraph = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | >((props, ref) =>

); 9 | 10 | Paragraph.displayName = "Paragraph"; 11 | -------------------------------------------------------------------------------- /src/components/text-block.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "div"; 4 | 5 | export const TextBlock = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | >((props, ref) =>

); 9 | 10 | TextBlock.displayName = "TextBlock"; 11 | -------------------------------------------------------------------------------- /src/css/breakpoints.ts: -------------------------------------------------------------------------------- 1 | import { type Breakpoint } from "./types"; 2 | 3 | export type BaseBreakpoint = Pick; 4 | 5 | export const initialBreakpoints: Array = [ 6 | { label: "Mobile", minWidth: 360 }, 7 | { label: "Tablet", minWidth: 768 }, 8 | { label: "Laptop", minWidth: 1024 }, 9 | { label: "Desktop", minWidth: 1280 }, 10 | ]; 11 | -------------------------------------------------------------------------------- /src/components/link.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "a"; 4 | 5 | export type LinkProps = Omit, "href"> & { 6 | href?: string; 7 | } 8 | 9 | export const Link = forwardRef< 10 | ElementRef, 11 | LinkProps 12 | >(({href = '', ...props}, ref) => ); 13 | 14 | Link.displayName = "Link"; 15 | -------------------------------------------------------------------------------- /src/components/input.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "input"; 4 | 5 | export const Input = forwardRef< 6 | ElementRef, 7 | ComponentProps 8 | // Make sure children are not passed down to an input, because this will result in error. 9 | >(({ children: _children, ...props }, ref) => ); 10 | 11 | Input.displayName = "Input"; 12 | -------------------------------------------------------------------------------- /src/css/units.ts: -------------------------------------------------------------------------------- 1 | // This file was generated by yarn mdn-data 2 | export const units = [ 3 | "ch", 4 | "cm", 5 | "deg", 6 | "dpcm", 7 | "dpi", 8 | "dppx", 9 | "em", 10 | "ex", 11 | "fr", 12 | "grad", 13 | "Hz", 14 | "in", 15 | "kHz", 16 | "mm", 17 | "ms", 18 | "pc", 19 | "pt", 20 | "px", 21 | "Q", 22 | "rad", 23 | "rem", 24 | "s", 25 | "turn", 26 | "vh", 27 | "vmax", 28 | "vmin", 29 | "vw", 30 | "x", 31 | "%" 32 | ] as const; -------------------------------------------------------------------------------- /src/components/button.tsx: -------------------------------------------------------------------------------- 1 | import React, { forwardRef, type ElementRef, type ComponentProps } from "react"; 2 | 3 | const defaultTag = "button"; 4 | 5 | export type ButtonProps = ComponentProps 6 | 7 | export const Button = forwardRef< 8 | ElementRef, 9 | ButtonProps 10 | >((props, ref) =>