frontPanel/src/pages/Questions/BranchingMap/nameCutter.ts

19 lines
511 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const nameCutter = (name: string) => {
//слова без пробелов не переносятся. В одной строке максимум 7 символов
if (name.slice(2, 7).includes(" ")) {
const newName = name.slice(0, 18);
if (name.length >= 18) {
return newName + "...";
} else {
return newName;
}
} else {
const newName = name.slice(0, 7);
if (name.length >= 7) {
return newName + "...";
} else {
return newName;
}
}
};