(
node: SceneNode &
SceneNodeMixin &
BlendMixin &
LayoutMixin &
GeometryMixin &
MinimalBlendMixin,
children: string,
additionalAttr: string,
settings: TailwindSettings,
)
| 250 | }; |
| 251 | |
| 252 | export const tailwindContainer = ( |
| 253 | node: SceneNode & |
| 254 | SceneNodeMixin & |
| 255 | BlendMixin & |
| 256 | LayoutMixin & |
| 257 | GeometryMixin & |
| 258 | MinimalBlendMixin, |
| 259 | children: string, |
| 260 | additionalAttr: string, |
| 261 | settings: TailwindSettings, |
| 262 | ): string => { |
| 263 | // Ignore the view when size is zero or less |
| 264 | if (node.width < 0 || node.height < 0) { |
| 265 | return children; |
| 266 | } |
| 267 | |
| 268 | const builder = new TailwindDefaultBuilder(node, settings) |
| 269 | .commonPositionStyles() |
| 270 | .commonShapeStyles(); |
| 271 | |
| 272 | if (!builder.attributes && !additionalAttr) { |
| 273 | return children; |
| 274 | } |
| 275 | |
| 276 | const build = builder.build(additionalAttr); |
| 277 | |
| 278 | // Determine if we should use img tag |
| 279 | let tag = "div"; |
| 280 | let src = ""; |
| 281 | const topFill = retrieveTopFill(node.fills); |
| 282 | |
| 283 | if (topFill?.type === "IMAGE") { |
| 284 | addWarning("Image fills are replaced with placeholders"); |
| 285 | const imageURL = getPlaceholderImage(node.width, node.height); |
| 286 | |
| 287 | if (!("children" in node) || node.children.length === 0) { |
| 288 | tag = "img"; |
| 289 | src = ` src="${imageURL}"`; |
| 290 | } else { |
| 291 | builder.addAttributes(`bg-[url(${imageURL})]`); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | // Generate appropriate HTML |
| 296 | if (children) { |
| 297 | return `\n<${tag}${build}${src}>${indentString(children)}\n</${tag}>`; |
| 298 | } else if ( |
| 299 | SELF_CLOSING_TAGS.includes(tag) || |
| 300 | settings.tailwindGenerationMode === "jsx" |
| 301 | ) { |
| 302 | return `\n<${tag}${build}${src} />`; |
| 303 | } else { |
| 304 | return `\n<${tag}${build}${src}></${tag}>`; |
| 305 | } |
| 306 | }; |
| 307 | |
| 308 | export const tailwindLine = ( |
| 309 | node: LineNode, |
no test coverage detected