Portfolio/front/index.ts
2025-03-24 09:50:58 +01:00

43 lines
1.2 KiB
TypeScript

import Categories from "./Categories";
import Header from "./Header";
import TabRouter from "./Tabs/TabRouter";
interface FrontProps {
columns: number;
rows: number;
selectedTab: "About" | "Projects" | "Contact";
scrollPosition: number;
userSpecs: {
userName?: string;
};
}
const minimumWidth = 90;
const minimumHeight = 20;
const terminalTooSmall = (width: number, height: number) => {
return (
`\x1b[31mOh no!\x1b[0m Your terminal window is too small!${newLine}` +
`Minimum size required: ${minimumWidth}x${minimumHeight}${newLine}` +
`Current size: ${width >= minimumWidth ? width : `\x1b[31m${width}\x1b[0m`}x${
height >= minimumHeight ? height : `\x1b[31m${height}\x1b[0m`
}${newLine}`
);
};
const Front = async ({ columns, rows, selectedTab, scrollPosition, userSpecs }: FrontProps) => {
if (columns < minimumWidth || rows < minimumHeight) {
return terminalTooSmall(columns, rows);
}
return (
`${Header({ width: columns, height: 3 })}${newLine}` +
`${Categories({ width: columns, height: 3, selectedTab })}${newLine}` +
`${await TabRouter({ width: columns, height: rows - 6, selectedTab, scrollPosition, userSpecs })}`
);
};
const newLine = "\n\r";
export default Front;
export { newLine };