19 lines
567 B
TypeScript
19 lines
567 B
TypeScript
export const TITLE_MAX_LENGTH = 15;
|
|
export const SECONDARY_TITLE_MAX_LENGTH = 20;
|
|
|
|
export const clampTitle = (value: string, maxLength: number = TITLE_MAX_LENGTH) =>
|
|
value.slice(0, maxLength);
|
|
|
|
export const clampSecondaryTitle = (value: string, maxLength: number = SECONDARY_TITLE_MAX_LENGTH) =>
|
|
value.slice(0, maxLength);
|
|
|
|
export const applyTitleLimit = (
|
|
prev: string,
|
|
next: string,
|
|
maxLength: number = TITLE_MAX_LENGTH
|
|
) => {
|
|
if (next.length <= maxLength) return next;
|
|
if (prev.length >= maxLength) return prev;
|
|
return next.slice(0, maxLength);
|
|
};
|