| 36 | } from "./htmlMain"; |
| 37 | |
| 38 | export class HtmlDefaultBuilder { |
| 39 | styles: Array<string>; |
| 40 | data: Array<string>; |
| 41 | node: SceneNode; |
| 42 | settings: HTMLSettings; |
| 43 | cssClassName: string | null = null; |
| 44 | |
| 45 | get name() { |
| 46 | if (this.settings.htmlGenerationMode === "styled-components") { |
| 47 | return this.settings.showLayerNames |
| 48 | ? (this.node as any).uniqueName || this.node.name |
| 49 | : ""; |
| 50 | } |
| 51 | return this.settings.showLayerNames ? this.node.name : ""; |
| 52 | } |
| 53 | |
| 54 | get visible() { |
| 55 | return this.node.visible; |
| 56 | } |
| 57 | |
| 58 | get isJSX() { |
| 59 | return this.settings.htmlGenerationMode === "jsx"; |
| 60 | } |
| 61 | |
| 62 | get exportCSS() { |
| 63 | return this.settings.htmlGenerationMode === "svelte"; |
| 64 | } |
| 65 | |
| 66 | get needsJSXTextEscaping() { |
| 67 | const mode = this.settings.htmlGenerationMode; |
| 68 | return mode === "jsx" || mode === "styled-components" || mode === "svelte"; |
| 69 | } |
| 70 | |
| 71 | get useStyledComponents() { |
| 72 | return this.settings.htmlGenerationMode === "styled-components"; |
| 73 | } |
| 74 | |
| 75 | get useInlineStyles() { |
| 76 | return ( |
| 77 | this.settings.htmlGenerationMode === "html" || |
| 78 | this.settings.htmlGenerationMode === "jsx" |
| 79 | ); |
| 80 | } |
| 81 | |
| 82 | // Get the appropriate HTML element based on node type |
| 83 | get htmlElement(): string { |
| 84 | if (this.node.type === "TEXT") return "p"; |
| 85 | return "div"; |
| 86 | } |
| 87 | |
| 88 | constructor(node: SceneNode, settings: HTMLSettings) { |
| 89 | this.node = node; |
| 90 | this.settings = settings; |
| 91 | this.styles = []; |
| 92 | this.data = []; |
| 93 | |
| 94 | // For both Svelte and styled-components, use sequential class names |
| 95 | if ( |
nothing calls this directly
no outgoing calls
no test coverage detected