Skip to content

Commit a16318e

Browse files
r0b1nIllia Obukhau
authored andcommitted
feat(html-element-web): add design preview for html element widget
This adds design preview, the iteration over items is needed to represent repeating nodes of the widget, though in case of HTML content the items are not greyed out
1 parent edd4650 commit a16318e

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

packages/pluggableWidgets/html-element-web/src/HTMLElement.editorPreview.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1-
import { ReactElement, createElement } from "react";
1+
import { ReactElement, createElement, Fragment } from "react";
22
import { HTMLElementPreviewProps } from "../typings/HTMLElementProps";
3+
import { HTMLTag } from "./components/HTMLTag";
4+
import { prepareTag } from "./utils/props-utils";
35

46
export function preview(props: HTMLElementPreviewProps): ReactElement {
5-
return <div className={props.className}>HTML Element</div>;
7+
const tag = prepareTag(props.tagName, props.tagNameCustom);
8+
9+
const items = props.tagUseRepeat ? [1, 2, 3] : [1];
10+
11+
return (
12+
<Fragment>
13+
{items.map(i => (
14+
<HTMLTag
15+
key={i}
16+
tagName={tag}
17+
attributes={{
18+
className: props.className,
19+
style: props.styleObject
20+
}}
21+
>
22+
{props.tagContentRepeatHTML}
23+
{props.tagContentHTML}
24+
<props.tagContentRepeatContainer.renderer>
25+
<div />
26+
</props.tagContentRepeatContainer.renderer>
27+
<props.tagContentContainer.renderer>
28+
<div />
29+
</props.tagContentContainer.renderer>
30+
</HTMLTag>
31+
))}
32+
</Fragment>
33+
);
634
}
735

836
export function getPreviewCss(): string {

0 commit comments

Comments
 (0)