Files
webstudio/packages/jsx-utils/README.md
T
Giuseppe 2ca3907988 feat: JSX utils (#2396)
Adds utils to work with JSX and transform it to Webstudio Embed Template
as well as converting Tailwind styles to Webstudio Embed Template style
declarations and a fake `<HeroIcon>` component to `HtmlEmbed` with
inline SVG taken from heroicons (we will need this for ai).
2023-10-01 12:17:43 +02:00

641 B

JSX Utils

Utilities to work with JSX, including converting it to Webstudio format.

Usage

Install the package

pnpm i @webstudio-is/jsx-utils

Transform a JSX string to Webstudio Embed Template:

import { jsxToWSEmbedTemplate } from "@webstudio-is/jsx-utils";

await jsxToWSEmbedTemplate("<Box>hello</Box>");

Other utils:

  • traverseTemplate and traverseTemplateAsync to traverse a WsEmbedTemplate and work with nodes
  • tailwindToWebstudio converts a template className prop to Webstudio local styles
  • heroiconsToSvgEmbed converts <HeroIcon name="iconName" type="solid"> to HtmlEmbed with inline SVG