Skip to content

Commit 452478c

Browse files
Add(textBuilder): support truncate (#235)
1 parent f98c644 commit 452478c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/backend/src/tailwind/tailwindTextBuilder.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class TailwindTextBuilder extends TailwindDefaultBuilder {
5555
// textIndentStyle,
5656
blurStyle,
5757
shadowStyle,
58+
this.truncateText(node),
5859
]
5960
.filter(Boolean)
6061
.join(" ");
@@ -68,6 +69,19 @@ export class TailwindTextBuilder extends TailwindDefaultBuilder {
6869
});
6970
}
7071

72+
truncateText = (
73+
node: TextNode,
74+
) => {
75+
if (node.textTruncation !== "DISABLED" && node.maxLines) {
76+
if (node.maxLines > 0 && node.maxLines < 7) {
77+
return `line-clamp-${node.maxLines}`
78+
} else {
79+
return `line-clamp-[${node.maxLines}]`
80+
}
81+
}
82+
return "";
83+
};
84+
7185
getTailwindColorFromFills = (
7286
fills: ReadonlyArray<Paint> | PluginAPI["mixed"],
7387
) => {
@@ -112,6 +126,9 @@ export class TailwindTextBuilder extends TailwindDefaultBuilder {
112126
if (config.fontFamily.mono.includes(fontName.family)) {
113127
return "font-mono";
114128
}
129+
if (config.fontFamily.display.includes(fontName.family)) {
130+
return "font-display";
131+
}
115132
const underscoreFontName = fontName.family.replace(/\s/g, "_");
116133

117134
return "font-['" + underscoreFontName + "']";

0 commit comments

Comments
 (0)