mirror of
https://github.com/goauthentik/authentik
synced 2026-05-09 00:22:24 +02:00
* web: Remove duplicate styles. * web: Touch up contrast. * web: Shrink searchbar. * web: Flesh out library fixes. * web: Refine layout. * web: Touch up multi column. * web: Fix header alignment. * web: Fix up search behavior. * web: Fix alignment with multiple columns. * web: Wrap styles. * web: Remove color override. - note: I think this is deprecated. * Fix up menu styles. * web: Revert expansion component changes. * web: rename. * web: use row as default. * web: Remove unused. * web: Fix icon sizing. * web: Fix sizing. * slightly bigger cards Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix rac alignment Signed-off-by: Jens Langhammer <jens@goauthentik.io> * ok a bit bigger Signed-off-by: Jens Langhammer <jens@goauthentik.io> * web: Adjust border. * web: Fix properties. * tweaks Signed-off-by: Jens Langhammer <jens@goauthentik.io> * web: Fix multi-line alignment. --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
46 lines
1000 B
TypeScript
46 lines
1000 B
TypeScript
/**
|
|
* @file String utilities.
|
|
*/
|
|
|
|
import { msg } from "@lit/localize";
|
|
|
|
const truncationEllipsis = msg("...", {
|
|
desc: "Truncation ellipsis",
|
|
id: "ellipsis",
|
|
});
|
|
|
|
/**
|
|
* Truncate a string based on character count.
|
|
*
|
|
* @see {@linkcode truncateWords}
|
|
*/
|
|
export function truncate(input?: string | null, maxLength = 10): string {
|
|
const trimmed = input?.trim() ?? "";
|
|
|
|
if (!trimmed || trimmed.length <= maxLength) {
|
|
return trimmed;
|
|
}
|
|
|
|
return trimmed.substring(0, maxLength) + truncationEllipsis;
|
|
}
|
|
|
|
/**
|
|
* Truncate a string based on maximum word count.
|
|
*
|
|
* @see {@linkcode truncate}
|
|
*
|
|
*/
|
|
export function truncateWords(input?: string | null, maxLength = 10): string {
|
|
const trimmed = input?.trim() ?? "";
|
|
|
|
if (!trimmed || trimmed.length <= maxLength) {
|
|
return trimmed;
|
|
}
|
|
|
|
const array = trimmed.split(" ");
|
|
|
|
const ellipsis = array.length > maxLength ? truncationEllipsis : "";
|
|
|
|
return array.slice(0, maxLength).join(" ") + ellipsis;
|
|
}
|