Files
webstudio/packages/sdk-components-react/src/code-text.ws.ts
T
Oleg Isonen 81b67c5dd6 feat: New Icons (#4590)
## Description

- [x] left sidebar tab icons

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
0000)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-12-24 21:17:15 +01:00

68 lines
1.6 KiB
TypeScript

import { BracesIcon } from "@webstudio-is/icons/svg";
import {
defaultStates,
type PresetStyle,
type WsComponentMeta,
type WsComponentPropsMeta,
} from "@webstudio-is/react-sdk";
import { code } from "@webstudio-is/sdk/normalize.css";
import type { defaultTag } from "./code-text";
import { props } from "./__generated__/code-text.props";
const presetStyle = {
code: [
...code,
{
property: "display",
value: { type: "keyword", value: "block" },
},
{
property: "whiteSpaceCollapse",
value: { type: "keyword", value: "preserve" },
},
{
property: "textWrapMode",
value: { type: "keyword", value: "wrap" },
},
{
property: "paddingLeft",
value: { type: "unit", value: 0.2, unit: "em" },
},
{
property: "paddingRight",
value: { type: "unit", value: 0.2, unit: "em" },
},
{
property: "backgroundColor",
value: { type: "rgb", r: 238, g: 238, b: 238, alpha: 1 },
},
],
} satisfies PresetStyle<typeof defaultTag>;
export const meta: WsComponentMeta = {
category: "general",
type: "embed",
description:
"Use this component when you want to display code as text on the page.",
icon: BracesIcon,
constraints: {
relation: "ancestor",
component: { $neq: "CodeText" },
},
states: defaultStates,
presetStyle,
order: 9,
};
export const propsMeta: WsComponentPropsMeta = {
props: {
...props,
code: {
required: true,
control: "codetext",
type: "string",
},
},
initialProps: ["id", "className", "lang", "code"],
};