ui: share truncate and firstLine from text.ts
This commit is contained in:
1 parent
12e1e0ba7a
commit
a6cfb9a2cd
8 files changed
+47
-30
No files matched your search
@@ -4,6 +4,7 @@ import type { ThreadId } from "@t3tools/contracts";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { ClickRow, wheelStep } from "./Button.tsx";
|
||||
import { truncate } from "./text.ts";
|
||||
import { colors, statusColor } from "./theme.ts";
|
||||
|
||||
/**
|
||||
@@ -125,8 +126,3 @@ function SectionHeader({ label }: { readonly label: string }) {
|
||||
</text>
|
||||
);
|
||||
}
|
||||
|
||||
function truncate(text: string, width: number): string {
|
||||
const single = text.replace(/\s+/g, " ");
|
||||
return single.length > width ? `${single.slice(0, Math.max(0, width - 1))}…` : single;
|
||||
}
|
||||
Reference in new issue
Block a user